Page MenuHome

Collision: allow disabling collision without removing the modifier.
ClosedPublic

Authored by Alexander Gavrilov (angavrilov) on Jan 10 2021, 7:01 PM.

Details

Summary

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.

Diff Detail

Repository
rB Blender
Branch
temp-angavrilov-disable-collider (branched from master)
Build Status
Buildable 12077
Build 12077: arc lint + arc unit

Event Timeline

Alexander Gavrilov (angavrilov) requested review of this revision.Jan 10 2021, 7:01 PM
Alexander Gavrilov (angavrilov) created this revision.

Also show the enable collision property as an eye icon next to the Collisions button at the top of the physics panel.

I think the Enable Collisions checkbox should still also exist in the Collisions subpanel for documentation purposes if nothing else.

Removed the Enabled Collisions checkbox from the collision panel.

Is this supposed to work with animated settings?
For me, if the collider starts off, then at least the cloth sim will not react to it even if it is toggled on before it hits the collision object:

(This is with an empty cache of course)

Edit: Removed outdated feedback.

Now the flag should not be checked when building the dependency graph, but later.

Ok it works now.

Just one thing:
I think toggling the on/off setting should invalidate the cache. Just like when toggling "single sided" in the collision settings for example.

Otherwise, you will have to invalidate the cache manually which is cumbersome.

Fixed the RNA update callback to invalidate cache.

LGTM

As the other patch, remember to add this to the docs and release log. :)

This revision is now accepted and ready to land.Jan 11 2021, 5:24 PM