[Bf-blender-cvs] [f2b51d960d8] temp-geometry-nodes-expandable-geometry-socket-prototype: support rotation input in instance node

Jacques Lucke noreply at git.blender.org
Wed Aug 4 17:10:49 CEST 2021


Commit: f2b51d960d8464218381b15de94e4ee5e61ad235
Author: Jacques Lucke
Date:   Wed Aug 4 13:41:33 2021 +0200
Branches: temp-geometry-nodes-expandable-geometry-socket-prototype
https://developer.blender.org/rBf2b51d960d8464218381b15de94e4ee5e61ad235

support rotation input in instance node

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

M	source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc
M	source/blender/nodes/geometry/nodes/node_geo_point_instance.cc

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

diff --git a/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc b/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc
index 72de9337322..b413f0e4614 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc
@@ -549,6 +549,7 @@ static void geo_node_point_distribute_exec(GeoNodeExecParams params)
 
   if (density <= 0.0f) {
     params.set_output("Geometry", GeometrySet());
+    params.set_output("Rotation", Array<float3>());
     return;
   }
 
@@ -556,6 +557,7 @@ static void geo_node_point_distribute_exec(GeoNodeExecParams params)
   geometry_set_gather_instances(geometry_set, set_groups);
   if (set_groups.is_empty()) {
     params.set_output("Geometry", GeometrySet());
+    params.set_output("Rotation", Array<float3>());
     return;
   }
 
@@ -570,6 +572,7 @@ static void geo_node_point_distribute_exec(GeoNodeExecParams params)
   if (set_groups.is_empty()) {
     params.error_message_add(NodeWarningType::Error, TIP_("Input geometry must contain a mesh"));
     params.set_output("Geometry", GeometrySet());
+    params.set_output("Rotation", Array<float3>());
     return;
   }
 
diff --git a/source/blender/nodes/geometry/nodes/node_geo_point_instance.cc b/source/blender/nodes/geometry/nodes/node_geo_point_instance.cc
index b119b7b31e9..0a8570f5d5b 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_point_instance.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_point_instance.cc
@@ -38,6 +38,7 @@ static bNodeSocketTemplate geo_node_point_instance_in[] = {
      PROP_NONE,
      SOCK_HIDE_LABEL},
     {SOCK_INT, N_("Seed"), 0, 0, 0, 0, -10000, 10000},
+    {SOCK_VECTOR, N_("Rotation"), 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f, PROP_EULER},
     {-1, ""},
 };
 
@@ -172,8 +173,9 @@ static void add_instances_from_component(InstancesComponent &instances,
 
   GVArray_Typed<float3> positions = src_geometry.attribute_get_for_read<float3>(
       "position", domain, {0, 0, 0});
-  GVArray_Typed<float3> rotations = src_geometry.attribute_get_for_read<float3>(
-      "rotation", domain, {0, 0, 0});
+  Array<float3> rotations_array = params.get_input<Array<float3>>("Rotation");
+  fn::GVArray_For_RepeatedGSpan rotations_repeated{domain_size, rotations_array.as_span()};
+  GVArray_Typed<float3> rotations{rotations_repeated};
   GVArray_Typed<float3> scales = src_geometry.attribute_get_for_read<float3>(
       "scale", domain, {1, 1, 1});
   GVArray_Typed<int> id_attribute = src_geometry.attribute_get_for_read<int>("id", domain, -1);



More information about the Bf-blender-cvs mailing list