Skip to content

Commit

Permalink
fix: unexpected outline visibility changing on export
Browse files Browse the repository at this point in the history
  • Loading branch information
saturday06 committed Jun 7, 2024
1 parent 41b6bb1 commit 19af516
Showing 1 changed file with 37 additions and 30 deletions.
67 changes: 37 additions & 30 deletions src/io_scene_vrm/exporter/abstract_base_vrm_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ def clear_blend_shape_proxy_previews(
@staticmethod
def enter_hide_mtoon1_outline_geometry_nodes(
context: Context,
) -> dict[str, tuple[str, bool, bool]]:
object_name_to_modifier: dict[str, tuple[str, bool, bool]] = {}
) -> dict[str, list[tuple[str, bool, bool]]]:
object_name_to_modifiers: dict[str, list[tuple[str, bool, bool]]] = {}
for obj in context.blend_data.objects:
for modifier in obj.modifiers:
if not modifier.show_viewport:
Expand All @@ -208,44 +208,51 @@ def enter_hide_mtoon1_outline_geometry_nodes(
or node_group.name != shader.OUTLINE_GEOMETRY_GROUP_NAME
):
continue
object_name_to_modifier[obj.name] = (
modifier.name,
modifier.show_render,
modifier.show_viewport,
modifiers = object_name_to_modifiers.get(obj.name)
if modifiers is None:
modifiers = []
object_name_to_modifiers[obj.name] = modifiers
modifiers = object_name_to_modifiers[obj.name]
modifiers.append(
(
modifier.name,
modifier.show_render,
modifier.show_viewport,
)
)
if modifier.show_render:
modifier.show_render = False
if modifier.show_viewport:
modifier.show_viewport = False
return object_name_to_modifier
return object_name_to_modifiers

@staticmethod
def exit_hide_mtoon1_outline_geometry_nodes(
context: Context,
object_name_to_modifier: dict[str, tuple[str, bool, bool]],
object_name_to_modifiers: dict[str, list[tuple[str, bool, bool]]],
) -> None:
for object_name, (
modifier_name,
render,
viewport,
) in object_name_to_modifier.items():
obj = context.blend_data.objects.get(object_name)
if not obj:
continue
modifier = obj.modifiers.get(modifier_name)
if (
not modifier
or modifier.type != "NODES"
or not isinstance(modifier, NodesModifier)
):
continue
node_group = modifier.node_group
if not node_group or node_group.name != shader.OUTLINE_GEOMETRY_GROUP_NAME:
continue
if modifier.show_render != render:
modifier.show_render = render
if modifier.show_viewport != viewport:
modifier.show_viewport = viewport
for object_name, modifiers in object_name_to_modifiers.items():
for modifier_name, render, viewport in modifiers:
obj = context.blend_data.objects.get(object_name)
if not obj:
continue
modifier = obj.modifiers.get(modifier_name)
if (
not modifier
or modifier.type != "NODES"
or not isinstance(modifier, NodesModifier)
):
continue
node_group = modifier.node_group
if (
not node_group
or node_group.name != shader.OUTLINE_GEOMETRY_GROUP_NAME
):
continue
if modifier.show_render != render:
modifier.show_render = render
if modifier.show_viewport != viewport:
modifier.show_viewport = viewport

@staticmethod
@contextmanager
Expand Down

0 comments on commit 19af516

Please sign in to comment.