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.
This commit is contained in:
parent
2d1120c171
commit
23d2174d6b
Notes:
blender-bot
2023-02-14 05:36:11 +01:00
Referenced by issue #86813, UI and input changes for mesh primitive nodes
|
@ -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,
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue