WIP: uv-simple-select #1

Closed
Chris Blackbourn wants to merge 182 commits from uv-simple-select into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
2 changed files with 15 additions and 21 deletions
Showing only changes of commit c7c524d8d4 - Show all commits

View File

@ -71,16 +71,11 @@ class CurvesGeometryRuntime {
mutable SharedCache<Vector<curves::nurbs::BasisCache>> nurbs_basis_cache; mutable SharedCache<Vector<curves::nurbs::BasisCache>> nurbs_basis_cache;
/** Cache of evaluated positions. */
struct EvaluatedPositions {
Vector<float3> vector;
/** /**
* The evaluated positions result, using a separate span in case all curves are poly curves, * Cache of evaluated positions for all curves. The positions span will
* in which case a separate array of evaluated positions is unnecessary. * be used directly rather than the cache when all curves are poly type.
*/ */
Span<float3> span; mutable SharedCache<Vector<float3>> evaluated_position_cache;
};
mutable SharedCache<EvaluatedPositions> evaluated_position_cache;
/** /**
* A cache of bounds shared between data-blocks with unchanged positions and radii. * A cache of bounds shared between data-blocks with unchanged positions and radii.

View File

@ -605,17 +605,15 @@ void CurvesGeometry::ensure_nurbs_basis_cache() const
Span<float3> CurvesGeometry::evaluated_positions() const Span<float3> CurvesGeometry::evaluated_positions() const
{ {
const bke::CurvesGeometryRuntime &runtime = *this->runtime; const bke::CurvesGeometryRuntime &runtime = *this->runtime;
this->ensure_nurbs_basis_cache();
runtime.evaluated_position_cache.ensure([&](CurvesGeometryRuntime::EvaluatedPositions &r_data) {
if (this->is_single_type(CURVE_TYPE_POLY)) { if (this->is_single_type(CURVE_TYPE_POLY)) {
r_data.span = this->positions(); runtime.evaluated_position_cache.ensure(
r_data.vector.clear_and_shrink(); [&](Vector<float3> &r_data) { r_data.clear_and_shrink(); });
return; return this->positions();
} }
this->ensure_nurbs_basis_cache();
r_data.vector.resize(this->evaluated_points_num()); runtime.evaluated_position_cache.ensure([&](Vector<float3> &r_data) {
r_data.span = r_data.vector; r_data.resize(this->evaluated_points_num());
MutableSpan<float3> evaluated_positions = r_data.vector; MutableSpan<float3> evaluated_positions = r_data;
const OffsetIndices<int> points_by_curve = this->points_by_curve(); const OffsetIndices<int> points_by_curve = this->points_by_curve();
const OffsetIndices<int> evaluated_points_by_curve = this->evaluated_points_by_curve(); const OffsetIndices<int> evaluated_points_by_curve = this->evaluated_points_by_curve();
@ -672,7 +670,7 @@ Span<float3> CurvesGeometry::evaluated_positions() const
} }
}); });
}); });
return runtime.evaluated_position_cache.data().span; return runtime.evaluated_position_cache.data();
} }
Span<float3> CurvesGeometry::evaluated_tangents() const Span<float3> CurvesGeometry::evaluated_tangents() const
@ -781,6 +779,7 @@ static void evaluate_generic_data_for_curve(
Span<float3> CurvesGeometry::evaluated_normals() const Span<float3> CurvesGeometry::evaluated_normals() const
{ {
const bke::CurvesGeometryRuntime &runtime = *this->runtime; const bke::CurvesGeometryRuntime &runtime = *this->runtime;
this->ensure_nurbs_basis_cache();
runtime.evaluated_normal_cache.ensure([&](Vector<float3> &r_data) { runtime.evaluated_normal_cache.ensure([&](Vector<float3> &r_data) {
const OffsetIndices<int> points_by_curve = this->points_by_curve(); const OffsetIndices<int> points_by_curve = this->points_by_curve();
const OffsetIndices<int> evaluated_points_by_curve = this->evaluated_points_by_curve(); const OffsetIndices<int> evaluated_points_by_curve = this->evaluated_points_by_curve();