Changeset View
Changeset View
Standalone View
Standalone View
source/blender/depsgraph/intern/builder/deg_builder_relations.cc
| Show First 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | |||||
| #include "DNA_meta_types.h" | #include "DNA_meta_types.h" | ||||
| #include "DNA_node_types.h" | #include "DNA_node_types.h" | ||||
| #include "DNA_particle_types.h" | #include "DNA_particle_types.h" | ||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "DNA_rigidbody_types.h" | #include "DNA_rigidbody_types.h" | ||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "DNA_texture_types.h" | #include "DNA_texture_types.h" | ||||
| #include "DNA_world_types.h" | #include "DNA_world_types.h" | ||||
| #include "DNA_object_force.h" | |||||
| #include "BKE_action.h" | #include "BKE_action.h" | ||||
| #include "BKE_armature.h" | #include "BKE_armature.h" | ||||
| #include "BKE_animsys.h" | #include "BKE_animsys.h" | ||||
| #include "BKE_constraint.h" | #include "BKE_constraint.h" | ||||
| #include "BKE_curve.h" | #include "BKE_curve.h" | ||||
| #include "BKE_effect.h" | #include "BKE_effect.h" | ||||
| #include "BKE_collision.h" | |||||
| #include "BKE_fcurve.h" | #include "BKE_fcurve.h" | ||||
| #include "BKE_group.h" | #include "BKE_group.h" | ||||
| #include "BKE_key.h" | #include "BKE_key.h" | ||||
| #include "BKE_library.h" | #include "BKE_library.h" | ||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BKE_material.h" | #include "BKE_material.h" | ||||
| #include "BKE_mball.h" | #include "BKE_mball.h" | ||||
| #include "BKE_modifier.h" | #include "BKE_modifier.h" | ||||
| ▲ Show 20 Lines • Show All 155 Lines • ▼ Show 20 Lines | void DepsgraphRelationBuilder::add_operation_relation( | ||||
| else { | else { | ||||
| DEG_DEBUG_PRINTF("add_operation_relation(%p = %s, %p = %s, %d, %s) Failed\n", | DEG_DEBUG_PRINTF("add_operation_relation(%p = %s, %p = %s, %d, %s) Failed\n", | ||||
| node_from, (node_from) ? node_from->identifier().c_str() : "<None>", | node_from, (node_from) ? node_from->identifier().c_str() : "<None>", | ||||
| node_to, (node_to) ? node_to->identifier().c_str() : "<None>", | node_to, (node_to) ? node_to->identifier().c_str() : "<None>", | ||||
| type, description); | type, description); | ||||
| } | } | ||||
| } | } | ||||
| void DepsgraphRelationBuilder::add_collision_relations(const OperationKey &key, Scene *scene, Object *ob, Group *group, int layer, bool dupli, const char *name) | |||||
| { | |||||
| unsigned int numcollobj; | |||||
| Object **collobjs = get_collisionobjects_ext(scene, ob, group, layer, &numcollobj, eModifierType_Collision, dupli); | |||||
| for (unsigned int i = 0; i < numcollobj; i++) | |||||
| { | |||||
| Object *ob1 = collobjs[i]; | |||||
| ComponentKey trf_key(&ob1->id, DEPSNODE_TYPE_TRANSFORM); | |||||
| add_relation(trf_key, key, DEPSREL_TYPE_STANDARD, name); | |||||
| ComponentKey coll_key(&ob1->id, DEPSNODE_TYPE_GEOMETRY); | |||||
| add_relation(coll_key, key, DEPSREL_TYPE_STANDARD, name); | |||||
| } | |||||
| if (collobjs) | |||||
| MEM_freeN(collobjs); | |||||
| } | |||||
| void DepsgraphRelationBuilder::add_forcefield_relations(const OperationKey &key, Scene *scene, Object *ob, ParticleSystem *psys, EffectorWeights *eff, bool add_absorption, const char *name) | |||||
| { | |||||
| ListBase *effectors = pdInitEffectors(scene, ob, psys, eff, false); | |||||
| if (effectors) { | |||||
| for (EffectorCache *eff = (EffectorCache *)effectors->first; eff; eff = eff->next) { | |||||
| if (eff->ob != ob) { | |||||
| ComponentKey eff_key(&eff->ob->id, DEPSNODE_TYPE_TRANSFORM); | |||||
| add_relation(eff_key, key, DEPSREL_TYPE_STANDARD, name); | |||||
| } | |||||
| if (eff->psys) { | |||||
| if (eff->ob != ob) { | |||||
| ComponentKey eff_key(&eff->ob->id, DEPSNODE_TYPE_EVAL_PARTICLES); | |||||
| add_relation(eff_key, key, DEPSREL_TYPE_STANDARD, name); | |||||
| } | |||||
| else if (eff->psys != psys) { | |||||
| OperationKey eff_key(&eff->ob->id, DEPSNODE_TYPE_EVAL_PARTICLES, DEG_OPCODE_PSYS_EVAL, eff->psys->name); | |||||
| add_relation(eff_key, key, DEPSREL_TYPE_STANDARD, name); | |||||
| } | |||||
| } | |||||
| if (eff->pd->forcefield == PFIELD_SMOKEFLOW && eff->pd->f_source) { | |||||
| ComponentKey trf_key(&eff->pd->f_source->id, DEPSNODE_TYPE_TRANSFORM); | |||||
| add_relation(trf_key, key, DEPSREL_TYPE_STANDARD, "Smoke Force Domain"); | |||||
| ComponentKey eff_key(&eff->pd->f_source->id, DEPSNODE_TYPE_GEOMETRY); | |||||
| add_relation(eff_key, key, DEPSREL_TYPE_STANDARD, "Smoke Force Domain"); | |||||
| } | |||||
| if (add_absorption && (eff->pd->flag & PFIELD_VISIBILITY)) { | |||||
| add_collision_relations(key, scene, ob, NULL, eff->ob->lay, true, "Force Absorption"); | |||||
| } | |||||
| } | |||||
| } | |||||
| pdEndEffectors(&effectors); | |||||
| } | |||||
| /* **** Functions to build relations between entities **** */ | /* **** Functions to build relations between entities **** */ | ||||
| void DepsgraphRelationBuilder::build_scene(Main *bmain, Scene *scene) | void DepsgraphRelationBuilder::build_scene(Main *bmain, Scene *scene) | ||||
| { | { | ||||
| /* LIB_TAG_DOIT is used to indicate whether node for given ID was already | /* LIB_TAG_DOIT is used to indicate whether node for given ID was already | ||||
| * created or not. | * created or not. | ||||
| */ | */ | ||||
| BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, false); | BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, false); | ||||
| ▲ Show 20 Lines • Show All 878 Lines • ▼ Show 20 Lines | #if 0 | ||||
| if (part->ren_as == PART_DRAW_GR && part->dup_group) { | if (part->ren_as == PART_DRAW_GR && part->dup_group) { | ||||
| for (go = part->dup_group->gobject.first; go; go = go->next) { | for (go = part->dup_group->gobject.first; go; go = go->next) { | ||||
| node2 = dag_get_node(dag, go->ob); | node2 = dag_get_node(dag, go->ob); | ||||
| dag_add_relation(dag, node2, node, DAG_RL_OB_OB, "Particle Group Visualization"); | dag_add_relation(dag, node2, node, DAG_RL_OB_OB, "Particle Group Visualization"); | ||||
| } | } | ||||
| } | } | ||||
| #endif | #endif | ||||
| /* effectors */ | /* collisions */ | ||||
| ListBase *effectors = pdInitEffectors(scene, ob, psys, part->effector_weights, false); | if (part->type != PART_HAIR) { | ||||
| add_collision_relations(psys_key, scene, ob, part->collision_group, ob->lay, true, "Particle Collision"); | |||||
| 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->id, DEPSNODE_TYPE_GEOMETRY); // xxx: particles instead? | |||||
| add_relation(eff_key, psys_key, DEPSREL_TYPE_STANDARD, "Particle Field"); | |||||
| } | |||||
| } | |||||
| } | } | ||||
| pdEndEffectors(&effectors); | /* effectors */ | ||||
| add_forcefield_relations(psys_key, scene, ob, psys, part->effector_weights, part->type == PART_HAIR, "Particle Field"); | |||||
| /* boids */ | /* boids */ | ||||
| if (part->boids) { | if (part->boids) { | ||||
| BoidRule *rule = NULL; | BoidRule *rule = NULL; | ||||
| BoidState *state = NULL; | BoidState *state = NULL; | ||||
| for (state = (BoidState *)part->boids->states.first; state; state = state->next) { | for (state = (BoidState *)part->boids->states.first; state; state = state->next) { | ||||
| for (rule = (BoidRule *)state->rules.first; rule; rule = rule->next) { | for (rule = (BoidRule *)state->rules.first; rule; rule = rule->next) { | ||||
| ▲ Show 20 Lines • Show All 824 Lines • Show Last 20 Lines | |||||