[Bf-blender-cvs] [48731f45c24] master: Nodes: provide access to type specific data through node tree ref

Jacques Lucke noreply at git.blender.org
Fri Mar 19 21:14:40 CET 2021


Commit: 48731f45c248a368e4d52b5a136bcfd04a401b65
Author: Jacques Lucke
Date:   Fri Mar 19 20:35:48 2021 +0100
Branches: master
https://developer.blender.org/rB48731f45c248a368e4d52b5a136bcfd04a401b65

Nodes: provide access to type specific data through node tree ref

===================================================================

M	source/blender/modifiers/intern/MOD_nodes.cc
M	source/blender/nodes/NOD_node_tree_ref.hh

===================================================================

diff --git a/source/blender/modifiers/intern/MOD_nodes.cc b/source/blender/modifiers/intern/MOD_nodes.cc
index 003002e5fac..14264847a1a 100644
--- a/source/blender/modifiers/intern/MOD_nodes.cc
+++ b/source/blender/modifiers/intern/MOD_nodes.cc
@@ -586,12 +586,12 @@ class GeometryNodesEvaluator {
     void *buffer = allocator_.allocate(type.size(), type.alignment());
 
     if (bsocket->type == SOCK_OBJECT) {
-      Object *object = ((bNodeSocketValueObject *)bsocket->default_value)->value;
+      Object *object = socket->default_value<bNodeSocketValueObject>()->value;
       PersistentObjectHandle object_handle = handle_map_.lookup(object);
       new (buffer) PersistentObjectHandle(object_handle);
     }
     else if (bsocket->type == SOCK_COLLECTION) {
-      Collection *collection = ((bNodeSocketValueCollection *)bsocket->default_value)->value;
+      Collection *collection = socket->default_value<bNodeSocketValueCollection>()->value;
       PersistentCollectionHandle collection_handle = handle_map_.lookup(collection);
       new (buffer) PersistentCollectionHandle(collection_handle);
     }
diff --git a/source/blender/nodes/NOD_node_tree_ref.hh b/source/blender/nodes/NOD_node_tree_ref.hh
index 6b8eb21bf9a..b9c5d41658a 100644
--- a/source/blender/nodes/NOD_node_tree_ref.hh
+++ b/source/blender/nodes/NOD_node_tree_ref.hh
@@ -116,6 +116,9 @@ class SocketRef : NonCopyable, NonMovable {
   bNodeTree *btree() const;
 
   bool is_available() const;
+
+  void *default_value() const;
+  template<typename T> T *default_value() const;
 };
 
 class InputSocketRef final : public SocketRef {
@@ -169,6 +172,9 @@ class NodeRef : NonCopyable, NonMovable {
   bool is_group_input_node() const;
   bool is_group_output_node() const;
   bool is_muted() const;
+
+  void *storage() const;
+  template<typename T> T *storage() const;
 };
 
 class LinkRef : NonCopyable, NonMovable {
@@ -379,6 +385,16 @@ inline bool SocketRef::is_available() const
   return (bsocket_->flag & SOCK_UNAVAIL) == 0;
 }
 
+inline void *SocketRef::default_value() const
+{
+  return bsocket_->default_value;
+}
+
+template<typename T> inline T *SocketRef::default_value() const
+{
+  return (T *)bsocket_->default_value;
+}
+
 /* --------------------------------------------------------------------
  * InputSocketRef inline methods.
  */
@@ -507,6 +523,16 @@ inline bool NodeRef::is_muted() const
   return (bnode_->flag & NODE_MUTED) != 0;
 }
 
+inline void *NodeRef::storage() const
+{
+  return bnode_->storage;
+}
+
+template<typename T> inline T *NodeRef::storage() const
+{
+  return (T *)bnode_->storage;
+}
+
 /* --------------------------------------------------------------------
  * LinkRef inline methods.
  */



More information about the Bf-blender-cvs mailing list