Fix T50230: Rigid Body simulation shouldn't step when time is beyond cached area

This makes the last time (`ltime`) stored in the rigid body world (`rbw`)
only be updated once a simulation step actually occurs, this prevents
another simulation step from being solved unless the current time is
exactly one frame after the last cached frame. Thus this prevents the
formation of gaps in the cache, such as seen in T50230.

Reviewers: mont29, sergey, angavrilov

Tags: #physics

Maniphest Tasks: T50230

Differential Revision: https://developer.blender.org/D2458
This commit is contained in:
2017-06-30 15:56:44 +02:00
parent 76eefa5c0d
commit 9cd6b03187

View File

@@ -1563,12 +1563,8 @@ void BKE_rigidbody_do_simulation(Scene *scene, float ctime)
BKE_ptcache_id_time(&pid, scene, ctime, &startframe, &endframe, NULL); BKE_ptcache_id_time(&pid, scene, ctime, &startframe, &endframe, NULL);
cache = rbw->pointcache; cache = rbw->pointcache;
if (ctime <= startframe) {
rbw->ltime = startframe;
return;
}
/* make sure we don't go out of cache frame range */ /* make sure we don't go out of cache frame range */
else if (ctime > endframe) { if (ctime > endframe) {
ctime = endframe; ctime = endframe;
} }
@@ -1584,7 +1580,6 @@ void BKE_rigidbody_do_simulation(Scene *scene, float ctime)
if (BKE_ptcache_read(&pid, ctime, can_simulate)) { if (BKE_ptcache_read(&pid, ctime, can_simulate)) {
BKE_ptcache_validate(cache, (int)ctime); BKE_ptcache_validate(cache, (int)ctime);
rbw->ltime = ctime;
return; return;
} }