From e12c08e8d170b7ca40f204a5b0423c23a9fbc2c1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 17 Apr 2019 06:17:24 +0200 Subject: ClangFormat: apply to source, most of intern Apply clang format as proposed in T53211. For details on usage and instructions for migrating branches without conflicts, see: https://wiki.blender.org/wiki/Tools/ClangFormat --- .../depsgraph/intern/builder/deg_builder_rna.cc | 549 ++++++++++----------- 1 file changed, 261 insertions(+), 288 deletions(-) (limited to 'source/blender/depsgraph/intern/builder/deg_builder_rna.cc') diff --git a/source/blender/depsgraph/intern/builder/deg_builder_rna.cc b/source/blender/depsgraph/intern/builder/deg_builder_rna.cc index c8c6cc75418..810d3ee3f66 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_rna.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_rna.cc @@ -55,74 +55,67 @@ namespace DEG { /* ********************************* ID Data ******************************** */ class RNANodeQueryIDData { -public: - explicit RNANodeQueryIDData(const ID *id) - : id_(id), - contraint_to_pchan_map_(NULL) { - } + public: + explicit RNANodeQueryIDData(const ID *id) : id_(id), contraint_to_pchan_map_(NULL) + { + } - ~RNANodeQueryIDData() { - if (contraint_to_pchan_map_ != NULL) { - BLI_ghash_free(contraint_to_pchan_map_, NULL, NULL); - } - } + ~RNANodeQueryIDData() + { + if (contraint_to_pchan_map_ != NULL) { + BLI_ghash_free(contraint_to_pchan_map_, NULL, NULL); + } + } - const bPoseChannel *get_pchan_for_constraint(const bConstraint *constraint) - { - ensure_constraint_to_pchan_map(); - return static_cast( - BLI_ghash_lookup(contraint_to_pchan_map_, constraint)); - } + const bPoseChannel *get_pchan_for_constraint(const bConstraint *constraint) + { + ensure_constraint_to_pchan_map(); + return static_cast(BLI_ghash_lookup(contraint_to_pchan_map_, constraint)); + } - void ensure_constraint_to_pchan_map() - { - if (contraint_to_pchan_map_ != NULL) { - return; - } - BLI_assert(GS(id_->name) == ID_OB); - const Object *object = reinterpret_cast(id_); - contraint_to_pchan_map_ = - BLI_ghash_ptr_new("id data pchan constraint map"); - if (object->pose != NULL) { - LISTBASE_FOREACH ( - const bPoseChannel *, pchan, &object->pose->chanbase) - { - LISTBASE_FOREACH ( - const bConstraint *, constraint, &pchan->constraints) - { - BLI_ghash_insert(contraint_to_pchan_map_, - const_cast(constraint), - const_cast(pchan)); - } - } - } - } + void ensure_constraint_to_pchan_map() + { + if (contraint_to_pchan_map_ != NULL) { + return; + } + BLI_assert(GS(id_->name) == ID_OB); + const Object *object = reinterpret_cast(id_); + contraint_to_pchan_map_ = BLI_ghash_ptr_new("id data pchan constraint map"); + if (object->pose != NULL) { + LISTBASE_FOREACH (const bPoseChannel *, pchan, &object->pose->chanbase) { + LISTBASE_FOREACH (const bConstraint *, constraint, &pchan->constraints) { + BLI_ghash_insert(contraint_to_pchan_map_, + const_cast(constraint), + const_cast(pchan)); + } + } + } + } -protected: - /* ID this data corresponds to. */ - const ID *id_; + protected: + /* ID this data corresponds to. */ + const ID *id_; - /* indexed by bConstraint*, returns pose channel which contains that - * constraint. */ - GHash *contraint_to_pchan_map_; + /* indexed by bConstraint*, returns pose channel which contains that + * constraint. */ + GHash *contraint_to_pchan_map_; }; /* ***************************** Node Identifier **************************** */ RNANodeIdentifier::RNANodeIdentifier() - : id(NULL), - type(NodeType::UNDEFINED), - component_name(""), - operation_code(OperationCode::OPERATION), - operation_name(), - operation_name_tag(-1) + : id(NULL), + type(NodeType::UNDEFINED), + component_name(""), + operation_code(OperationCode::OPERATION), + operation_name(), + operation_name_tag(-1) { } bool RNANodeIdentifier::is_valid() const { - return id != NULL && - type != NodeType::UNDEFINED; + return id != NULL && type != NodeType::UNDEFINED; } /* ********************************** Query ********************************* */ @@ -131,264 +124,244 @@ namespace { void ghash_id_data_free_func(void *value) { - RNANodeQueryIDData *id_data = static_cast(value); - OBJECT_GUARDED_DELETE(id_data, RNANodeQueryIDData); + RNANodeQueryIDData *id_data = static_cast(value); + OBJECT_GUARDED_DELETE(id_data, RNANodeQueryIDData); } } // namespace RNANodeQuery::RNANodeQuery(Depsgraph *depsgraph) - : depsgraph_(depsgraph), - id_data_map_(BLI_ghash_ptr_new("rna node query id data hash")) + : depsgraph_(depsgraph), id_data_map_(BLI_ghash_ptr_new("rna node query id data hash")) { } RNANodeQuery::~RNANodeQuery() { - BLI_ghash_free(id_data_map_, NULL, ghash_id_data_free_func); + BLI_ghash_free(id_data_map_, NULL, ghash_id_data_free_func); } Node *RNANodeQuery::find_node(const PointerRNA *ptr, const PropertyRNA *prop, RNAPointerSource source) { - const RNANodeIdentifier node_identifier = construct_node_identifier( - ptr, prop, source); - if (!node_identifier.is_valid()) { - return NULL; - } - IDNode *id_node = depsgraph_->find_id_node(node_identifier.id); - if (id_node == NULL) { - return NULL; - } - ComponentNode *comp_node = id_node->find_component( - node_identifier.type, node_identifier.component_name); - if (comp_node == NULL) { - return NULL; - } - if (node_identifier.operation_code == OperationCode::OPERATION) { - return comp_node; - } - return comp_node->find_operation(node_identifier.operation_code, - node_identifier.operation_name, - node_identifier.operation_name_tag); + const RNANodeIdentifier node_identifier = construct_node_identifier(ptr, prop, source); + if (!node_identifier.is_valid()) { + return NULL; + } + IDNode *id_node = depsgraph_->find_id_node(node_identifier.id); + if (id_node == NULL) { + return NULL; + } + ComponentNode *comp_node = id_node->find_component(node_identifier.type, + node_identifier.component_name); + if (comp_node == NULL) { + return NULL; + } + if (node_identifier.operation_code == OperationCode::OPERATION) { + return comp_node; + } + return comp_node->find_operation(node_identifier.operation_code, + node_identifier.operation_name, + node_identifier.operation_name_tag); } -RNANodeIdentifier RNANodeQuery::construct_node_identifier( - const PointerRNA *ptr, - const PropertyRNA *prop, - RNAPointerSource source) +RNANodeIdentifier RNANodeQuery::construct_node_identifier(const PointerRNA *ptr, + const PropertyRNA *prop, + RNAPointerSource source) { - RNANodeIdentifier node_identifier; - if (ptr->type == NULL) { - return node_identifier; - } - /* Set default values for returns. */ - node_identifier.id = static_cast(ptr->id.data); - node_identifier.component_name = ""; - node_identifier.operation_code = OperationCode::OPERATION; - node_identifier.operation_name = ""; - node_identifier.operation_name_tag = -1; - /* Handling of commonly known scenarios. */ - if (ptr->type == &RNA_PoseBone) { - const bPoseChannel *pchan = - static_cast(ptr->data); - if (prop != NULL && RNA_property_is_idprop(prop)) { - node_identifier.type = NodeType::PARAMETERS; - node_identifier.operation_code = OperationCode::ID_PROPERTY; - node_identifier.operation_name = - RNA_property_identifier( - reinterpret_cast(prop)); - node_identifier.operation_name_tag = -1; - } - else { - /* Bone - generally, we just want the bone component. */ - node_identifier.type = NodeType::BONE; - node_identifier.component_name = pchan->name; - /* But B-Bone properties should connect to the actual operation. */ - if (!ELEM(NULL, pchan->bone, prop) && pchan->bone->segments > 1 && - STRPREFIX(RNA_property_identifier(prop), "bbone_")) - { - node_identifier.operation_code = OperationCode::BONE_SEGMENTS; - } - } - return node_identifier; - } - else if (ptr->type == &RNA_Bone) { - const Bone *bone = static_cast(ptr->data); - /* Armature-level bone, but it ends up going to bone component - * anyway. */ - // NOTE: the ID in this case will end up being bArmature. - node_identifier.type = NodeType::BONE; - node_identifier.component_name = bone->name; - return node_identifier; - } - else if (RNA_struct_is_a(ptr->type, &RNA_Constraint)) { - const Object *object = static_cast(ptr->id.data); - const bConstraint *constraint = - static_cast(ptr->data); - RNANodeQueryIDData *id_data = ensure_id_data(&object->id); - /* Check whether is object or bone constraint. */ - /* NOTE: Currently none of the area can address transform of an object - * at a given constraint, but for rigging one might use constraint - * influence to be used to drive some corrective shape keys or so. */ - const bPoseChannel *pchan = - id_data->get_pchan_for_constraint(constraint); - if (pchan == NULL) { - node_identifier.type = NodeType::TRANSFORM; - node_identifier.operation_code = OperationCode::TRANSFORM_LOCAL; - } - else { - node_identifier.type = NodeType::BONE; - node_identifier.operation_code = OperationCode::BONE_LOCAL; - node_identifier.component_name = pchan->name; - } - return node_identifier; - } - else if (ELEM(ptr->type, &RNA_ConstraintTarget, &RNA_ConstraintTargetBone)) { - Object *object = (Object *)ptr->id.data; - bConstraintTarget *tgt = (bConstraintTarget *)ptr->data; - /* Check whether is object or bone constraint. */ - bPoseChannel *pchan = NULL; - bConstraint *con = BKE_constraint_find_from_target(object, tgt, &pchan); - if (con != NULL) { - if (pchan != NULL) { - node_identifier.type = NodeType::BONE; - node_identifier.operation_code = OperationCode::BONE_LOCAL; - node_identifier.component_name = pchan->name; - } - else { - node_identifier.type = NodeType::TRANSFORM; - node_identifier.operation_code = OperationCode::TRANSFORM_LOCAL; - } - return node_identifier; - } - } - else if (RNA_struct_is_a(ptr->type, &RNA_Modifier)) { - /* When modifier is used as FROM operation this is likely referencing to - * the property (for example, modifier's influence). - * But when it's used as TO operation, this is geometry component. */ - switch (source) { - case RNAPointerSource::ENTRY: - node_identifier.type = NodeType::GEOMETRY; - break; - case RNAPointerSource::EXIT: - node_identifier.type = NodeType::PARAMETERS; - node_identifier.operation_code = OperationCode::PARAMETERS_EVAL; - break; - } - return node_identifier; - } - else if (ptr->type == &RNA_Object) { - /* Transforms props? */ - if (prop != NULL) { - const char *prop_identifier = RNA_property_identifier((PropertyRNA *)prop); - /* TODO(sergey): How to optimize this? */ - if (strstr(prop_identifier, "location") || - strstr(prop_identifier, "rotation") || - strstr(prop_identifier, "scale") || - strstr(prop_identifier, "matrix_")) - { - node_identifier.type = NodeType::TRANSFORM; - return node_identifier; - } - else if (strstr(prop_identifier, "data")) { - /* We access object.data, most likely a geometry. - * Might be a bone tho. */ - node_identifier.type = NodeType::GEOMETRY; - return node_identifier; - } - else if (STREQ(prop_identifier, "hide_viewport") || - STREQ(prop_identifier, "hide_render")) - { - node_identifier.type = NodeType::OBJECT_FROM_LAYER; - return node_identifier; - } - } - } - else if (ptr->type == &RNA_ShapeKey) { - KeyBlock *key_block = static_cast(ptr->data); - node_identifier.id = static_cast(ptr->id.data); - node_identifier.type = NodeType::PARAMETERS; - node_identifier.operation_code = OperationCode::PARAMETERS_EVAL; - node_identifier.operation_name = key_block->name; - return node_identifier; - } - else if (ptr->type == &RNA_Key) { - node_identifier.id = static_cast(ptr->id.data); - node_identifier.type = NodeType::GEOMETRY; - return node_identifier; - } - else if (RNA_struct_is_a(ptr->type, &RNA_Sequence)) { - const Sequence *seq = static_cast(ptr->data); - /* Sequencer strip */ - node_identifier.type = NodeType::SEQUENCER; - node_identifier.component_name = seq->name; - return node_identifier; - } - else if (RNA_struct_is_a(ptr->type, &RNA_NodeSocket)) { - node_identifier.type = NodeType::SHADING; - return node_identifier; - } - else if (RNA_struct_is_a(ptr->type, &RNA_ShaderNode)) { - node_identifier.type = NodeType::SHADING; - return node_identifier; - } - else if (ELEM(ptr->type, &RNA_Curve, &RNA_TextCurve)) { - node_identifier.id = (ID *)ptr->id.data; - node_identifier.type = NodeType::GEOMETRY; - return node_identifier; - } - else if (ELEM(ptr->type, &RNA_BezierSplinePoint, &RNA_SplinePoint)) { - node_identifier.id = (ID *)ptr->id.data; - node_identifier.type = NodeType::GEOMETRY; - return node_identifier; - } - else if (RNA_struct_is_a(ptr->type, &RNA_ImageUser)) { - if (GS(node_identifier.id->name) == ID_NT) { - node_identifier.type = NodeType::ANIMATION; - node_identifier.operation_code = OperationCode::IMAGE_ANIMATION; - return node_identifier; - } - } - else if (ELEM(ptr->type, &RNA_MeshVertex, - &RNA_MeshEdge, - &RNA_MeshLoop, - &RNA_MeshPolygon)) - { - node_identifier.type = NodeType::GEOMETRY; - return node_identifier; - } - if (prop != NULL) { - /* All unknown data effectively falls under "parameter evaluation". */ - if (RNA_property_is_idprop(prop)) { - node_identifier.type = NodeType::PARAMETERS; - node_identifier.operation_code = OperationCode::ID_PROPERTY; - node_identifier.operation_name = - RNA_property_identifier((PropertyRNA *)prop); - node_identifier.operation_name_tag = -1; - } - else { - node_identifier.type = NodeType::PARAMETERS; - node_identifier.operation_code = OperationCode::PARAMETERS_EVAL; - node_identifier.operation_name = ""; - node_identifier.operation_name_tag = -1; - } - return node_identifier; - } - return node_identifier; + RNANodeIdentifier node_identifier; + if (ptr->type == NULL) { + return node_identifier; + } + /* Set default values for returns. */ + node_identifier.id = static_cast(ptr->id.data); + node_identifier.component_name = ""; + node_identifier.operation_code = OperationCode::OPERATION; + node_identifier.operation_name = ""; + node_identifier.operation_name_tag = -1; + /* Handling of commonly known scenarios. */ + if (ptr->type == &RNA_PoseBone) { + const bPoseChannel *pchan = static_cast(ptr->data); + if (prop != NULL && RNA_property_is_idprop(prop)) { + node_identifier.type = NodeType::PARAMETERS; + node_identifier.operation_code = OperationCode::ID_PROPERTY; + node_identifier.operation_name = RNA_property_identifier( + reinterpret_cast(prop)); + node_identifier.operation_name_tag = -1; + } + else { + /* Bone - generally, we just want the bone component. */ + node_identifier.type = NodeType::BONE; + node_identifier.component_name = pchan->name; + /* But B-Bone properties should connect to the actual operation. */ + if (!ELEM(NULL, pchan->bone, prop) && pchan->bone->segments > 1 && + STRPREFIX(RNA_property_identifier(prop), "bbone_")) { + node_identifier.operation_code = OperationCode::BONE_SEGMENTS; + } + } + return node_identifier; + } + else if (ptr->type == &RNA_Bone) { + const Bone *bone = static_cast(ptr->data); + /* Armature-level bone, but it ends up going to bone component + * anyway. */ + // NOTE: the ID in this case will end up being bArmature. + node_identifier.type = NodeType::BONE; + node_identifier.component_name = bone->name; + return node_identifier; + } + else if (RNA_struct_is_a(ptr->type, &RNA_Constraint)) { + const Object *object = static_cast(ptr->id.data); + const bConstraint *constraint = static_cast(ptr->data); + RNANodeQueryIDData *id_data = ensure_id_data(&object->id); + /* Check whether is object or bone constraint. */ + /* NOTE: Currently none of the area can address transform of an object + * at a given constraint, but for rigging one might use constraint + * influence to be used to drive some corrective shape keys or so. */ + const bPoseChannel *pchan = id_data->get_pchan_for_constraint(constraint); + if (pchan == NULL) { + node_identifier.type = NodeType::TRANSFORM; + node_identifier.operation_code = OperationCode::TRANSFORM_LOCAL; + } + else { + node_identifier.type = NodeType::BONE; + node_identifier.operation_code = OperationCode::BONE_LOCAL; + node_identifier.component_name = pchan->name; + } + return node_identifier; + } + else if (ELEM(ptr->type, &RNA_ConstraintTarget, &RNA_ConstraintTargetBone)) { + Object *object = (Object *)ptr->id.data; + bConstraintTarget *tgt = (bConstraintTarget *)ptr->data; + /* Check whether is object or bone constraint. */ + bPoseChannel *pchan = NULL; + bConstraint *con = BKE_constraint_find_from_target(object, tgt, &pchan); + if (con != NULL) { + if (pchan != NULL) { + node_identifier.type = NodeType::BONE; + node_identifier.operation_code = OperationCode::BONE_LOCAL; + node_identifier.component_name = pchan->name; + } + else { + node_identifier.type = NodeType::TRANSFORM; + node_identifier.operation_code = OperationCode::TRANSFORM_LOCAL; + } + return node_identifier; + } + } + else if (RNA_struct_is_a(ptr->type, &RNA_Modifier)) { + /* When modifier is used as FROM operation this is likely referencing to + * the property (for example, modifier's influence). + * But when it's used as TO operation, this is geometry component. */ + switch (source) { + case RNAPointerSource::ENTRY: + node_identifier.type = NodeType::GEOMETRY; + break; + case RNAPointerSource::EXIT: + node_identifier.type = NodeType::PARAMETERS; + node_identifier.operation_code = OperationCode::PARAMETERS_EVAL; + break; + } + return node_identifier; + } + else if (ptr->type == &RNA_Object) { + /* Transforms props? */ + if (prop != NULL) { + const char *prop_identifier = RNA_property_identifier((PropertyRNA *)prop); + /* TODO(sergey): How to optimize this? */ + if (strstr(prop_identifier, "location") || strstr(prop_identifier, "rotation") || + strstr(prop_identifier, "scale") || strstr(prop_identifier, "matrix_")) { + node_identifier.type = NodeType::TRANSFORM; + return node_identifier; + } + else if (strstr(prop_identifier, "data")) { + /* We access object.data, most likely a geometry. + * Might be a bone tho. */ + node_identifier.type = NodeType::GEOMETRY; + return node_identifier; + } + else if (STREQ(prop_identifier, "hide_viewport") || STREQ(prop_identifier, "hide_render")) { + node_identifier.type = NodeType::OBJECT_FROM_LAYER; + return node_identifier; + } + } + } + else if (ptr->type == &RNA_ShapeKey) { + KeyBlock *key_block = static_cast(ptr->data); + node_identifier.id = static_cast(ptr->id.data); + node_identifier.type = NodeType::PARAMETERS; + node_identifier.operation_code = OperationCode::PARAMETERS_EVAL; + node_identifier.operation_name = key_block->name; + return node_identifier; + } + else if (ptr->type == &RNA_Key) { + node_identifier.id = static_cast(ptr->id.data); + node_identifier.type = NodeType::GEOMETRY; + return node_identifier; + } + else if (RNA_struct_is_a(ptr->type, &RNA_Sequence)) { + const Sequence *seq = static_cast(ptr->data); + /* Sequencer strip */ + node_identifier.type = NodeType::SEQUENCER; + node_identifier.component_name = seq->name; + return node_identifier; + } + else if (RNA_struct_is_a(ptr->type, &RNA_NodeSocket)) { + node_identifier.type = NodeType::SHADING; + return node_identifier; + } + else if (RNA_struct_is_a(ptr->type, &RNA_ShaderNode)) { + node_identifier.type = NodeType::SHADING; + return node_identifier; + } + else if (ELEM(ptr->type, &RNA_Curve, &RNA_TextCurve)) { + node_identifier.id = (ID *)ptr->id.data; + node_identifier.type = NodeType::GEOMETRY; + return node_identifier; + } + else if (ELEM(ptr->type, &RNA_BezierSplinePoint, &RNA_SplinePoint)) { + node_identifier.id = (ID *)ptr->id.data; + node_identifier.type = NodeType::GEOMETRY; + return node_identifier; + } + else if (RNA_struct_is_a(ptr->type, &RNA_ImageUser)) { + if (GS(node_identifier.id->name) == ID_NT) { + node_identifier.type = NodeType::ANIMATION; + node_identifier.operation_code = OperationCode::IMAGE_ANIMATION; + return node_identifier; + } + } + else if (ELEM(ptr->type, &RNA_MeshVertex, &RNA_MeshEdge, &RNA_MeshLoop, &RNA_MeshPolygon)) { + node_identifier.type = NodeType::GEOMETRY; + return node_identifier; + } + if (prop != NULL) { + /* All unknown data effectively falls under "parameter evaluation". */ + if (RNA_property_is_idprop(prop)) { + node_identifier.type = NodeType::PARAMETERS; + node_identifier.operation_code = OperationCode::ID_PROPERTY; + node_identifier.operation_name = RNA_property_identifier((PropertyRNA *)prop); + node_identifier.operation_name_tag = -1; + } + else { + node_identifier.type = NodeType::PARAMETERS; + node_identifier.operation_code = OperationCode::PARAMETERS_EVAL; + node_identifier.operation_name = ""; + node_identifier.operation_name_tag = -1; + } + return node_identifier; + } + return node_identifier; } RNANodeQueryIDData *RNANodeQuery::ensure_id_data(const ID *id) { - RNANodeQueryIDData **id_data_ptr; - if (!BLI_ghash_ensure_p(id_data_map_, - const_cast(id), - reinterpret_cast(&id_data_ptr))) - { - *id_data_ptr = OBJECT_GUARDED_NEW(RNANodeQueryIDData, id); - } - return *id_data_ptr; + RNANodeQueryIDData **id_data_ptr; + if (!BLI_ghash_ensure_p( + id_data_map_, const_cast(id), reinterpret_cast(&id_data_ptr))) { + *id_data_ptr = OBJECT_GUARDED_NEW(RNANodeQueryIDData, id); + } + return *id_data_ptr; } } // namespace DEG -- cgit v1.2.3