diff options
author | Sergej Reich <sergej.reich@googlemail.com> | 2013-02-16 20:17:45 +0400 |
---|---|---|
committer | Sergej Reich <sergej.reich@googlemail.com> | 2013-02-16 20:17:45 +0400 |
commit | fda8927d01ba719963154a56b45952ee541a869d (patch) | |
tree | 481a8081680c63988e3690ca6998025ffc2d891b /source/blender/blenkernel/intern/rigidbody.c | |
parent | d9cc542728aa45aa3615b1396e5a147ec5c08cfa (diff) |
rigidbody: Further fix for background scenes
Since rigid bodies need their world to be be updated correctly we now
pass it alongside the parent scene in scene_update_tagged_recursive().
Add BKE_object_handle_update_ex() as well as other object functions
that take a RigidBodyWorld for this.
Ideally this shouldn't be needed but we'd have to restructure scene
handling for that. It's not a small taks however and definitely not
something that can be done before release.
Thanks to Campbell for review.
Diffstat (limited to 'source/blender/blenkernel/intern/rigidbody.c')
-rw-r--r-- | source/blender/blenkernel/intern/rigidbody.c | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c index 9ae82422ca2..26f0c25617f 100644 --- a/source/blender/blenkernel/intern/rigidbody.c +++ b/source/blender/blenkernel/intern/rigidbody.c @@ -1130,31 +1130,23 @@ static void rigidbody_update_simulation_post_step(RigidBodyWorld *rbw) } } } - /* Sync rigid body and object transformations */ -void BKE_rigidbody_sync_transforms(Scene *scene, Object *ob, float ctime) +void BKE_rigidbody_sync_transforms(RigidBodyWorld *rbw, Object *ob, float ctime) { - RigidBodyWorld *rbw = scene->rigidbody_world; RigidBodyOb *rbo = ob->rigidbody_object; - bool world_ok = true; /* keep original transform for kinematic and passive objects */ - if ((rbo == NULL) || (rbo->flag & RBO_FLAG_KINEMATIC) || (rbo->type == RBO_TYPE_PASSIVE)) + if (ELEM(NULL, rbw, rbo) || rbo->flag & RBO_FLAG_KINEMATIC || rbo->type == RBO_TYPE_PASSIVE) return; - - /* "scene" may not be the one where object + rigidbody sim actually reside - * due to the quirks of how background-sets eval works [#33970] - */ - if (rbw) { - /* 1) no cache exists before startframe */ - /* 2) keep original transform when simulation is muted */ - world_ok = (ctime > rbw->pointcache->startframe) && !(rbw->flag & RBW_FLAG_MUTED); - } /* use rigid body transform after cache start frame if objects is not being transformed */ - if (world_ok && !((ob->flag & SELECT) && (G.moving & G_TRANSFORM_OBJ))) { + if (ctime > rbw->pointcache->startframe && !(ob->flag & SELECT && G.moving & G_TRANSFORM_OBJ)) { float mat[4][4], size_mat[4][4], size[3]; + /* keep original transform when the simulation is muted */ + if (rbw->flag & RBW_FLAG_MUTED) + return; + normalize_qt(rbo->orn); // RB_TODO investigate why quaternion isn't normalized at this point quat_to_mat4(mat, rbo->orn); copy_v3_v3(mat[3], rbo->pos); |