Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/BKE_curves.hh
| Show First 20 Lines • Show All 331 Lines • ▼ Show 20 Lines | public: | ||||
| * Call #ensure_evaluated_offsets() first to ensure that the evaluated offsets cache is current. | * Call #ensure_evaluated_offsets() first to ensure that the evaluated offsets cache is current. | ||||
| */ | */ | ||||
| Span<int> bezier_evaluated_offsets_for_curve(int curve_index) const; | Span<int> bezier_evaluated_offsets_for_curve(int curve_index) const; | ||||
| Span<float3> evaluated_positions() const; | Span<float3> evaluated_positions() const; | ||||
| Span<float3> evaluated_tangents() const; | Span<float3> evaluated_tangents() const; | ||||
| Span<float3> evaluated_normals() const; | Span<float3> evaluated_normals() const; | ||||
| Span<float3> evaluated_positions_for_curve(int curve_index) const; | |||||
| /** | /** | ||||
| * Return a cache of accumulated lengths along the curve. Each item is the length of the | * Return a cache of accumulated lengths along the curve. Each item is the length of the | ||||
| * subsequent segment (the first value is the length of the first segment rather than 0). | * subsequent segment (the first value is the length of the first segment rather than 0). | ||||
| * This calculation is rather trivial, and only depends on the evaluated positions, but | * This calculation is rather trivial, and only depends on the evaluated positions, but | ||||
| * the results are used often, and it is necessarily single threaded per curve, so it is cached. | * the results are used often, and it is necessarily single threaded per curve, so it is cached. | ||||
| * | * | ||||
| * \param cyclic: This argument is redundant with the data stored for the curve, | * \param cyclic: This argument is redundant with the data stored for the curve, | ||||
| * but is passed for performance reasons to avoid looking up the attribute. | * but is passed for performance reasons to avoid looking up the attribute. | ||||
| ▲ Show 20 Lines • Show All 592 Lines • ▼ Show 20 Lines | |||||
| inline Span<float> CurvesGeometry::evaluated_lengths_for_curve(const int curve_index, | inline Span<float> CurvesGeometry::evaluated_lengths_for_curve(const int curve_index, | ||||
| const bool cyclic) const | const bool cyclic) const | ||||
| { | { | ||||
| BLI_assert(!this->runtime->length_cache_dirty); | BLI_assert(!this->runtime->length_cache_dirty); | ||||
| const IndexRange range = this->lengths_range_for_curve(curve_index, cyclic); | const IndexRange range = this->lengths_range_for_curve(curve_index, cyclic); | ||||
| return this->runtime->evaluated_length_cache.as_span().slice(range); | return this->runtime->evaluated_length_cache.as_span().slice(range); | ||||
| } | } | ||||
| inline Span<float3> CurvesGeometry::evaluated_positions_for_curve(const int curve_index) const | |||||
| { | |||||
| BLI_assert(!this->runtime->position_cache_dirty); | |||||
| const IndexRange points = this->evaluated_points_for_curve(curve_index); | |||||
| return this->runtime->evaluated_position_cache.as_span().slice(points); | |||||
| } | |||||
| inline float CurvesGeometry::evaluated_length_total_for_curve(const int curve_index, | inline float CurvesGeometry::evaluated_length_total_for_curve(const int curve_index, | ||||
| const bool cyclic) const | const bool cyclic) const | ||||
| { | { | ||||
| const Span<float> lengths = this->evaluated_lengths_for_curve(curve_index, cyclic); | const Span<float> lengths = this->evaluated_lengths_for_curve(curve_index, cyclic); | ||||
| if (lengths.is_empty()) { | if (lengths.is_empty()) { | ||||
| return 0.0f; | return 0.0f; | ||||
| } | } | ||||
| return lengths.last(); | return lengths.last(); | ||||
| ▲ Show 20 Lines • Show All 63 Lines • Show Last 20 Lines | |||||