Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2021-06-25 06:18:57 +0300
committerHans Goudey <h.goudey@me.com>2021-06-25 06:18:57 +0300
commitc8698e6657951712aad666381e7e7b06abb600f8 (patch)
tree8347151d16f5bc07d0b41c34ad3e28acf7b2d1a6
parentb517b9f6467cafcaa3e50574734e6d776eadb5cd (diff)
Slightly fix deformation in some cases (mostly edge cases)temp-geometry-nodes-curve-deform-node
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_curve_deform.cc27
1 files changed, 21 insertions, 6 deletions
diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_deform.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_deform.cc
index dde7191fb69..dc3cab763d5 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_curve_deform.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_curve_deform.cc
@@ -35,10 +35,10 @@ using blender::bke::GeometryInstanceGroup;
static bNodeSocketTemplate geo_node_curve_deform_in[] = {
{SOCK_GEOMETRY, N_("Geometry")},
{SOCK_GEOMETRY, N_("Curve")},
- {SOCK_STRING, N_("Factor")},
- {SOCK_FLOAT, N_("Factor"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
{SOCK_BOOLEAN, N_("Use Bounds")},
{SOCK_BOOLEAN, N_("Stretch")},
+ {SOCK_BOOLEAN, N_("Temp Only Bounds")},
+ {SOCK_VECTOR, N_("Weird Hack"), 0.5f, 0.5f, 0.5f, 1.0f, -FLT_MAX, FLT_MAX, PROP_TRANSLATION},
{-1, ""},
};
@@ -168,6 +168,7 @@ static float3 deform_position(const SplineDeformInput &in,
struct Bounds {
float3 min;
float3 max;
+ float3 size;
float3 inv_size;
};
@@ -178,15 +179,16 @@ static Bounds position_bounds(const Span<float3> positions)
for (const float3 &position : positions) {
minmax_v3v3_v3(min, max, position);
}
- return {min, max, float3::safe_divide(float3(1), max - min)};
+ const float3 size = max - min;
+ return {min, max, size, float3::safe_divide(float3(1), size)};
}
static Bounds dummy_parameter_bounds(const GeometryNodeCurveDeformAxis deform_axis)
{
if (axis_is_negative(deform_axis)) {
- return {float3(-1), float3(0), float3(-1)};
+ return {float3(-1), float3(0), float3(-1), float3(-1)};
}
- return {float3(0), float3(1), float3(1)};
+ return {float3(0), float3(1), float3(1), float3(1)};
}
static float process_parameter(const float3 position,
@@ -220,6 +222,15 @@ static void execute_on_component(const GeoNodeExecParams &params,
const Bounds bounds = position_bounds(positions);
const Bounds parameter_bounds = input.use_bounds ? bounds : dummy_parameter_bounds(deform_axis);
+ float3 center_offset(0);
+ if (bounds.size[next_axis] != 0.0f) {
+ center_offset[next_axis] = 0.5f;
+ }
+ float3 input_center_offset = params.get_input<float3>("Weird Hack");
+ if (!input_center_offset.is_zero()) {
+ center_offset = input_center_offset;
+ }
+
threading::parallel_for(positions.index_range(), 1024, [&](IndexRange range) {
for (const int i : range) {
const float parameter = process_parameter(
@@ -227,13 +238,17 @@ static void execute_on_component(const GeoNodeExecParams &params,
const Spline::LookupResult lookup = input.spline.lookup_evaluated_length(parameter);
- const float3 co = (positions[i] - bounds.min) * bounds.inv_size * 2.0f - float3(1);
+ const float3 co = ((positions[i] - bounds.min) * bounds.inv_size - center_offset) *
+ bounds.size;
if (is_negative) {
positions[i] = deform_position(input, lookup, co[next_axis], co[other_axis], is_negative);
}
else {
positions[i] = deform_position(input, lookup, co[other_axis], co[next_axis], is_negative);
}
+ if (params.get_input<bool>("Temp Only Bounds")) {
+ positions[i] = co;
+ }
}
});