Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Gavrilov <angavrilov@gmail.com>2021-01-09 21:15:53 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2021-01-11 19:34:32 +0300
commitac290bfbe434df43fea19f7130313a1769aefdad (patch)
tree2f91e38b51820982aa869b41101878a0ae77ca13 /release/scripts/startup/bl_ui/properties_physics_common.py
parentb271475a9e0ba69a5b48da92c4895e65325dda86 (diff)
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
Diffstat (limited to 'release/scripts/startup/bl_ui/properties_physics_common.py')
-rw-r--r--release/scripts/startup/bl_ui/properties_physics_common.py6
1 files changed, 5 insertions, 1 deletions
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)