[Bf-blender-cvs] [7253c67] particles_refactor: Only call the 'validate' function for particles once, to prevent them from being removed and added back to the world continuously, which resets the motion state each time. Also set the USED flag outside of validate since this is not executed every step and would otherwise delete all existing particles.

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


Commit: 7253c6752bf0ac239c52767a84321e8d4b8c06c4
Author: Lukas Tönne
Date:   Thu Jan 2 14:41:11 2014 +0100
https://developer.blender.org/rB7253c6752bf0ac239c52767a84321e8d4b8c06c4

Only call the 'validate' function for particles once, to prevent them
from being removed and added back to the world continuously, which
resets the motion state each time. Also set the USED flag outside of
validate since this is not executed every step and would otherwise
delete all existing particles.

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

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

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

diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c
index 9542391..ec306d9 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -628,8 +628,6 @@ static rbRigidBody *rigidbody_validate_particle(RigidBodyWorld *rbw, Object *UNU
 
 	RB_body_set_mass(body, 1.0f);
 //	RB_body_set_kinematic_state(body, rbo->flag & RBO_FLAG_KINEMATIC || rbo->flag & RBO_FLAG_DISABLED);
-	
-	RB_body_set_flag(body, RB_BODY_USED);
 
 	if (rbw && rbw->physics_world)
 		RB_dworld_add_body(rbw->physics_world, body, 0xFFFF);
@@ -650,9 +648,14 @@ static void rigidbody_world_build_particles(RigidBodyWorld *rbw, Object *ob, NPa
 	NParticleIterator iter;
 
 	for (BKE_nparticle_iter_init(state, &iter); BKE_nparticle_iter_valid(&iter); BKE_nparticle_iter_next(&iter)) {
-		rbRigidBody *body = rigidbody_validate_particle(rbw, ob, &iter, rebuild);
-		if (body)
+		/* XXX no equivalent to RBO_FLAG_NEEDS_VALIDATE for particles yet */
+		rbRigidBody *body = BKE_nparticle_iter_get_pointer(&iter, "rigid_body");
+		if (!body)
+			body = rigidbody_validate_particle(rbw, ob, &iter, rebuild);
+		if (body) {
 			rigidbody_sync_particle(rbw, ob, &iter);
+			RB_body_set_flag(body, RB_BODY_USED);
+		}
 	}
 }




More information about the Bf-blender-cvs mailing list