Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/curves_geometry.cc
| Show First 20 Lines • Show All 548 Lines • ▼ Show 20 Lines | this->runtime->nurbs_basis_cache_mutex.ensure([&]() { | ||||
| const IndexMask nurbs_mask = this->indices_for_curve_type(CURVE_TYPE_NURBS, nurbs_indices); | const IndexMask nurbs_mask = this->indices_for_curve_type(CURVE_TYPE_NURBS, nurbs_indices); | ||||
| if (nurbs_mask.is_empty()) { | if (nurbs_mask.is_empty()) { | ||||
| return; | return; | ||||
| } | } | ||||
| this->runtime->nurbs_basis_cache.resize(this->curves_num()); | this->runtime->nurbs_basis_cache.resize(this->curves_num()); | ||||
| MutableSpan<curves::nurbs::BasisCache> basis_caches(this->runtime->nurbs_basis_cache); | MutableSpan<curves::nurbs::BasisCache> basis_caches(this->runtime->nurbs_basis_cache); | ||||
| const OffsetIndices points_by_curve = this->points_by_curve(); | const OffsetIndices<int> points_by_curve = this->points_by_curve(); | ||||
| VArray<bool> cyclic = this->cyclic(); | VArray<bool> cyclic = this->cyclic(); | ||||
| VArray<int8_t> orders = this->nurbs_orders(); | VArray<int8_t> orders = this->nurbs_orders(); | ||||
| VArray<int8_t> knots_modes = this->nurbs_knots_modes(); | VArray<int8_t> knots_modes = this->nurbs_knots_modes(); | ||||
| threading::parallel_for(nurbs_mask.index_range(), 64, [&](const IndexRange range) { | threading::parallel_for(nurbs_mask.index_range(), 64, [&](const IndexRange range) { | ||||
| for (const int curve_index : nurbs_mask.slice(range)) { | for (const int curve_index : nurbs_mask.slice(range)) { | ||||
| const IndexRange points = points_by_curve[curve_index]; | const IndexRange points = points_by_curve[curve_index]; | ||||
| const IndexRange evaluated_points = this->evaluated_points_for_curve(curve_index); | const IndexRange evaluated_points = this->evaluated_points_for_curve(curve_index); | ||||
| Show All 29 Lines | if (this->is_single_type(CURVE_TYPE_POLY)) { | ||||
| this->runtime->evaluated_position_cache.clear_and_shrink(); | this->runtime->evaluated_position_cache.clear_and_shrink(); | ||||
| return; | return; | ||||
| } | } | ||||
| this->runtime->evaluated_position_cache.resize(this->evaluated_points_num()); | this->runtime->evaluated_position_cache.resize(this->evaluated_points_num()); | ||||
| MutableSpan<float3> evaluated_positions = this->runtime->evaluated_position_cache; | MutableSpan<float3> evaluated_positions = this->runtime->evaluated_position_cache; | ||||
| this->runtime->evaluated_positions_span = evaluated_positions; | this->runtime->evaluated_positions_span = evaluated_positions; | ||||
| const OffsetIndices points_by_curve = this->points_by_curve(); | const OffsetIndices<int> points_by_curve = this->points_by_curve(); | ||||
| VArray<int8_t> types = this->curve_types(); | VArray<int8_t> types = this->curve_types(); | ||||
| VArray<bool> cyclic = this->cyclic(); | VArray<bool> cyclic = this->cyclic(); | ||||
| VArray<int> resolution = this->resolution(); | VArray<int> resolution = this->resolution(); | ||||
| Span<float3> positions = this->positions(); | Span<float3> positions = this->positions(); | ||||
| Span<float3> handle_positions_left = this->handle_positions_left(); | Span<float3> handle_positions_left = this->handle_positions_left(); | ||||
| Span<float3> handle_positions_right = this->handle_positions_right(); | Span<float3> handle_positions_right = this->handle_positions_right(); | ||||
| Span<int> bezier_evaluated_offsets = this->runtime->bezier_evaluated_offsets; | Span<int> bezier_evaluated_offsets = this->runtime->bezier_evaluated_offsets; | ||||
| ▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | this->runtime->tangent_cache_mutex.ensure([&]() { | ||||
| }); | }); | ||||
| /* Correct the first and last tangents of non-cyclic Bezier curves so that they align with | /* Correct the first and last tangents of non-cyclic Bezier curves so that they align with | ||||
| * the inner handles. This is a separate loop to avoid the cost when Bezier type curves are | * the inner handles. This is a separate loop to avoid the cost when Bezier type curves are | ||||
| * not used. */ | * not used. */ | ||||
| Vector<int64_t> bezier_indices; | Vector<int64_t> bezier_indices; | ||||
| const IndexMask bezier_mask = this->indices_for_curve_type(CURVE_TYPE_BEZIER, bezier_indices); | const IndexMask bezier_mask = this->indices_for_curve_type(CURVE_TYPE_BEZIER, bezier_indices); | ||||
| if (!bezier_mask.is_empty()) { | if (!bezier_mask.is_empty()) { | ||||
| const OffsetIndices points_by_curve = this->points_by_curve(); | const OffsetIndices<int> points_by_curve = this->points_by_curve(); | ||||
| const Span<float3> positions = this->positions(); | const Span<float3> positions = this->positions(); | ||||
| const Span<float3> handles_left = this->handle_positions_left(); | const Span<float3> handles_left = this->handle_positions_left(); | ||||
| const Span<float3> handles_right = this->handle_positions_right(); | const Span<float3> handles_right = this->handle_positions_right(); | ||||
| threading::parallel_for(bezier_mask.index_range(), 1024, [&](IndexRange range) { | threading::parallel_for(bezier_mask.index_range(), 1024, [&](IndexRange range) { | ||||
| for (const int curve_index : bezier_mask.slice(range)) { | for (const int curve_index : bezier_mask.slice(range)) { | ||||
| if (cyclic[curve_index]) { | if (cyclic[curve_index]) { | ||||
| continue; | continue; | ||||
| ▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | case CURVE_TYPE_NURBS: | ||||
| dst); | dst); | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| Span<float3> CurvesGeometry::evaluated_normals() const | Span<float3> CurvesGeometry::evaluated_normals() const | ||||
| { | { | ||||
| this->runtime->normal_cache_mutex.ensure([&]() { | this->runtime->normal_cache_mutex.ensure([&]() { | ||||
| const OffsetIndices points_by_curve = this->points_by_curve(); | const OffsetIndices<int> points_by_curve = this->points_by_curve(); | ||||
| const VArray<int8_t> types = this->curve_types(); | const VArray<int8_t> types = this->curve_types(); | ||||
| const VArray<bool> cyclic = this->cyclic(); | const VArray<bool> cyclic = this->cyclic(); | ||||
| const VArray<int8_t> normal_mode = this->normal_mode(); | const VArray<int8_t> normal_mode = this->normal_mode(); | ||||
| const VArray<int> resolution = this->resolution(); | const VArray<int> resolution = this->resolution(); | ||||
| const VArray<int8_t> nurbs_orders = this->nurbs_orders(); | const VArray<int8_t> nurbs_orders = this->nurbs_orders(); | ||||
| const Span<float> nurbs_weights = this->nurbs_weights(); | const Span<float> nurbs_weights = this->nurbs_weights(); | ||||
| const Span<float3> evaluated_tangents = this->evaluated_tangents(); | const Span<float3> evaluated_tangents = this->evaluated_tangents(); | ||||
| ▲ Show 20 Lines • Show All 800 Lines • Show Last 20 Lines | |||||