Blender V5.3
blender::ed::curves::CurvesGeometry Class Reference

#include <BKE_curves.hh>

Inherits blender::CurvesGeometry.

Classes

struct  BlendWriteData

Public Member Functions

template<typename T>
VArray< T > adapt_domain (const VArray< T > &varray, AttrDomain from, AttrDomain to) const
Constructors/Destructor
 CurvesGeometry ()
 CurvesGeometry (int point_num, int curve_num)
 CurvesGeometry (const CurvesGeometry &other)
 CurvesGeometry (CurvesGeometry &&other)
CurvesGeometry & operator= (const CurvesGeometry &other)
CurvesGeometry & operator= (CurvesGeometry &&other)
 ~CurvesGeometry ()
Accessors
Span< int > offsets () const
MutableSpan< int > offsets_for_write ()
VArray< int8_t > curve_types () const
MutableSpan< int8_t > curve_types_for_write ()
void fill_curve_types (CurveType type)
void fill_curve_types (const IndexMask &selection, CurveType type)
void update_curve_types ()
Span< float3 > positions () const
MutableSpan< float3 > positions_for_write ()
VArray< float > radius () const
MutableSpan< float > radius_for_write ()
VArray< bool > cyclic () const
MutableSpan< bool > cyclic_for_write ()
VArray< int > resolution () const
MutableSpan< int > resolution_for_write ()
VArray< float > tilt () const
MutableSpan< float > tilt_for_write ()
VArray< int8_t > normal_mode () const
MutableSpan< int8_t > normal_mode_for_write ()
VArray< int8_t > handle_types_left () const
MutableSpan< int8_t > handle_types_left_for_write ()
VArray< int8_t > handle_types_right () const
MutableSpan< int8_t > handle_types_right_for_write ()
std::optional< Span< float3 > > handle_positions_left () const
MutableSpan< float3 > handle_positions_left_for_write ()
std::optional< Span< float3 > > handle_positions_right () const
MutableSpan< float3 > handle_positions_right_for_write ()
VArray< int8_t > nurbs_orders () const
MutableSpan< int8_t > nurbs_orders_for_write ()
VArray< int8_t > nurbs_knots_modes () const
MutableSpan< int8_t > nurbs_knots_modes_for_write ()
std::optional< Span< float > > nurbs_weights () const
MutableSpan< float > nurbs_weights_for_write ()
std::optional< Span< float2 > > surface_uv_coords () const
MutableSpan< float2 > surface_uv_coords_for_write ()
Span< float > nurbs_custom_knots () const
MutableSpan< float > nurbs_custom_knots_for_write ()
OffsetIndices< int > nurbs_custom_knots_by_curve () const
IndexMask nurbs_custom_knot_curves (IndexMaskMemory &memory) const
void nurbs_custom_knots_update_size ()
void nurbs_custom_knots_resize (int knots_num)
Span< MDeformVert > deform_verts () const
MutableSpan< MDeformVert > deform_verts_for_write ()
Operations
std::optional< Bounds< float3 > > bounds_min_max (bool use_radius=true) const
void count_memory (MemoryCounter &memory) const
std::optional< int > material_index_max () const
void resize (int points_num, int curves_num)
void tag_positions_changed ()
void tag_topology_changed ()
void tag_normals_changed ()
void tag_radii_changed ()
void tag_material_index_changed ()
void translate (const float3 &translation)
void transform (const float4x4 &matrix)
void calculate_bezier_auto_handles ()
void calculate_bezier_aligned_handles ()
void remove_points (const IndexMask &points_to_delete, const AttributeFilter &attribute_filter)
void remove_curves (const IndexMask &curves_to_delete, const AttributeFilter &attribute_filter)
void reverse_curves (const IndexMask &curves_to_reverse)
void remove_attributes_based_on_types ()
Domain Interpolation
AttributeAccessor attributes () const
MutableAttributeAccessor attributes_for_write ()
GVArray adapt_domain (const GVArray &varray, AttrDomain from, AttrDomain to) const
File reading/writing.
void blend_read (BlendDataReader &reader)
void blend_write_prepare (BlendWriteData &write_data, bool use_5_0_compatibility)
void blend_write (BlendWriter &writer, ID &id, const BlendWriteData &write_data)

#CurvesGeometry Inline Methods

int points_num () const
int curves_num () const
bool is_empty () const
IndexRange points_range () const
IndexRange curves_range () const
OffsetIndices< int > points_by_curve () const
bool has_curve_with_type (CurveType type) const
bool has_curve_with_type (Span< CurveType > types) const
bool is_single_type (CurveType type) const
const std::array< int, CURVE_TYPES_NUM > & curve_type_counts () const
bool nurbs_has_custom_knots () const
int evaluated_points_num () const
Span< int > bezier_evaluated_offsets_for_curve (int curve_index) const
Span< float > evaluated_lengths_for_curve (int curve_index, bool cyclic) const
float evaluated_length_total_for_curve (int curve_index, bool cyclic) const

Evaluation

IndexMask indices_for_curve_type (CurveType type, IndexMaskMemory &memory) const
IndexMask indices_for_curve_type (CurveType type, const IndexMask &selection, IndexMaskMemory &memory) const
Array< int > point_to_curve_map () const
OffsetIndices< int > evaluated_points_by_curve () const
bool has_cyclic_curve () const
Span< float3 > evaluated_positions () const
Span< float3 > evaluated_tangents () const
Span< float3 > evaluated_normals () const
void ensure_evaluated_lengths () const
void ensure_can_interpolate_to_evaluated () const
void interpolate_to_evaluated (int curve_index, GSpan src, GMutableSpan dst) const
void interpolate_to_evaluated (GSpan src, GMutableSpan dst) const

Additional Inherited Members

Public Attributes inherited from blender::CurvesGeometry
int * curve_offsets = nullptr
struct AttributeStorage attribute_storage
CustomData point_data
CustomData curve_data_legacy
int point_num = 0
int curve_num = 0
ListBaseT< struct bDeformGroup > vertex_group_names = {nullptr, nullptr}
int vertex_group_active_index = 0
int attributes_active_index = -1
bke::CurvesGeometryRuntime * runtime = nullptr
float * custom_knots = nullptr
int custom_knot_num = 0
char _pad [4] = {}

Detailed Description

A C++ class that wraps the DNA struct for better encapsulation and ease of use. It inherits directly from the struct rather than storing a pointer to avoid more complicated ownership handling.

Definition at line 156 of file BKE_curves.hh.

Constructor & Destructor Documentation

◆ CurvesGeometry() [1/4]

◆ CurvesGeometry() [2/4]

blender::bke::CurvesGeometry::CurvesGeometry ( int point_num,
int curve_num )

Create curves with the given size. Only the position attribute is created, along with the offsets.

Definition at line 70 of file curves_geometry.cc.

◆ CurvesGeometry() [3/4]

blender::bke::CurvesGeometry::CurvesGeometry ( const CurvesGeometry & other)

Definition at line 106 of file curves_geometry.cc.

◆ CurvesGeometry() [4/4]

Definition at line 166 of file curves_geometry.cc.

◆ ~CurvesGeometry()

Member Function Documentation

◆ adapt_domain() [1/2]

Definition at line 1921 of file curves_geometry.cc.

◆ adapt_domain() [2/2]

template<typename T>
VArray< T > blender::bke::CurvesGeometry::adapt_domain ( const VArray< T > & varray,
AttrDomain from,
AttrDomain to ) const
inline

Definition at line 500 of file BKE_curves.hh.

◆ attributes()

◆ attributes_for_write()

◆ bezier_evaluated_offsets_for_curve()

Retrieve offsets into a Bezier curve's evaluated points for each control point. Stored in the same format as OffsetIndices. Call evaluated_points_by_curve() first to ensure that the evaluated offsets cache is current.

Definition at line 1070 of file BKE_curves.hh.

◆ blend_read()

◆ blend_write()

void blender::bke::CurvesGeometry::blend_write ( BlendWriter & writer,
ID & id,
const BlendWriteData & write_data )

Definition at line 2070 of file curves_geometry.cc.

◆ blend_write_prepare()

void blender::bke::CurvesGeometry::blend_write_prepare ( CurvesGeometry::BlendWriteData & write_data,
bool use_5_0_compatibility )

This function needs to be called before blend_write and before the CurvesGeometry struct is written because it can mutate the CustomData and AttributeStorage structs.

Definition at line 2048 of file curves_geometry.cc.

◆ bounds_min_max()

std::optional< Bounds< float3 > > blender::bke::CurvesGeometry::bounds_min_max ( bool use_radius = true) const

The largest and smallest position values of evaluated points.

Definition at line 1430 of file curves_geometry.cc.

◆ calculate_bezier_aligned_handles()

Calculate handle positions for Align handle types. Ensure that both handles position fall on the same line, both handle will be moved unless the handles are already aligned.

Definition at line 1363 of file curves_geometry.cc.

◆ calculate_bezier_auto_handles()

Calculate handle positions for Auto, Vector handle types.

Definition at line 1331 of file curves_geometry.cc.

◆ count_memory()

Definition at line 1477 of file curves_geometry.cc.

◆ curve_type_counts()

const std::array< int, CURVE_TYPES_NUM > & blender::bke::CurvesGeometry::curve_type_counts ( ) const
inline

Return the number of curves with each type.

Definition at line 1044 of file BKE_curves.hh.

◆ curve_types()

The type (CurveType) of each curve, or potentially a single if all are the same type.

Definition at line 232 of file curves_geometry.cc.

◆ curve_types_for_write()

Mutable access to curve types. Call tag_topology_changed and update_curve_types after changing any type. Consider using the other methods to change types below.

Definition at line 241 of file curves_geometry.cc.

◆ curves_num()

The number of curves in the data-block.

Definition at line 1005 of file BKE_curves.hh.

◆ curves_range()

Definition at line 1023 of file BKE_curves.hh.

◆ cyclic()

Whether the curve loops around to connect to itself, on the curve domain.

Definition at line 405 of file curves_geometry.cc.

◆ cyclic_for_write()

Mutable access to curve cyclic values. Call tag_topology_changed after changes.

Definition at line 410 of file curves_geometry.cc.

◆ deform_verts()

Vertex group data, encoded as an array of indices and weights for every vertex.

Warning
: May be empty.

Definition at line 654 of file curves_geometry.cc.

◆ deform_verts_for_write()

◆ ensure_can_interpolate_to_evaluated()

◆ ensure_evaluated_lengths()

Calculates the data described by evaluated_lengths_for_curve if necessary.

Definition at line 1226 of file curves_geometry.cc.

◆ evaluated_length_total_for_curve()

float blender::bke::CurvesGeometry::evaluated_length_total_for_curve ( int curve_index,
bool cyclic ) const
inline

Definition at line 1095 of file BKE_curves.hh.

◆ evaluated_lengths_for_curve()

Span< float > blender::bke::CurvesGeometry::evaluated_lengths_for_curve ( int curve_index,
bool cyclic ) const
inline

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). 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.

Parameters
cyclicThis argument is redundant with the data stored for the curve, but is passed for performance reasons to avoid looking up the attribute.

Definition at line 1088 of file BKE_curves.hh.

◆ evaluated_normals()

◆ evaluated_points_by_curve()

The offsets of every curve's evaluated points.

Definition at line 749 of file curves_geometry.cc.

◆ evaluated_points_num()

The total number of points in the evaluated poly curve. This can depend on the resolution attribute if it exists.

Definition at line 1064 of file BKE_curves.hh.

◆ evaluated_positions()

◆ evaluated_tangents()

◆ fill_curve_types() [1/2]

Set the types for the curves in the selection and call update_curve_types.

Definition at line 270 of file curves_geometry.cc.

◆ fill_curve_types() [2/2]

Set all curve types to the value and call update_curve_types.

Definition at line 247 of file curves_geometry.cc.

◆ handle_positions_left()

The positions of Bezier curve handles. Though these are really control points for the Bezier segments, they are stored in separate arrays to better reflect user expectations. Note that values may be generated automatically based on the handle types. Call tag_positions_changed after changes.

Definition at line 483 of file curves_geometry.cc.

◆ handle_positions_left_for_write()

◆ handle_positions_right()

Definition at line 498 of file curves_geometry.cc.

◆ handle_positions_right_for_write()

◆ handle_types_left()

Handle types for Bezier control points. Call tag_topology_changed after changes.

Definition at line 449 of file curves_geometry.cc.

◆ handle_types_left_for_write()

◆ handle_types_right()

◆ handle_types_right_for_write()

◆ has_curve_with_type() [1/2]

Definition at line 1033 of file BKE_curves.hh.

◆ has_curve_with_type() [2/2]

Definition at line 1038 of file BKE_curves.hh.

◆ has_cyclic_curve()

Definition at line 778 of file curves_geometry.cc.

◆ indices_for_curve_type() [1/2]

Definition at line 792 of file curves_geometry.cc.

◆ indices_for_curve_type() [2/2]

All of the curve indices for curves with a specific type.

Definition at line 786 of file curves_geometry.cc.

◆ interpolate_to_evaluated() [1/2]

Evaluate generic data for curve control points to the standard evaluated points of the curves.

Definition at line 1199 of file curves_geometry.cc.

◆ interpolate_to_evaluated() [2/2]

Evaluate a generic data to the standard evaluated points of a specific curve, defined by the resolution attribute or other factors, depending on the curve type.

Warning
This function expects offsets to the evaluated points for each curve to be calculated. That can be ensured with ensure_can_interpolate_to_evaluated.

Definition at line 1179 of file curves_geometry.cc.

◆ is_empty()

Return true if there are no curves in the geometry.

Definition at line 1013 of file BKE_curves.hh.

◆ is_single_type()

Return true if all of the curves have the provided type.

Definition at line 1028 of file BKE_curves.hh.

◆ material_index_max()

std::optional< int > blender::bke::CurvesGeometry::material_index_max ( ) const

Get the largest material index used by the geometry or nullopt if there are none. The returned value is clamped between 0 and MAXMAT even if the stored material indices may be out of that range.

Definition at line 1463 of file curves_geometry.cc.

◆ normal_mode()

Which method to use for calculating the normals of evaluated points (NormalMode). Call tag_normals_changed after changes.

Definition at line 427 of file curves_geometry.cc.

◆ normal_mode_for_write()

◆ nurbs_custom_knot_curves()

Builds mask of NURBS curves with knot mode NURBS_KNOT_MODE_CUSTOM.

Definition at line 589 of file curves_geometry.cc.

◆ nurbs_custom_knots()

Custom knots for NURBS curves with knots mode NURBS_KNOT_MODE_CUSTOM.

Definition at line 571 of file curves_geometry.cc.

◆ nurbs_custom_knots_by_curve()

The offsets of every curve into arrays on #CurvesGeometry::nurbs_custom_knots. Curves with knot mode other than NURBS_KNOT_MODE_CUSTOM will have zero sized IndexRange.

Definition at line 598 of file curves_geometry.cc.

◆ nurbs_custom_knots_for_write()

◆ nurbs_custom_knots_resize()

Resizes custom knots array. Used when knots number is known in advance and knot values are set together with topological data.

Definition at line 644 of file curves_geometry.cc.

◆ nurbs_custom_knots_update_size()

Resizes custom knots array depending on topological data. Depends on curve offsets, knot modes, orders and cyclic data. Used to resize internal knots array before writing knots.

Definition at line 630 of file curves_geometry.cc.

◆ nurbs_has_custom_knots()

Definition at line 1009 of file BKE_curves.hh.

◆ nurbs_knots_modes()

The automatic generation mode for each NURBS curve's knots vector, on the curve domain. Call tag_topology_changed after changes.

Definition at line 538 of file curves_geometry.cc.

◆ nurbs_knots_modes_for_write()

◆ nurbs_orders()

The order (degree plus one) of each NURBS curve, on the curve domain. Call tag_topology_changed after changes.

Definition at line 513 of file curves_geometry.cc.

◆ nurbs_orders_for_write()

◆ nurbs_weights()

The weight for each control point for NURBS curves. Call tag_positions_changed after changes.

Definition at line 524 of file curves_geometry.cc.

◆ nurbs_weights_for_write()

◆ offsets()

The index of the first point in every curve. The size of this span is one larger than the number of curves, but the spans will be empty if there are no curves/points.

Consider using points_by_curve rather than these offsets directly.

Definition at line 388 of file curves_geometry.cc.

◆ offsets_for_write()

◆ operator=() [1/2]

CurvesGeometry & blender::bke::CurvesGeometry::operator= ( const CurvesGeometry & other)

Definition at line 156 of file curves_geometry.cc.

◆ operator=() [2/2]

CurvesGeometry & blender::bke::CurvesGeometry::operator= ( CurvesGeometry && other)

Definition at line 202 of file curves_geometry.cc.

◆ point_to_curve_map()

Definition at line 800 of file curves_geometry.cc.

◆ points_by_curve()

The offsets of every curve into arrays on the points domain.

Definition at line 1058 of file BKE_curves.hh.

◆ points_num()

The total number of control points in all curves.

Definition at line 1001 of file BKE_curves.hh.

◆ points_range()

Definition at line 1019 of file BKE_curves.hh.

◆ positions()

Definition at line 366 of file curves_geometry.cc.

◆ positions_for_write()

◆ radius()

Definition at line 377 of file curves_geometry.cc.

◆ radius_for_write()

◆ remove_attributes_based_on_types()

Remove any attributes that are unused based on the types in the curves.

Definition at line 1807 of file curves_geometry.cc.

◆ remove_curves()

void blender::bke::CurvesGeometry::remove_curves ( const IndexMask & curves_to_delete,
const AttributeFilter & attribute_filter )

Definition at line 1679 of file curves_geometry.cc.

◆ remove_points()

void blender::bke::CurvesGeometry::remove_points ( const IndexMask & points_to_delete,
const AttributeFilter & attribute_filter )

Definition at line 1599 of file curves_geometry.cc.

◆ resize()

void blender::bke::CurvesGeometry::resize ( int points_num,
int curves_num )

Change the number of curves and/or points.

Warning
To avoid redundant writes, newly created attribute values are not initialized. They must be initialized by the caller afterwards.

Definition at line 1266 of file curves_geometry.cc.

◆ resolution()

How many evaluated points to create for each segment when evaluating Bezier, Catmull Rom, and NURBS curves. On the curve domain. Values must be one or greater.

Definition at line 416 of file curves_geometry.cc.

◆ resolution_for_write()

Mutable access to curve resolution. Call tag_topology_changed after changes.

Definition at line 421 of file curves_geometry.cc.

◆ reverse_curves()

void blender::bke::CurvesGeometry::reverse_curves ( const IndexMask & curves_to_reverse)

Change the direction of selected curves (switch the start and end) without changing their shape.

Definition at line 1740 of file curves_geometry.cc.

◆ surface_uv_coords()

UV coordinate for each curve that encodes where the curve is attached to the surface mesh.

Definition at line 555 of file curves_geometry.cc.

◆ surface_uv_coords_for_write()

◆ tag_material_index_changed()

Call after changing the "material_index" attribute.

Definition at line 1317 of file curves_geometry.cc.

◆ tag_normals_changed()

Call after changing the "tilt" or "up" attributes.

Definition at line 1309 of file curves_geometry.cc.

◆ tag_positions_changed()

Call after deforming the position attribute.

Definition at line 1290 of file curves_geometry.cc.

◆ tag_radii_changed()

Call when making manual changes to the "radius" attribute. The attribute API will also call this in #finish() calls.

Definition at line 1313 of file curves_geometry.cc.

◆ tag_topology_changed()

Call after any operation that changes the topology (number of points, evaluated points, or the total count).

Definition at line 1299 of file curves_geometry.cc.

◆ tilt()

The angle used to rotate evaluated normals around the tangents after their calculation. Call tag_normals_changed after changes.

Definition at line 438 of file curves_geometry.cc.

◆ tilt_for_write()

◆ transform()

Definition at line 1416 of file curves_geometry.cc.

◆ translate()

void blender::bke::CurvesGeometry::translate ( const float3 & translation)

Definition at line 1389 of file curves_geometry.cc.

◆ update_curve_types()

Update the cached count of curves of each type, necessary after curve_types_for_write.

Definition at line 361 of file curves_geometry.cc.


The documentation for this class was generated from the following files: