Skip to content

Commit

Permalink
fix: remove unnecessary .blend link
Browse files Browse the repository at this point in the history
  • Loading branch information
saturday06 committed Nov 20, 2024
1 parent b23c9fd commit d55bb32
Showing 1 changed file with 22 additions and 25 deletions.
47 changes: 22 additions & 25 deletions src/io_scene_vrm/common/shader.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,6 @@
COLOR_SOCKET_CLASSES: Final = (NodeSocketColor,)
STRING_SOCKET_CLASSES: Final = (NodeSocketString,)

file_names = [
"mtoon0.blend",
]

OUTLINE_GEOMETRY_GROUP_NAME: Final = "VRM Add-on MToon 1.0 Outline Geometry Revision 1"

UV_GROUP_NAME: Final = "VRM Add-on MToon 1.0 UV Revision 1"
Expand Down Expand Up @@ -251,15 +247,28 @@ def generate_backup_suffix() -> str:


def add_shaders(context: Context) -> None:
for file_name in file_names:
path = Path(__file__).with_name(file_name)
with context.blend_data.libraries.load(str(path), link=False) as (
data_from,
data_to,
):
for node_group in data_from.node_groups:
if node_group not in context.blend_data.node_groups:
data_to.node_groups.append(node_group)
blend_path = Path(__file__).with_name("mtoon0.blend")
node_tree_path = str(blend_path) + "/NodeTree"
library_appended = False
for shader_node_group_name in ["matcap_vector", "MToon_unversioned"]:
if shader_node_group_name in context.blend_data.node_groups:
continue
result = bpy.ops.wm.append(
filepath=node_tree_path + "/" + shader_node_group_name,
filename=shader_node_group_name,
directory=node_tree_path,
link=False,
)
if result == {"FINISHED"}:
library_appended = True

if not library_appended:
return

for library in list(context.blend_data.libraries):
if blend_path.samefile(library.filepath) and library.users <= 1:
context.blend_data.libraries.remove(library)
return


def load_mtoon1_node_group(
Expand Down Expand Up @@ -1447,18 +1456,6 @@ def copy_node_tree(
)


def shader_node_group_import(context: Context, shader_node_group_name: str) -> None:
if shader_node_group_name in context.blend_data.node_groups:
return
for file_name in file_names:
path = str(Path(__file__).with_name(file_name)) + "/NodeTree"
bpy.ops.wm.append(
filepath=path + "/" + shader_node_group_name,
filename=shader_node_group_name,
directory=path,
)


def get_image_name_and_sampler_type(
shader_node: Node, input_socket_name: str
) -> Optional[tuple[str, int, int]]:
Expand Down

0 comments on commit d55bb32

Please sign in to comment.