Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/depsgraph.c
| Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | |||||
| #include "DNA_material_types.h" | #include "DNA_material_types.h" | ||||
| #include "DNA_mesh_types.h" | #include "DNA_mesh_types.h" | ||||
| #include "DNA_node_types.h" | #include "DNA_node_types.h" | ||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "DNA_screen_types.h" | #include "DNA_screen_types.h" | ||||
| #include "DNA_windowmanager_types.h" | #include "DNA_windowmanager_types.h" | ||||
| #include "DNA_movieclip_types.h" | #include "DNA_movieclip_types.h" | ||||
| #include "DNA_mask_types.h" | #include "DNA_mask_types.h" | ||||
| #include "DNA_modifier_types.h" | |||||
| #include "DNA_rigidbody_types.h" | |||||
| #include "BKE_anim.h" | #include "BKE_anim.h" | ||||
| #include "BKE_animsys.h" | #include "BKE_animsys.h" | ||||
| #include "BKE_action.h" | #include "BKE_action.h" | ||||
| #include "BKE_DerivedMesh.h" | #include "BKE_DerivedMesh.h" | ||||
| #include "BKE_collision.h" | |||||
| #include "BKE_effect.h" | #include "BKE_effect.h" | ||||
| #include "BKE_fcurve.h" | #include "BKE_fcurve.h" | ||||
| #include "BKE_global.h" | #include "BKE_global.h" | ||||
| #include "BKE_idcode.h" | #include "BKE_idcode.h" | ||||
| #include "BKE_image.h" | #include "BKE_image.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" | ||||
| ▲ Show 20 Lines • Show All 370 Lines • ▼ Show 20 Lines | static void dag_add_lamp_driver_relations(DagForest *dag, DagNode *node, Lamp *la) | ||||
| /* lamp's nodetree */ | /* lamp's nodetree */ | ||||
| if (la->nodetree) | if (la->nodetree) | ||||
| dag_add_shader_nodetree_driver_relations(dag, node, la->nodetree); | dag_add_shader_nodetree_driver_relations(dag, node, la->nodetree); | ||||
| la->id.tag &= ~LIB_TAG_DOIT; | la->id.tag &= ~LIB_TAG_DOIT; | ||||
| } | } | ||||
| static void check_and_create_collision_relation(DagForest *dag, Object *ob, DagNode *node, Object *ob1, int skip_forcefield, bool no_collision) | static void create_collision_relation(DagForest *dag, DagNode *node, Object *ob1, const char *name) | ||||
| { | { | ||||
| DagNode *node2; | DagNode *node2 = dag_get_node(dag, ob1); | ||||
| if (ob1->pd && (ob1->pd->deflect || ob1->pd->forcefield) && (ob1 != ob)) { | dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, name); | ||||
| if ((skip_forcefield && ob1->pd->forcefield == skip_forcefield) || (no_collision && ob1->pd->forcefield == 0)) | |||||
| return; | |||||
| node2 = dag_get_node(dag, ob1); | |||||
| dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Field Collision"); | |||||
| } | |||||
| } | } | ||||
| static void dag_add_collision_field_relation(DagForest *dag, Scene *scene, Object *ob, DagNode *node, int skip_forcefield, bool no_collision) | void dag_add_collision_relations(DagForest *dag, Scene *scene, Object *ob, DagNode *node, Group *group, int layer, unsigned int modifier_type, DagCollobjFilterFunction fn, bool dupli, const char *name) | ||||
| { | { | ||||
| Base *base; | unsigned int numcollobj; | ||||
| ParticleSystem *particle_system; | Object **collobjs = get_collisionobjects_ext(scene, ob, group, layer, &numcollobj, modifier_type, dupli); | ||||
| for (particle_system = ob->particlesystem.first; | for (unsigned int i = 0; i < numcollobj; i++) { | ||||
| particle_system; | Object *ob1 = collobjs[i]; | ||||
| particle_system = particle_system->next) | |||||
| { | |||||
| EffectorWeights *effector_weights = particle_system->part->effector_weights; | |||||
| if (effector_weights->group) { | |||||
| GroupObject *group_object; | |||||
| for (group_object = effector_weights->group->gobject.first; | if (!fn || fn(ob1, modifiers_findByType(ob1, modifier_type))) { | ||||
| group_object; | create_collision_relation(dag, node, ob1, name); | ||||
| group_object = group_object->next) | |||||
| { | |||||
| if ((group_object->ob->lay & ob->lay)) { | |||||
| check_and_create_collision_relation(dag, ob, node, group_object->ob, skip_forcefield, no_collision); | |||||
| } | } | ||||
| } | } | ||||
| if (collobjs) | |||||
| MEM_freeN(collobjs); | |||||
| } | } | ||||
| void dag_add_forcefield_relations(DagForest *dag, Scene *scene, Object *ob, DagNode *node, EffectorWeights *effector_weights, bool add_absorption, int skip_forcefield, const char *name) | |||||
| { | |||||
| ListBase *effectors = pdInitEffectors(scene, ob, NULL, effector_weights, false); | |||||
| if (effectors) { | |||||
| for (EffectorCache *eff = effectors->first; eff; eff = eff->next) { | |||||
| if (eff->ob != ob && eff->pd->forcefield != skip_forcefield) { | |||||
| create_collision_relation(dag, node, eff->ob, name); | |||||
| if (eff->pd->forcefield == PFIELD_SMOKEFLOW && eff->pd->f_source) { | |||||
| create_collision_relation(dag, node, eff->pd->f_source, "Smoke Force Domain"); | |||||
| } | } | ||||
| /* would be nice to have a list of colliders here | if (add_absorption && (eff->pd->flag & PFIELD_VISIBILITY)) { | ||||
| * so for now walk all objects in scene check 'same layer rule' */ | /* Actual code uses get_collider_cache */ | ||||
| for (base = scene->base.first; base; base = base->next) { | dag_add_collision_relations(dag, scene, ob, node, NULL, eff->ob->lay, eModifierType_Collision, NULL, true, "Force Absorption"); | ||||
| if ((base->lay & ob->lay)) { | |||||
| Object *ob1 = base->object; | |||||
| check_and_create_collision_relation(dag, ob, node, ob1, skip_forcefield, no_collision); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | |||||
| pdEndEffectors(&effectors); | |||||
| } | |||||
| static void build_dag_object(DagForest *dag, DagNode *scenenode, Main *bmain, Scene *scene, Object *ob, int mask) | static void build_dag_object(DagForest *dag, DagNode *scenenode, Main *bmain, Scene *scene, Object *ob, int mask) | ||||
| { | { | ||||
| bConstraint *con; | bConstraint *con; | ||||
| DagNode *node; | DagNode *node; | ||||
| DagNode *node2; | DagNode *node2; | ||||
| DagNode *node3; | DagNode *node3; | ||||
| Key *key; | Key *key; | ||||
| ▲ Show 20 Lines • Show All 133 Lines • ▼ Show 20 Lines | if ((ob->transflag & OB_DUPLIGROUP) && ob->dup_group) { | ||||
| node2 = dag_get_node(dag, go->ob); | node2 = dag_get_node(dag, go->ob); | ||||
| /* node2 changes node1, this keeps animations updated in groups?? not logical? */ | /* node2 changes node1, this keeps animations updated in groups?? not logical? */ | ||||
| dag_add_relation(dag, node2, node, DAG_RL_OB_OB, "Dupligroup"); | dag_add_relation(dag, node2, node, DAG_RL_OB_OB, "Dupligroup"); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* softbody collision */ | /* rigidbody force fields */ | ||||
| if ((ob->type == OB_MESH) || (ob->type == OB_CURVE) || (ob->type == OB_LATTICE)) { | if ((ob->type == OB_MESH) || (ob->type == OB_CURVE) || (ob->type == OB_LATTICE)) { | ||||
| if (ob->particlesystem.first || | if (ob->rigidbody_object && scene->rigidbody_world) { | ||||
| modifiers_isModifierEnabled(ob, eModifierType_Softbody) || | dag_add_forcefield_relations(dag, scene, ob, node, scene->rigidbody_world->effector_weights, true, 0, "Force Field"); | ||||
| modifiers_isModifierEnabled(ob, eModifierType_Cloth) || | |||||
| modifiers_isModifierEnabled(ob, eModifierType_DynamicPaint)) | |||||
| { | |||||
| dag_add_collision_field_relation(dag, scene, ob, node, 0, false); /* TODO: use effectorweight->group */ | |||||
| } | |||||
| else if (modifiers_isModifierEnabled(ob, eModifierType_Smoke)) { | |||||
| dag_add_collision_field_relation(dag, scene, ob, node, PFIELD_SMOKEFLOW, false); | |||||
| } | |||||
| else if (ob->rigidbody_object) { | |||||
| dag_add_collision_field_relation(dag, scene, ob, node, 0, true); | |||||
| } | } | ||||
| } | } | ||||
| /* object data drivers */ | /* object data drivers */ | ||||
| if (ob->data) { | if (ob->data) { | ||||
| AnimData *adt = BKE_animdata_from_id((ID *)ob->data); | AnimData *adt = BKE_animdata_from_id((ID *)ob->data); | ||||
| if (adt) | if (adt) | ||||
| dag_add_driver_relation(adt, dag, node, 1); | dag_add_driver_relation(adt, dag, node, 1); | ||||
| } | } | ||||
| /* object type/data relationships */ | /* object type/data relationships */ | ||||
| ▲ Show 20 Lines • Show All 87 Lines • ▼ Show 20 Lines | #endif // XXX old animation system | ||||
| psys = ob->particlesystem.first; | psys = ob->particlesystem.first; | ||||
| if (psys) { | if (psys) { | ||||
| GroupObject *go; | GroupObject *go; | ||||
| for (; psys; psys = psys->next) { | for (; psys; psys = psys->next) { | ||||
| BoidRule *rule = NULL; | BoidRule *rule = NULL; | ||||
| BoidState *state = NULL; | BoidState *state = NULL; | ||||
| ParticleSettings *part = psys->part; | ParticleSettings *part = psys->part; | ||||
| ListBase *effectors = NULL; | |||||
| EffectorCache *eff; | |||||
| if (part->adt) { | if (part->adt) { | ||||
| dag_add_driver_relation(part->adt, dag, node, 1); | dag_add_driver_relation(part->adt, dag, node, 1); | ||||
| } | } | ||||
| dag_add_relation(dag, node, node, DAG_RL_OB_DATA, "Particle-Object Relation"); | dag_add_relation(dag, node, node, DAG_RL_OB_DATA, "Particle-Object Relation"); | ||||
| if (!psys_check_enabled(ob, psys, G.is_rendering)) | if (!psys_check_enabled(ob, psys, G.is_rendering)) | ||||
| Show All 22 Lines | for (; psys; psys = psys->next) { | ||||
| 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"); | ||||
| } | } | ||||
| } | } | ||||
| effectors = pdInitEffectors(scene, ob, psys, part->effector_weights, false); | if (part->type != PART_HAIR) { | ||||
| /* Actual code uses get_collider_cache */ | |||||
| if (effectors) { | dag_add_collision_relations(dag, scene, ob, node, part->collision_group, ob->lay, eModifierType_Collision, NULL, true, "Particle Collision"); | ||||
| for (eff = 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"); | |||||
| } | |||||
| } | |||||
| } | } | ||||
| pdEndEffectors(&effectors); | dag_add_forcefield_relations(dag, scene, ob, node, part->effector_weights, part->type == PART_HAIR, 0, "Particle Force Field"); | ||||
| if (part->boids) { | if (part->boids) { | ||||
| for (state = part->boids->states.first; state; state = state->next) { | for (state = part->boids->states.first; state; state = state->next) { | ||||
| for (rule = state->rules.first; rule; rule = rule->next) { | for (rule = state->rules.first; rule; rule = rule->next) { | ||||
| Object *ruleob = NULL; | Object *ruleob = NULL; | ||||
| if (rule->type == eBoidRuleType_Avoid) | if (rule->type == eBoidRuleType_Avoid) | ||||
| ruleob = ((BoidRuleGoalAvoid *)rule)->ob; | ruleob = ((BoidRuleGoalAvoid *)rule)->ob; | ||||
| else if (rule->type == eBoidRuleType_FollowLeader) | else if (rule->type == eBoidRuleType_FollowLeader) | ||||
| ▲ Show 20 Lines • Show All 2,870 Lines • Show Last 20 Lines | |||||