diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2018-12-12 19:21:37 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2018-12-12 19:21:37 +0300 |
commit | 80ad2f8cf6bf6612f629491057d8588787440e20 (patch) | |
tree | 9e778613a56d66ce0d55f4a91fa3fc733c18531c /source/blender/blenkernel/intern/rigidbody.c | |
parent | 4e0291f185570b12abe82ce57ff38c4ae27aa2ac (diff) |
Fix (unreported) Broken rigidbody requirements when adding objects to a RB collection.
We have to ensure objects get expected RB data, when they are added to a
RB collection...
Diffstat (limited to 'source/blender/blenkernel/intern/rigidbody.c')
-rw-r--r-- | source/blender/blenkernel/intern/rigidbody.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c index aa5051e25cd..7d4bd74389e 100644 --- a/source/blender/blenkernel/intern/rigidbody.c +++ b/source/blender/blenkernel/intern/rigidbody.c @@ -61,6 +61,7 @@ #include "BKE_layer.h" #include "BKE_library.h" #include "BKE_library_query.h" +#include "BKE_main.h" #include "BKE_mesh.h" #include "BKE_mesh_runtime.h" #include "BKE_object.h" @@ -1173,6 +1174,23 @@ void BKE_rigidbody_constraints_collection_validate(Scene *scene, RigidBodyWorld } } +void BKE_rigidbody_main_collection_object_add(Main *bmain, Collection *collection, Object *object) +{ + for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) { + RigidBodyWorld *rbw = scene->rigidbody_world; + + if (rbw == NULL) { + continue; + } + + if (rbw->group == collection && object->type == OB_MESH && object->rigidbody_object == NULL) { + object->rigidbody_object = BKE_rigidbody_create_object(scene, object, RBO_TYPE_ACTIVE); + } + if (rbw->constraints == collection && object->rigidbody_constraint == NULL) { + object->rigidbody_constraint = BKE_rigidbody_create_constraint(scene, object, RBC_TYPE_FIXED); + } + } +} /* ************************************** */ /* Utilities API */ |