[Bf-blender-cvs] [b4596cf] depsgraph_refactor: Ported over build functions for particle systems.
Lukas Tönne
noreply at git.blender.org
Sat Apr 12 09:34:28 CEST 2014
Commit: b4596cfdd971c60f808175975237901aa5a03587
Author: Lukas Tönne
Date: Thu Apr 10 13:58:08 2014 +0200
https://developer.blender.org/rBb4596cfdd971c60f808175975237901aa5a03587
Ported over build functions for particle systems.
===================================================================
M source/blender/depsgraph/intern/depsgraph_build.h
M source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
M source/blender/depsgraph/intern/depsgraph_build_relations.cpp
M source/blender/depsgraph/intern/depsgraph_type_defines.cpp
M source/blender/depsgraph/intern/depsgraph_types.h
===================================================================
diff --git a/source/blender/depsgraph/intern/depsgraph_build.h b/source/blender/depsgraph/intern/depsgraph_build.h
index 03dc742..1bf8160 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.h
+++ b/source/blender/depsgraph/intern/depsgraph_build.h
@@ -74,6 +74,7 @@ struct DepsgraphNodeBuilder {
ComponentDepsNode *build_object_transform(Object *ob, IDDepsNode *ob_node);
void build_constraints(ComponentDepsNode *comp_node, eDepsNode_Type constraint_op_type);
void build_rigidbody(IDDepsNode *scene_node, Scene *scene);
+ void build_particles(IDDepsNode *ob_node, Object *ob);
void build_animdata(IDDepsNode *id_node);
OperationDepsNode *build_driver(ComponentDepsNode *adt_node, FCurve *fcurve);
void build_ik_pose(ComponentDepsNode *bone_node, Object *ob, bPoseChannel *pchan, bConstraint *con);
@@ -153,6 +154,7 @@ struct DepsgraphRelationBuilder {
void build_driver(IDPtr id, FCurve *fcurve);
void build_world(Scene *scene, World *world);
void build_rigidbody(Scene *scene);
+ void build_particles(Scene *scene, Object *ob);
void build_ik_pose(Object *ob, bPoseChannel *pchan, bConstraint *con);
void build_splineik_pose(Object *ob, bPoseChannel *pchan, bConstraint *con);
void build_rig(Scene *scene, Object *ob);
diff --git a/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp b/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
index f6c1454..ab776cf 100644
--- a/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
@@ -246,12 +246,10 @@ IDDepsNode *DepsgraphNodeBuilder::build_object(Object *ob)
}
}
-#if 0
/* particle systems */
if (ob->particlesystem.first) {
- deg_build_particles_graph(graph, scene, ob);
+ build_particles(ob_node, ob);
}
-#endif
/* return object node... */
return ob_node;
@@ -433,6 +431,42 @@ void DepsgraphNodeBuilder::build_rigidbody(IDDepsNode *scene_node, Scene *scene)
}
}
+void DepsgraphNodeBuilder::build_particles(IDDepsNode *ob_node, Object *ob)
+{
+ /* == Particle Systems Nodes ==
+ * There are two types of nodes associated with representing
+ * particle systems:
+ * 1) Component (EVAL_PARTICLES) - This is the particle-system
+ * evaluation context for an object. It acts as the container
+ * for all the nodes associated with a particular set of particle
+ * systems.
+ * 2) Particle System Eval Operation - This operation node acts as a
+ * blackbox evaluation step for one particle system referenced by
+ * the particle systems stack. All dependencies link to this operation.
+ */
+
+ /* component for all particle systems */
+ ComponentDepsNode *psys_comp = add_component_node(ob_node, DEPSNODE_TYPE_EVAL_PARTICLES);
+
+ /* particle systems */
+ for (ParticleSystem *psys = (ParticleSystem *)ob->particlesystem.first; psys; psys = psys->next) {
+ ParticleSettings *part = psys->part;
+
+ /* particle settings */
+ // XXX: what if this is used more than once!
+ IDDepsNode *part_node = add_id_node(part);
+ build_animdata(part_node);
+
+ /* this particle system */
+ add_operation_node(psys_comp, DEPSNODE_TYPE_OP_PARTICLE,
+ DEPSOP_TYPE_EXEC, BKE_particle_system_eval,
+ deg_op_name_psys_eval, PointerRNA_NULL);
+ }
+
+ /* pointcache */
+ // TODO...
+}
+
/* IK Solver Eval Steps */
void DepsgraphNodeBuilder::build_ik_pose(ComponentDepsNode *bone_node, Object *ob, bPoseChannel *pchan, bConstraint *con)
{
diff --git a/source/blender/depsgraph/intern/depsgraph_build_relations.cpp b/source/blender/depsgraph/intern/depsgraph_build_relations.cpp
index 7e88673..af78f4c 100644
--- a/source/blender/depsgraph/intern/depsgraph_build_relations.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_build_relations.cpp
@@ -201,12 +201,10 @@ void DepsgraphRelationBuilder::build_object(Scene *scene, Object *ob)
#endif
}
-#if 0
/* particle systems */
if (ob->particlesystem.first) {
- deg_build_particles_graph(graph, scene, ob);
+ build_particles(scene, ob);
}
-#endif
}
void DepsgraphRelationBuilder::build_object_parent(Object *ob)
@@ -539,6 +537,93 @@ void DepsgraphRelationBuilder::build_rigidbody(Scene *scene)
}
}
+void DepsgraphRelationBuilder::build_particles(Scene *scene, Object *ob)
+{
+ /* particle systems */
+ for (ParticleSystem *psys = (ParticleSystem *)ob->particlesystem.first; psys; psys = psys->next) {
+ ParticleSettings *part = psys->part;
+
+ /* particle settings */
+ build_animdata(part);
+
+ /* this particle system */
+ OperationKey psys_key(ob, DEPSNODE_TYPE_OP_PARTICLE, deg_op_name_psys_eval);
+
+ /* XXX: if particle system is later re-enabled, we must do full rebuild? */
+ if (!psys_check_enabled(ob, psys))
+ continue;
+
+#if 0
+ if (ELEM(part->phystype, PART_PHYS_KEYED, PART_PHYS_BOIDS)) {
+ ParticleTarget *pt;
+
+ for (pt = psys->targets.first; pt; pt = pt->next) {
+ if (pt->ob && BLI_findlink(&pt->ob->particlesystem, pt->psys - 1)) {
+ node2 = dag_get_node(dag, pt->ob);
+ dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Particle Targets");
+ }
+ }
+ }
+
+ if (part->ren_as == PART_DRAW_OB && part->dup_ob) {
+ node2 = dag_get_node(dag, part->dup_ob);
+ /* note that this relation actually runs in the wrong direction, the problem
+ * is that dupli system all have this (due to parenting), and the render
+ * engine instancing assumes particular ordering of objects in list */
+ dag_add_relation(dag, node, node2, DAG_RL_OB_OB, "Particle Object Visualization");
+ if (part->dup_ob->type == OB_MBALL)
+ dag_add_relation(dag, node, node2, DAG_RL_DATA_DATA, "Particle Object Visualization");
+ }
+
+ if (part->ren_as == PART_DRAW_GR && part->dup_group) {
+ for (go = part->dup_group->gobject.first; go; go = go->next) {
+ node2 = dag_get_node(dag, go->ob);
+ dag_add_relation(dag, node2, node, DAG_RL_OB_OB, "Particle Group Visualization");
+ }
+ }
+#endif
+
+ /* effectors */
+ ListBase *effectors = pdInitEffectors(scene, ob, psys, part->effector_weights, false);
+
+ if (effectors) {
+ for (EffectorCache *eff = (EffectorCache *)effectors->first; eff; eff = eff->next) {
+ if (eff->psys) {
+ // XXX: DAG_RL_DATA_DATA | DAG_RL_OB_DATA
+ ComponentKey eff_key(eff->ob, DEPSNODE_TYPE_GEOMETRY); // xxx: particles instead?
+ add_relation(eff_key, psys_key, DEPSREL_TYPE_STANDARD, "Particle Field");
+ }
+ }
+ }
+
+ pdEndEffectors(&effectors);
+
+ /* boids */
+ if (part->boids) {
+ BoidRule *rule = NULL;
+ BoidState *state = NULL;
+
+ for (state = (BoidState *)part->boids->states.first; state; state = state->next) {
+ for (rule = (BoidRule *)state->rules.first; rule; rule = rule->next) {
+ Object *ruleob = NULL;
+ if (rule->type == eBoidRuleType_Avoid)
+ ruleob = ((BoidRuleGoalAvoid *)rule)->ob;
+ else if (rule->type == eBoidRuleType_FollowLeader)
+ ruleob = ((BoidRuleFollowLeader *)rule)->ob;
+
+ if (ruleob) {
+ ComponentKey ruleob_key(ruleob, DEPSNODE_TYPE_TRANSFORM);
+ add_relation(ruleob_key, psys_key, DEPSREL_TYPE_TRANSFORM, "Boid Rule");
+ }
+ }
+ }
+ }
+ }
+
+ /* pointcache */
+ // TODO...
+}
+
/* IK Solver Eval Steps */
void DepsgraphRelationBuilder::build_ik_pose(Object *ob, bPoseChannel *pchan, bConstraint *con)
{
diff --git a/source/blender/depsgraph/intern/depsgraph_type_defines.cpp b/source/blender/depsgraph/intern/depsgraph_type_defines.cpp
index c566cdc..664d410 100644
--- a/source/blender/depsgraph/intern/depsgraph_type_defines.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_type_defines.cpp
@@ -94,6 +94,7 @@ const string deg_op_name_rigidbody_world_simulate = "Rigidbody World Do Simulati
const string deg_op_name_rigidbody_object_sync = "RigidBodyObject Sync";
const string deg_op_name_ik_solver = "IK Solver";
const string deg_op_name_spline_ik_solver = "Spline IK Solver";
+const string deg_op_name_psys_eval = "PSys Eval";
string deg_op_name_driver(const ChannelDriver *driver)
{
return string_format("Driver @ %p", driver);
diff --git a/source/blender/depsgraph/intern/depsgraph_types.h b/source/blender/depsgraph/intern/depsgraph_types.h
index 9568a69..fcffa09 100644
--- a/source/blender/depsgraph/intern/depsgraph_types.h
+++ b/source/blender/depsgraph/intern/depsgraph_types.h
@@ -109,6 +109,7 @@ extern const string deg_op_name_rigidbody_world_simulate;
extern const string deg_op_name_rigidbody_object_sync;
extern const string deg_op_name_ik_solver;
extern const string deg_op_name_spline_ik_solver;
+extern const string deg_op_name_psys_eval;
string deg_op_name_driver(const ChannelDriver *driver);
/* Type of operation */
More information about the Bf-blender-cvs
mailing list