[Bf-blender-cvs] [ec314ae] object_nodes: Use a dedicated struct EffectorContext for storing results of effector lookup rather than a plain ListBase.

Lukas Tönne noreply at git.blender.org
Tue Nov 24 09:42:53 CET 2015


Commit: ec314ae15fe599498984a4ed5a55b053ff71a624
Author: Lukas Tönne
Date:   Sat Oct 10 10:01:01 2015 +0200
Branches: object_nodes
https://developer.blender.org/rBec314ae15fe599498984a4ed5a55b053ff71a624

Use a dedicated struct EffectorContext for storing results of effector
lookup rather than a plain ListBase.

This paves the way for future inclusion of evaluation context info in
the EffectorContext struct, and hides some of the annoying details of
the ListBase double dereferencing.

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

M	source/blender/blenkernel/BKE_effect.h
M	source/blender/blenkernel/BKE_particle.h
M	source/blender/blenkernel/intern/boids.c
M	source/blender/blenkernel/intern/cloth.c
M	source/blender/blenkernel/intern/depsgraph.c
M	source/blender/blenkernel/intern/dynamicpaint.c
M	source/blender/blenkernel/intern/effect.c
M	source/blender/blenkernel/intern/particle.c
M	source/blender/blenkernel/intern/particle_system.c
M	source/blender/blenkernel/intern/rigidbody.c
M	source/blender/blenkernel/intern/smoke.c
M	source/blender/blenkernel/intern/softbody.c
M	source/blender/depsgraph/intern/depsgraph_build_relations.cc
M	source/blender/makesdna/DNA_particle_types.h
M	source/blender/physics/BPH_mass_spring.h
M	source/blender/physics/intern/BPH_mass_spring.cpp

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

diff --git a/source/blender/blenkernel/BKE_effect.h b/source/blender/blenkernel/BKE_effect.h
index f8fee44..0b79a89 100644
--- a/source/blender/blenkernel/BKE_effect.h
+++ b/source/blender/blenkernel/BKE_effect.h
@@ -109,11 +109,24 @@ typedef struct EffectorCache {
 	int flag;
 } EffectorCache;
 
+typedef struct EffectorContext {
+	ListBase effectors;
+	
+	void *eval_func;
+	void *eval_data;
+} EffectorContext;
+
 void            free_partdeflect(struct PartDeflect *pd);
-struct ListBase *pdInitEffectors(struct Scene *scene, struct Object *ob_src, struct ParticleSystem *psys_src, struct EffectorWeights *weights, bool precalc);
-void            pdEndEffectors(struct ListBase **effectors);
-void            pdPrecalculateEffectors(struct ListBase *effectors);
-void            pdDoEffectors(struct ListBase *effectors, struct ListBase *colliders, struct EffectorWeights *weights, struct EffectedPoint *point, float *force, float *impulse);
+struct EffectorContext *pdInitEffectors(struct Scene *scene, struct Object *ob_src, struct ParticleSystem *psys_src, struct EffectorWeights *weights, bool precalc);
+void            pdEndEffectors(struct EffectorContext *effctx);
+void            pdPrecalculateEffectors(struct EffectorContext *effctx);
+void            pdDoEffectors(struct EffectorContext *effctx, struct ListBase *colliders, struct EffectorWeights *weights,
+                              struct EffectedPoint *point, float *force, float *impulse);
+
+struct EffectorContext *pdInitJITEffectors(struct Scene *scene, struct Object *ob_src, struct ParticleSystem *psys_src, struct EffectorWeights *weights, bool precalc);
+void            pdEndJITEffectors(struct EffectorContext *effctx);
+void            pdDoJITEffectors(struct EffectorContext *effctx, struct ListBase *colliders, struct EffectorWeights *weights,
+                                 struct EffectedPoint *point, float *force, float *impulse);
 
 void pd_point_from_particle(struct ParticleSimulationData *sim, struct ParticleData *pa, struct ParticleKey *state, struct EffectedPoint *point);
 void pd_point_from_loc(struct Scene *scene, float *loc, float *vel, int index, struct EffectedPoint *point);
diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h
index 00cc48c..b89efff 100644
--- a/source/blender/blenkernel/BKE_particle.h
+++ b/source/blender/blenkernel/BKE_particle.h
@@ -62,6 +62,7 @@ struct RNG;
 struct BVHTreeRay;
 struct BVHTreeRayHit; 
 struct EdgeHash;
+struct EffectorContext;
 
 #define PARTICLE_P              ParticleData * pa; int p
 #define LOOP_PARTICLES  for (p = 0, pa = psys->particles; p < psys->totpart; p++, pa++)
@@ -329,8 +330,8 @@ void psys_find_parents(struct ParticleSimulationData *sim);
 void psys_cache_paths(struct ParticleSimulationData *sim, float cfra);
 void psys_cache_edit_paths(struct Scene *scene, struct Object *ob, struct PTCacheEdit *edit, float cfra);
 void psys_cache_child_paths(struct ParticleSimulationData *sim, float cfra, int editupdate);
-int do_guides(struct ParticleSettings *part, struct ListBase *effectors, ParticleKey *state, int pa_num, float time);
-void precalc_guides(struct ParticleSimulationData *sim, struct ListBase *effectors);
+int do_guides(struct ParticleSettings *part, struct EffectorContext *effectors, ParticleKey *state, int pa_num, float time);
+void precalc_guides(struct ParticleSimulationData *sim, struct EffectorContext *effectors);
 float psys_get_timestep(struct ParticleSimulationData *sim);
 float psys_get_child_time(struct ParticleSystem *psys, struct ChildParticle *cpa, float cfra, float *birthtime, float *dietime);
 float psys_get_child_size(struct ParticleSystem *psys, struct ChildParticle *cpa, float cfra, float *pa_time);
diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c
index 64b9bf4..a87bd1d 100644
--- a/source/blender/blenkernel/intern/boids.c
+++ b/source/blender/blenkernel/intern/boids.c
@@ -72,7 +72,7 @@ static int rule_goal_avoid(BoidRule *rule, BoidBrainData *bbd, BoidValues *val,
 	BoidSettings *boids = bbd->part->boids;
 	BoidParticle *bpa = pa->boid;
 	EffectedPoint epoint;
-	ListBase *effectors = bbd->sim->psys->effectors;
+	EffectorContext *effectors = bbd->sim->psys->effectors;
 	EffectorCache *cur, *eff = NULL;
 	EffectorCache temp_eff;
 	EffectorData efd, cur_efd;
@@ -86,7 +86,7 @@ static int rule_goal_avoid(BoidRule *rule, BoidBrainData *bbd, BoidValues *val,
 	pd_point_from_particle(bbd->sim, pa, &pa->state, &epoint);
 
 	/* first find out goal/predator with highest priority */
-	if (effectors) for (cur = effectors->first; cur; cur=cur->next) {
+	if (effectors) for (cur = effectors->effectors.first; cur; cur=cur->next) {
 		Object *eob = cur->ob;
 		PartDeflect *pd = cur->pd;
 
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index 7a2a4e0..1c6c485 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -344,7 +344,7 @@ static int do_step_cloth(Object *ob, ClothModifierData *clmd, DerivedMesh *resul
 {
 	ClothVertex *verts = NULL;
 	Cloth *cloth;
-	ListBase *effectors = NULL;
+	EffectorContext *effectors;
 	MVert *mvert;
 	unsigned int i = 0;
 	int ret = 0;
@@ -378,7 +378,7 @@ static int do_step_cloth(Object *ob, ClothModifierData *clmd, DerivedMesh *resul
 
 	// TIMEIT_END(cloth_step)
 
-	pdEndEffectors(&effectors);
+	pdEndEffectors(effectors);
 
 	// printf ( "%f\n", ( float ) tval() );
 	
diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c
index 42b6b31..477d8c8 100644
--- a/source/blender/blenkernel/intern/depsgraph.c
+++ b/source/blender/blenkernel/intern/depsgraph.c
@@ -761,7 +761,7 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Main *bmain, Sc
 			BoidRule *rule = NULL;
 			BoidState *state = NULL;
 			ParticleSettings *part = psys->part;
-			ListBase *effectors = NULL;
+			EffectorContext *effectors;
 			EffectorCache *eff;
 
 			dag_add_relation(dag, node, node, DAG_RL_OB_DATA, "Particle-Object Relation");
@@ -800,7 +800,7 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Main *bmain, Sc
 			effectors = pdInitEffectors(scene, ob, psys, part->effector_weights, false);
 
 			if (effectors) {
-				for (eff = effectors->first; eff; eff = eff->next) {
+				for (eff = effectors->effectors.first; eff; eff = eff->next) {
 					if (eff->psys) {
 						node2 = dag_get_node(dag, eff->ob);
 						dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Particle Field");
@@ -808,7 +808,7 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Main *bmain, Sc
 				}
 			}
 
-			pdEndEffectors(&effectors);
+			pdEndEffectors(effectors);
 
 			if (part->boids) {
 				for (state = part->boids->states.first; state; state = state->next) {
diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c
index f3ce988..25eeb3c 100644
--- a/source/blender/blenkernel/intern/dynamicpaint.c
+++ b/source/blender/blenkernel/intern/dynamicpaint.c
@@ -4177,7 +4177,9 @@ static int dynamicPaint_prepareEffectStep(DynamicPaintSurface *surface, Scene *s
 	/* Init force data if required */
 	if (surface->effect & MOD_DPAINT_EFFECT_DO_DRIP) {
 		float vel[3] = {0};
-		ListBase *effectors = pdInitEffectors(scene, ob, NULL, surface->effector_weights, true);
+		EffectorContext *effectors;
+
+		effectors = pdInitEffectors(scene, ob, NULL, surface->effector_weights, true);
 
 		/* allocate memory for force data (dir vector + strength) */
 		*force = MEM_mallocN(sData->total_points * 4 * sizeof(float), "PaintEffectForces");
@@ -4229,7 +4231,7 @@ static int dynamicPaint_prepareEffectStep(DynamicPaintSurface *surface, Scene *s
 			}
 			average_force /= sData->total_points;
 		}
-		pdEndEffectors(&effectors);
+		pdEndEffectors(effectors);
 	}
 
 	/* Get number of required steps using average point distance
diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c
index e66fa86..ece29bc 100644
--- a/source/blender/blenkernel/intern/effect.c
+++ b/source/blender/blenkernel/intern/effect.c
@@ -157,7 +157,7 @@ static EffectorCache *new_effector_cache(Scene *scene, Object *ob, ParticleSyste
 	eff->frame = -1;
 	return eff;
 }
-static void add_object_to_effectors(ListBase **effectors, Scene *scene, EffectorWeights *weights, Object *ob, Object *ob_src)
+static void add_object_to_effectors(EffectorContext *effctx, Scene *scene, EffectorWeights *weights, Object *ob, Object *ob_src)
 {
 	EffectorCache *eff = NULL;
 
@@ -167,17 +167,14 @@ static void add_object_to_effectors(ListBase **effectors, Scene *scene, Effector
 	if (ob->pd->shape == PFIELD_SHAPE_POINTS && !ob->derivedFinal )
 		return;
 
-	if (*effectors == NULL)
-		*effectors = MEM_callocN(sizeof(ListBase), "effectors list");
-
 	eff = new_effector_cache(scene, ob, NULL, ob->pd);
 
 	/* make sure imat is up to date */
 	invert_m4_m4(ob->imat, ob->obmat);
 
-	BLI_addtail(*effectors, eff);
+	BLI_addtail(&effctx->effectors, eff);
 }
-static void add_particles_to_effectors(ListBase **effectors, Scene *scene, EffectorWeights *weights, Object *ob, ParticleSystem *psys, ParticleSystem *psys_src)
+static void add_particles_to_effectors(EffectorContext *effctx, Scene *scene, EffectorWeights *weights, Object *ob, ParticleSystem *psys, ParticleSystem *psys_src)
 {
 	ParticleSettings *part= psys->part;
 
@@ -188,27 +185,21 @@ static void add_particles_to_effectors(ListBase **effectors, Scene *scene, Effec
 		return;
 
 	if ( part->pd && part->pd->forcefield && weights->weight[part->pd->forcefield] != 0.0f) {
-		if (*effectors == NULL)
-			*effectors = MEM_callocN(sizeof(ListBase), "effectors list");
-
-		BLI_addtail(*effectors, new_effector_cache(scene, ob, psys, part->pd));
+		BLI_addtail(&effctx->effectors, new_effector_cache(scene, ob, psys, part->pd));
 	}
 
 	if (part->pd2 && part->pd2->forcefield && weights->weight[part->pd2->forcefield] != 0.0f) {
-		if (*effectors == NULL)
-			*effectors = MEM_callocN(sizeof(ListBase), "effectors list");
-
-		BLI_addtail(*effectors, new_effector_cache(scene, ob, psys, part->pd2))

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list