diff options
author | Hans Goudey <h.goudey@me.com> | 2021-03-22 18:58:46 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2021-03-22 18:58:46 +0300 |
commit | 23d2174d6bc40f4426ece2cb5627fc78ea9cf2fa (patch) | |
tree | 5e4c8879f51e1072b00b4913f5fae67ad6a7a75a /source/blender/nodes/geometry | |
parent | 2d1120c1718da183a4178bec9d3d999ef7ac827f (diff) |
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.
Diffstat (limited to 'source/blender/nodes/geometry')
8 files changed, 17 insertions, 67 deletions
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)); + const float4x4 transform = float4x4::identity(); const BMeshCreateParams bmcp = {true}; const BMAllocTemplate allocsize = {0, 0, 0, 0}; @@ -69,10 +63,8 @@ static void geo_node_mesh_primitive_ico_sphere_exec(GeoNodeExecParams params) { const int subdivisions = std::min(params.extract_input<int>("Subdivisions"), 10); 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_ico_sphere_mesh(location, rotation, subdivisions, radius); + Mesh *mesh = create_ico_sphere_mesh(subdivisions, radius); params.set_output("Geometry", GeometrySet::create_with_mesh(mesh)); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_plane.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_plane.cc index adb1d4a9eb4..9bc0521d7d3 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_plane.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_plane.cc @@ -31,8 +31,6 @@ static bNodeSocketTemplate geo_node_mesh_primitive_plane_in[] = { {SOCK_FLOAT, N_("Size"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, FLT_MAX, PROP_DISTANCE}, {SOCK_INT, N_("Vertices X"), 10, 0.0f, 0.0f, 0.0f, 2, 1000}, {SOCK_INT, N_("Vertices Y"), 10, 0.0f, 0.0f, 0.0f, 2, 1000}, - {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, ""}, }; @@ -154,8 +152,6 @@ static void geo_node_mesh_primitive_plane_exec(GeoNodeExecParams params) const float size = params.extract_input<float>("Size"); const int verts_x = params.extract_input<int>("Vertices X"); const int verts_y = params.extract_input<int>("Vertices Y"); - const float3 location = params.extract_input<float3>("Location"); - const float3 rotation = params.extract_input<float3>("Rotation"); if (verts_x < 2 || verts_y < 2) { params.set_output("Geometry", GeometrySet()); return; @@ -164,8 +160,6 @@ static void geo_node_mesh_primitive_plane_exec(GeoNodeExecParams params) Mesh *mesh = create_plane_mesh(verts_x, verts_y, size); 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_uv_sphere.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc index 7b07722fd5a..b7d249c18bc 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc @@ -31,8 +31,6 @@ static bNodeSocketTemplate geo_node_mesh_primitive_uv_sphere_in[] = { {SOCK_INT, N_("Segments"), 32, 0.0f, 0.0f, 0.0f, 3, 1024}, {SOCK_INT, N_("Rings"), 16, 0.0f, 0.0f, 0.0f, 3, 1024}, {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, ""}, }; @@ -67,14 +65,9 @@ static int sphere_face_total(const int segments, const int rings) return quads + triangles; } -static Mesh *create_uv_sphere_mesh_bmesh(const float3 location, - const float3 rotation, - const float radius, - const int segments, - const int rings) +static Mesh *create_uv_sphere_mesh_bmesh(const float radius, const int segments, const int rings) { - float4x4 transform; - loc_eul_size_to_mat4(transform.values, location, rotation, float3(1.0f)); + const float4x4 transform = float4x4::identity(); const BMeshCreateParams bmcp = {true}; const BMAllocTemplate allocsize = {sphere_vert_total(segments, rings), @@ -109,10 +102,8 @@ static void geo_node_mesh_primitive_uv_sphere_exec(GeoNodeExecParams params) } 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_uv_sphere_mesh_bmesh(location, rotation, radius, segments_num, rings_num); + Mesh *mesh = create_uv_sphere_mesh_bmesh(radius, segments_num, rings_num); params.set_output("Geometry", GeometrySet::create_with_mesh(mesh)); } |