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.
This commit is contained in:
2013-04-24 23:09:25 +00:00
parent 11c6abe53b
commit 2043d801e8
9 changed files with 99 additions and 21 deletions

View File

@@ -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; }