Page MenuHome

Changes of rigid body related settings during simulation will break the simulation (worked in 2.78c)
Closed, ResolvedPublicBUG


System Information
Win7 x64

Blender Version
Broken: 2.79 RC (Master since between April and Juli)
Worked: 2.78c

Short description of error
Rigid body physics doesn't allow changes of related settings during simulation anymore. Either on mesh objects itself or on constraint objects a change immediately invalidates the simulation point cache and everything is lost.

Changing settings of physics during simulation is a crucial part for VFX work. This has been possible since Bullet is accessible from viewport, it was fully supported by Blender and Bullet in all past Blender releases. Also this breaks some Bullet related add-ons like the Bullet Constraints Builder on a fundamental level.

Exact steps for others to reproduce the error

  • Add rigid body property to the default cube
  • Start simulation and change mass of the object during simulation

Expected behavior: Cube continues to drop without noticeable influence
Current behavior: Cube suddenly jumps out of frame, orange cache indicator in timeline disappears

Event Timeline

Ummmm, ya, this is a bad thing....

Hey @Luca Rood (LucaRood), if there is no further fix to be expected, can you revert the changes leading to this serious issue now for the release please?


Can someone test this patch to make sure it fixes this and T50230 before I commit?

diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c
index 167b3ad1fec..03eb83376e7 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -1596,8 +1596,12 @@ void BKE_rigidbody_do_simulation(Scene *scene, float ctime)
 	BKE_ptcache_id_time(&pid, scene, ctime, &startframe, &endframe, NULL);
 	cache = rbw->pointcache;
+	if (ctime <= startframe) {
+		rbw->ltime = startframe;
+		return;
+	}
 	/* make sure we don't go out of cache frame range */
-	if (ctime > endframe) {
+	else if (ctime > endframe) {
 		ctime = endframe;
@@ -1611,12 +1615,9 @@ void BKE_rigidbody_do_simulation(Scene *scene, float ctime)
 	// RB_TODO deal with interpolated, old and baked results
 	bool can_simulate = (ctime == rbw->ltime + 1) && !(cache->flag & PTCACHE_BAKED);
-	if (cache->flag & PTCACHE_OUTDATED || cache->last_exact == 0) {
-		rbw->ltime = cache->startframe;
-	}
-	if (BKE_ptcache_read(&pid, ctime, can_simulate)) {
+	if (BKE_ptcache_read(&pid, ctime, can_simulate) == PTCACHE_READ_EXACT) {
 		BKE_ptcache_validate(cache, (int)ctime);
+		rbw->ltime = ctime;

Also found another bug unrelated to this which was introduced after 2.78 and is in the RC (baking is broken).
Will look into it later today.

The issue seems to be solved by this patch. Thanks for taking care of it.