Changeset View
Changeset View
Standalone View
Standalone View
source/blender/depsgraph/intern/builder/deg_builder_relations.cc
| Show First 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | |||||
| #include "BKE_collision.h" | #include "BKE_collision.h" | ||||
| #include "BKE_fcurve.h" | #include "BKE_fcurve.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" | ||||
| #include "BKE_gpencil_modifier.h" | |||||
| #include "BKE_node.h" | #include "BKE_node.h" | ||||
| #include "BKE_object.h" | #include "BKE_object.h" | ||||
| #include "BKE_particle.h" | #include "BKE_particle.h" | ||||
| #include "BKE_rigidbody.h" | #include "BKE_rigidbody.h" | ||||
| #include "BKE_shader_fx.h" | |||||
| #include "BKE_sound.h" | #include "BKE_sound.h" | ||||
| #include "BKE_tracking.h" | #include "BKE_tracking.h" | ||||
| #include "BKE_world.h" | #include "BKE_world.h" | ||||
| #include "RNA_access.h" | #include "RNA_access.h" | ||||
| #include "RNA_types.h" | #include "RNA_types.h" | ||||
| } /* extern "C" */ | } /* extern "C" */ | ||||
| ▲ Show 20 Lines • Show All 420 Lines • ▼ Show 20 Lines | add_relation(local_transform_key, | ||||
| "ObLocal -> ObParent"); | "ObLocal -> ObParent"); | ||||
| } | } | ||||
| /* Modifiers. */ | /* Modifiers. */ | ||||
| if (object->modifiers.first != NULL) { | if (object->modifiers.first != NULL) { | ||||
| BuilderWalkUserData data; | BuilderWalkUserData data; | ||||
| data.builder = this; | data.builder = this; | ||||
| modifiers_foreachIDLink(object, modifier_walk, &data); | modifiers_foreachIDLink(object, modifier_walk, &data); | ||||
| } | } | ||||
| /* Grease Pencil Modifiers. */ | |||||
| if (object->greasepencil_modifiers.first != NULL) { | |||||
| BuilderWalkUserData data; | |||||
| data.builder = this; | |||||
| BKE_gpencil_modifiers_foreachIDLink(object, modifier_walk, &data); | |||||
| } | |||||
| /* Shader FX. */ | |||||
| if (object->shader_fx.first != NULL) { | |||||
| BuilderWalkUserData data; | |||||
| data.builder = this; | |||||
| BKE_shaderfx_foreachIDLink(object, modifier_walk, &data); | |||||
| } | |||||
| /* Constraints. */ | /* Constraints. */ | ||||
| if (object->constraints.first != NULL) { | if (object->constraints.first != NULL) { | ||||
| BuilderWalkUserData data; | BuilderWalkUserData data; | ||||
| data.builder = this; | data.builder = this; | ||||
| BKE_constraints_id_loop(&object->constraints, constraint_walk, &data); | BKE_constraints_id_loop(&object->constraints, constraint_walk, &data); | ||||
| } | } | ||||
| /* Object constraints. */ | /* Object constraints. */ | ||||
| if (object->constraints.first != NULL) { | if (object->constraints.first != NULL) { | ||||
| Show All 29 Lines | void DepsgraphRelationBuilder::build_object(Base *base, Object *object) | ||||
| /* Animation data */ | /* Animation data */ | ||||
| build_animdata(&object->id); | build_animdata(&object->id); | ||||
| /* Object data. */ | /* Object data. */ | ||||
| build_object_data(object); | build_object_data(object); | ||||
| /* Particle systems. */ | /* Particle systems. */ | ||||
| if (object->particlesystem.first != NULL) { | if (object->particlesystem.first != NULL) { | ||||
| build_particles(object); | build_particles(object); | ||||
| } | } | ||||
| /* Grease pencil. */ | |||||
| if (object->gpd != NULL) { | |||||
| build_gpencil(object->gpd); | |||||
| } | |||||
| /* Proxy object to copy from. */ | /* Proxy object to copy from. */ | ||||
| if (object->proxy_from != NULL) { | if (object->proxy_from != NULL) { | ||||
| build_object(NULL, object->proxy_from); | build_object(NULL, object->proxy_from); | ||||
| ComponentKey ob_pose_key(&object->proxy_from->id, DEG_NODE_TYPE_EVAL_POSE); | ComponentKey ob_pose_key(&object->proxy_from->id, DEG_NODE_TYPE_EVAL_POSE); | ||||
| ComponentKey proxy_pose_key(&object->id, DEG_NODE_TYPE_EVAL_POSE); | ComponentKey proxy_pose_key(&object->id, DEG_NODE_TYPE_EVAL_POSE); | ||||
| add_relation(ob_pose_key, proxy_pose_key, "Proxy Pose"); | add_relation(ob_pose_key, proxy_pose_key, "Proxy Pose"); | ||||
| ComponentKey ob_transform_key(&object->proxy_from->id, DEG_NODE_TYPE_TRANSFORM); | ComponentKey ob_transform_key(&object->proxy_from->id, DEG_NODE_TYPE_TRANSFORM); | ||||
| Show All 40 Lines | void DepsgraphRelationBuilder::build_object_data(Object *object) | ||||
| /* type-specific data. */ | /* type-specific data. */ | ||||
| switch (object->type) { | switch (object->type) { | ||||
| case OB_MESH: | case OB_MESH: | ||||
| case OB_CURVE: | case OB_CURVE: | ||||
| case OB_FONT: | case OB_FONT: | ||||
| case OB_SURF: | case OB_SURF: | ||||
| case OB_MBALL: | case OB_MBALL: | ||||
| case OB_LATTICE: | case OB_LATTICE: | ||||
| case OB_GPENCIL: | |||||
| { | { | ||||
| build_object_data_geometry(object); | build_object_data_geometry(object); | ||||
| break; | break; | ||||
| } | } | ||||
| case OB_ARMATURE: | case OB_ARMATURE: | ||||
| if (ID_IS_LINKED(object) && object->proxy_from != NULL) { | if (ID_IS_LINKED(object) && object->proxy_from != NULL) { | ||||
| build_proxy_rig(object); | build_proxy_rig(object); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 1,152 Lines • ▼ Show 20 Lines | LISTBASE_FOREACH (ModifierData *, md, &object->modifiers) { | ||||
| TimeSourceKey time_src_key; | TimeSourceKey time_src_key; | ||||
| add_relation(time_src_key, obdata_ubereval_key, "Time Source"); | add_relation(time_src_key, obdata_ubereval_key, "Time Source"); | ||||
| } | } | ||||
| if (md->type == eModifierType_Cloth) { | if (md->type == eModifierType_Cloth) { | ||||
| build_cloth(object, md); | build_cloth(object, md); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* Grease Pencil Modifiers */ | |||||
| if (object->greasepencil_modifiers.first != NULL) { | |||||
| ModifierUpdateDepsgraphContext ctx = {}; | |||||
| ctx.scene = scene_; | |||||
| ctx.object = object; | |||||
| LISTBASE_FOREACH(GpencilModifierData *, md, &object->greasepencil_modifiers) { | |||||
| const GpencilModifierTypeInfo *mti = BKE_gpencil_modifierType_getInfo((GpencilModifierType)md->type); | |||||
| if (mti->updateDepsgraph) { | |||||
| DepsNodeHandle handle = create_node_handle(obdata_ubereval_key); | |||||
| ctx.node = reinterpret_cast< ::DepsNodeHandle* >(&handle); | |||||
| mti->updateDepsgraph(md, &ctx); | |||||
| } | |||||
| if (BKE_object_modifier_gpencil_use_time(object, md)) { | |||||
| TimeSourceKey time_src_key; | |||||
| add_relation(time_src_key, obdata_ubereval_key, "Time Source"); | |||||
| } | |||||
| } | |||||
| } | |||||
| /* Shader FX */ | |||||
| if (object->shader_fx.first != NULL) { | |||||
| ModifierUpdateDepsgraphContext ctx = {}; | |||||
| ctx.scene = scene_; | |||||
| ctx.object = object; | |||||
| LISTBASE_FOREACH(ShaderFxData *, fx, &object->shader_fx) { | |||||
| const ShaderFxTypeInfo *fxi = BKE_shaderfxType_getInfo((ShaderFxType)fx->type); | |||||
| if (fxi->updateDepsgraph) { | |||||
| DepsNodeHandle handle = create_node_handle(obdata_ubereval_key); | |||||
| ctx.node = reinterpret_cast< ::DepsNodeHandle* >(&handle); | |||||
| fxi->updateDepsgraph(fx, &ctx); | |||||
| } | |||||
| if (BKE_object_shaderfx_use_time(object, fx)) { | |||||
| TimeSourceKey time_src_key; | |||||
| add_relation(time_src_key, obdata_ubereval_key, "Time Source"); | |||||
| } | |||||
| } | |||||
| } | |||||
| /* Materials. */ | /* Materials. */ | ||||
| if (object->totcol) { | if (object->totcol) { | ||||
| for (int a = 1; a <= object->totcol; a++) { | for (int a = 1; a <= object->totcol; a++) { | ||||
| Material *ma = give_current_material(object, a); | Material *ma = give_current_material(object, a); | ||||
| if (ma != NULL) { | if (ma != NULL) { | ||||
| build_material(ma); | build_material(ma); | ||||
| if (object->type == OB_MESH) { | if (object->type == OB_MESH) { | ||||
| ▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | void DepsgraphRelationBuilder::build_object_data_geometry_datablock(ID *obdata) | ||||
| build_animdata(obdata); | build_animdata(obdata); | ||||
| /* ShapeKeys. */ | /* ShapeKeys. */ | ||||
| Key *key = BKE_key_from_id(obdata); | Key *key = BKE_key_from_id(obdata); | ||||
| if (key != NULL) { | if (key != NULL) { | ||||
| build_shapekeys(key); | build_shapekeys(key); | ||||
| } | } | ||||
| /* Link object data evaluation node to exit operation. */ | /* Link object data evaluation node to exit operation. */ | ||||
| OperationKey obdata_geom_eval_key(obdata, | OperationKey obdata_geom_eval_key(obdata, | ||||
| DEG_NODE_TYPE_GEOMETRY, | DEG_NODE_TYPE_GEOMETRY, | ||||
| DEG_OPCODE_PLACEHOLDER, | DEG_OPCODE_PLACEHOLDER, | ||||
| "Geometry Eval"); | "Geometry Eval"); | ||||
| OperationKey obdata_geom_done_key(obdata, | OperationKey obdata_geom_done_key(obdata, | ||||
| DEG_NODE_TYPE_GEOMETRY, | DEG_NODE_TYPE_GEOMETRY, | ||||
| DEG_OPCODE_PLACEHOLDER, | DEG_OPCODE_PLACEHOLDER, | ||||
| "Eval Done"); | "Eval Done"); | ||||
| add_relation(obdata_geom_eval_key, | add_relation(obdata_geom_eval_key, | ||||
| obdata_geom_done_key, | obdata_geom_done_key, | ||||
| "ObData Geom Eval Done"); | "ObData Geom Eval Done"); | ||||
| /* Type-specific links. */ | /* Type-specific links. */ | ||||
| const ID_Type id_type = GS(obdata->name); | const ID_Type id_type = GS(obdata->name); | ||||
| switch (id_type) { | switch (id_type) { | ||||
| case ID_ME: | case ID_ME: | ||||
| break; | break; | ||||
| case ID_MB: | case ID_MB: | ||||
| break; | break; | ||||
| case ID_CU: | case ID_CU: | ||||
| { | { | ||||
| Curve *cu = (Curve *)obdata; | Curve *cu = (Curve *)obdata; | ||||
| if (cu->bevobj != NULL) { | if (cu->bevobj != NULL) { | ||||
| ComponentKey bevob_geom_key(&cu->bevobj->id, | ComponentKey bevob_geom_key(&cu->bevobj->id, | ||||
| DEG_NODE_TYPE_GEOMETRY); | DEG_NODE_TYPE_GEOMETRY); | ||||
| add_relation(bevob_geom_key, | add_relation(bevob_geom_key, | ||||
| obdata_geom_eval_key, | obdata_geom_eval_key, | ||||
| "Curve Bevel Geometry"); | "Curve Bevel Geometry"); | ||||
| ComponentKey bevob_key(&cu->bevobj->id, | ComponentKey bevob_key(&cu->bevobj->id, | ||||
| DEG_NODE_TYPE_TRANSFORM); | DEG_NODE_TYPE_TRANSFORM); | ||||
| add_relation(bevob_key, | add_relation(bevob_key, | ||||
| obdata_geom_eval_key, | obdata_geom_eval_key, | ||||
| "Curve Bevel Transform"); | "Curve Bevel Transform"); | ||||
| build_object(NULL, cu->bevobj); | build_object(NULL, cu->bevobj); | ||||
| } | } | ||||
| if (cu->taperobj != NULL) { | if (cu->taperobj != NULL) { | ||||
| ComponentKey taperob_key(&cu->taperobj->id, | ComponentKey taperob_key(&cu->taperobj->id, | ||||
| DEG_NODE_TYPE_GEOMETRY); | DEG_NODE_TYPE_GEOMETRY); | ||||
| add_relation(taperob_key, obdata_geom_eval_key, "Curve Taper"); | add_relation(taperob_key, obdata_geom_eval_key, "Curve Taper"); | ||||
| build_object(NULL, cu->taperobj); | build_object(NULL, cu->taperobj); | ||||
| } | } | ||||
| if (cu->textoncurve != NULL) { | if (cu->textoncurve != NULL) { | ||||
| ComponentKey textoncurve_key(&cu->textoncurve->id, | ComponentKey textoncurve_key(&cu->textoncurve->id, | ||||
| DEG_NODE_TYPE_GEOMETRY); | DEG_NODE_TYPE_GEOMETRY); | ||||
| add_relation(textoncurve_key, | add_relation(textoncurve_key, | ||||
| obdata_geom_eval_key, | obdata_geom_eval_key, | ||||
| "Text on Curve"); | "Text on Curve"); | ||||
| build_object(NULL, cu->textoncurve); | build_object(NULL, cu->textoncurve); | ||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| case ID_LT: | case ID_LT: | ||||
| break; | break; | ||||
| case ID_GD: /* Grease Pencil */ | |||||
| { | |||||
| bGPdata *gpd = (bGPdata *)obdata; | |||||
| /* Geometry cache needs to be recalculated on frame change | |||||
| * (e.g. to fix crashes after scrubbing the timeline when | |||||
| * onion skinning is enabled, since the ghosts need to be | |||||
| * re-added to the cache once scrubbing ends) | |||||
sergey: Verify indentation. | |||||
| */ | |||||
| TimeSourceKey time_key; | |||||
| ComponentKey geometry_key(obdata, DEG_NODE_TYPE_GEOMETRY); | |||||
| add_relation(time_key, | |||||
| geometry_key, | |||||
| "GP Frame Change"); | |||||
| /* Geometry cache also needs to be recalculated when Material | |||||
| * settings change (e.g. when fill.opacity changes on/off, | |||||
| * we need to rebuild the bGPDstroke->triangles caches) | |||||
| */ | |||||
| for (int i = 0; i < gpd->totcol; i++) { | |||||
Not Done Inline ActionsHere we use explicit check to NULL. sergey: Here we use explicit check to `NULL`. | |||||
| Material *ma = gpd->mat[i]; | |||||
| if ((ma != NULL) && (ma->gp_style != NULL)) { | |||||
| OperationKey material_key(&ma->id, | |||||
Not Done Inline ActionsEither wrap all the arguments to the new line, or indent wrapped ones to after (. See code style page for examples. sergey: Either wrap all the arguments to the new line, or indent wrapped ones to after `(`. See code… | |||||
| DEG_NODE_TYPE_SHADING, | |||||
| DEG_OPCODE_MATERIAL_UPDATE); | |||||
| add_relation(material_key, | |||||
| geometry_key, | |||||
| "Material -> GP Data"); | |||||
| } | |||||
| } | |||||
| break; | |||||
| } | |||||
| default: | default: | ||||
| BLI_assert(!"Should not happen"); | BLI_assert(!"Should not happen"); | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| void DepsgraphRelationBuilder::build_armature(bArmature *armature) | void DepsgraphRelationBuilder::build_armature(bArmature *armature) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 266 Lines • ▼ Show 20 Lines | GHASH_FOREACH_BEGIN(ComponentDepsNode *, comp_node, id_node->components) | ||||
| if (!comp_node->depends_on_cow()) { | if (!comp_node->depends_on_cow()) { | ||||
| /* Component explicitly requests to not add relation. */ | /* Component explicitly requests to not add relation. */ | ||||
| continue; | continue; | ||||
| } | } | ||||
| int rel_flag = DEPSREL_FLAG_NO_FLUSH; | int rel_flag = DEPSREL_FLAG_NO_FLUSH; | ||||
| if (id_type == ID_ME && comp_node->type == DEG_NODE_TYPE_GEOMETRY) { | if (id_type == ID_ME && comp_node->type == DEG_NODE_TYPE_GEOMETRY) { | ||||
| rel_flag &= ~DEPSREL_FLAG_NO_FLUSH; | rel_flag &= ~DEPSREL_FLAG_NO_FLUSH; | ||||
| } | } | ||||
| /* materials need update grease pencil objects */ | |||||
| if (id_type == ID_MA) { | |||||
| rel_flag &= ~DEPSREL_FLAG_NO_FLUSH; | |||||
| } | |||||
| /* Notes on exceptions: | /* Notes on exceptions: | ||||
| * - Parameters component is where drivers are living. Changing any | * - Parameters component is where drivers are living. Changing any | ||||
| * of the (custom) properties in the original datablock (even the | * of the (custom) properties in the original datablock (even the | ||||
| * ones which do not imply other component update) need to make | * ones which do not imply other component update) need to make | ||||
| * sure drivers are properly updated. | * sure drivers are properly updated. | ||||
| * This way, for example, changing ID property will properly poke | * This way, for example, changing ID property will properly poke | ||||
| * all drivers to be updated. | * all drivers to be updated. | ||||
| * | * | ||||
| ▲ Show 20 Lines • Show All 120 Lines • Show Last 20 Lines | |||||
Verify indentation.