[Bf-blender-cvs] [aa8360d0fa6] geometry-nodes: Geometry Nodes: initial test trying to use id properties to initialize group inputs

Jacques Lucke noreply at git.blender.org
Mon Oct 26 18:24:48 CET 2020


Commit: aa8360d0fa60e4b34fc9cb517d6cb731610ed4d0
Author: Jacques Lucke
Date:   Mon Oct 26 18:23:51 2020 +0100
Branches: geometry-nodes
https://developer.blender.org/rBaa8360d0fa60e4b34fc9cb517d6cb731610ed4d0

Geometry Nodes: initial test trying to use id properties to initialize group inputs

The settings can only be set via Python currently. The matching between properties
and group inputs is based on the socket identifier (which is e.g. `Input_5`).
Maybe we'll have to use a different matching strategy in the future, will see.

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

M	source/blender/modifiers/intern/MOD_nodes.cc

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

diff --git a/source/blender/modifiers/intern/MOD_nodes.cc b/source/blender/modifiers/intern/MOD_nodes.cc
index 42c9fd25b88..bfded4d847a 100644
--- a/source/blender/modifiers/intern/MOD_nodes.cc
+++ b/source/blender/modifiers/intern/MOD_nodes.cc
@@ -355,15 +355,55 @@ static GeometryPtr compute_geometry(const DerivedNodeTree &tree,
     /* Initialize remaining group inputs. */
     for (const DOutputSocket *socket : remaining_input_sockets) {
       const CPPType &type = *socket_cpp_type_get(*socket->typeinfo());
-      if (type.is<float>()) {
-        float *value_in = allocator.construct<float>(nmd->test_float_input);
-        group_inputs.add_new(socket, value_in);
+      void *value_in = allocator.allocate(type.size(), type.alignment());
+      if (nmd->settings.properties != nullptr) {
+        StringRefNull socket_identifier = socket->identifier();
+        const IDProperty *property = IDP_GetPropertyFromGroup(nmd->settings.properties,
+                                                              socket_identifier.c_str());
+        if (property != nullptr) {
+          const int property_type = property->type;
+          switch (property_type) {
+            case IDP_FLOAT: {
+              if (type.is<float>()) {
+                *(float *)value_in = IDP_Float(property);
+              }
+              else if (type.is<int>()) {
+                *(int *)value_in = IDP_Float(property);
+              }
+              break;
+            }
+            case IDP_DOUBLE: {
+              if (type.is<float>()) {
+                *(float *)value_in = IDP_Double(property);
+              }
+              else if (type.is<int>()) {
+                *(int *)value_in = IDP_Double(property);
+              }
+              break;
+            }
+            case IDP_INT: {
+              if (type.is<float>()) {
+                *(float *)value_in = IDP_Int(property);
+              }
+              else if (type.is<int>()) {
+                *(int *)value_in = IDP_Int(property);
+              }
+              break;
+            }
+            default: {
+              type.copy_to_uninitialized(type.default_value(), value_in);
+              break;
+            }
+          }
+        }
+        else {
+          type.copy_to_uninitialized(type.default_value(), value_in);
+        }
       }
       else {
-        void *value_in = allocator.allocate(type.size(), type.alignment());
         type.copy_to_uninitialized(type.default_value(), value_in);
-        group_inputs.add_new(socket, {type, value_in});
       }
+      group_inputs.add_new(socket, {type, value_in});
     }
   }



More information about the Bf-blender-cvs mailing list