Page MenuHome

Fix T61600: Physics properties inactive when appending objects
ClosedPublic

Authored by Dalai Felinto (dfelinto) on Feb 19 2019, 11:36 PM.

Details

Summary

This problem existed in 2.79 as well. The rigid body setting is related
to the scene the object was created.

We now clear all the rigid body properties of the appended objects to
prevent them from lingering in this state where they have settings yet
cannot be used in the simulation.

Diff Detail

Repository
rB Blender

Event Timeline

Brecht Van Lommel (brecht) requested changes to this revision.Feb 20 2019, 12:17 PM

This will crash if there is no local scene with rigid body settings, since BKE_rigidbody_remove_object assumes the scene is not NULL.

Further I'm not sure this is the right place to do it, @Bastien Montagne (mont29)?

This revision now requires changes to proceed.Feb 20 2019, 12:17 PM

@Brecht Van Lommel (brecht), you are right. I had some logic for that, but removed in a cleanup.

Anyways, waiting for @Bastien Montagne (mont29)'s 2 cents here.

source/blender/blenkernel/intern/library.c
1978
- BKE_rigidbody_remove_object(bmain, scene_rigidbody, ob);
+ BKE_rigidbody_remove_object(bmain, scene_rigidbody ? scene_rigidbody : bmain->scene.first, ob);

... or similar.

source/blender/blenkernel/intern/library.c
1978

This whole assumption in the rigid body code that there is only one scene with rigid bodies is quite weak. That's not easy to fix though.

Maybe for now BKE_rigidbody_remove_object could just not have a scene parameter and loop over all scenes.

Well, RigidBody does not necessarily assume there is only one scene having it? So code above should not just handle first scene found with a RBW, imho, should be applied to all potential scenes having it.
And if no scenes have it, then just call BKE_rigidbody_free_object() instead? With a NULL rbw (which shall be OK, since if there are no rbw in any scenes, there should be no RB sim, hence no runtimedata like rbo->shared->physics_object [rbo->shared is calloc'ed on readfile, so its pointers are NULL until RB sim is run]).

Agree rigidbody code has a lot of weirdnesses and weaknesses, but nobody is really maintaining this currently, so we have to live with monkey-patching as we find issues with it… :/

Addressing comments from review, patch ready to commit.

This revision is now accepted and ready to land.Feb 22 2019, 2:45 PM
This revision was automatically updated to reflect the committed changes.