diff options
author | Jacques Lucke <jacques@blender.org> | 2020-12-02 15:25:25 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2020-12-02 17:38:47 +0300 |
commit | 6be56c13e96048cbc494ba5473a8deaf2cf5a6f8 (patch) | |
tree | 83435d439b3d106eb1405b2b815bf1d5aa1fdd43 /source/blender/nodes/NOD_derived_node_tree.hh | |
parent | ddbe3274eff68523547bc8eb70dd95c3d411b89b (diff) |
Geometry Nodes: initial scattering and geometry nodes
This is the initial merge from the geometry-nodes branch.
Nodes:
* Attribute Math
* Boolean
* Edge Split
* Float Compare
* Object Info
* Point Distribute
* Point Instance
* Random Attribute
* Random Float
* Subdivision Surface
* Transform
* Triangulate
It includes the initial evaluation of geometry node groups in the Geometry Nodes modifier.
Notes on the Generic attribute access API
The API adds an indirection for attribute access. That has the following benefits:
* Most code does not have to care about how an attribute is stored internally.
This is mainly necessary, because we have to deal with "legacy" attributes
such as vertex weights and attributes that are embedded into other structs
such as vertex positions.
* When reading from an attribute, we generally don't care what domain the
attribute is stored on. So we want to abstract away the interpolation that
that adapts attributes from one domain to another domain (this is not
actually implemented yet).
Other possible improvements for later iterations include:
* Actually implement interpolation between domains.
* Don't use inheritance for the different attribute types. A single class for read
access and one for write access might be enough, because we know all the ways
in which attributes are stored internally. We don't want more different internal
structures in the future. On the contrary, ideally we can consolidate the different
storage formats in the future to reduce the need for this indirection.
* Remove the need for heap allocations when creating attribute accessors.
It includes commits from:
* Dalai Felinto
* Hans Goudey
* Jacques Lucke
* Léo Depoix
Diffstat (limited to 'source/blender/nodes/NOD_derived_node_tree.hh')
-rw-r--r-- | source/blender/nodes/NOD_derived_node_tree.hh | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/source/blender/nodes/NOD_derived_node_tree.hh b/source/blender/nodes/NOD_derived_node_tree.hh index 9c71ae79cf2..087bfac4442 100644 --- a/source/blender/nodes/NOD_derived_node_tree.hh +++ b/source/blender/nodes/NOD_derived_node_tree.hh @@ -31,6 +31,8 @@ #include "NOD_node_tree_ref.hh" +#include "BLI_vector_set.hh" + namespace blender::nodes { class DSocket; @@ -65,6 +67,8 @@ class DSocket : NonCopyable, NonMovable { PointerRNA *rna() const; StringRefNull idname() const; StringRefNull name() const; + StringRefNull identifier() const; + bNodeSocketType *typeinfo() const; const SocketRef &socket_ref() const; bNodeSocket *bsocket() const; @@ -147,6 +151,8 @@ class DNode : NonCopyable, NonMovable { PointerRNA *rna() const; StringRefNull idname() const; StringRefNull name() const; + bNode *bnode() const; + bNodeType *typeinfo() const; private: void destruct_with_sockets(); @@ -180,11 +186,15 @@ class DerivedNodeTree : NonCopyable, NonMovable { Vector<DOutputSocket *> output_sockets_; MultiValueMap<const bNodeType *, DNode *> nodes_by_type_; + VectorSet<const NodeTreeRef *> used_node_tree_refs_; + bNodeTree *btree_; public: DerivedNodeTree(bNodeTree *btree, NodeTreeRefMap &node_tree_refs); ~DerivedNodeTree(); + bNodeTree *btree() const; + Span<const DNode *> nodes() const; Span<const DNode *> nodes_by_type(StringRefNull idname) const; Span<const DNode *> nodes_by_type(const bNodeType *nodetype) const; @@ -195,6 +205,10 @@ class DerivedNodeTree : NonCopyable, NonMovable { Span<const DGroupInput *> group_inputs() const; + Span<const NodeTreeRef *> used_node_tree_refs() const; + + bool has_link_cycles() const; + std::string to_dot() const; private: @@ -229,6 +243,15 @@ class DerivedNodeTree : NonCopyable, NonMovable { Vector<DParentNode *> &&all_parent_nodes); }; +namespace derived_node_tree_types { +using nodes::DerivedNodeTree; +using nodes::DGroupInput; +using nodes::DInputSocket; +using nodes::DNode; +using nodes::DOutputSocket; +using nodes::DParentNode; +}; // namespace derived_node_tree_types + /* -------------------------------------------------------------------- * DSocket inline methods. */ @@ -288,6 +311,16 @@ inline StringRefNull DSocket::name() const return socket_ref_->name(); } +inline StringRefNull DSocket::identifier() const +{ + return socket_ref_->identifier(); +} + +inline bNodeSocketType *DSocket::typeinfo() const +{ + return socket_ref_->bsocket()->typeinfo; +} + inline const SocketRef &DSocket::socket_ref() const { return *socket_ref_; @@ -445,6 +478,16 @@ inline StringRefNull DNode::name() const return node_ref_->name(); } +inline bNode *DNode::bnode() const +{ + return node_ref_->bnode(); +} + +inline bNodeType *DNode::typeinfo() const +{ + return node_ref_->bnode()->typeinfo; +} + /* -------------------------------------------------------------------- * DParentNode inline methods. */ @@ -468,6 +511,11 @@ inline int DParentNode::id() const * DerivedNodeTree inline methods. */ +inline bNodeTree *DerivedNodeTree::btree() const +{ + return btree_; +} + inline Span<const DNode *> DerivedNodeTree::nodes() const { return nodes_by_id_; @@ -504,4 +552,9 @@ inline Span<const DGroupInput *> DerivedNodeTree::group_inputs() const return group_inputs_; } +inline Span<const NodeTreeRef *> DerivedNodeTree::used_node_tree_refs() const +{ + return used_node_tree_refs_; +} + } // namespace blender::nodes |