[Bf-blender-cvs] [750798a7773] fracture_modifier: crash fix for deleting connected objects before its connectors

Martin Felke noreply at git.blender.org
Sun Feb 18 11:21:01 CET 2018


Commit: 750798a77731efbe7a496669a52421e9a445c566
Author: Martin Felke
Date:   Sun Feb 18 11:20:39 2018 +0100
Branches: fracture_modifier
https://developer.blender.org/rB750798a77731efbe7a496669a52421e9a445c566

crash fix for deleting connected objects before its connectors

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

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

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

diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c
index 04043617661..b88900f3746 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -1409,7 +1409,7 @@ void BKE_rigidbody_remove_shard(Scene *scene, MeshIsland *mi)
 	}
 }
 
-static bool do_remove_modifier(RigidBodyWorld* rbw, ModifierData *md)
+static bool do_remove_modifier(RigidBodyWorld* rbw, ModifierData *md, Object *ob)
 {
 	RigidBodyShardCon *con;
 	MeshIsland *mi;
@@ -1420,6 +1420,8 @@ static bool do_remove_modifier(RigidBodyWorld* rbw, ModifierData *md)
 	{
 		fmd = (FractureModifierData *)md;
 		modFound = true;
+		GroupObject *go;
+
 		for (con = fmd->meshConstraints.first; con; con = con->next) {
 			if (rbw && rbw->physics_world && con->physics_constraint) {
 				RB_dworld_remove_constraint(rbw->physics_world, con->physics_constraint);
@@ -1428,6 +1430,23 @@ static bool do_remove_modifier(RigidBodyWorld* rbw, ModifierData *md)
 			}
 		}
 
+		/*if we are part of a connected object, delete the parent's constraints here too*/
+		for (go = rbw->group->gobject.first; go; go = go->next)
+		{
+			FractureModifierData *fmdi = (FractureModifierData*)modifiers_findByType(go->ob, eModifierType_Fracture);
+			if (fmdi && ob != go->ob)
+			{
+				for (con = fmdi->meshConstraints.first; con; con = con->next) {
+					if (rbw && rbw->physics_world && con->physics_constraint) {
+						RB_dworld_remove_constraint(rbw->physics_world, con->physics_constraint);
+						RB_constraint_delete(con->physics_constraint);
+						con->physics_constraint = NULL;
+					}
+				}
+			}
+		}
+
+
 		for (mi = fmd->meshIslands.first; mi; mi = mi->next) {
 			if (mi->rigidbody != NULL) {
 				if (rbw->physics_world && mi->rigidbody && mi->rigidbody->physics_object)
@@ -1474,7 +1493,7 @@ void BKE_rigidbody_remove_object(Scene *scene, Object *ob)
 
 	if (rbw) {
 		for (md = ob->modifiers.first; md; md = md->next) {
-			modFound = do_remove_modifier(rbw, md);
+			modFound = do_remove_modifier(rbw, md, ob);
 		}
 
 		if (!modFound) {



More information about the Bf-blender-cvs mailing list