From ac290bfbe434df43fea19f7130313a1769aefdad Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Sat, 9 Jan 2021 21:15:53 +0300 Subject: Collision: allow disabling collision without removing the modifier. The `object.collision.use` flag was treated as a redundant marker of the existence of the modifier, going as far as adding/removing it when the value was changed, which is not actually very useful. Removing the modifier loses its position in the stack, and requires a dependency graph rebuild. It feels it may be a legacy flag? What would be useful however is the ability to toggle collisions dynamically without removing the modifier. This patch adjusts the code to keep the modifier when the flag is disabled, and add it if it doesn't exist when the flag is enabled. The modifier now checks the flag at the start and quickly exits after cleaning up stale data. The redesigned setting is exposed in the UI. Collisions can't be disabled by simply using the modifier enable flags because the modifier merely saves a snapshot of the mesh at a certain point of the modifier stack for other objects to use, and thus has to be able to clear the stale data. Differential Revision: https://developer.blender.org/D10064 --- release/scripts/startup/bl_ui/properties_physics_common.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'release') diff --git a/release/scripts/startup/bl_ui/properties_physics_common.py b/release/scripts/startup/bl_ui/properties_physics_common.py index 1ffaa47168f..3ee6894f349 100644 --- a/release/scripts/startup/bl_ui/properties_physics_common.py +++ b/release/scripts/startup/bl_ui/properties_physics_common.py @@ -48,6 +48,7 @@ def physics_add(layout, md, name, type, typeicon, toggles): if toggles: row.prop(md, "show_viewport", text="") row.prop(md, "show_render", text="") + return row else: row.operator( "object.modifier_add", @@ -89,7 +90,10 @@ class PHYSICS_PT_add(PhysicButtonsPanel, Panel): col.operator("object.forcefield_toggle", text="Force Field", icon='X') if obj.type == 'MESH': - physics_add(col, context.collision, "Collision", 'COLLISION', 'MOD_PHYSICS', False) + row = physics_add(col, context.collision, "Collision", 'COLLISION', 'MOD_PHYSICS', False) + if row and obj.collision: + row.prop(obj.collision, "use", text="", icon="HIDE_OFF" if obj.collision.use else "HIDE_ON") + physics_add(col, context.cloth, "Cloth", 'CLOTH', 'MOD_CLOTH', True) physics_add(col, context.dynamic_paint, "Dynamic Paint", 'DYNAMIC_PAINT', 'MOD_DYNAMICPAINT', True) -- cgit v1.2.3