Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergej Reich <sergej.reich@googlemail.com>2013-04-07 18:09:29 +0400
committerSergej Reich <sergej.reich@googlemail.com>2013-04-07 18:09:29 +0400
commit42e8f3e88971a320c4204d5386f740b23b4ecf16 (patch)
tree6d169ddb87c435b5989bbc38daf2d91d11d084b4 /source/blender/editors/transform/transform_conversions.c
parentfd6a96216819f14763e4b6c8ab33ec58fead5bd2 (diff)
rigidbody: Fix/workaround for transforming rigid bodies with parents
Since we use the rigid body transform when transforming rigid bodies things like parents and constraints add an offset because rigid body transforms are in global space. Now we just don't take rigid body transform into account on simulation start frame so there are no problems when doing the initial setup. The problem still exists when simulation is running of course. To properly fix this we'd have to solve parenting and constratins while taking rigid bodies into account before and after transform. We'll have to see if it's really needed, would like to avoid it though.
Diffstat (limited to 'source/blender/editors/transform/transform_conversions.c')
-rw-r--r--source/blender/editors/transform/transform_conversions.c40
1 files changed, 24 insertions, 16 deletions
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index 820a343497c..f711dd1d438 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -4596,23 +4596,28 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
if (t->mode != TFM_DUMMY && ob->rigidbody_object) {
float rot[3][3], scale[3];
+ float ctime = BKE_scene_frame_get(scene);
- /* save original object transform */
- copy_v3_v3(td->ext->oloc, ob->loc);
+ /* only use rigid body transform if simulation is running, avoids problems with initial setup of rigid bodies */
+ if (BKE_rigidbody_check_sim_running(scene->rigidbody_world, ctime)) {
- if (ob->rotmode > 0) {
- copy_v3_v3(td->ext->orot, ob->rot);
- }
- else if (ob->rotmode == ROT_MODE_AXISANGLE) {
- td->ext->orotAngle = ob->rotAngle;
- copy_v3_v3(td->ext->orotAxis, ob->rotAxis);
- }
- else {
- copy_qt_qt(td->ext->oquat, ob->quat);
+ /* save original object transform */
+ copy_v3_v3(td->ext->oloc, ob->loc);
+
+ if (ob->rotmode > 0) {
+ copy_v3_v3(td->ext->orot, ob->rot);
+ }
+ else if (ob->rotmode == ROT_MODE_AXISANGLE) {
+ td->ext->orotAngle = ob->rotAngle;
+ copy_v3_v3(td->ext->orotAxis, ob->rotAxis);
+ }
+ else {
+ copy_qt_qt(td->ext->oquat, ob->quat);
+ }
+ /* update object's loc/rot to get current rigid body transform */
+ mat4_to_loc_rot_size(ob->loc, rot, scale, ob->obmat);
+ BKE_object_mat3_to_rot(ob, rot, FALSE);
}
- /* update object's loc/rot to get current rigid body transform */
- mat4_to_loc_rot_size(ob->loc, rot, scale, ob->obmat);
- BKE_object_mat3_to_rot(ob, rot, FALSE);
}
/* axismtx has the real orientation */
@@ -5571,8 +5576,11 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
recalcObPaths = 1;
}
/* restore rigid body transform */
- if (ob->rigidbody_object && canceled)
- BKE_rigidbody_aftertrans_update(ob, td->ext->oloc, td->ext->orot, td->ext->oquat, td->ext->orotAxis, td->ext->orotAngle);
+ if (ob->rigidbody_object && canceled) {
+ float ctime = BKE_scene_frame_get(t->scene);
+ if (BKE_rigidbody_check_sim_running(t->scene->rigidbody_world, ctime))
+ BKE_rigidbody_aftertrans_update(ob, td->ext->oloc, td->ext->orot, td->ext->oquat, td->ext->orotAxis, td->ext->orotAngle);
+ }
}
/* recalculate motion paths for objects (if necessary)