Fix T58993: Duplicating after setting a rigid body world crashes Blender.
authorBastien Montagne <montagne29@wanadoo.fr>
Mon, 10 Dec 2018 13:10:12 +0000 (14:10 +0100)
committerBastien Montagne <montagne29@wanadoo.fr>
Mon, 10 Dec 2018 14:10:29 +0000 (15:10 +0100)
There is no guarantee that object in rigidbody collection already have a
valid rgigidbody data when rebuilding deg relations, that is often
generated on-the-fly by actual rigid body simulation.

Note that this can be an issue when generating deg relations I guess...
But at least it won't crash anymore.

source/blender/depsgraph/intern/builder/deg_builder_relations.cc

index 23f1d229d6adeee449102744a9479e0c139d2d93..f66a0a8963ae4d682e0a814e919b05271b744e70 100644 (file)
@@ -1627,7 +1627,7 @@ void DepsgraphRelationBuilder::build_rigidbody(Scene *scene)
 
                        /* Geometry must be known to create the rigid body. RBO_MESH_BASE uses the non-evaluated
                         * mesh, so then the evaluation is unnecessary. */
-                       if (object->rigidbody_object->mesh_source != RBO_MESH_BASE) {
+                       if (object->rigidbody_object != NULL && object->rigidbody_object->mesh_source != RBO_MESH_BASE) {
                                ComponentKey geom_key(&object->id, DEG_NODE_TYPE_GEOMETRY);
                                add_relation(geom_key, init_key, "Object Geom Eval -> Rigidbody Rebuild");
                        }