Skip to content

Commit

Permalink
Fix performance bottleneck
Browse files Browse the repository at this point in the history
  • Loading branch information
aelmiger committed Apr 25, 2024
1 parent bd77d99 commit 9057052
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions syclops/utility/blender_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -701,17 +701,28 @@ def add_volume_attribute(obj: bpy.types.Object):

def refresh_modifiers():
"""Flip the visibility of all modifiers to refresh them."""
modifier_states = {}

# Store the initial state of each modifier
for obj in bpy.data.objects:
for mod in obj.modifiers:
modifier_states[(obj.name, mod.name)] = mod.show_viewport

# Disable all modifiers
for obj in bpy.data.objects:
for mod in obj.modifiers:
if mod.show_viewport:
mod.show_viewport = False
bpy.context.view_layer.update()
mod.show_viewport = True
bpy.context.view_layer.update()
elif render_visibility(obj):

bpy.context.view_layer.update()

# Restore the state of modifiers based on the stored state
for obj in bpy.data.objects:
for mod in obj.modifiers:
if modifier_states[(obj.name, mod.name)]:
mod.show_viewport = True
bpy.context.view_layer.update()

bpy.context.view_layer.update()

def _get_num_clumps(num_objects: int, ratio: float) -> int:
return int(-(ratio * num_objects) / (ratio - 1))
Expand Down

0 comments on commit 9057052

Please sign in to comment.