diff --git a/source/blender/editors/transform/transform_convert_curves.cc b/source/blender/editors/transform/transform_convert_curves.cc index a05839d2a94..ef2c3e44823 100644 --- a/source/blender/editors/transform/transform_convert_curves.cc +++ b/source/blender/editors/transform/transform_convert_curves.cc @@ -262,9 +262,10 @@ static OffsetIndices recent_position_offsets(TransCustomData &custom_data, } /** - * Creates map of indices to `tc.data` representing curve in layout - * [L0, P0, R0, L1, P1, R1, L2,P2, R2], where [P0, P1, P2], [L0, L1, L2] and [R0, R1, R2] are - * positions, left handles and right handles respectively. + * Creates map of indices to `tc.data` representing the curves. + * For bezier curves it uses the layout [L0, P0, R0, L1, P1, R1, L2, P2, R2], where [P0, P1, P2], + * [L0, L1, L2] and [R0, R1, R2] are positions, left handles and right handles respectively. + * Other curve types just use the positions [P0, P1, ..., Pn] of the control points directly. */ static void fill_map(const CurveType curve_type, const IndexRange curve_points, @@ -272,24 +273,22 @@ static void fill_map(const CurveType curve_type, const int handles_offset, MutableSpan map) { - const int attr_num = (curve_type == CURVE_TYPE_BEZIER) ? 3 : 1; - const int left_handle_index = handles_offset + position_offsets_in_td[1].start(); const int position_index = curve_points.start() + position_offsets_in_td[0].start(); - const int right_handle_index = handles_offset + position_offsets_in_td[2].start(); - - std::array first_per_attr = {curve_type == CURVE_TYPE_BEZIER ? left_handle_index : - position_index, - /* Next two unused for non Bezier curves. */ - position_index, - right_handle_index}; - - threading::parallel_for(curve_points.index_range(), 4096, [&](const IndexRange range) { - for (const int i : range) { - for (const int attr : IndexRange(attr_num)) { - map[i * attr_num + attr] = first_per_attr[attr] + i; + if (curve_type == CURVE_TYPE_BEZIER) { + const int left_handle_index = handles_offset + position_offsets_in_td[1].start(); + const int right_handle_index = handles_offset + position_offsets_in_td[2].start(); + std::array first_per_attr = {left_handle_index, position_index, right_handle_index}; + threading::parallel_for(curve_points.index_range(), 4096, [&](const IndexRange range) { + for (const int i : range) { + for (const int attr : IndexRange(3)) { + map[i * 3 + attr] = first_per_attr[attr] + i; + } } - } - }); + }); + } + else { + array_utils::fill_index_range(map, position_index); + } } } // namespace blender::ed::transform::curves