Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/BKE_curves.hh
| Show First 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | |||||
| /** | /** | ||||
| * Contains derived data, caches, and other information not saved in files, besides a few pointers | * Contains derived data, caches, and other information not saved in files, besides a few pointers | ||||
| * to arrays that are kept in the non-runtime struct to avoid dereferencing this whenever they are | * to arrays that are kept in the non-runtime struct to avoid dereferencing this whenever they are | ||||
| * accessed. | * accessed. | ||||
| */ | */ | ||||
| class CurvesGeometryRuntime { | class CurvesGeometryRuntime { | ||||
| public: | public: | ||||
| /** | /** | ||||
| * The cached number of curves with each type. Unlike other caches here, this is not computed | |||||
| * lazily, since it is needed so often and types are not adjusted much anyway. | |||||
| */ | |||||
| std::array<int, CURVE_TYPES_NUM> type_counts; | |||||
| /** | |||||
| * Cache of offsets into the evaluated array for each curve, accounting for all previous | * Cache of offsets into the evaluated array for each curve, accounting for all previous | ||||
| * evaluated points, Bezier curve vector segments, different resolutions per curve, etc. | * evaluated points, Bezier curve vector segments, different resolutions per curve, etc. | ||||
| */ | */ | ||||
| mutable Vector<int> evaluated_offsets_cache; | mutable Vector<int> evaluated_offsets_cache; | ||||
| mutable Vector<int> bezier_evaluated_offsets; | mutable Vector<int> bezier_evaluated_offsets; | ||||
| mutable std::mutex offsets_cache_mutex; | mutable std::mutex offsets_cache_mutex; | ||||
| mutable bool offsets_cache_dirty = true; | mutable bool offsets_cache_dirty = true; | ||||
| ▲ Show 20 Lines • Show All 80 Lines • ▼ Show 20 Lines | public: | ||||
| /** | /** | ||||
| * Access a range of indices of point data for a specific curve. | * Access a range of indices of point data for a specific curve. | ||||
| */ | */ | ||||
| IndexRange points_for_curve(int index) const; | IndexRange points_for_curve(int index) const; | ||||
| IndexRange points_for_curves(IndexRange curves) const; | IndexRange points_for_curves(IndexRange curves) const; | ||||
| /** The type (#CurveType) of each curve, or potentially a single if all are the same type. */ | /** The type (#CurveType) of each curve, or potentially a single if all are the same type. */ | ||||
| VArray<int8_t> curve_types() const; | VArray<int8_t> curve_types() const; | ||||
| /** Mutable access to curve types. Call #tag_topology_changed after changing any type. */ | /** Mutable access to curve types. Call #update_curve_types after changing any type. */ | ||||
| MutableSpan<int8_t> curve_types_for_write(); | MutableSpan<int8_t> curve_types_for_write(); | ||||
| /** Set all curve types to the value and call #update_curve_types. */ | |||||
JacquesLucke: `Short for`, not sure if there is a word missing here. | |||||
Done Inline ActionsNo, that's just a phrase, but I can reword it. HooglyBoogly: No, that's just a phrase, but I can reword it. | |||||
| void fill_curve_types(CurveType type); | |||||
| /** Set the types for the curves in the selection and call #update_curve_types. */ | |||||
| void fill_curve_types(IndexMask selection, CurveType type); | |||||
| /** Update the cached count of curves of each type, necessary after #curve_types_for_write. */ | |||||
| void update_curve_types(); | |||||
| bool has_curve_with_type(const CurveType type) const; | bool has_curve_with_type(const CurveType type) const; | ||||
| /** Return the number of curves with each type. */ | |||||
| std::array<int, CURVE_TYPES_NUM> count_curve_types() const; | |||||
| /** Return true if all of the curves have the provided type. */ | /** Return true if all of the curves have the provided type. */ | ||||
| bool is_single_type(CurveType type) const; | bool is_single_type(CurveType type) const; | ||||
| /** Return the number of curves with each type. */ | |||||
| const std::array<int, CURVE_TYPES_NUM> &curve_type_counts() const; | |||||
Done Inline ActionsWonder if it would be good to return a const std::array<int, CURVE_TYPES_NUM> &. That would be more clear imo. JacquesLucke: Wonder if it would be good to return a `const std::array<int, CURVE_TYPES_NUM> &`. That would… | |||||
| Span<float3> positions() const; | Span<float3> positions() const; | ||||
| MutableSpan<float3> positions_for_write(); | MutableSpan<float3> positions_for_write(); | ||||
| /** Whether the curve loops around to connect to itself, on the curve domain. */ | /** Whether the curve loops around to connect to itself, on the curve domain. */ | ||||
| VArray<bool> cyclic() const; | VArray<bool> cyclic() const; | ||||
| /** Mutable access to curve cyclic values. Call #tag_topology_changed after changes. */ | /** Mutable access to curve cyclic values. Call #tag_topology_changed after changes. */ | ||||
| MutableSpan<bool> cyclic_for_write(); | MutableSpan<bool> cyclic_for_write(); | ||||
| ▲ Show 20 Lines • Show All 443 Lines • ▼ Show 20 Lines | |||||
| Curves *curves_new_nomain(int points_num, int curves_num); | Curves *curves_new_nomain(int points_num, int curves_num); | ||||
| /** | /** | ||||
| * Create a new curves data-block containing a single curve with the given length and type. | * Create a new curves data-block containing a single curve with the given length and type. | ||||
| */ | */ | ||||
| Curves *curves_new_nomain_single(int points_num, CurveType type); | Curves *curves_new_nomain_single(int points_num, CurveType type); | ||||
| std::array<int, CURVE_TYPES_NUM> calculate_type_counts(const VArray<int8_t> &types); | |||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name #CurvesGeometry Inline Methods | /** \name #CurvesGeometry Inline Methods | ||||
| * \{ */ | * \{ */ | ||||
| inline int CurvesGeometry::points_num() const | inline int CurvesGeometry::points_num() const | ||||
| { | { | ||||
| Show All 9 Lines | |||||
| } | } | ||||
| inline IndexRange CurvesGeometry::curves_range() const | inline IndexRange CurvesGeometry::curves_range() const | ||||
| { | { | ||||
| return IndexRange(this->curves_num()); | return IndexRange(this->curves_num()); | ||||
| } | } | ||||
| inline bool CurvesGeometry::is_single_type(const CurveType type) const | inline bool CurvesGeometry::is_single_type(const CurveType type) const | ||||
| { | { | ||||
| return this->count_curve_types()[type] == this->curves_num(); | return this->curve_type_counts()[type] == this->curves_num(); | ||||
| } | |||||
| inline bool CurvesGeometry::has_curve_with_type(const CurveType type) const | |||||
| { | |||||
| return this->curve_type_counts()[type] > 0; | |||||
| } | |||||
| inline const std::array<int, CURVE_TYPES_NUM> &CurvesGeometry::curve_type_counts() const | |||||
| { | |||||
| BLI_assert(this->runtime->type_counts == calculate_type_counts(this->curve_types())); | |||||
| return this->runtime->type_counts; | |||||
| } | } | ||||
| inline IndexRange CurvesGeometry::points_for_curve(const int index) const | inline IndexRange CurvesGeometry::points_for_curve(const int index) const | ||||
| { | { | ||||
| /* Offsets are not allocated when there are no curves. */ | /* Offsets are not allocated when there are no curves. */ | ||||
| BLI_assert(this->curve_size > 0); | BLI_assert(this->curve_size > 0); | ||||
| BLI_assert(this->curve_offsets != nullptr); | BLI_assert(this->curve_offsets != nullptr); | ||||
| const int offset = this->curve_offsets[index]; | const int offset = this->curve_offsets[index]; | ||||
| ▲ Show 20 Lines • Show All 87 Lines • Show Last 20 Lines | |||||
Short for, not sure if there is a word missing here.