diff options
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_rigidbody.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/rigidbody.c | 10 |
3 files changed, 12 insertions, 2 deletions
diff --git a/source/blender/blenkernel/BKE_rigidbody.h b/source/blender/blenkernel/BKE_rigidbody.h index 607c3026388..2b19f60b5e4 100644 --- a/source/blender/blenkernel/BKE_rigidbody.h +++ b/source/blender/blenkernel/BKE_rigidbody.h @@ -52,6 +52,7 @@ void BKE_rigidbody_free_constraint(struct Object *ob); struct RigidBodyOb *BKE_rigidbody_copy_object(struct Object *ob); struct RigidBodyCon *BKE_rigidbody_copy_constraint(struct Object *ob); +void BKE_rigidbody_relink_constraint(struct RigidBodyCon *rbc); /* -------------- */ /* Setup */ diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 2312d801e0d..87457621ced 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -3185,6 +3185,9 @@ void BKE_object_relink(Object *ob) if (ob->adt) BKE_relink_animdata(ob->adt); + + if (ob->rigidbody_constraint) + BKE_rigidbody_relink_constraint(ob->rigidbody_constraint); ID_NEW(ob->parent); diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c index 58afc658867..24355149926 100644 --- a/source/blender/blenkernel/intern/rigidbody.c +++ b/source/blender/blenkernel/intern/rigidbody.c @@ -203,8 +203,6 @@ RigidBodyCon *BKE_rigidbody_copy_constraint(Object *ob) /* just duplicate the whole struct first (to catch all the settings) */ rbcN = MEM_dupallocN(ob->rigidbody_constraint); - // RB_TODO be more clever about copying constrained objects - /* tag object as needing to be verified */ rbcN->flag |= RBC_FLAG_NEEDS_VALIDATE; @@ -216,6 +214,13 @@ RigidBodyCon *BKE_rigidbody_copy_constraint(Object *ob) return rbcN; } +/* preserve relationships between constraints and rigid bodies after duplication */ +void BKE_rigidbody_relink_constraint(RigidBodyCon *rbc) +{ + ID_NEW(rbc->ob1); + ID_NEW(rbc->ob2); +} + /* ************************************** */ /* Setup Utilities - Validate Sim Instances */ @@ -1291,6 +1296,7 @@ void BKE_rigidbody_free_object(Object *ob) {} void BKE_rigidbody_free_constraint(Object *ob) {} struct RigidBodyOb *BKE_rigidbody_copy_object(Object *ob) { return NULL; } struct RigidBodyCon *BKE_rigidbody_copy_constraint(Object *ob) { return NULL; } +void BKE_rigidbody_relink_constraint(RigidBodyCon *rbc) {} void BKE_rigidbody_validate_sim_shape(Object *ob, short rebuild) {} void BKE_rigidbody_validate_sim_object(RigidBodyWorld *rbw, Object *ob, short rebuild) {} void BKE_rigidbody_validate_sim_constraint(RigidBodyWorld *rbw, Object *ob, short rebuild) {} |