[Bf-blender-cvs] [23d2174d6bc] master: Geometry Nodes: Remove location and rotation from mesh primitives

Hans Goudey noreply at git.blender.org
Mon Mar 22 16:58:51 CET 2021


Commit: 23d2174d6bc40f4426ece2cb5627fc78ea9cf2fa
Author: Hans Goudey
Date:   Mon Mar 22 11:58:46 2021 -0400
Branches: master
https://developer.blender.org/rB23d2174d6bc40f4426ece2cb5627fc78ea9cf2fa

Geometry Nodes: Remove location and rotation from mesh primitives

Following some discussion among the geometry nodes team, it was decided
that keeping the primitive nodes simpler and requiring a separate
transform node to move the generated geometry from the origin would
be better.
 - It's more consistent with the current general idea of "building
   block nodes"
 - It makes more sense for the future when it will be possible to
   use instancing to control the transforms.
 - It reduces UI clutter when the controls are not necessary.

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

M	source/blender/nodes/geometry/node_geometry_util.hh
M	source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_circle.cc
M	source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc
M	source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cube.cc
M	source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cylinder.cc
M	source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_ico_sphere.cc
M	source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_plane.cc
M	source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc

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

diff --git a/source/blender/nodes/geometry/node_geometry_util.hh b/source/blender/nodes/geometry/node_geometry_util.hh
index 8eac8bc0a20..fb80bd08797 100644
--- a/source/blender/nodes/geometry/node_geometry_util.hh
+++ b/source/blender/nodes/geometry/node_geometry_util.hh
@@ -52,9 +52,7 @@ void transform_mesh(Mesh *mesh,
                     const float3 rotation,
                     const float3 scale);
 
-Mesh *create_cylinder_or_cone_mesh(const float3 location,
-                                   const float3 rotation,
-                                   const float radius_top,
+Mesh *create_cylinder_or_cone_mesh(const float radius_top,
                                    const float radius_bottom,
                                    const float depth,
                                    const int verts_num,
diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_circle.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_circle.cc
index 6d286a9d583..3cf77a76682 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_circle.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_circle.cc
@@ -27,8 +27,6 @@
 static bNodeSocketTemplate geo_node_mesh_primitive_circle_in[] = {
     {SOCK_INT, N_("Vertices"), 32, 0.0f, 0.0f, 0.0f, 3, 4096},
     {SOCK_FLOAT, N_("Radius"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, FLT_MAX, PROP_DISTANCE},
-    {SOCK_VECTOR, N_("Location"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_TRANSLATION},
-    {SOCK_VECTOR, N_("Rotation"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_EULER},
     {-1, ""},
 };
 
@@ -207,22 +205,17 @@ static void geo_node_mesh_primitive_circle_exec(GeoNodeExecParams params)
   const GeometryNodeMeshCircleFillType fill_type = (const GeometryNodeMeshCircleFillType)
                                                        storage.fill_type;
 
+  const float radius = params.extract_input<float>("Radius");
   const int verts_num = params.extract_input<int>("Vertices");
   if (verts_num < 3) {
     params.set_output("Geometry", GeometrySet());
     return;
   }
 
-  const float radius = params.extract_input<float>("Radius");
-  const float3 location = params.extract_input<float3>("Location");
-  const float3 rotation = params.extract_input<float3>("Rotation");
-
   Mesh *mesh = create_circle_mesh(radius, verts_num, fill_type);
 
   BLI_assert(BKE_mesh_is_valid(mesh));
 
-  transform_mesh(mesh, location, rotation, float3(1));
-
   params.set_output("Geometry", GeometrySet::create_with_mesh(mesh));
 }
 
diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc
index 6286357d6c6..72b05dcce70 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc
@@ -32,8 +32,6 @@ static bNodeSocketTemplate geo_node_mesh_primitive_cone_in[] = {
     {SOCK_FLOAT, N_("Radius Top"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, FLT_MAX, PROP_DISTANCE},
     {SOCK_FLOAT, N_("Radius Bottom"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, FLT_MAX, PROP_DISTANCE},
     {SOCK_FLOAT, N_("Depth"), 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, FLT_MAX, PROP_DISTANCE},
-    {SOCK_VECTOR, N_("Location"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_TRANSLATION},
-    {SOCK_VECTOR, N_("Rotation"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_EULER},
     {-1, ""},
 };
 
@@ -191,16 +189,13 @@ static int face_total(const GeometryNodeMeshCircleFillType fill_type,
   return face_total;
 }
 
-Mesh *create_cylinder_or_cone_mesh(const float3 location,
-                                   const float3 rotation,
-                                   const float radius_top,
+Mesh *create_cylinder_or_cone_mesh(const float radius_top,
                                    const float radius_bottom,
                                    const float depth,
                                    const int verts_num,
                                    const GeometryNodeMeshCircleFillType fill_type)
 {
-  float4x4 transform;
-  loc_eul_size_to_mat4(transform.values, location, rotation, float3(1));
+  const float4x4 transform = float4x4::identity();
 
   const bool top_is_point = radius_top == 0.0f;
   const bool bottom_is_point = radius_bottom == 0.0f;
@@ -252,11 +247,9 @@ static void geo_node_mesh_primitive_cone_exec(GeoNodeExecParams params)
   const float radius_top = params.extract_input<float>("Radius Top");
   const float radius_bottom = params.extract_input<float>("Radius Bottom");
   const float depth = params.extract_input<float>("Depth");
-  const float3 location = params.extract_input<float3>("Location");
-  const float3 rotation = params.extract_input<float3>("Rotation");
 
   Mesh *mesh = create_cylinder_or_cone_mesh(
-      location, rotation, radius_top, radius_bottom, depth, verts_num, fill_type);
+      radius_top, radius_bottom, depth, verts_num, fill_type);
 
   BKE_mesh_translate(mesh, float3(0.0f, 0.0f, depth * 0.5f), false);
 
diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cube.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cube.cc
index 1ef84c7d070..1803a13f651 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cube.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cube.cc
@@ -25,8 +25,6 @@
 
 static bNodeSocketTemplate geo_node_mesh_primitive_cube_in[] = {
     {SOCK_FLOAT, N_("Size"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, FLT_MAX, PROP_DISTANCE},
-    {SOCK_VECTOR, N_("Location"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_TRANSLATION},
-    {SOCK_VECTOR, N_("Rotation"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_EULER},
     {-1, ""},
 };
 
@@ -37,10 +35,9 @@ static bNodeSocketTemplate geo_node_mesh_primitive_cube_out[] = {
 
 namespace blender::nodes {
 
-static Mesh *create_cube_mesh(const float3 location, const float3 rotation, const float size)
+static Mesh *create_cube_mesh(const float size)
 {
-  float4x4 transform;
-  loc_eul_size_to_mat4(transform.values, location, rotation, float3(1));
+  const float4x4 transform = float4x4::identity();
 
   const BMeshCreateParams bmcp = {true};
   const BMAllocTemplate allocsize = {8, 12, 24, 6};
@@ -63,10 +60,8 @@ static Mesh *create_cube_mesh(const float3 location, const float3 rotation, cons
 static void geo_node_mesh_primitive_cube_exec(GeoNodeExecParams params)
 {
   const float size = params.extract_input<float>("Size");
-  const float3 location = params.extract_input<float3>("Location");
-  const float3 rotation = params.extract_input<float3>("Rotation");
 
-  Mesh *mesh = create_cube_mesh(location, rotation, size);
+  Mesh *mesh = create_cube_mesh(size);
   params.set_output("Geometry", GeometrySet::create_with_mesh(mesh));
 }
 
diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cylinder.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cylinder.cc
index 158491f40e7..f443b4387d3 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cylinder.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cylinder.cc
@@ -28,8 +28,6 @@ static bNodeSocketTemplate geo_node_mesh_primitive_cylinder_in[] = {
     {SOCK_INT, N_("Vertices"), 32, 0.0f, 0.0f, 0.0f, 3, 4096},
     {SOCK_FLOAT, N_("Radius"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, FLT_MAX, PROP_DISTANCE},
     {SOCK_FLOAT, N_("Depth"), 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, FLT_MAX, PROP_DISTANCE},
-    {SOCK_VECTOR, N_("Location"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_TRANSLATION},
-    {SOCK_VECTOR, N_("Rotation"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_EULER},
     {-1, ""},
 };
 
@@ -67,20 +65,16 @@ static void geo_node_mesh_primitive_cylinder_exec(GeoNodeExecParams params)
   const GeometryNodeMeshCircleFillType fill_type = (const GeometryNodeMeshCircleFillType)
                                                        storage.fill_type;
 
+  const float radius = params.extract_input<float>("Radius");
+  const float depth = params.extract_input<float>("Depth");
   const int verts_num = params.extract_input<int>("Vertices");
   if (verts_num < 3) {
     params.set_output("Geometry", GeometrySet());
     return;
   }
 
-  const float radius = params.extract_input<float>("Radius");
-  const float depth = params.extract_input<float>("Depth");
-  const float3 location = params.extract_input<float3>("Location");
-  const float3 rotation = params.extract_input<float3>("Rotation");
-
   /* The cylinder is a special case of the cone mesh where the top and bottom radius are equal. */
-  Mesh *mesh = create_cylinder_or_cone_mesh(
-      location, rotation, radius, radius, depth, verts_num, fill_type);
+  Mesh *mesh = create_cylinder_or_cone_mesh(radius, radius, depth, verts_num, fill_type);
 
   params.set_output("Geometry", GeometrySet::create_with_mesh(mesh));
 }
diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_ico_sphere.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_ico_sphere.cc
index 9aaccb7d805..f16b37fe977 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_ico_sphere.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_ico_sphere.cc
@@ -26,8 +26,6 @@
 static bNodeSocketTemplate geo_node_mesh_primitive_ico_sphere_in[] = {
     {SOCK_FLOAT, N_("Radius"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, FLT_MAX, PROP_DISTANCE},
     {SOCK_INT, N_("Subdivisions"), 1, 0, 0, 0, 0, 7},
-    {SOCK_VECTOR, N_("Location"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_TRANSLATION},
-    {SOCK_VECTOR, N_("Rotation"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_EULER},
     {-1, ""},
 };
 
@@ -38,13 +36,9 @@ static bNodeSocketTemplate geo_node_mesh_primitive_ico_sphere_out[] = {
 
 namespace blender::nodes {
 
-static Mesh *create_ico_sphere_mesh(const float3 location,
-                                    const float3 rotation,
-                                    const int subdivisions,
-                                    const float radius)
+static Mesh *create_ico_sphere_mesh(const int subdivisions, const float radius)
 {
-  float4x4 transform;
-  loc_eul_size_to_mat4(transform.values, location, rotation, float3(1.0f));


@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list