From 1fe9d671cf19f339917a78cb3ab0b6148ab1ceff Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Thu, 11 Aug 2016 13:36:29 +0300 Subject: Fix T49004 and motion blur of cloth, softbody, etc past the end frame. Point cache read code contains checks designed to prevent it reading stale data when the relevant simulation code should instead compute the next frame from the previous one. However in some situations like motion blur subframes the simulation can't possibly do it and just exits. This causes completely incorrect motion blur at or after the last cached frame. To fix, add a parameter that tells the cache code whether it should apply the checks and exit, or read what it can even if stale (true means exactly same as old behavior). Doing this in cache rather than clamping the frame number better in the caller lets it handle the case of incomplete cache that stops before the official last frame. Reviewed By: mont29, lukastoenne Maniphest Tasks: T49004 Differential Revision: https://developer.blender.org/D2144 --- source/blender/blenkernel/intern/rigidbody.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern/rigidbody.c') diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c index 0f1f9b4bdf7..c3ae5736aa9 100644 --- a/source/blender/blenkernel/intern/rigidbody.c +++ b/source/blender/blenkernel/intern/rigidbody.c @@ -1560,14 +1560,16 @@ void BKE_rigidbody_do_simulation(Scene *scene, float ctime) /* try to read from cache */ // RB_TODO deal with interpolated, old and baked results - if (BKE_ptcache_read(&pid, ctime)) { + bool can_simulate = (ctime == rbw->ltime + 1) && !(cache->flag & PTCACHE_BAKED); + + if (BKE_ptcache_read(&pid, ctime, can_simulate)) { BKE_ptcache_validate(cache, (int)ctime); rbw->ltime = ctime; return; } /* advance simulation, we can only step one frame forward */ - if (ctime == rbw->ltime + 1 && !(cache->flag & PTCACHE_BAKED)) { + if (can_simulate) { /* write cache for first frame when on second frame */ if (rbw->ltime == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact == 0)) { BKE_ptcache_write(&pid, startframe); -- cgit v1.2.3