Cleanup: Rename "spline" variables to "curve"

Ref T95355
This commit is contained in:
Hans Goudey 2022-03-17 17:08:36 -05:00
parent ee2d39b3a7
commit 0835996cc9
Notes: blender-bot 2023-02-14 10:21:11 +01:00
Referenced by issue #95355, New Curves data block
3 changed files with 49 additions and 49 deletions

View File

@ -140,18 +140,18 @@ static void curves_batch_cache_fill_segments_proc_pos(Curves *curves,
for (const int i : IndexRange(curve_size)) {
const IndexRange curve_range = geometry.range_for_curve(i);
Span<float3> spline_positions = positions.slice(curve_range);
Span<float3> curve_positions = positions.slice(curve_range);
float total_len = 0.0f;
float *seg_data_first;
for (const int i_spline : spline_positions.index_range()) {
for (const int i_curve : curve_positions.index_range()) {
float *seg_data = (float *)GPU_vertbuf_raw_step(attr_step);
copy_v3_v3(seg_data, spline_positions[i_spline]);
if (i_spline == 0) {
copy_v3_v3(seg_data, curve_positions[i_curve]);
if (i_curve == 0) {
seg_data_first = seg_data;
}
else {
total_len += blender::math::distance(spline_positions[i_spline - 1],
spline_positions[i_spline]);
total_len += blender::math::distance(curve_positions[i_curve - 1],
curve_positions[i_curve]);
}
seg_data[3] = total_len;
}
@ -159,7 +159,7 @@ static void curves_batch_cache_fill_segments_proc_pos(Curves *curves,
*(float *)GPU_vertbuf_raw_step(length_step) = total_len;
if (total_len > 0.0f) {
/* Divide by total length to have a [0-1] number. */
for ([[maybe_unused]] const int i_spline : spline_positions.index_range()) {
for ([[maybe_unused]] const int i_curve : curve_positions.index_range()) {
seg_data_first[3] /= total_len;
seg_data_first += 4;
}

View File

@ -32,7 +32,7 @@ static void copy_with_map(const VArray<T> &src, Span<int> map, MutableSpan<T> ds
static Curves *create_curve_from_vert_indices(const MeshComponent &mesh_component,
const Span<int> vert_indices,
const Span<int> curve_offsets,
const IndexRange cyclic_splines)
const IndexRange cyclic_curves)
{
Curves *curves_id = bke::curves_new_nomain(vert_indices.size(), curve_offsets.size());
bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id->geometry);
@ -41,7 +41,7 @@ static Curves *create_curve_from_vert_indices(const MeshComponent &mesh_componen
curves.curve_types().fill(CURVE_TYPE_POLY);
curves.cyclic().fill(false);
curves.cyclic().slice(cyclic_splines).fill(true);
curves.cyclic().slice(cyclic_curves).fill(true);
Set<bke::AttributeIDRef> source_attribute_ids = mesh_component.attribute_ids();
@ -67,7 +67,7 @@ static Curves *create_curve_from_vert_indices(const MeshComponent &mesh_componen
continue;
}
/* Copy attribute based on the map for this spline. */
/* Copy attribute based on the map for this curve. */
attribute_math::convert_to_static_type(mesh_attribute.type(), [&](auto dummy) {
using T = decltype(dummy);
bke::OutputAttribute_Typed<T> attribute =
@ -81,12 +81,12 @@ static Curves *create_curve_from_vert_indices(const MeshComponent &mesh_componen
}
struct CurveFromEdgesOutput {
/** The indices in the mesh for each control point of each result splines. */
/** The indices in the mesh for each control point of each result curves. */
Vector<int> vert_indices;
/** The first index of each curve in the result. */
Vector<int> curve_offsets;
/** A subset of splines that should be set cyclic. */
IndexRange cyclic_splines;
/** A subset of curves that should be set cyclic. */
IndexRange cyclic_curves;
};
static CurveFromEdgesOutput edges_to_curve_point_indices(Span<MVert> verts,
@ -128,7 +128,7 @@ static CurveFromEdgesOutput edges_to_curve_point_indices(Span<MVert> verts,
Array<int> unused_edges = std::move(used_slots);
for (const int start_vert : verts.index_range()) {
/* The vertex will be part of a cyclic spline. */
/* The vertex will be part of a cyclic curve. */
if (neighbor_count[start_vert] == 2) {
continue;
}
@ -171,10 +171,10 @@ static CurveFromEdgesOutput edges_to_curve_point_indices(Span<MVert> verts,
}
}
/* All splines added after this are cyclic. */
/* All curves added after this are cyclic. */
const int cyclic_start = curve_offsets.size();
/* All remaining edges are part of cyclic splines (we skipped vertices with two edges before). */
/* All remaining edges are part of cyclic curves (we skipped vertices with two edges before). */
for (const int start_vert : verts.index_range()) {
if (unused_edges[start_vert] != 2) {
continue;
@ -230,7 +230,7 @@ Curves *mesh_to_curve_convert(const MeshComponent &mesh_component, const IndexMa
selected_edges);
return create_curve_from_vert_indices(
mesh_component, output.vert_indices, output.curve_offsets, output.cyclic_splines);
mesh_component, output.vert_indices, output.curve_offsets, output.cyclic_curves);
}
} // namespace blender::geometry

View File

@ -224,20 +224,20 @@ static void copy_point_attributes_without_id(GeometrySet &geometry_set,
/** \} */
/* -------------------------------------------------------------------- */
/** \name Duplicate Splines
/** \name Duplicate Curves
* \{ */
/**
* Copies the attributes for spline duplicates. If copying the spline domain, the attributes are
* Copies the attributes for curve duplicates. If copying the curve domain, the attributes are
* copied with an offset fill, otherwise a mapping is used.
*/
static void copy_spline_attributes_without_id(const GeometrySet &geometry_set,
const CurveComponent &src_component,
const bke::CurvesGeometry &src_curves,
const IndexMask selection,
const Span<int> curve_offsets,
bke::CurvesGeometry &dst_curves,
CurveComponent &dst_component)
static void copy_curve_attributes_without_id(const GeometrySet &geometry_set,
const CurveComponent &src_component,
const bke::CurvesGeometry &src_curves,
const IndexMask selection,
const Span<int> curve_offsets,
bke::CurvesGeometry &dst_curves,
CurveComponent &dst_component)
{
Map<AttributeIDRef, AttributeKind> gathered_attributes;
gather_attributes_without_id(
@ -290,16 +290,16 @@ static void copy_spline_attributes_without_id(const GeometrySet &geometry_set,
/**
* Copy the stable ids to the first duplicate and create new ids based on a hash of the original id
* and the duplicate number. In the spline case, copy the entire spline's points to the
* and the duplicate number. In the curve case, copy the entire curve's points to the
* destination,
* then loop over the remaining ones point by point, hashing their ids to the new ids.
*/
static void copy_stable_id_splines(const bke::CurvesGeometry &src_curves,
const IndexMask selection,
const Span<int> curve_offsets,
const CurveComponent &src_component,
bke::CurvesGeometry &dst_curves,
CurveComponent &dst_component)
static void copy_stable_id_curves(const bke::CurvesGeometry &src_curves,
const IndexMask selection,
const Span<int> curve_offsets,
const CurveComponent &src_component,
bke::CurvesGeometry &dst_curves,
CurveComponent &dst_component)
{
ReadAttributeLookup src_attribute = src_component.attribute_try_get_for_read("id");
if (!src_attribute) {
@ -329,10 +329,10 @@ static void copy_stable_id_splines(const bke::CurvesGeometry &src_curves,
dst_attribute.save();
}
static void duplicate_splines(GeometrySet &geometry_set,
const Field<int> &count_field,
const Field<bool> &selection_field,
const IndexAttributes &attributes)
static void duplicate_curves(GeometrySet &geometry_set,
const Field<int> &count_field,
const Field<bool> &selection_field,
const IndexAttributes &attributes)
{
if (!geometry_set.has_curves()) {
geometry_set.keep_only({GEO_COMPONENT_TYPE_INSTANCES});
@ -356,19 +356,19 @@ static void duplicate_splines(GeometrySet &geometry_set,
Array<int> curve_offsets(selection.size() + 1);
Array<int> point_offsets(selection.size() + 1);
int dst_splines_size = 0;
int dst_curves_size = 0;
int dst_points_size = 0;
for (const int i_spline : selection.index_range()) {
const int count = std::max(counts[selection[i_spline]], 0);
curve_offsets[i_spline] = dst_splines_size;
point_offsets[i_spline] = dst_points_size;
dst_splines_size += count;
dst_points_size += count * curves.range_for_curve(selection[i_spline]).size();
for (const int i_curve : selection.index_range()) {
const int count = std::max(counts[selection[i_curve]], 0);
curve_offsets[i_curve] = dst_curves_size;
point_offsets[i_curve] = dst_points_size;
dst_curves_size += count;
dst_points_size += count * curves.range_for_curve(selection[i_curve]).size();
}
curve_offsets.last() = dst_splines_size;
curve_offsets.last() = dst_curves_size;
point_offsets.last() = dst_points_size;
Curves *new_curves_id = bke::curves_new_nomain(dst_points_size, dst_splines_size);
Curves *new_curves_id = bke::curves_new_nomain(dst_points_size, dst_curves_size);
bke::CurvesGeometry &new_curves = bke::CurvesGeometry::wrap(new_curves_id->geometry);
MutableSpan<int> all_dst_offsets = new_curves.offsets();
@ -389,10 +389,10 @@ static void duplicate_splines(GeometrySet &geometry_set,
CurveComponent dst_component;
dst_component.replace(new_curves_id, GeometryOwnershipType::Editable);
copy_spline_attributes_without_id(
copy_curve_attributes_without_id(
geometry_set, src_component, curves, selection, curve_offsets, new_curves, dst_component);
copy_stable_id_splines(
copy_stable_id_curves(
curves, selection, curve_offsets, src_component, new_curves, dst_component);
if (attributes.duplicate_index) {
@ -1099,7 +1099,7 @@ static void node_geo_exec(GeoNodeExecParams params)
geometry_set.modify_geometry_sets([&](GeometrySet &geometry_set) {
switch (duplicate_domain) {
case ATTR_DOMAIN_CURVE:
duplicate_splines(geometry_set, count_field, selection_field, attributes);
duplicate_curves(geometry_set, count_field, selection_field, attributes);
break;
case ATTR_DOMAIN_FACE:
duplicate_faces(geometry_set, count_field, selection_field, attributes);