99 if (
params.node_tree().typeinfo->validate_link(
124 memmove(
data.data(), &
data[start_index],
sizeof(
T) * num);
142 data.first() = start_data;
143 data[num - 1] = end_data;
162 dst.
first() = start_data;
163 dst.
last() = end_data;
175 const int left = offsets[index] >
lookup.evaluated_index ? index - 1 : index;
178 const float offset_in_segment =
lookup.evaluated_index +
lookup.factor - offsets[
left];
179 const int segment_eval_num = offsets[
left + 1] - offsets[
left];
180 const float factor =
std::clamp(offset_in_segment / segment_eval_num, 0.0f, 1.0f);
197 linear_trim_data<float3>(start, end, spline.
positions());
198 linear_trim_data<float>(start, end, spline.
radii());
199 linear_trim_data<float>(start, end, spline.
tilts());
206 using T = decltype(dummy);
207 linear_trim_data<T>(start, end, src->typed<T>());
248 using T = decltype(dummy);
249 VArray<T> eval_data = spline.interpolate_to_evaluated<T>(src->typed<T>());
250 linear_trim_to_output_data<T>(
251 start, end, eval_data.get_internal_span(), dst->typed<T>());
257 linear_trim_to_output_data<float3>(
261 linear_trim_to_output_data<float>(
265 linear_trim_to_output_data<float>(
291 linear_trim_data<float>(start, end, bezier_spline.
radii());
292 linear_trim_data<float>(start, end, bezier_spline.
tilts());
298 using T = decltype(dummy);
299 linear_trim_data<T>(start, end, src->typed<T>());
309 if (start_lookup.
factor == 1.0f) {
363 bezier_spline.
resize(num);
370 switch (spline->type()) {
384 spline->mark_cache_invalid();
412 to_single_point_data<float>(
trim, bezier.
radii());
413 to_single_point_data<float>(
trim, bezier.
tilts());
418 using T = decltype(dummy);
419 to_single_point_data<T>(trim, data->typed<T>());
432 to_single_point_data<float>(
trim, spline.
radii());
433 to_single_point_data<float>(
trim, spline.
tilts());
438 using T = decltype(dummy);
439 to_single_point_data<T>(trim, data->typed<T>());
462 using T = decltype(dummy);
463 VArray<T> eval_data = spline.interpolate_to_evaluated<T>(src->typed<T>());
464 to_single_point_data<T>(trim, eval_data.get_internal_span(), dst->typed<T>());
483 switch (spline->type()) {
513 evaluator.
add(start_field);
514 evaluator.add(end_field);
515 evaluator.evaluate();
516 const VArray<float> starts = evaluator.get_evaluated<
float>(0);
517 const VArray<float> ends = evaluator.get_evaluated<
float>(1);
524 for (const int i : range) {
525 SplinePtr &spline = splines[i];
528 if (spline->is_cyclic()) {
532 if (spline->evaluated_edges_num() == 0) {
536 const float length = spline->length();
537 if (length == 0.0f) {
541 const float start = starts[i];
542 const float end = ends[i];
547 if (mode == GEO_NODE_CURVE_SAMPLE_LENGTH) {
548 to_single_point_spline(spline,
549 spline->lookup_evaluated_length(std::clamp(start, 0.0f, length)));
552 to_single_point_spline(spline,
553 spline->lookup_evaluated_factor(std::clamp(start, 0.0f, 1.0f)));
558 if (mode == GEO_NODE_CURVE_SAMPLE_LENGTH) {
560 spline->lookup_evaluated_length(std::clamp(start, 0.0f, length)),
561 spline->lookup_evaluated_length(std::clamp(end, 0.0f, length)));
565 spline->lookup_evaluated_factor(std::clamp(start, 0.0f, 1.0f)),
566 spline->lookup_evaluated_factor(std::clamp(end, 0.0f, 1.0f)));
573 geometry_set.replace_curves(dst_curves_id);
587 geometry_set.modify_geometry_sets([&](
GeometrySet &geometry_set) {
594 geometry_set.modify_geometry_sets([&](
GeometrySet &geometry_set) {
599 params.set_output(
"Curve", std::move(geometry_set));
Low-level operations for curves.
@ GEO_COMPONENT_TYPE_CURVE
void node_type_update(struct bNodeType *ntype, void(*updatefunc)(struct bNodeTree *ntree, struct bNode *node))
#define NODE_STORAGE_FUNCS(StorageT)
void nodeSetSocketAvailability(struct bNodeTree *ntree, struct bNodeSocket *sock, bool is_available)
void node_type_init(struct bNodeType *ntype, void(*initfunc)(struct bNodeTree *ntree, struct bNode *node))
#define NODE_CLASS_GEOMETRY
#define GEO_NODE_TRIM_CURVE
void node_type_storage(struct bNodeType *ntype, const char *storagename, void(*freefunc)(struct bNode *node), void(*copyfunc)(struct bNodeTree *dest_ntree, struct bNode *dest_node, const struct bNode *src_node))
void nodeRegisterType(struct bNodeType *ntype)
std::unique_ptr< Spline > SplinePtr
std::unique_ptr< CurveEval > curves_to_curve_eval(const Curves &curves)
Curves * curve_eval_to_curves(const CurveEval &curve_eval)
#define BLI_assert_unreachable()
static uint8 component(Color32 c, uint i)
GeometryNodeCurveSampleMode
@ GEO_NODE_CURVE_SAMPLE_FACTOR
@ GEO_NODE_CURVE_SAMPLE_LENGTH
_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
void uiItemR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int flag, const char *name, int icon)
blender::MutableSpan< float > tilts() final
blender::Span< blender::float3 > handle_positions_right() const
void resize(int size) final
blender::Span< blender::float3 > handle_positions_left() const
InsertResult calculate_segment_insertion(int index, int next_index, float parameter)
blender::Span< int8_t > handle_types_left() const
blender::Span< int > control_point_offsets() const
blender::Span< int8_t > handle_types_right() const
blender::MutableSpan< blender::float3 > positions() final
blender::MutableSpan< float > radii() final
static void remember_deformed_curve_positions_if_necessary(GeometrySet &geometry)
blender::MutableSpan< float > tilts() final
blender::MutableSpan< float > radii() final
blender::MutableSpan< blender::float3 > positions() final
void resize(int size) final
virtual blender::MutableSpan< blender::float3 > positions()=0
virtual blender::MutableSpan< float > tilts()=0
virtual void resize(int size)=0
blender::bke::CustomDataAttributes attributes
virtual blender::MutableSpan< float > radii()=0
virtual blender::GVArray interpolate_to_evaluated(const blender::GVArray &src) const =0
virtual blender::Span< blender::float3 > evaluated_positions() const =0
constexpr T & last(const int64_t n=0) const
constexpr void copy_from(Span< T > values)
constexpr T & first() const
constexpr const T * end() const
constexpr const T * begin() const
Span< T > get_internal_span() const
std::optional< blender::GSpan > get_for_read(const AttributeIDRef &attribute_id) const
bool create(const AttributeIDRef &attribute_id, eCustomDataType data_type)
std::optional< blender::GMutableSpan > get_for_write(const AttributeIDRef &attribute_id)
bool foreach_attribute(const AttributeForeachCallback callback, eAttrDomain domain) const
int add(GField field, GVArray *varray_ptr)
Span< SocketDeclarationPtr > outputs() const
Span< SocketDeclarationPtr > inputs() const
void operator()(LinkSearchOpParams ¶ms)
GeometryNodeCurveSampleMode mode
SyclQueue void void * src
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
static char * trim(char *str)
void convert_to_static_type(const CPPType &cpp_type, const Func &func)
T mix2(float factor, const T &a, const T &b)
GAttributeReader lookup(const void *owner, const AttributeIDRef &attribute_id)
void curves_copy_parameters(const Curves &src, Curves &dst)
T clamp(const T &a, const T &min, const T &max)
static PolySpline to_single_point_nurbs(const Spline &spline, const Spline::LookupResult &lookup)
static void trim_poly_spline(Spline &spline, const Spline::LookupResult &start_lookup, const Spline::LookupResult &end_lookup)
static void linear_trim_data(const TrimLocation &start, const TrimLocation &end, MutableSpan< T > data)
static void geometry_set_curve_trim(GeometrySet &geometry_set, const GeometryNodeCurveSampleMode mode, Field< float > &start_field, Field< float > &end_field)
static void node_init(bNodeTree *UNUSED(tree), bNode *node)
static void shift_slice_to_start(MutableSpan< T > data, const int start_index, const int num)
static PolySpline trim_nurbs_spline(const Spline &spline, const Spline::LookupResult &start_lookup, const Spline::LookupResult &end_lookup)
static TrimLocation lookup_control_point_position(const Spline::LookupResult &lookup, const BezierSpline &spline)
static void node_declare(NodeDeclarationBuilder &b)
static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms)
static void node_update(bNodeTree *ntree, bNode *node)
static void trim_bezier_spline(Spline &spline, const Spline::LookupResult &start_lookup, const Spline::LookupResult &end_lookup)
static void to_single_point_poly(Spline &spline, const Spline::LookupResult &lookup)
static void trim_spline(SplinePtr &spline, const Spline::LookupResult start, const Spline::LookupResult end)
static void linear_trim_to_output_data(const TrimLocation &start, const TrimLocation &end, Span< T > src, MutableSpan< T > dst)
static void to_single_point_spline(SplinePtr &spline, const Spline::LookupResult &lookup)
static void node_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
static void to_single_point_bezier(Spline &spline, const Spline::LookupResult &lookup)
static void to_single_point_data(const TrimLocation &trim, MutableSpan< T > data)
static void node_geo_exec(GeoNodeExecParams params)
void search_link_ops_for_declarations(GatherLinkSearchOpParams ¶ms, Span< SocketDeclarationPtr > declarations)
void parallel_for(IndexRange range, int64_t grain_size, const Function &function)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
static void node_init(const struct bContext *C, bNodeTree *ntree, bNode *node)
void register_node_type_geo_curve_trim()
void geo_node_type_base(bNodeType *ntype, int type, const char *name, short nclass)
void node_copy_standard_storage(bNodeTree *UNUSED(dest_ntree), bNode *dest_node, const bNode *src_node)
void node_free_standard_storage(bNode *node)
blender::float3 right_handle
blender::float3 left_handle
blender::float3 handle_prev
blender::float3 handle_next
GeometryComponent & get_component_for_write(GeometryComponentType component_type)
const Curves * get_curves_for_read() const
struct bNodeSocket * next
NodeGeometryExecFunction geometry_node_execute
NodeGatherSocketLinkOperationsFunction gather_link_search_ops
void(* draw_buttons)(struct uiLayout *, struct bContext *C, struct PointerRNA *ptr)
NodeDeclareFunction declare