diff options
author | Jacques Lucke <jacques@blender.org> | 2022-06-05 13:14:13 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2022-06-05 13:14:32 +0300 |
commit | 899ec8b6b8035bde44d49d228c30698499a87080 (patch) | |
tree | 1c0acb436e033eb5551531774ffb0ff9a57dd268 /source/blender/blenkernel/intern | |
parent | 176d7bcc2eb47b9820861037f90a7fb26de8c9a0 (diff) |
Curves: use uv coordinates to attach curves to mesh
This implements the new way to attach curves to a mesh surface using
a uv map (based on the recent discussion in T95776).
The curves data block now not only stores a reference to the surface object
but also a name of a uv map on that object. Having a uv map is optional
for most operations, but it will be required later for animation (when the
curves are supposed to be deformed based on deformation of the surface).
The "Empty Hair" operator in the Add menu sets the uv map name automatically
if possible. It's possible to start working without a uv map and to attach the
curves to a uv map later on. It's also possible to reattach the curves to a new
uv map using the "Curves > Snap to Nearest Surface" operator in curves sculpt
mode.
Note, the implementation to do the reverse lookup from uv to a position on the
surface is trivial and inefficient now. A more efficient data structure will be
implemented separately soon.
Differential Revision: https://developer.blender.org/D15125
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/curves_geometry.cc | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/source/blender/blenkernel/intern/curves_geometry.cc b/source/blender/blenkernel/intern/curves_geometry.cc index c2e67d853c9..2fa31bd4100 100644 --- a/source/blender/blenkernel/intern/curves_geometry.cc +++ b/source/blender/blenkernel/intern/curves_geometry.cc @@ -35,10 +35,9 @@ static const std::string ATTR_HANDLE_POSITION_RIGHT = "handle_right"; static const std::string ATTR_NURBS_ORDER = "nurbs_order"; static const std::string ATTR_NURBS_WEIGHT = "nurbs_weight"; static const std::string ATTR_NURBS_KNOTS_MODE = "knots_mode"; -static const std::string ATTR_SURFACE_TRIANGLE_INDEX = "surface_triangle_index"; -static const std::string ATTR_SURFACE_TRIANGLE_COORDINATE = "surface_triangle_coordinate"; static const std::string ATTR_SELECTION_POINT_FLOAT = ".selection_point_float"; static const std::string ATTR_SELECTION_CURVE_FLOAT = ".selection_curve_float"; +static const std::string ATTR_SURFACE_UV_COORDINATE = "surface_uv_coordinate"; /* -------------------------------------------------------------------- */ /** \name Constructors/Destructor @@ -419,24 +418,14 @@ MutableSpan<int8_t> CurvesGeometry::nurbs_knots_modes_for_write() return get_mutable_attribute<int8_t>(*this, ATTR_DOMAIN_CURVE, ATTR_NURBS_KNOTS_MODE, 0); } -VArray<int> CurvesGeometry::surface_triangle_indices() const +Span<float2> CurvesGeometry::surface_uv_coords() const { - return get_varray_attribute<int>(*this, ATTR_DOMAIN_CURVE, ATTR_SURFACE_TRIANGLE_INDEX, -1); + return get_span_attribute<float2>(*this, ATTR_DOMAIN_CURVE, ATTR_SURFACE_UV_COORDINATE); } -MutableSpan<int> CurvesGeometry::surface_triangle_indices_for_write() +MutableSpan<float2> CurvesGeometry::surface_uv_coords_for_write() { - return get_mutable_attribute<int>(*this, ATTR_DOMAIN_CURVE, ATTR_SURFACE_TRIANGLE_INDEX, -1); -} - -Span<float2> CurvesGeometry::surface_triangle_coords() const -{ - return get_span_attribute<float2>(*this, ATTR_DOMAIN_CURVE, ATTR_SURFACE_TRIANGLE_COORDINATE); -} - -MutableSpan<float2> CurvesGeometry::surface_triangle_coords_for_write() -{ - return get_mutable_attribute<float2>(*this, ATTR_DOMAIN_CURVE, ATTR_SURFACE_TRIANGLE_COORDINATE); + return get_mutable_attribute<float2>(*this, ATTR_DOMAIN_CURVE, ATTR_SURFACE_UV_COORDINATE); } VArray<float> CurvesGeometry::selection_point_float() const |