diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2018-12-10 17:01:32 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2018-12-10 17:10:29 +0300 |
commit | 7f98ba4725f992e7f982ed4f0f7e910790380de3 (patch) | |
tree | 8dd0cc2da5e362749c766c83091131757a7adaba /source/blender/makesrna/intern/rna_rigidbody.c | |
parent | 073a011f91a52cf1648b2d76606f0f2fff412098 (diff) |
Proper fix for rigidbody collections's objects missing rb data.
We cannot let those data be generated on-the-fly in RBW evaluation
anymore, since those would be added to CoW eval object and never ported
back to orig objects.
We *could* get orig objects in eval code, of course, but as in
constratints, this is not really threadsafe and future proof, depsgraph
evaluation should really write back to orig data as little as possible.
So instead, add code to ensure required data is generated to objects
when their collection is added to rigidbody world.
Note that we *may* want to clean that up once collection is no more used
by RB? On the other hand, people might want to keep those data around to
be able to switch between different setups easily... So think it's OK to
keep them at least for now.
Diffstat (limited to 'source/blender/makesrna/intern/rna_rigidbody.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_rigidbody.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/source/blender/makesrna/intern/rna_rigidbody.c b/source/blender/makesrna/intern/rna_rigidbody.c index e0d0ae57b30..15046928ce7 100644 --- a/source/blender/makesrna/intern/rna_rigidbody.c +++ b/source/blender/makesrna/intern/rna_rigidbody.c @@ -149,6 +149,22 @@ static void rna_RigidBodyWorld_split_impulse_set(PointerRNA *ptr, bool value) #endif } +static void rna_RigidBodyWorld_objects_collection_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + RigidBodyWorld *rbw = (RigidBodyWorld *)ptr->data; + + BKE_rigidbody_objects_collection_validate(scene, rbw); + rna_RigidBodyWorld_reset(bmain, scene, ptr); +} + +static void rna_RigidBodyWorld_constraints_collection_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + RigidBodyWorld *rbw = (RigidBodyWorld *)ptr->data; + + BKE_rigidbody_constraints_collection_validate(scene, rbw); + rna_RigidBodyWorld_reset(bmain, scene, ptr); +} + /* ******************************** */ static void rna_RigidBodyOb_reset(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr)) @@ -773,13 +789,13 @@ static void rna_def_rigidbody_world(BlenderRNA *brna) RNA_def_property_pointer_sdna(prop, NULL, "group"); RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK); RNA_def_property_ui_text(prop, "Collection", "Collection containing objects participating in this simulation"); - RNA_def_property_update(prop, NC_SCENE, "rna_RigidBodyWorld_reset"); + RNA_def_property_update(prop, NC_SCENE, "rna_RigidBodyWorld_objects_collection_update"); prop = RNA_def_property(srna, "constraints", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "Collection"); RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK); RNA_def_property_ui_text(prop, "Constraints", "Collection containing rigid body constraint objects"); - RNA_def_property_update(prop, NC_SCENE, "rna_RigidBodyWorld_reset"); + RNA_def_property_update(prop, NC_SCENE, "rna_RigidBodyWorld_constraints_collection_update"); /* booleans */ prop = RNA_def_property(srna, "enabled", PROP_BOOLEAN, PROP_NONE); |