diff options
author | Jacques Lucke <jacques@blender.org> | 2022-04-07 13:49:13 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2022-04-07 13:50:15 +0300 |
commit | 50869b408b20f621fe8860e9f3551fb653b4b714 (patch) | |
tree | 4f2bb84aa32298577e4a078b4f27648b93673293 /source/blender/blenkernel | |
parent | e5c7f3722370f3cd70a7a00079820332c5b92de4 (diff) |
Curves: operator to snap curves to surface
This operator snaps the first point of every curve to the corresponding
surface object. The shape of individual curves or their orientation is
not changed.
There are two different attachment modes:
* `Nearest`: Move each curve so that the first point is on the closest
point on the surface. This should be used when the topology of the
surface mesh changed, but the shape generally stayed the same.
* `Deform`: Use the existing attachment information that is stored
for curves to move curves to their new location when the surface
mesh was deformed. This generally does not work when the
topology changed.
The purpose of the operator is to help setup the "ground truth"
for how curves are attached to the surface. When the ground
truth surface changed, the original curves have to be updated
as well. Deforming curves based on an animated surface will be
done with geometry nodes independent of the operator.
In the UI, the operator is currently exposed in curves sculpt mode
in the `Curves > Snap Curves to Surface` menu.
Differential Revision: https://developer.blender.org/D14515
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_curves.hh | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_curves.hh b/source/blender/blenkernel/BKE_curves.hh index 8d24b6136b2..9061bb9fb81 100644 --- a/source/blender/blenkernel/BKE_curves.hh +++ b/source/blender/blenkernel/BKE_curves.hh @@ -368,6 +368,17 @@ inline int curve_segment_size(const int points_num, const bool cyclic) return cyclic ? points_num : points_num - 1; } +inline float2 encode_surface_bary_coord(const float3 &v) +{ + BLI_assert(std::abs(v.x + v.y + v.z - 1.0f) < 0.00001f); + return {v.x, v.y}; +} + +inline float3 decode_surface_bary_coord(const float2 &v) +{ + return {v.x, v.y, 1.0f - v.x - v.y}; +} + namespace bezier { /** |