Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/rigidbody.c
| Show First 20 Lines • Show All 178 Lines • ▼ Show 20 Lines | |||||
| /* Copying Methods --------------------- */ | /* Copying Methods --------------------- */ | ||||
| /* These just copy the data, clearing out references to physics objects. | /* These just copy the data, clearing out references to physics objects. | ||||
| * Anything that uses them MUST verify that the copied object will | * Anything that uses them MUST verify that the copied object will | ||||
| * be added to relevant groups later... | * be added to relevant groups later... | ||||
| */ | */ | ||||
| RigidBodyOb *BKE_rigidbody_copy_object(const Object *ob) | RigidBodyOb *BKE_rigidbody_copy_object(const Object *ob, const int UNUSED(flag)) | ||||
| { | { | ||||
| RigidBodyOb *rboN = NULL; | RigidBodyOb *rboN = NULL; | ||||
| if (ob->rigidbody_object) { | if (ob->rigidbody_object) { | ||||
| /* just duplicate the whole struct first (to catch all the settings) */ | /* just duplicate the whole struct first (to catch all the settings) */ | ||||
| rboN = MEM_dupallocN(ob->rigidbody_object); | rboN = MEM_dupallocN(ob->rigidbody_object); | ||||
| /* tag object as needing to be verified */ | /* tag object as needing to be verified */ | ||||
| rboN->flag |= RBO_FLAG_NEEDS_VALIDATE; | rboN->flag |= RBO_FLAG_NEEDS_VALIDATE; | ||||
| /* clear out all the fields which need to be revalidated later */ | /* clear out all the fields which need to be revalidated later */ | ||||
| rboN->physics_object = NULL; | rboN->physics_object = NULL; | ||||
| rboN->physics_shape = NULL; | rboN->physics_shape = NULL; | ||||
| } | } | ||||
| /* return new copy of settings */ | /* return new copy of settings */ | ||||
| return rboN; | return rboN; | ||||
| } | } | ||||
| RigidBodyCon *BKE_rigidbody_copy_constraint(const Object *ob) | RigidBodyCon *BKE_rigidbody_copy_constraint(const Object *ob, const int UNUSED(flag)) | ||||
| { | { | ||||
| RigidBodyCon *rbcN = NULL; | RigidBodyCon *rbcN = NULL; | ||||
| if (ob->rigidbody_constraint) { | if (ob->rigidbody_constraint) { | ||||
| /* just duplicate the whole struct first (to catch all the settings) */ | /* just duplicate the whole struct first (to catch all the settings) */ | ||||
| rbcN = MEM_dupallocN(ob->rigidbody_constraint); | rbcN = MEM_dupallocN(ob->rigidbody_constraint); | ||||
| /* tag object as needing to be verified */ | /* tag object as needing to be verified */ | ||||
| ▲ Show 20 Lines • Show All 724 Lines • ▼ Show 20 Lines | RigidBodyWorld *BKE_rigidbody_create_world(Scene *scene) | ||||
| rbw->pointcache = BKE_ptcache_add(&(rbw->ptcaches)); | rbw->pointcache = BKE_ptcache_add(&(rbw->ptcaches)); | ||||
| rbw->pointcache->step = 1; | rbw->pointcache->step = 1; | ||||
| /* return this sim world */ | /* return this sim world */ | ||||
| return rbw; | return rbw; | ||||
| } | } | ||||
| RigidBodyWorld *BKE_rigidbody_world_copy(RigidBodyWorld *rbw) | RigidBodyWorld *BKE_rigidbody_world_copy(RigidBodyWorld *rbw, const int flag) | ||||
| { | { | ||||
| RigidBodyWorld *rbwn = MEM_dupallocN(rbw); | RigidBodyWorld *rbw_copy = MEM_dupallocN(rbw); | ||||
| if (rbw->effector_weights) | if (rbw->effector_weights) { | ||||
| rbwn->effector_weights = MEM_dupallocN(rbw->effector_weights); | rbw_copy->effector_weights = MEM_dupallocN(rbw->effector_weights); | ||||
| if (rbwn->group) | } | ||||
| id_us_plus(&rbwn->group->id); | if ((flag & LIB_ID_COPY_NO_USER_REFCOUNT) == 0) { | ||||
| if (rbwn->constraints) | id_us_plus((ID *)rbw_copy->group); | ||||
| id_us_plus(&rbwn->constraints->id); | id_us_plus((ID *)rbw_copy->constraints); | ||||
| } | |||||
| rbwn->pointcache = BKE_ptcache_copy_list(&rbwn->ptcaches, &rbw->ptcaches, false); | |||||
| /* XXX Never copy caches here? */ | |||||
| rbwn->objects = NULL; | rbw_copy->pointcache = BKE_ptcache_copy_list(&rbw_copy->ptcaches, &rbw->ptcaches, flag & ~LIB_ID_COPY_CACHES); | ||||
| rbwn->physics_world = NULL; | |||||
| rbwn->numbodies = 0; | rbw_copy->objects = NULL; | ||||
| rbw_copy->physics_world = NULL; | |||||
| rbw_copy->numbodies = 0; | |||||
| return rbwn; | return rbw_copy; | ||||
| } | } | ||||
| void BKE_rigidbody_world_groups_relink(RigidBodyWorld *rbw) | void BKE_rigidbody_world_groups_relink(RigidBodyWorld *rbw) | ||||
| { | { | ||||
| ID_NEW_REMAP(rbw->group); | ID_NEW_REMAP(rbw->group); | ||||
| ID_NEW_REMAP(rbw->constraints); | ID_NEW_REMAP(rbw->constraints); | ||||
| ID_NEW_REMAP(rbw->effector_weights->group); | ID_NEW_REMAP(rbw->effector_weights->group); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 761 Lines • Show Last 20 Lines | |||||