Blender  V3.3
BKE_curves.hh
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #pragma once
4 
5 #include "BKE_curves.h"
6 
12 #include <mutex>
13 
14 #include "BLI_float3x3.hh"
15 #include "BLI_float4x4.hh"
17 #include "BLI_index_mask.hh"
18 #include "BLI_math_vec_types.hh"
19 #include "BLI_span.hh"
20 #include "BLI_task.hh"
21 #include "BLI_vector.hh"
22 #include "BLI_virtual_array.hh"
23 
24 #include "BKE_attribute.hh"
25 
26 namespace blender::bke {
27 
28 template<typename T, BLI_ENABLE_IF(std::is_integral_v<T>)>
29 constexpr IndexRange offsets_to_range(Span<T> offsets, int64_t index)
30 {
31  BLI_assert(index >= 0);
32  BLI_assert(index < offsets.size());
33 
34  const int offset = offsets[index];
35  const int offset_next = offsets[index + 1];
36  return {offset, offset_next - offset};
37 }
38 
39 namespace curves::nurbs {
40 
41 struct BasisCache {
52 
58  bool invalid = false;
59 };
60 
61 } // namespace curves::nurbs
62 
69  public:
74  std::array<int, CURVE_TYPES_NUM> type_counts;
75 
83  mutable bool offsets_cache_dirty = true;
84 
87  mutable bool nurbs_basis_cache_dirty = true;
88 
92  mutable bool position_cache_dirty = true;
98 
106  mutable bool length_cache_dirty = true;
107 
111  mutable bool tangent_cache_dirty = true;
112 
116  mutable bool normal_cache_dirty = true;
117 };
118 
125  public:
126  CurvesGeometry();
132  CurvesGeometry(const CurvesGeometry &other);
134  CurvesGeometry &operator=(const CurvesGeometry &other);
136  ~CurvesGeometry();
137 
138  static CurvesGeometry &wrap(::CurvesGeometry &dna_struct)
139  {
140  CurvesGeometry *geometry = reinterpret_cast<CurvesGeometry *>(&dna_struct);
141  return *geometry;
142  }
143  static const CurvesGeometry &wrap(const ::CurvesGeometry &dna_struct)
144  {
145  const CurvesGeometry *geometry = reinterpret_cast<const CurvesGeometry *>(&dna_struct);
146  return *geometry;
147  }
148 
149  /* --------------------------------------------------------------------
150  * Accessors.
151  */
152 
153  int points_num() const;
154  int curves_num() const;
155  IndexRange points_range() const;
156  IndexRange curves_range() const;
157 
162  Span<int> offsets() const;
164 
168  IndexRange points_for_curve(int index) const;
170 
172  VArray<int8_t> curve_types() const;
181  void fill_curve_types(IndexMask selection, CurveType type);
183  void update_curve_types();
184 
185  bool has_curve_with_type(CurveType type) const;
188  bool is_single_type(CurveType type) const;
190  const std::array<int, CURVE_TYPES_NUM> &curve_type_counts() const;
196  IndexMask selection,
197  Vector<int64_t> &r_indices) const;
198 
199  Span<float3> positions() const;
201 
203  VArray<bool> cyclic() const;
206 
211  VArray<int> resolution() const;
214 
219  VArray<float> tilt() const;
221 
226  VArray<int8_t> normal_mode() const;
228 
236 
247 
254 
261 
265  Span<float> nurbs_weights() const;
267 
273 
278 
285  bool bounds_min_max(float3 &min, float3 &max) const;
286 
287  private:
288  /* --------------------------------------------------------------------
289  * Evaluation.
290  */
291 
292  public:
297  int evaluated_points_num() const;
298 
303  IndexRange evaluated_points_for_curve(int index) const;
305 
312 
314  void ensure_evaluated_offsets() const;
315 
320  Span<int> bezier_evaluated_offsets_for_curve(int curve_index) const;
321 
325 
335  Span<float> evaluated_lengths_for_curve(int curve_index, bool cyclic) const;
336  float evaluated_length_total_for_curve(int curve_index, bool cyclic) const;
337 
339  void ensure_evaluated_lengths() const;
340 
342 
350  void interpolate_to_evaluated(int curve_index, GSpan src, GMutableSpan dst) const;
355 
356  private:
360  void ensure_nurbs_basis_cache() const;
361 
363  IndexRange lengths_range_for_curve(int curve_index, bool cyclic) const;
364 
365  /* --------------------------------------------------------------------
366  * Operations.
367  */
368 
369  public:
374  void resize(int points_num, int curves_num);
375 
377  void tag_positions_changed();
382  void tag_topology_changed();
384  void tag_normals_changed();
385 
386  void translate(const float3 &translation);
387  void transform(const float4x4 &matrix);
388 
390 
391  void remove_points(IndexMask points_to_delete);
392  void remove_curves(IndexMask curves_to_delete);
393 
398  void reverse_curves(IndexMask curves_to_reverse);
399 
404 
407 
408  /* --------------------------------------------------------------------
409  * Attributes.
410  */
411 
412  GVArray adapt_domain(const GVArray &varray, eAttrDomain from, eAttrDomain to) const;
413  template<typename T>
415  {
416  return this->adapt_domain(GVArray(varray), from, to).typed<T>();
417  }
418 };
419 
425  public:
434  std::optional<Array<float3>> positions;
439  std::optional<Array<float3x3>> deform_mats;
440 
442  {
443  }
444 
449  bool is_valid() const;
450 };
451 
452 namespace curves {
453 
454 /* -------------------------------------------------------------------- */
462 inline int segments_num(const int points_num, const bool cyclic)
463 {
464  BLI_assert(points_num > 0);
465  return (cyclic && points_num > 1) ? points_num : points_num - 1;
466 }
467 
469 {
470  BLI_assert(std::abs(v.x + v.y + v.z - 1.0f) < 0.00001f);
471  return {v.x, v.y};
472 }
473 
475 {
476  return {v.x, v.y, 1.0f - v.x - v.y};
477 }
478 
481 /* -------------------------------------------------------------------- */
485 namespace poly {
486 
494 
501 
507 
508 } // namespace poly
509 
512 /* -------------------------------------------------------------------- */
516 namespace bezier {
517 
523 bool segment_is_vector(const int8_t left, const int8_t right);
524 bool segment_is_vector(Span<int8_t> handle_types_left,
525  Span<int8_t> handle_types_right,
526  int segment_index);
527 
532 bool last_cyclic_segment_is_vector(Span<int8_t> handle_types_left,
533  Span<int8_t> handle_types_right);
534 
540 bool point_is_sharp(Span<int8_t> handle_types_left, Span<int8_t> handle_types_right, int index);
541 
550 void calculate_evaluated_offsets(Span<int8_t> handle_types_left,
551  Span<int8_t> handle_types_right,
552  bool cyclic,
553  int resolution,
554  MutableSpan<int> evaluated_offsets);
555 
557 struct Insertion {
563 };
564 
579 Insertion insert(const float3 &point_prev,
580  const float3 &handle_prev,
581  const float3 &handle_next,
582  const float3 &point_next,
583  float parameter);
584 
591 float3 calculate_vector_handle(const float3 &point, const float3 &next_point);
592 
599 void calculate_auto_handles(bool cyclic,
600  Span<int8_t> types_left,
601  Span<int8_t> types_right,
603  MutableSpan<float3> positions_left,
604  MutableSpan<float3> positions_right);
605 
613 void set_handle_position(const float3 &position,
615  HandleType type_other,
616  const float3 &new_handle,
617  float3 &handle,
618  float3 &handle_other);
619 
626 void evaluate_segment(const float3 &point_0,
627  const float3 &point_1,
628  const float3 &point_2,
629  const float3 &point_3,
631 
642  Span<float3> handles_left,
643  Span<float3> handles_right,
644  Span<int> evaluated_offsets,
645  MutableSpan<float3> evaluated_positions);
646 
652 void interpolate_to_evaluated(GSpan src, Span<int> evaluated_offsets, GMutableSpan dst);
653 
654 } // namespace bezier
655 
658 /* -------------------------------------------------------------------- */
662 namespace catmull_rom {
663 
669 int calculate_evaluated_num(int points_num, bool cyclic, int resolution);
670 
675 void interpolate_to_evaluated(GSpan src, bool cyclic, int resolution, GMutableSpan dst);
676 
682  const bool cyclic,
683  const Span<int> evaluated_offsets,
684  GMutableSpan dst);
685 
686 } // namespace catmull_rom
687 
690 /* -------------------------------------------------------------------- */
694 namespace nurbs {
695 
699 bool check_valid_num_and_order(int points_num, int8_t order, bool cyclic, KnotsMode knots_mode);
700 
710  int points_num, int8_t order, bool cyclic, int resolution, KnotsMode knots_mode);
711 
717 int knots_num(int points_num, int8_t order, bool cyclic);
718 
727 void calculate_knots(
728  int points_num, KnotsMode mode, int8_t order, bool cyclic, MutableSpan<float> knots);
729 
736 void calculate_basis_cache(int points_num,
737  int evaluated_num,
738  int8_t order,
739  bool cyclic,
740  Span<float> knots,
741  BasisCache &basis_cache);
742 
751 void interpolate_to_evaluated(const BasisCache &basis_cache,
752  int8_t order,
753  Span<float> control_weights,
754  GSpan src,
755  GMutableSpan dst);
756 
757 } // namespace nurbs
758 
761 } // namespace curves
762 
763 Curves *curves_new_nomain(int points_num, int curves_num);
765 
770 
775 void curves_copy_parameters(const Curves &src, Curves &dst);
776 
777 std::array<int, CURVE_TYPES_NUM> calculate_type_counts(const VArray<int8_t> &types);
778 
779 /* -------------------------------------------------------------------- */
783 inline int CurvesGeometry::points_num() const
784 {
785  return this->point_num;
786 }
787 inline int CurvesGeometry::curves_num() const
788 {
789  return this->curve_num;
790 }
792 {
793  return IndexRange(this->points_num());
794 }
796 {
797  return IndexRange(this->curves_num());
798 }
799 
801 {
802  return this->curve_type_counts()[type] == this->curves_num();
803 }
804 
806 {
807  return this->curve_type_counts()[type] > 0;
808 }
809 
811 {
812  return std::any_of(
813  types.begin(), types.end(), [&](CurveType type) { return this->has_curve_with_type(type); });
814 }
815 
816 inline const std::array<int, CURVE_TYPES_NUM> &CurvesGeometry::curve_type_counts() const
817 {
818  BLI_assert(this->runtime->type_counts == calculate_type_counts(this->curve_types()));
819  return this->runtime->type_counts;
820 }
821 
822 inline IndexRange CurvesGeometry::points_for_curve(const int index) const
823 {
824  /* Offsets are not allocated when there are no curves. */
825  BLI_assert(this->curve_num > 0);
826  BLI_assert(this->curve_offsets != nullptr);
827  const int offset = this->curve_offsets[index];
828  const int offset_next = this->curve_offsets[index + 1];
829  return {offset, offset_next - offset};
830 }
831 
833 {
834  /* Offsets are not allocated when there are no curves. */
835  BLI_assert(this->curve_num > 0);
836  BLI_assert(this->curve_offsets != nullptr);
837  const int offset = this->curve_offsets[curves.start()];
838  const int offset_next = this->curve_offsets[curves.one_after_last()];
839  return {offset, offset_next - offset};
840 }
841 
843 {
844  /* This could avoid calculating offsets in the future in simple circumstances. */
845  return this->evaluated_offsets().last();
846 }
847 
849 {
850  BLI_assert(!this->runtime->offsets_cache_dirty);
851  return offsets_to_range(this->runtime->evaluated_offsets_cache.as_span(), index);
852 }
853 
855 {
856  BLI_assert(!this->runtime->offsets_cache_dirty);
857  BLI_assert(this->curve_num > 0);
858  const int offset = this->runtime->evaluated_offsets_cache[curves.start()];
859  const int offset_next = this->runtime->evaluated_offsets_cache[curves.one_after_last()];
860  return {offset, offset_next - offset};
861 }
862 
864 {
865  const IndexRange points = this->points_for_curve(curve_index);
866  return this->runtime->bezier_evaluated_offsets.as_span().slice(points);
867 }
868 
869 inline IndexRange CurvesGeometry::lengths_range_for_curve(const int curve_index,
870  const bool cyclic) const
871 {
872  BLI_assert(cyclic == this->cyclic()[curve_index]);
873  const IndexRange points = this->evaluated_points_for_curve(curve_index);
874  const int start = points.start() + curve_index;
875  return {start, curves::segments_num(points.size(), cyclic)};
876 }
877 
879  const bool cyclic) const
880 {
881  BLI_assert(!this->runtime->length_cache_dirty);
882  const IndexRange range = this->lengths_range_for_curve(curve_index, cyclic);
883  return this->runtime->evaluated_length_cache.as_span().slice(range);
884 }
885 
886 inline float CurvesGeometry::evaluated_length_total_for_curve(const int curve_index,
887  const bool cyclic) const
888 {
889  const Span<float> lengths = this->evaluated_lengths_for_curve(curve_index, cyclic);
890  if (lengths.is_empty()) {
891  return 0.0f;
892  }
893  return lengths.last();
894 }
895 
898 /* -------------------------------------------------------------------- */
902 namespace curves::bezier {
903 
904 inline bool point_is_sharp(const Span<int8_t> handle_types_left,
905  const Span<int8_t> handle_types_right,
906  const int index)
907 {
908  return ELEM(handle_types_left[index], BEZIER_HANDLE_VECTOR, BEZIER_HANDLE_FREE) ||
909  ELEM(handle_types_right[index], BEZIER_HANDLE_VECTOR, BEZIER_HANDLE_FREE);
910 }
911 
913 {
915 }
916 
917 inline bool segment_is_vector(const int8_t left, const int8_t right)
918 {
920 }
921 
922 inline float3 calculate_vector_handle(const float3 &point, const float3 &next_point)
923 {
924  return math::interpolate(point, next_point, 1.0f / 3.0f);
925 }
926 
929 } // namespace curves::bezier
930 
939 
941  CurvesSurfaceTransforms(const Object &curves_ob, const Object *surface_ob);
942 };
943 
944 } // namespace blender::bke
eAttrDomain
Definition: BKE_attribute.h:25
Low-level operations for curves that cannot be defined in the C++ header yet.
#define BLI_assert(a)
Definition: BLI_assert.h:46
#define ELEM(...)
ThreadMutex mutex
CurveType
HandleType
@ BEZIER_HANDLE_FREE
@ BEZIER_HANDLE_VECTOR
struct CurvesGeometry CurvesGeometry
KnotsMode
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble right
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint order
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to curves
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Sky Generate a procedural sky texture Noise Generate fractal Perlin noise Wave Generate procedural bands or rings with noise Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a point
ATTR_WARN_UNUSED_RESULT const BMVert * v
VArray< T > typed() const
constexpr int64_t one_after_last() const
constexpr int64_t size() const
constexpr int64_t start() const
constexpr const T & last(const int64_t n=0) const
Definition: BLI_span.hh:313
constexpr int64_t size() const
Definition: BLI_span.hh:240
constexpr bool is_empty() const
Definition: BLI_span.hh:248
CurvesEditHints(const Curves &curves_id_orig)
Definition: BKE_curves.hh:441
std::optional< Array< float3 > > positions
Definition: BKE_curves.hh:434
std::optional< Array< float3x3 > > deform_mats
Definition: BKE_curves.hh:439
Vector< float3 > evaluated_normal_cache
Definition: BKE_curves.hh:114
Vector< curves::nurbs::BasisCache > nurbs_basis_cache
Definition: BKE_curves.hh:85
Vector< float3 > evaluated_tangent_cache
Definition: BKE_curves.hh:109
Vector< float3 > evaluated_position_cache
Definition: BKE_curves.hh:90
std::array< int, CURVE_TYPES_NUM > type_counts
Definition: BKE_curves.hh:74
IndexRange evaluated_points_for_curve(int index) const
Definition: BKE_curves.hh:848
VArray< int8_t > handle_types_left() const
MutableSpan< float3 > positions_for_write()
void translate(const float3 &translation)
void remove_points(IndexMask points_to_delete)
VArray< float > selection_curve_float() const
VArray< int8_t > normal_mode() const
MutableSpan< int8_t > handle_types_right_for_write()
VArray< int8_t > handle_types_right() const
void ensure_can_interpolate_to_evaluated() const
IndexRange curves_range() const
Definition: BKE_curves.hh:795
MutableSpan< int8_t > curve_types_for_write()
MutableSpan< int > resolution_for_write()
const std::array< int, CURVE_TYPES_NUM > & curve_type_counts() const
Definition: BKE_curves.hh:816
MutableSpan< float3 > handle_positions_left_for_write()
MutableAttributeAccessor attributes_for_write()
MutableSpan< float3 > handle_positions_right_for_write()
IndexRange points_for_curves(IndexRange curves) const
Definition: BKE_curves.hh:832
MutableSpan< int8_t > nurbs_knots_modes_for_write()
Span< float > evaluated_lengths_for_curve(int curve_index, bool cyclic) const
Definition: BKE_curves.hh:878
MutableSpan< float > tilt_for_write()
MutableSpan< float > selection_point_float_for_write()
VArray< float > tilt() const
Span< float3 > evaluated_tangents() const
MutableSpan< float > selection_curve_float_for_write()
IndexRange evaluated_points_for_curves(IndexRange curves) const
Definition: BKE_curves.hh:854
MutableSpan< int8_t > nurbs_orders_for_write()
Span< float > nurbs_weights() const
MutableSpan< float2 > surface_uv_coords_for_write()
IndexRange points_for_curve(int index) const
Definition: BKE_curves.hh:822
Span< float3 > handle_positions_left() const
VArray< int > resolution() const
Span< int > evaluated_offsets() const
Span< int > bezier_evaluated_offsets_for_curve(int curve_index) const
Definition: BKE_curves.hh:863
void interpolate_to_evaluated(int curve_index, GSpan src, GMutableSpan dst) const
static const CurvesGeometry & wrap(const ::CurvesGeometry &dna_struct)
Definition: BKE_curves.hh:143
IndexRange points_range() const
Definition: BKE_curves.hh:791
VArray< int8_t > nurbs_knots_modes() const
Span< float3 > evaluated_normals() const
VArray< float > selection_point_float() const
IndexMask indices_for_curve_type(CurveType type, Vector< int64_t > &r_indices) const
void remove_curves(IndexMask curves_to_delete)
static CurvesGeometry & wrap(::CurvesGeometry &dna_struct)
Definition: BKE_curves.hh:138
VArray< T > adapt_domain(const VArray< T > &varray, eAttrDomain from, eAttrDomain to) const
Definition: BKE_curves.hh:414
Span< float3 > positions() const
bool has_curve_with_type(CurveType type) const
Definition: BKE_curves.hh:805
MutableSpan< float > nurbs_weights_for_write()
void resize(int points_num, int curves_num)
Span< float3 > handle_positions_right() const
MutableSpan< int8_t > normal_mode_for_write()
void fill_curve_types(CurveType type)
AttributeAccessor attributes() const
float evaluated_length_total_for_curve(int curve_index, bool cyclic) const
Definition: BKE_curves.hh:886
void reverse_curves(IndexMask curves_to_reverse)
bool is_single_type(CurveType type) const
Definition: BKE_curves.hh:800
MutableSpan< int > offsets_for_write()
bool bounds_min_max(float3 &min, float3 &max) const
Span< float2 > surface_uv_coords() const
GVArray adapt_domain(const GVArray &varray, eAttrDomain from, eAttrDomain to) const
void transform(const float4x4 &matrix)
Span< float3 > evaluated_positions() const
VArray< int8_t > curve_types() const
VArray< bool > cyclic() const
CurvesGeometry & operator=(const CurvesGeometry &other)
MutableSpan< bool > cyclic_for_write()
VArray< int8_t > nurbs_orders() const
MutableSpan< int8_t > handle_types_left_for_write()
StackEntry * from
SyclQueue void void * src
static bool is_cyclic(const Nurb *nu)
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
static char ** types
Definition: makesdna.c:67
static int left
#define T
Insertion insert(const float3 &point_prev, const float3 &handle_prev, const float3 &handle_next, const float3 &point_next, float parameter)
Definition: curve_bezier.cc:61
bool segment_is_vector(const HandleType left, const HandleType right)
Definition: BKE_curves.hh:912
bool point_is_sharp(Span< int8_t > handle_types_left, Span< int8_t > handle_types_right, int index)
Definition: BKE_curves.hh:904
void calculate_auto_handles(bool cyclic, Span< int8_t > types_left, Span< int8_t > types_right, Span< float3 > positions, MutableSpan< float3 > positions_left, MutableSpan< float3 > positions_right)
void calculate_evaluated_offsets(Span< int8_t > handle_types_left, Span< int8_t > handle_types_right, bool cyclic, int resolution, MutableSpan< int > evaluated_offsets)
Definition: curve_bezier.cc:29
float3 calculate_vector_handle(const float3 &point, const float3 &next_point)
Definition: BKE_curves.hh:922
void evaluate_segment(const float3 &point_0, const float3 &point_1, const float3 &point_2, const float3 &point_3, MutableSpan< float3 > result)
bool last_cyclic_segment_is_vector(Span< int8_t > handle_types_left, Span< int8_t > handle_types_right)
Definition: curve_bezier.cc:23
void calculate_evaluated_positions(Span< float3 > positions, Span< float3 > handles_left, Span< float3 > handles_right, Span< int > evaluated_offsets, MutableSpan< float3 > evaluated_positions)
void set_handle_position(const float3 &position, HandleType type, HandleType type_other, const float3 &new_handle, float3 &handle, float3 &handle_other)
void interpolate_to_evaluated(GSpan src, Span< int > evaluated_offsets, GMutableSpan dst)
int calculate_evaluated_num(int points_num, bool cyclic, int resolution)
void interpolate_to_evaluated(GSpan src, bool cyclic, int resolution, GMutableSpan dst)
int calculate_evaluated_num(int points_num, int8_t order, bool cyclic, int resolution, KnotsMode knots_mode)
Definition: curve_nurbs.cc:32
bool check_valid_num_and_order(int points_num, int8_t order, bool cyclic, KnotsMode knots_mode)
Definition: curve_nurbs.cc:13
void calculate_knots(int points_num, KnotsMode mode, int8_t order, bool cyclic, MutableSpan< float > knots)
Definition: curve_nurbs.cc:52
void calculate_basis_cache(int points_num, int evaluated_num, int8_t order, bool cyclic, Span< float > knots, BasisCache &basis_cache)
Definition: curve_nurbs.cc:149
int knots_num(int points_num, int8_t order, bool cyclic)
Definition: curve_nurbs.cc:44
void interpolate_to_evaluated(const BasisCache &basis_cache, int8_t order, Span< float > control_weights, GSpan src, GMutableSpan dst)
Definition: curve_nurbs.cc:229
void calculate_normals_z_up(Span< float3 > tangents, MutableSpan< float3 > normals)
Definition: curve_poly.cc:119
void calculate_normals_minimum(Span< float3 > tangents, bool cyclic, MutableSpan< float3 > normals)
Definition: curve_poly.cc:154
void calculate_tangents(Span< float3 > positions, bool is_cyclic, MutableSpan< float3 > tangents)
Definition: curve_poly.cc:41
float3 decode_surface_bary_coord(const float2 &v)
Definition: BKE_curves.hh:474
int segments_num(const int points_num, const bool cyclic)
Definition: BKE_curves.hh:462
float2 encode_surface_bary_coord(const float3 &v)
Definition: BKE_curves.hh:468
void curves_copy_parameters(const Curves &src, Curves &dst)
Definition: curves.cc:391
std::array< int, CURVE_TYPES_NUM > calculate_type_counts(const VArray< int8_t > &types)
constexpr IndexRange offsets_to_range(Span< T > offsets, int64_t index)
Definition: BKE_curves.hh:29
Curves * curves_new_nomain_single(int points_num, CurveType type)
Definition: curves.cc:375
Curves * curves_new_nomain(int points_num, int curves_num)
Definition: curves.cc:367
T abs(const T &a)
T interpolate(const T &a, const T &b, const FactorT &t)
MutableSpan< float3 > positions
MutableSpan< float3 > tangents
MutableSpan< float3 > normals
#define min(a, b)
Definition: sort.c:35
__int64 int64_t
Definition: stdint.h:89
signed char int8_t
Definition: stdint.h:75
CurvesGeometryRuntimeHandle * runtime
float max