[Bf-blender-cvs] [a6ef823ac46] master: Fix T61124: Lag on physics simulation

Sergey Sharybin noreply at git.blender.org
Wed Feb 6 10:13:12 CET 2019


Commit: a6ef823ac4686d1dfcb04b49344e4a7c09d378a0
Author: Sergey Sharybin
Date:   Wed Feb 6 10:09:00 2019 +0100
Branches: master
https://developer.blender.org/rBa6ef823ac4686d1dfcb04b49344e4a7c09d378a0

Fix T61124: Lag on physics simulation

Need to synchronize simulated frame back to original object.

Solves the lag during transformation, but amount of floppyness is
lower for some reason. Final animated object behaves the same as
in older Blender though.

===================================================================

M	source/blender/blenkernel/intern/softbody.c

===================================================================

diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c
index 133d645a279..86791512dc6 100644
--- a/source/blender/blenkernel/intern/softbody.c
+++ b/source/blender/blenkernel/intern/softbody.c
@@ -3344,6 +3344,16 @@ static void softbody_step(struct Depsgraph *depsgraph, Scene *scene, Object *ob,
 	}
 }
 
+static void sbStoreLastFrame(struct Depsgraph *depsgraph, Object *object, float framenr)
+{
+	if (!DEG_is_active(depsgraph)) {
+		return;
+	}
+	Object *object_orig = DEG_get_original_object(object);
+	object->soft->last_frame = framenr;
+	object_orig->soft->last_frame = framenr;
+}
+
 /* simulates one step. framenr is in frames */
 void sbObjectStep(struct Depsgraph *depsgraph, Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], int numVerts)
 {
@@ -3415,7 +3425,7 @@ void sbObjectStep(struct Depsgraph *depsgraph, Scene *scene, Object *ob, float c
 		BKE_ptcache_validate(cache, framenr);
 		cache->flag &= ~PTCACHE_REDO_NEEDED;
 
-		sb->last_frame = framenr;
+		sbStoreLastFrame(depsgraph, ob, framenr);
 
 		return;
 	}
@@ -3436,7 +3446,7 @@ void sbObjectStep(struct Depsgraph *depsgraph, Scene *scene, Object *ob, float c
 		if (cache_result == PTCACHE_READ_INTERPOLATED && cache->flag & PTCACHE_REDO_NEEDED && can_write_cache)
 			BKE_ptcache_write(&pid, framenr);
 
-		sb->last_frame = framenr;
+		sbStoreLastFrame(depsgraph, ob, framenr);
 
 		return;
 	}
@@ -3471,5 +3481,5 @@ void sbObjectStep(struct Depsgraph *depsgraph, Scene *scene, Object *ob, float c
 	BKE_ptcache_validate(cache, framenr);
 	BKE_ptcache_write(&pid, framenr);
 
-	sb->last_frame = framenr;
+	sbStoreLastFrame(depsgraph, ob, framenr);
 }



More information about the Bf-blender-cvs mailing list