Skip to content

Commit

Permalink
fix: remove default geometry node group
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippeCrassous committed Apr 2, 2021
1 parent 839ff49 commit 93deb9d
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion mixer/blender_data/modifier_proxies.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import logging
from typing import Any, Dict, Optional, TYPE_CHECKING, Tuple, Union

import bpy
import bpy.types as T # noqa

from mixer.blender_data.json_codec import serialize
Expand Down Expand Up @@ -85,7 +86,17 @@ def save(
key: Union[int, str],
context: Context,
):
# the modifier is always created with a default geometry node with no relevant inputs.
# the modifier is always created with a default geometry node : remove it
node_group = modifier.node_group
if node_group is not None:
if node_group.users != 1:
logger.error(f"save(): default node group {node_group} has {node_group.users} users")
return
if node_group.mixer_uuid != "":
logger.error(f"save(): default node group {node_group} has uuid {node_group.mixer_uuid}")
return
bpy.data.node_groups.remove(node_group)

# update the geometry node reference before updating the input entries
super().save(modifier, parent, key, context)
self.save_inputs(modifier)
Expand All @@ -110,10 +121,12 @@ def apply(
context: Context,
to_blender: bool = True,
) -> Union[StructProxy, NonePtrProxy]:

super().apply(modifier, parent, key, delta, context, to_blender)
if not isinstance(delta, DeltaUpdate):
logger.error(f"apply(): Internal error, unexpected delta type {type(delta)}")
return self

delta_inputs = getattr(delta.value, "_inputs", None)
if delta_inputs is not None or "node_group" in delta.value._data:
# also write inputs when the node_group changes
Expand Down

0 comments on commit 93deb9d

Please sign in to comment.