Refactor: Move depsgraph node keys to own file

They are not specific to the relations builder and could be
used outside of it.
This commit is contained in:
2022-09-15 15:40:06 +02:00
parent 78b7a1c3a8
commit f948ffaa9f
4 changed files with 171 additions and 136 deletions

View File

@@ -26,6 +26,8 @@ set(SRC
intern/builder/deg_builder.cc
intern/builder/deg_builder_cache.cc
intern/builder/deg_builder_cycle.cc
intern/builder/deg_builder_key.cc
intern/builder/deg_builder_key.h
intern/builder/deg_builder_map.cc
intern/builder/deg_builder_nodes.cc
intern/builder/deg_builder_nodes_rig.cc
@@ -34,7 +36,6 @@ set(SRC
intern/builder/deg_builder_pchanmap.cc
intern/builder/deg_builder_relations.cc
intern/builder/deg_builder_relations_drivers.cc
intern/builder/deg_builder_relations_keys.cc
intern/builder/deg_builder_relations_rig.cc
intern/builder/deg_builder_relations_scene.cc
intern/builder/deg_builder_relations_view_layer.cc

View File

@@ -7,20 +7,26 @@
* Methods for constructing depsgraph
*/
#include "intern/builder/deg_builder_relations.h"
#include "intern/builder/deg_builder_key.h"
#include "RNA_path.h"
namespace blender::deg {
////////////////////////////////////////////////////////////////////////////////
/* Time source. */
/* -------------------------------------------------------------------- */
/** \name Time source
* \{ */
string TimeSourceKey::identifier() const
{
return string("TimeSourceKey");
}
////////////////////////////////////////////////////////////////////////////////
// Component.
/** \} */
/* -------------------------------------------------------------------- */
/** \name Component
* \{ */
string ComponentKey::identifier() const
{
@@ -35,8 +41,11 @@ string ComponentKey::identifier() const
return result;
}
////////////////////////////////////////////////////////////////////////////////
// Operation.
/** \} */
/* -------------------------------------------------------------------- */
/** \name Operation
* \{ */
string OperationKey::identifier() const
{
@@ -51,8 +60,11 @@ string OperationKey::identifier() const
return result;
}
////////////////////////////////////////////////////////////////////////////////
// RNA path.
/** \} */
/* -------------------------------------------------------------------- */
/** \name RNA path
* \{ */
RNAPathKey::RNAPathKey(ID *id, const char *path, RNAPointerSource source) : id(id), source(source)
{
@@ -79,4 +91,6 @@ string RNAPathKey::identifier() const
return string("RnaPathKey(") + "id: " + id_name + ", prop: '" + prop_name + "')";
}
/** \} */
} // namespace blender::deg

View File

@@ -0,0 +1,145 @@
/* SPDX-License-Identifier: GPL-2.0-or-later
* Copyright 2013 Blender Foundation. All rights reserved. */
/** \file
* \ingroup depsgraph
*/
#pragma once
#include "intern/builder/deg_builder_rna.h"
#include "intern/depsgraph_type.h"
#include "DNA_ID.h"
#include "RNA_access.h"
#include "RNA_types.h"
struct ID;
struct PropertyRNA;
namespace blender::deg {
struct TimeSourceKey {
TimeSourceKey() = default;
string identifier() const;
};
struct ComponentKey {
ComponentKey() = default;
inline ComponentKey(const ID *id, NodeType type, const char *name = "")
: id(id), type(type), name(name)
{
}
string identifier() const;
const ID *id = nullptr;
NodeType type = NodeType::UNDEFINED;
const char *name = "";
};
struct OperationKey {
OperationKey() = default;
inline OperationKey(const ID *id, NodeType component_type, const char *name, int name_tag = -1)
: id(id),
component_type(component_type),
component_name(""),
opcode(OperationCode::OPERATION),
name(name),
name_tag(name_tag)
{
}
OperationKey(const ID *id,
NodeType component_type,
const char *component_name,
const char *name,
int name_tag)
: id(id),
component_type(component_type),
component_name(component_name),
opcode(OperationCode::OPERATION),
name(name),
name_tag(name_tag)
{
}
OperationKey(const ID *id, NodeType component_type, OperationCode opcode)
: id(id),
component_type(component_type),
component_name(""),
opcode(opcode),
name(""),
name_tag(-1)
{
}
OperationKey(const ID *id,
NodeType component_type,
const char *component_name,
OperationCode opcode)
: id(id),
component_type(component_type),
component_name(component_name),
opcode(opcode),
name(""),
name_tag(-1)
{
}
OperationKey(const ID *id,
NodeType component_type,
OperationCode opcode,
const char *name,
int name_tag = -1)
: id(id),
component_type(component_type),
component_name(""),
opcode(opcode),
name(name),
name_tag(name_tag)
{
}
OperationKey(const ID *id,
NodeType component_type,
const char *component_name,
OperationCode opcode,
const char *name,
int name_tag = -1)
: id(id),
component_type(component_type),
component_name(component_name),
opcode(opcode),
name(name),
name_tag(name_tag)
{
}
string identifier() const;
const ID *id = nullptr;
NodeType component_type = NodeType::UNDEFINED;
const char *component_name = "";
OperationCode opcode = OperationCode::OPERATION;
const char *name = "";
int name_tag = -1;
};
struct RNAPathKey {
RNAPathKey(ID *id, const char *path, RNAPointerSource source);
RNAPathKey(ID *id, const PointerRNA &ptr, PropertyRNA *prop, RNAPointerSource source);
string identifier() const;
ID *id;
PointerRNA ptr;
PropertyRNA *prop;
RNAPointerSource source;
};
} // namespace blender::deg

View File

@@ -14,14 +14,13 @@
#include "DNA_ID.h"
#include "RNA_access.h"
#include "RNA_path.h"
#include "RNA_types.h"
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "intern/builder/deg_builder.h"
#include "intern/builder/deg_builder_key.h"
#include "intern/builder/deg_builder_map.h"
#include "intern/builder/deg_builder_rna.h"
#include "intern/builder/deg_builder_stack.h"
@@ -69,8 +68,6 @@ struct bNodeTree;
struct bPoseChannel;
struct bSound;
struct PropertyRNA;
namespace blender::deg {
struct ComponentNode;
@@ -84,128 +81,6 @@ struct Relation;
struct RootPChanMap;
struct TimeSourceNode;
struct TimeSourceKey {
TimeSourceKey() = default;
string identifier() const;
};
struct ComponentKey {
ComponentKey() = default;
inline ComponentKey(const ID *id, NodeType type, const char *name = "")
: id(id), type(type), name(name)
{
}
string identifier() const;
const ID *id = nullptr;
NodeType type = NodeType::UNDEFINED;
const char *name = "";
};
struct OperationKey {
OperationKey() = default;
inline OperationKey(const ID *id, NodeType component_type, const char *name, int name_tag = -1)
: id(id),
component_type(component_type),
component_name(""),
opcode(OperationCode::OPERATION),
name(name),
name_tag(name_tag)
{
}
OperationKey(const ID *id,
NodeType component_type,
const char *component_name,
const char *name,
int name_tag)
: id(id),
component_type(component_type),
component_name(component_name),
opcode(OperationCode::OPERATION),
name(name),
name_tag(name_tag)
{
}
OperationKey(const ID *id, NodeType component_type, OperationCode opcode)
: id(id),
component_type(component_type),
component_name(""),
opcode(opcode),
name(""),
name_tag(-1)
{
}
OperationKey(const ID *id,
NodeType component_type,
const char *component_name,
OperationCode opcode)
: id(id),
component_type(component_type),
component_name(component_name),
opcode(opcode),
name(""),
name_tag(-1)
{
}
OperationKey(const ID *id,
NodeType component_type,
OperationCode opcode,
const char *name,
int name_tag = -1)
: id(id),
component_type(component_type),
component_name(""),
opcode(opcode),
name(name),
name_tag(name_tag)
{
}
OperationKey(const ID *id,
NodeType component_type,
const char *component_name,
OperationCode opcode,
const char *name,
int name_tag = -1)
: id(id),
component_type(component_type),
component_name(component_name),
opcode(opcode),
name(name),
name_tag(name_tag)
{
}
string identifier() const;
const ID *id = nullptr;
NodeType component_type = NodeType::UNDEFINED;
const char *component_name = "";
OperationCode opcode = OperationCode::OPERATION;
const char *name = "";
int name_tag = -1;
};
struct RNAPathKey {
RNAPathKey(ID *id, const char *path, RNAPointerSource source);
RNAPathKey(ID *id, const PointerRNA &ptr, PropertyRNA *prop, RNAPointerSource source);
string identifier() const;
ID *id;
PointerRNA ptr;
PropertyRNA *prop;
RNAPointerSource source;
};
class DepsgraphRelationBuilder : public DepsgraphBuilder {
public:
DepsgraphRelationBuilder(Main *bmain, Depsgraph *graph, DepsgraphBuilderCache *cache);