diff options
author | Jacques Lucke <mail@jlucke.com> | 2019-08-23 10:52:12 +0300 |
---|---|---|
committer | Jacques Lucke <mail@jlucke.com> | 2019-08-23 10:52:12 +0300 |
commit | a1aa4a259713f26c32a5fac4adbe0751e0479f5b (patch) | |
tree | 0737940d32513ad8e2458760c81ad7c1c61e1ce6 /source/blender/depsgraph/intern | |
parent | 232049dd9408e15d2082181e60ddd775b375ff19 (diff) |
RNA: Cleanup PointerRNA struct
The old layout of `PointerRNA` was confusing for historic reasons:
```
typedef struct PointerRNA {
struct {
void *data;
} id;
struct StructRNA *type;
void *data;
} PointerRNA;
```
This patch updates it to:
```
typedef struct PointerRNA {
struct ID *owner_id;
struct StructRNA *type;
void *data;
} PointerRNA;
```
Throughout the code base `id.data` was replaced with `owner_id`.
Furthermore, many explicit pointer type casts were added which
were implicit before. Some type casts to `ID *` were removed.
Reviewers: brecht, campbellbarton
Differential Revision: https://developer.blender.org/D5558
Diffstat (limited to 'source/blender/depsgraph/intern')
4 files changed, 16 insertions, 16 deletions
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_cache.cc b/source/blender/depsgraph/intern/builder/deg_builder_cache.cc index 3df707e92c1..3cfb4f95e5e 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_cache.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_cache.cc @@ -103,9 +103,9 @@ void animated_property_cb(ID * /*id*/, FCurve *fcurve, void *data_v) /* Get storage for the ID. * This is needed to deal with cases when nested datablock is animated by its parent. */ AnimatedPropertyStorage *animated_property_storage = data->animated_property_storage; - if (pointer_rna.id.data != data->pointer_rna.id.data) { + if (pointer_rna.owner_id != data->pointer_rna.owner_id) { animated_property_storage = data->builder_cache->ensureAnimatedPropertyStorage( - reinterpret_cast<ID *>(pointer_rna.id.data)); + pointer_rna.owner_id); } /* Set the property as animated. */ animated_property_storage->tagPropertyAsAnimated(&pointer_rna, property_rna); diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index 3c226338bfd..ba6a4756313 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -1384,7 +1384,7 @@ void DepsgraphRelationBuilder::build_driver_data(ID *id, FCurve *fcu) * it. This is necessary to provide more granular dependencies specifically for * Bone objects, because the armature data doesn't have per-bone components, * and generic add_relation can only add one link. */ - ID *id_ptr = (ID *)property_entry_key.ptr.id.data; + ID *id_ptr = property_entry_key.ptr.owner_id; bool is_bone = id_ptr && property_entry_key.ptr.type == &RNA_Bone; /* If the Bone property is referenced via obj.pose.bones[].bone, * the RNA pointer refers to the Object ID, so skip to data. */ @@ -1433,8 +1433,8 @@ void DepsgraphRelationBuilder::build_driver_data(ID *id, FCurve *fcu) PointerRNA ptr; RNA_id_pointer_create(id, &id_ptr); if (RNA_path_resolve_full(&id_ptr, fcu->rna_path, &ptr, NULL, NULL)) { - if (id_ptr.id.data != ptr.id.data) { - ComponentKey cow_key((ID *)ptr.id.data, NodeType::COPY_ON_WRITE); + if (id_ptr.owner_id != ptr.owner_id) { + ComponentKey cow_key(ptr.owner_id, NodeType::COPY_ON_WRITE); add_relation(cow_key, driver_key, "Driven CoW -> Driver", RELATION_CHECK_BEFORE_ADD); } } diff --git a/source/blender/depsgraph/intern/builder/deg_builder_rna.cc b/source/blender/depsgraph/intern/builder/deg_builder_rna.cc index be494104522..d3ae3da9b56 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_rna.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_rna.cc @@ -177,7 +177,7 @@ RNANodeIdentifier RNANodeQuery::construct_node_identifier(const PointerRNA *ptr, return node_identifier; } /* Set default values for returns. */ - node_identifier.id = static_cast<ID *>(ptr->id.data); + node_identifier.id = ptr->owner_id; node_identifier.component_name = ""; node_identifier.operation_code = OperationCode::OPERATION; node_identifier.operation_name = ""; @@ -239,7 +239,7 @@ RNANodeIdentifier RNANodeQuery::construct_node_identifier(const PointerRNA *ptr, return node_identifier; } else if (RNA_struct_is_a(ptr->type, &RNA_Constraint)) { - const Object *object = static_cast<const Object *>(ptr->id.data); + const Object *object = reinterpret_cast<const Object *>(ptr->owner_id); const bConstraint *constraint = static_cast<const bConstraint *>(ptr->data); RNANodeQueryIDData *id_data = ensure_id_data(&object->id); /* Check whether is object or bone constraint. */ @@ -259,7 +259,7 @@ RNANodeIdentifier RNANodeQuery::construct_node_identifier(const PointerRNA *ptr, return node_identifier; } else if (ELEM(ptr->type, &RNA_ConstraintTarget, &RNA_ConstraintTargetBone)) { - Object *object = (Object *)ptr->id.data; + Object *object = reinterpret_cast<Object *>(ptr->owner_id); bConstraintTarget *tgt = (bConstraintTarget *)ptr->data; /* Check whether is object or bone constraint. */ bPoseChannel *pchan = NULL; @@ -323,14 +323,14 @@ RNANodeIdentifier RNANodeQuery::construct_node_identifier(const PointerRNA *ptr, } else if (ptr->type == &RNA_ShapeKey) { KeyBlock *key_block = static_cast<KeyBlock *>(ptr->data); - node_identifier.id = static_cast<ID *>(ptr->id.data); + node_identifier.id = ptr->owner_id; 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<ID *>(ptr->id.data); + node_identifier.id = ptr->owner_id; node_identifier.type = NodeType::GEOMETRY; return node_identifier; } @@ -348,12 +348,12 @@ RNANodeIdentifier RNANodeQuery::construct_node_identifier(const PointerRNA *ptr, return node_identifier; } else if (ELEM(ptr->type, &RNA_Curve, &RNA_TextCurve)) { - node_identifier.id = (ID *)ptr->id.data; + node_identifier.id = ptr->owner_id; 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.id = ptr->owner_id; node_identifier.type = NodeType::GEOMETRY; return node_identifier; } diff --git a/source/blender/depsgraph/intern/depsgraph_query.cc b/source/blender/depsgraph/intern/depsgraph_query.cc index 23f2bf4194f..8556a351e2b 100644 --- a/source/blender/depsgraph/intern/depsgraph_query.cc +++ b/source/blender/depsgraph/intern/depsgraph_query.cc @@ -205,11 +205,11 @@ void DEG_get_evaluated_rna_pointer(const Depsgraph *depsgraph, if ((ptr == NULL) || (r_ptr_eval == NULL)) { return; } - ID *orig_id = (ID *)ptr->id.data; + ID *orig_id = ptr->owner_id; ID *cow_id = DEG_get_evaluated_id(depsgraph, orig_id); - if (ptr->id.data == ptr->data) { + if (ptr->owner_id == ptr->data) { /* For ID pointers, it's easy... */ - r_ptr_eval->id.data = (void *)cow_id; + r_ptr_eval->owner_id = cow_id; r_ptr_eval->data = (void *)cow_id; r_ptr_eval->type = ptr->type; } @@ -220,7 +220,7 @@ void DEG_get_evaluated_rna_pointer(const Depsgraph *depsgraph, const Object *ob_eval = (Object *)cow_id; bPoseChannel *pchan = (bPoseChannel *)ptr->data; const bPoseChannel *pchan_eval = BKE_pose_channel_find_name(ob_eval->pose, pchan->name); - r_ptr_eval->id.data = (void *)cow_id; + r_ptr_eval->owner_id = cow_id; r_ptr_eval->data = (void *)pchan_eval; r_ptr_eval->type = ptr->type; } |