[Bf-blender-cvs] [f077d9f] particles_refactor: Fix for rigid body removal methods: Flag new rigid bodies for particles as used to prevent freeing. Also remove bodies if they already exist, to prevent double adding and subsequent assert failure.

Lukas Tönne noreply at git.blender.org
Tue Apr 22 12:06:48 CEST 2014


Commit: f077d9f57ccbbb91bf4f611346cdef566026a9f9
Author: Lukas Tönne
Date:   Wed Jan 1 16:53:29 2014 +0100
https://developer.blender.org/rBf077d9f57ccbbb91bf4f611346cdef566026a9f9

Fix for rigid body removal methods: Flag new rigid bodies for particles
as used to prevent freeing. Also remove bodies if they already exist,
to prevent double adding and subsequent assert failure.

Conflicts:
	source/blender/blenkernel/intern/rigidbody.c

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

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

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

diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c
index cea8387..0effde2 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -518,9 +518,6 @@ static void rigidbody_validate_sim_object(RigidBodyWorld *rbw, Object *ob, bool
 	if (rbo->physics_shape == NULL || rebuild)
 		rigidbody_validate_sim_shape(ob, true);
 
-	if (rbo->physics_object && rebuild == false) {
-		RB_dworld_remove_body(rbw->physics_world, rbo->physics_object);
-	}
 	if (!rbo->physics_object || rebuild) {
 		if (rbo->physics_object) {
 			/* remove rigid body if it already exists before creating a new one
@@ -563,6 +560,8 @@ static void rigidbody_validate_sim_object(RigidBodyWorld *rbw, Object *ob, bool
 		RB_body_set_mass(body, RBO_GET_MASS(rbo));
 		RB_body_set_kinematic_state(body, rbo->flag & RBO_FLAG_KINEMATIC || rbo->flag & RBO_FLAG_DISABLED);
 	}
+	else
+		RB_dworld_remove_body(rbw->physics_world, rbo->physics_object);
 
 	if (rbw && rbw->physics_world)
 		RB_dworld_add_body(rbw->physics_world, rbo->physics_object, rbo->col_groups);
@@ -601,6 +600,8 @@ static rbRigidBody *rigidbody_validate_particle(RigidBodyWorld *rbw, Object *UNU
 			body = BLI_mempool_alloc(rbw->body_pool);
 		}
 	}
+	else
+		RB_dworld_remove_body(rbw->physics_world, body);
 	
 	RB_body_init(body, shape, loc, rot);
 	BKE_nparticle_iter_set_pointer(iter, "rigid_body", body);
@@ -629,6 +630,8 @@ static rbRigidBody *rigidbody_validate_particle(RigidBodyWorld *rbw, Object *UNU
 	RB_body_set_mass(rbo->physics_object, RBO_GET_MASS(rbo));
 	RB_body_set_kinematic_state(rbo->physics_object, rbo->flag & RBO_FLAG_KINEMATIC || rbo->flag & RBO_FLAG_DISABLED);
 #endif
+	
+	RB_body_set_flag(body, RB_BODY_USED);
 
 	if (rbw && rbw->physics_world)
 		RB_dworld_add_body(rbw->physics_world, body, 0xFFFF);




More information about the Bf-blender-cvs mailing list