WIP: Geometry Nodes: Rotation type #107954
|
@ -34,10 +34,7 @@ static void node_declare(NodeDeclarationBuilder &b)
|
||||||
.description(
|
.description(
|
||||||
"Index of the instance used for each point. This is only used when Pick Instances "
|
"Index of the instance used for each point. This is only used when Pick Instances "
|
||||||
"is on. By default the point index is used");
|
"is on. By default the point index is used");
|
||||||
b.add_input<decl::Vector>("Rotation")
|
b.add_input<decl::Rotation>("Rotation").field_on({0}).description("Rotation of the instances");
|
||||||
.subtype(PROP_EULER)
|
|
||||||
.field_on({0})
|
|
||||||
.description("Rotation of the instances");
|
|
||||||
b.add_input<decl::Vector>("Scale")
|
b.add_input<decl::Vector>("Scale")
|
||||||
.default_value({1.0f, 1.0f, 1.0f})
|
.default_value({1.0f, 1.0f, 1.0f})
|
||||||
.subtype(PROP_XYZ)
|
.subtype(PROP_XYZ)
|
||||||
|
@ -59,7 +56,7 @@ static void add_instances_from_component(
|
||||||
|
|
||||||
VArray<bool> pick_instance;
|
VArray<bool> pick_instance;
|
||||||
VArray<int> indices;
|
VArray<int> indices;
|
||||||
VArray<float3> rotations;
|
VArray<math::Quaternion> rotations;
|
||||||
VArray<float3> scales;
|
VArray<float3> scales;
|
||||||
|
|
||||||
const bke::GeometryFieldContext field_context{src_component, domain};
|
const bke::GeometryFieldContext field_context{src_component, domain};
|
||||||
|
@ -70,7 +67,7 @@ static void add_instances_from_component(
|
||||||
* selected indices should be copied. */
|
* selected indices should be copied. */
|
||||||
evaluator.add(params.get_input<Field<bool>>("Pick Instance"), &pick_instance);
|
evaluator.add(params.get_input<Field<bool>>("Pick Instance"), &pick_instance);
|
||||||
evaluator.add(params.get_input<Field<int>>("Instance Index"), &indices);
|
evaluator.add(params.get_input<Field<int>>("Instance Index"), &indices);
|
||||||
evaluator.add(params.get_input<Field<float3>>("Rotation"), &rotations);
|
evaluator.add(params.get_input<Field<math::Quaternion>>("Rotation"), &rotations);
|
||||||
evaluator.add(params.get_input<Field<float3>>("Scale"), &scales);
|
evaluator.add(params.get_input<Field<float3>>("Scale"), &scales);
|
||||||
evaluator.evaluate();
|
evaluator.evaluate();
|
||||||
|
|
||||||
|
@ -118,8 +115,7 @@ static void add_instances_from_component(
|
||||||
|
|
||||||
/* Compute base transform for every instances. */
|
/* Compute base transform for every instances. */
|
||||||
float4x4 &dst_transform = dst_transforms[range_i];
|
float4x4 &dst_transform = dst_transforms[range_i];
|
||||||
dst_transform = math::from_loc_rot_scale<float4x4>(
|
dst_transform = math::from_loc_rot_scale<float4x4>(positions[i], rotations[i], scales[i]);
|
||||||
positions[i], math::EulerXYZ(rotations[i]), scales[i]);
|
|
||||||
|
|
||||||
/* Reference that will be used by this new instance. */
|
/* Reference that will be used by this new instance. */
|
||||||
int dst_handle = empty_reference_handle;
|
int dst_handle = empty_reference_handle;
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
#include "BLI_math_matrix.hh"
|
#include "BLI_math_matrix.hh"
|
||||||
#include "BLI_math_matrix_types.hh"
|
#include "BLI_math_matrix_types.hh"
|
||||||
|
#include "BLI_math_quaternion.hh"
|
||||||
#include "BLI_task.hh"
|
#include "BLI_task.hh"
|
||||||
|
|
||||||
#include "DNA_mesh_types.h"
|
#include "DNA_mesh_types.h"
|
||||||
|
@ -26,9 +27,9 @@
|
||||||
|
|
||||||
namespace blender::nodes {
|
namespace blender::nodes {
|
||||||
|
|
||||||
static bool use_translate(const float3 rotation, const float3 scale)
|
static bool use_translate(const math::Quaternion rotation, const float3 scale)
|
||||||
{
|
{
|
||||||
if (compare_ff(math::length_squared(rotation), 0.0f, 1e-9f) != 1) {
|
if (!math::is_equal(float4(rotation), float4(math::Quaternion::identity()), 1e7f)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (compare_ff(scale.x, 1.0f, 1e-9f) != 1 || compare_ff(scale.y, 1.0f, 1e-9f) != 1 ||
|
if (compare_ff(scale.x, 1.0f, 1e-9f) != 1 || compare_ff(scale.y, 1.0f, 1e-9f) != 1 ||
|
||||||
|
@ -267,7 +268,7 @@ static void node_declare(NodeDeclarationBuilder &b)
|
||||||
{
|
{
|
||||||
b.add_input<decl::Geometry>("Geometry");
|
b.add_input<decl::Geometry>("Geometry");
|
||||||
b.add_input<decl::Vector>("Translation").subtype(PROP_TRANSLATION);
|
b.add_input<decl::Vector>("Translation").subtype(PROP_TRANSLATION);
|
||||||
b.add_input<decl::Vector>("Rotation").subtype(PROP_EULER);
|
b.add_input<decl::Rotation>("Rotation");
|
||||||
b.add_input<decl::Vector>("Scale").default_value({1, 1, 1}).subtype(PROP_XYZ);
|
b.add_input<decl::Vector>("Scale").default_value({1, 1, 1}).subtype(PROP_XYZ);
|
||||||
b.add_output<decl::Geometry>("Geometry").propagate_all();
|
b.add_output<decl::Geometry>("Geometry").propagate_all();
|
||||||
}
|
}
|
||||||
|
@ -276,7 +277,7 @@ static void node_geo_exec(GeoNodeExecParams params)
|
||||||
{
|
{
|
||||||
GeometrySet geometry_set = params.extract_input<GeometrySet>("Geometry");
|
GeometrySet geometry_set = params.extract_input<GeometrySet>("Geometry");
|
||||||
const float3 translation = params.extract_input<float3>("Translation");
|
const float3 translation = params.extract_input<float3>("Translation");
|
||||||
const float3 rotation = params.extract_input<float3>("Rotation");
|
const math::Quaternion rotation = params.extract_input<math::Quaternion>("Rotation");
|
||||||
const float3 scale = params.extract_input<float3>("Scale");
|
const float3 scale = params.extract_input<float3>("Scale");
|
||||||
|
|
||||||
/* Use only translation if rotation and scale don't apply. */
|
/* Use only translation if rotation and scale don't apply. */
|
||||||
|
|
Loading…
Reference in New Issue