49 if (spline->type() ==
type) {
64 splines_.
append(std::move(spline));
76 for (
int i =
mask.size() - 1; i >= 0; i--) {
84 spline->translate(translation);
85 spline->mark_cache_invalid();
92 spline->transform(matrix);
98 bool have_minmax =
false;
100 if (spline->size()) {
101 spline->bounds_min_max(
min,
max, use_evaluated);
113 length += spline->length();
122 count += spline->size();
145 offset += splines_[i]->evaluated_points_num();
154 float spline_length = 0.0f;
156 spline_lengths[i] = spline_length;
157 spline_length += splines_[i]->length();
159 spline_lengths.
last() = spline_length;
160 return spline_lengths;
166 spline->mark_cache_invalid();
172 switch (dna_handle_type) {
192 switch (twist_mode) {
222 std::unique_ptr<BezierSpline> spline = std::make_unique<BezierSpline>();
223 spline->set_resolution(nurb.
resolu);
227 spline->resize(src_points.size());
237 for (const int i : range) {
238 const BezTriple &bezt = src_points[i];
239 positions[i] = bezt.vec[1];
240 handle_positions_left[i] = bezt.vec[0];
241 handle_types_left[i] = handle_type_from_dna_bezt((eBezTriple_Handle)bezt.h1);
242 handle_positions_right[i] = bezt.vec[2];
243 handle_types_right[i] = handle_type_from_dna_bezt((eBezTriple_Handle)bezt.h2);
244 radii[i] = bezt.radius;
245 tilts[i] = bezt.tilt;
254 std::unique_ptr<NURBSpline> spline = std::make_unique<NURBSpline>();
255 spline->set_resolution(nurb.
resolu);
257 spline->set_order(nurb.
orderu);
261 spline->resize(src_points.size());
268 for (const int i : range) {
269 const BPoint &bp = src_points[i];
270 positions[i] = bp.vec;
271 weights[i] = bp.vec[3];
272 radii[i] = bp.radius;
282 std::unique_ptr<PolySpline> spline = std::make_unique<PolySpline>();
286 spline->resize(src_points.size());
292 for (const int i : range) {
293 const BPoint &bp = src_points[i];
294 positions[i] = bp.vec;
295 radii[i] = bp.radius;
308 std::unique_ptr<CurveEval>
curve = std::make_unique<CurveEval>();
313 for (const int i : range) {
314 switch (nurbs[i]->type) {
316 splines[i] = spline_from_dna_bezier(*nurbs[i]);
319 splines[i] = spline_from_dna_nurbs(*nurbs[i]);
322 splines[i] = spline_from_dna_poly(*nurbs[i]);
325 BLI_assert_unreachable();
335 spline->normal_mode = normal_mode;
352 if (
id.is_named() && skip.
contains(
id.name())) {
357 if (!src_attribute) {
364 if (!dst_attribute) {
398 std::unique_ptr<CurveEval> curve_eval = std::make_unique<CurveEval>();
399 for (
const int curve_index : curve_types.
index_range()) {
402 std::unique_ptr<Spline> spline;
404 switch (std::max<int8_t>(1, curve_types[curve_index])) {
406 spline = std::make_unique<PolySpline>();
407 spline->resize(points.
size());
411 std::unique_ptr<BezierSpline> bezier_spline = std::make_unique<BezierSpline>();
412 bezier_spline->resize(points.
size());
413 bezier_spline->set_resolution(resolution[curve_index]);
414 bezier_spline->handle_types_left().copy_from(handle_types_left.slice(points));
415 bezier_spline->handle_types_right().copy_from(handle_types_right.slice(points));
417 spline = std::move(bezier_spline);
421 std::unique_ptr<NURBSpline> nurb_spline = std::make_unique<NURBSpline>();
422 nurb_spline->resize(points.
size());
423 nurb_spline->set_resolution(resolution[curve_index]);
424 nurb_spline->weights().copy_from(nurbs_weights.slice(points));
425 nurb_spline->set_order(nurbs_orders[curve_index]);
426 nurb_spline->knots_mode =
static_cast<KnotsMode>(nurbs_knots_modes[curve_index]);
428 spline = std::move(nurb_spline);
436 spline->positions().fill(
float3(0));
437 spline->tilts().fill(0.0f);
438 spline->radii().fill(1.0f);
439 spline->normal_mode =
static_cast<NormalMode>(normal_mode[curve_index]);
440 curve_eval->add_spline(std::move(spline));
443 curve_eval->attributes.reallocate(curve_eval->splines().size());
458 "handle_type_left"});
497 for (
const int curve_index : curve_eval.
splines().index_range()) {
499 curve_types[curve_index] = curve_eval.
splines()[curve_index]->type();
500 normal_mode.
span[curve_index] = curve_eval.
splines()[curve_index]->normal_mode;
503 switch (spline.
type()) {
508 handle_type_right.
span.slice(points).copy_from(
src.handle_types_right());
509 handle_type_left.
span.slice(points).copy_from(
src.handle_types_left());
514 nurbs_knots_mode.
span[curve_index] =
static_cast<int8_t>(
src.knots_mode);
515 nurbs_order.
span[curve_index] =
src.order();
516 nurbs_weight.span.slice(points).copy_from(
src.weights());
526 curves.update_curve_types();
529 nurbs_weight.finish();
531 nurbs_knots_mode.
finish();
532 handle_type_right.
finish();
533 handle_type_left.
finish();
547 if (splines_.
size() == 0) {
550 const int layer_len = splines_.
first()->attributes.data.totlayer;
557 splines_.
first()->attributes.foreach_attribute(
559 ids_in_order[i] = attribute_id;
560 meta_data_in_order[i] = meta_data;
567 for (
const SplinePtr &spline : splines_) {
569 BLI_assert(spline->attributes.data.totlayer == layer_len);
572 spline->attributes.foreach_attribute(
578 BLI_assert(meta_data == meta_data_in_order[i]);
const ListBase * BKE_curve_nurbs_get_for_read(const struct Curve *cu)
Low-level operations for curves.
std::unique_ptr< Spline > SplinePtr
#define BLI_assert_unreachable()
@ NORMAL_MODE_MINIMUM_TWIST
@ NURBS_KNOT_MODE_ENDPOINT
@ NURBS_KNOT_MODE_ENDPOINT_BEZIER
_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
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 Map
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
void replace(CurveEval *curve, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
std::optional< blender::bke::AttributeAccessor > attributes() const final
std::optional< blender::bke::MutableAttributeAccessor > attributes_for_write() final
void replace(Curves *curve, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
std::optional< blender::bke::MutableAttributeAccessor > attributes_for_write() final
const T & last(const int64_t n=0) const
void set_all(const void *src)
constexpr int64_t size() const
constexpr bool contains(const T &value) const
IndexRange index_range() const
void remove_and_reorder(const int64_t index)
void append(const T &value)
IndexRange index_range() const
void resize(const int64_t new_size)
GAttributeReader lookup(const AttributeIDRef &attribute_id) const
GVArray lookup_or_default(const AttributeIDRef &attribute_id, const eAttrDomain domain, const eCustomDataType data_type, const void *default_value=nullptr) const
bool for_all(const AttributeForeachCallback fn) const
static CurvesGeometry & wrap(::CurvesGeometry &dna_struct)
void reallocate(int size)
GSpanAttributeWriter lookup_or_add_for_write_only_span(const AttributeIDRef &attribute_id, const eAttrDomain domain, const eCustomDataType data_type)
GAttributeWriter lookup_or_add_for_write(const AttributeIDRef &attribute_id, const eAttrDomain domain, const eCustomDataType data_type, const AttributeInit &initializer=AttributeInitDefault())
static SplinePtr spline_from_dna_nurbs(const Nurb &nurb)
std::unique_ptr< CurveEval > curve_eval_from_dna_curve(const Curve &dna_curve, const ListBase &nurbs_list)
std::unique_ptr< CurveEval > curves_to_curve_eval(const Curves &curves_id)
static SplinePtr spline_from_dna_poly(const Nurb &nurb)
static KnotsMode knots_mode_from_dna_nurb(const short flag)
static SplinePtr spline_from_dna_bezier(const Nurb &nurb)
static HandleType handle_type_from_dna_bezt(const eBezTriple_Handle dna_handle_type)
Curves * curve_eval_to_curves(const CurveEval &curve_eval)
static void copy_attributes_between_components(const blender::bke::AttributeAccessor &src_attributes, blender::bke::MutableAttributeAccessor &dst_attributes, Span< std::string > skip)
static NormalMode normal_mode_from_dna_curve(const int twist_mode)
SyclQueue void void * src
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)
Curves * curves_new_nomain(int points_num, int curves_num)
T length(const vec_base< T, Size > &a)
void parallel_for(IndexRange range, int64_t grain_size, const Function &function)
vec_base< float, 3 > float3
MutableSpan< float3 > positions
MutableSpan< float > radii
blender::Array< int > control_point_offsets() const
blender::Span< SplinePtr > splines() const
void mark_cache_invalid()
void translate(const blender::float3 &translation)
blender::Array< float > accumulated_spline_lengths() const
blender::bke::CustomDataAttributes attributes
blender::Array< int > evaluated_point_offsets() const
int total_control_point_num() const
void assert_valid_point_attributes() const
float total_length() const
bool bounds_min_max(blender::float3 &min, blender::float3 &max, bool use_evaluated) const
void add_spline(SplinePtr spline)
void add_splines(blender::MutableSpan< SplinePtr > splines)
void transform(const blender::float4x4 &matrix)
bool has_spline_with_type(const CurveType type) const
void remove_splines(blender::IndexMask mask)
MutableVArraySpan< T > span