diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-04-25 03:09:25 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-04-25 03:09:25 +0400 |
commit | 2043d801e88c8f56b0153f8acf0cccb554f0fa0c (patch) | |
tree | bffa8f8ea9769d092e7e75b9817b9bd4be7e6862 /source/blender/blenkernel/intern/rigidbody.c | |
parent | 11c6abe53b77baefa09737fa8f615f5c734f4b63 (diff) |
Fix #34806: rigid body world settings were not copied with a full scene copy.
Now copying a scene will also duplicate groups that consist entirely of objects
that are duplicated with the scene. The rigid body world will then also pointers
to these new groups.
Diffstat (limited to 'source/blender/blenkernel/intern/rigidbody.c')
-rw-r--r-- | source/blender/blenkernel/intern/rigidbody.c | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c index ca7bb542598..879ba6651c2 100644 --- a/source/blender/blenkernel/intern/rigidbody.c +++ b/source/blender/blenkernel/intern/rigidbody.c @@ -58,12 +58,13 @@ #include "BKE_animsys.h" #include "BKE_cdderivedmesh.h" #include "BKE_effect.h" +#include "BKE_global.h" #include "BKE_group.h" -#include "BKE_object.h" +#include "BKE_library.h" #include "BKE_mesh.h" +#include "BKE_object.h" #include "BKE_pointcache.h" #include "BKE_rigidbody.h" -#include "BKE_global.h" #include "BKE_utildefines.h" #include "RNA_access.h" @@ -724,6 +725,36 @@ RigidBodyWorld *BKE_rigidbody_create_world(Scene *scene) return rbw; } +RigidBodyWorld *BKE_rigidbody_world_copy(RigidBodyWorld *rbw) +{ + RigidBodyWorld *rbwn = MEM_dupallocN(rbw); + + if (rbw->effector_weights) + rbwn->effector_weights = MEM_dupallocN(rbw->effector_weights); + if (rbwn->group) + id_us_plus(&rbwn->group->id); + if (rbwn->constraints) + id_us_plus(&rbwn->constraints->id); + + rbwn->pointcache = BKE_ptcache_copy_list(&rbwn->ptcaches, &rbw->ptcaches, FALSE); + + rbwn->objects = NULL; + rbwn->physics_world = NULL; + rbwn->numbodies = 0; + + return rbwn; +} + +void BKE_rigidbody_world_groups_relink(RigidBodyWorld *rbw) +{ + if (rbw->group && rbw->group->id.newid) + rbw->group = (Group*)rbw->group->id.newid; + if (rbw->constraints && rbw->constraints->id.newid) + rbw->constraints = (Group*)rbw->constraints->id.newid; + if (rbw->effector_weights->group && rbw->effector_weights->group->id.newid) + rbw->effector_weights->group = (Group*)rbw->effector_weights->group->id.newid; +} + /* Add rigid body settings to the specified object */ RigidBodyOb *BKE_rigidbody_create_object(Scene *scene, Object *ob, short type) { @@ -1332,6 +1363,8 @@ void BKE_rigidbody_validate_sim_object(RigidBodyWorld *rbw, Object *ob, short re void BKE_rigidbody_validate_sim_constraint(RigidBodyWorld *rbw, Object *ob, short rebuild) {} void BKE_rigidbody_validate_sim_world(Scene *scene, RigidBodyWorld *rbw, short rebuild) {} struct RigidBodyWorld *BKE_rigidbody_create_world(Scene *scene) { return NULL; } +struct RigidBodyWorld *BKE_rigidbody_world_copy(RigidBodyWorld *rbw) { return NULL; } +void BKE_rigidbody_world_groups_relink(struct RigidBodyWorld *rbw) {} struct RigidBodyOb *BKE_rigidbody_create_object(Scene *scene, Object *ob, short type) { return NULL; } struct RigidBodyCon *BKE_rigidbody_create_constraint(Scene *scene, Object *ob, short type) { return NULL; } struct RigidBodyWorld *BKE_rigidbody_get_world(Scene *scene) { return NULL; } |