diff options
author | Sergej Reich <sergej.reich@googlemail.com> | 2013-03-03 10:09:48 +0400 |
---|---|---|
committer | Sergej Reich <sergej.reich@googlemail.com> | 2013-03-03 10:09:48 +0400 |
commit | ceaf8e48ef5fbdb7e45a06b84bf24365ec5c5ed1 (patch) | |
tree | 2f1ec600c61c696635fa2867e8ccf3c95a3937d7 /source/blender/blenkernel | |
parent | 5ff6a5c6abe36b1521d310b0f7e0f6dfd3afa1f3 (diff) |
rigidbody: Revert to running simulation on frame update
Instead of flagging the rigid body world for frame update just call
BKE_rigidbody_do_simulation() recursively for all scenes.
This avoids having to constantly check if the simulation needs to be
updated.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/intern/rigidbody.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/scene.c | 33 |
2 files changed, 9 insertions, 26 deletions
diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c index 025522fad25..d144ac927a6 100644 --- a/source/blender/blenkernel/intern/rigidbody.c +++ b/source/blender/blenkernel/intern/rigidbody.c @@ -1262,8 +1262,6 @@ void BKE_rigidbody_do_simulation(Scene *scene, float ctime) BKE_ptcache_id_time(&pid, scene, ctime, &startframe, &endframe, NULL); cache = rbw->pointcache; - rbw->flag &= ~RBW_FLAG_FRAME_UPDATE; - if (ctime <= startframe) { rbw->ltime = startframe; return; diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 9479e3e2e0e..5498122f0d4 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -1081,22 +1081,22 @@ static void scene_depsgraph_hack(Scene *scene, Scene *scene_parent) } -static void scene_flag_rbw_recursive(Scene *scene) +static void scene_rebuild_rbw_recursive(Scene *scene, float ctime) { if (scene->set) - scene_flag_rbw_recursive(scene->set); + scene_rebuild_rbw_recursive(scene->set, ctime); if (BKE_scene_check_rigidbody_active(scene)) - scene->rigidbody_world->flag |= RBW_FLAG_FRAME_UPDATE; + BKE_rigidbody_rebuild_world(scene, ctime); } -static void scene_rebuild_rbw_recursive(Scene *scene, float ctime) +static void scene_do_rb_simulation_recursive(Scene *scene, float ctime) { if (scene->set) - scene_rebuild_rbw_recursive(scene->set, ctime); + scene_do_rb_simulation_recursive(scene->set, ctime); if (BKE_scene_check_rigidbody_active(scene)) - BKE_rigidbody_rebuild_world(scene, ctime); + BKE_rigidbody_do_simulation(scene, ctime); } static void scene_update_tagged_recursive(Main *bmain, Scene *scene, Scene *scene_parent) @@ -1110,22 +1110,6 @@ static void scene_update_tagged_recursive(Main *bmain, Scene *scene, Scene *scen if (scene->set) scene_update_tagged_recursive(bmain, scene->set, scene_parent); - /* run rigidbody sim - * - calculate/read values from cache into RBO's, to get flushed - * later when objects are evaluated (if they're tagged for eval) - */ - // XXX: this position may still change, objects not being updated correctly before simulation is run - // NOTE: current position is so that rigidbody sim affects other objects - if (BKE_scene_check_rigidbody_active(scene) && scene->rigidbody_world->flag & RBW_FLAG_FRAME_UPDATE) { - /* we use frame time of parent (this is "scene" itself for top-level of sets recursion), - * as that is the active scene controlling all timing in file at the moment - */ - float ctime = BKE_scene_frame_get(scene_parent); - - /* however, "scene" contains the rigidbody world needed for eval... */ - BKE_rigidbody_do_simulation(scene, ctime); - } - /* scene objects */ for (base = scene->base.first; base; base = base->next) { Object *ob = base->object; @@ -1249,8 +1233,9 @@ void BKE_scene_update_for_newframe(Main *bmain, Scene *sce, unsigned int lay) tag_main_idcode(bmain, ID_MA, FALSE); tag_main_idcode(bmain, ID_LA, FALSE); - /* flag rigid body worlds for update */ - scene_flag_rbw_recursive(sce); + /* run rigidbody sim */ + /* NOTE: current position is so that rigidbody sim affects other objects, might change in the future */ + scene_do_rb_simulation_recursive(sce, ctime); /* BKE_object_handle_update() on all objects, groups and sets */ scene_update_tagged_recursive(bmain, sce, sce); |