[Bf-blender-cvs] [b6ff000] particles_refactor: Stub functions for creating and updating rigid bodies from particle systems in the RigidBodyWorld steps.

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


Commit: b6ff000ec2063bdeb3d57e429bb484aa1997e777
Author: Lukas Tönne
Date:   Mon Dec 23 09:35:55 2013 +0100
https://developer.blender.org/rBb6ff000ec2063bdeb3d57e429bb484aa1997e777

Stub functions for creating and updating rigid bodies from particle
systems in the RigidBodyWorld steps.

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

M	source/blender/blenkernel/BKE_nparticle.h
M	source/blender/blenkernel/intern/nparticle.c
M	source/blender/blenkernel/intern/rigidbody.c

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

diff --git a/source/blender/blenkernel/BKE_nparticle.h b/source/blender/blenkernel/BKE_nparticle.h
index bfee1e5..36d42db 100644
--- a/source/blender/blenkernel/BKE_nparticle.h
+++ b/source/blender/blenkernel/BKE_nparticle.h
@@ -116,4 +116,11 @@ struct NParticleDisplay *BKE_nparticle_display_particle(void);
 struct NParticleDisplay *BKE_nparticle_display_copy(struct NParticleDisplay *display);
 void BKE_nparticle_display_free(struct NParticleDisplay *display);
 
+
+struct Object;
+struct RigidBodyWorld;
+
+void BKE_nparticle_system_update_rigid_body(struct RigidBodyWorld *rbw, struct Object *ob, struct NParticleSystem *psys);
+void BKE_nparticle_system_apply_rigid_body(struct RigidBodyWorld *rbw, struct Object *ob, struct NParticleSystem *psys);
+
 #endif /* BKE_NPARTICLE_H */
diff --git a/source/blender/blenkernel/intern/nparticle.c b/source/blender/blenkernel/intern/nparticle.c
index 4fef842..74e8678 100644
--- a/source/blender/blenkernel/intern/nparticle.c
+++ b/source/blender/blenkernel/intern/nparticle.c
@@ -37,8 +37,11 @@
 #include "BLI_string.h"
 
 #include "DNA_nparticle_types.h"
+#include "DNA_object_types.h"
+#include "DNA_rigidbody_types.h"
 
 #include "BKE_nparticle.h"
+#include "BKE_rigidbody.h"
 
 /* XXX TODO make this configurable */
 #define PAGE_BYTES 65536
@@ -589,3 +592,14 @@ void BKE_nparticle_display_free(NParticleDisplay *display)
 {
 	MEM_freeN(display);
 }
+
+
+void BKE_nparticle_system_update_rigid_body(RigidBodyWorld *rbw, Object *ob, NParticleSystem *psys)
+{
+	
+}
+
+void BKE_nparticle_system_apply_rigid_body(RigidBodyWorld *rbw, Object *ob, NParticleSystem *psys)
+{
+	
+}
diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c
index 3f92f58..0e17166 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -62,6 +62,7 @@
 #include "BKE_group.h"
 #include "BKE_library.h"
 #include "BKE_mesh.h"
+#include "BKE_nparticle.h"
 #include "BKE_object.h"
 #include "BKE_pointcache.h"
 #include "BKE_rigidbody.h"
@@ -1117,8 +1118,12 @@ static void rigidbody_update_simulation(Scene *scene, RigidBodyWorld *rbw, bool
 	/* update objects */
 	for (go = rbw->group->gobject.first; go; go = go->next) {
 		Object *ob = go->ob;
+		ModifierData *md;
 
-		if (ob && ob->type == OB_MESH) {
+		if (!ob)
+			continue;
+		
+		if (ob->type == OB_MESH) {
 			/* validate that we've got valid object set up here... */
 			RigidBodyOb *rbo = ob->rigidbody_object;
 			/* update transformation matrix of the object so we don't get a frame of lag for simple animations */
@@ -1158,7 +1163,16 @@ static void rigidbody_update_simulation(Scene *scene, RigidBodyWorld *rbw, bool
 			/* update simulation object... */
 			rigidbody_update_sim_ob(scene, rbw, ob, rbo);
 		}
+
+		/* particles */
+		for (md = ob->modifiers.first; md; md = md->next) {
+			if (md->type == eModifierType_NParticleSystem) {
+				NParticleSystemModifierData *pmd = (NParticleSystemModifierData*)md;
+				BKE_nparticle_system_update_rigid_body(rbw, ob, pmd->psys);
+			}
+		}
 	}
+	
 	/* update constraints */
 	if (rbw->constraints == NULL) /* no constraints, move on */
 		return;
@@ -1201,16 +1215,26 @@ static void rigidbody_update_simulation_post_step(RigidBodyWorld *rbw)
 
 	for (go = rbw->group->gobject.first; go; go = go->next) {
 		Object *ob = go->ob;
-
-		if (ob) {
-			RigidBodyOb *rbo = ob->rigidbody_object;
-			/* reset kinematic state for transformed objects */
-			if (rbo && (ob->flag & SELECT) && (G.moving & G_TRANSFORM_OBJ)) {
-				RB_body_set_kinematic_state(rbo->physics_object, rbo->flag & RBO_FLAG_KINEMATIC || rbo->flag & RBO_FLAG_DISABLED);
-				RB_body_set_mass(rbo->physics_object, RBO_GET_MASS(rbo));
-				/* deactivate passive objects so they don't interfere with deactivation of active objects */
-				if (rbo->type == RBO_TYPE_PASSIVE)
-					RB_body_deactivate(rbo->physics_object);
+		RigidBodyOb *rbo;
+		ModifierData *md;
+
+		if (!ob)
+			continue;
+
+		rbo = ob->rigidbody_object;
+		/* reset kinematic state for transformed objects */
+		if (rbo && (ob->flag & SELECT) && (G.moving & G_TRANSFORM_OBJ)) {
+			RB_body_set_kinematic_state(rbo->physics_object, rbo->flag & RBO_FLAG_KINEMATIC || rbo->flag & RBO_FLAG_DISABLED);
+			RB_body_set_mass(rbo->physics_object, RBO_GET_MASS(rbo));
+			/* deactivate passive objects so they don't interfere with deactivation of active objects */
+			if (rbo->type == RBO_TYPE_PASSIVE)
+				RB_body_deactivate(rbo->physics_object);
+		}
+		
+		for (md = ob->modifiers.first; md; md = md->next) {
+			if (md->type == eModifierType_NParticleSystem) {
+				NParticleSystemModifierData *pmd = (NParticleSystemModifierData*)md;
+				BKE_nparticle_system_apply_rigid_body(rbw, ob, pmd->psys);
 			}
 		}
 	}




More information about the Bf-blender-cvs mailing list