34 auto &count =
b.add_input<
decl::Int>(
"Count"_ustr)
38 .evaluated_geometry_field()
46 .evaluated_geometry_field()
51 b.add_output<
decl::Vector>(
"Tangent"_ustr).anonymous_attribute_output();
52 b.add_output<
decl::Vector>(
"Normal"_ustr).anonymous_attribute_output();
53 b.add_output<
decl::Rotation>(
"Rotation"_ustr).anonymous_attribute_output();
56 if (
node !=
nullptr) {
83 for (const int i : range) {
84 const float3 tangent = tangents[i];
85 BLI_assert(math::is_unit(tangent));
86 const float3 binormal = math::normalize(math::cross(tangent, normals[i]));
87 const float3 normal = math::cross(binormal, tangent);
88 rotations[i] = math::to_quaternion(float3x3{normal, binormal, tangent});
101 if (iter.
domain != AttrDomain::Curve) {
110 point_attributes.
add(iter.
name,
121 const std::optional<StringRef> &rotation_id)
146 pointcloud->attributes_for_write());
169 if (!pointcloud_by_layer.
is_empty()) {
170 auto instances = std::make_unique<bke::Instances>(pointcloud_by_layer.
size());
173 for (
const int i : pointcloud_by_layer.
index_range()) {
174 PointCloud *pointcloud = pointcloud_by_layer[i];
190 instances->attributes_for_write());
208 std::optional<std::string> rotation_anonymous_id =
210 const bool need_tangent_and_normal = bool(rotation_anonymous_id);
211 std::optional<std::string> tangent_anonymous_id =
213 std::optional<std::string> normal_anonymous_id =
217 resample_attributes.
tangent_id = tangent_anonymous_id;
218 resample_attributes.
normal_id = normal_anonymous_id;
227 src_curves_id->geometry.wrap(),
231 resample_attributes);
233 dst_curves, attribute_filter, resample_attributes, rotation_anonymous_id);
234 geometry.replace_pointcloud(pointcloud);
238 for (
const int layer_index :
grease_pencil->layers().index_range()) {
241 if (drawing ==
nullptr) {
249 resample_attributes);
251 dst_curves, attribute_filter, resample_attributes, rotation_anonymous_id);
266 src_curves_id->geometry.wrap(),
270 resample_attributes);
272 dst_curves, attribute_filter, resample_attributes, rotation_anonymous_id);
273 geometry.replace_pointcloud(pointcloud);
277 for (
const int layer_index :
grease_pencil->layers().index_range()) {
280 if (drawing ==
nullptr) {
288 resample_attributes);
290 dst_curves, attribute_filter, resample_attributes, rotation_anonymous_id);
304 src_curves_id->geometry.wrap(),
307 resample_attributes);
309 dst_curves, attribute_filter, resample_attributes, rotation_anonymous_id);
310 geometry.replace_pointcloud(pointcloud);
315 for (
const int layer_index :
grease_pencil->layers().index_range()) {
318 if (drawing ==
nullptr) {
325 resample_attributes);
327 dst_curves, attribute_filter, resample_attributes, rotation_anonymous_id);
339 params.
set_output(
"Points"_ustr, std::move(geometry_set));
349 "Create points from the curve's evaluated points, based on the resolution attribute for "
350 "NURBS and Bézier splines"},
355 "Sample each spline by evenly distributing the specified number of points"},
360 "Sample each spline by splitting it into segments with the specified length"},
361 {0,
nullptr, 0,
nullptr,
nullptr},
367 "How to generate points from the input curve",
378 ntype.
ui_name =
"Curve to Points";
379 ntype.
ui_description =
"Generate a point cloud by sampling positions along curves";
CustomData interface, see also DNA_customdata_types.h.
Low-level operations for grease pencil.
#define NODE_STORAGE_FUNCS(StorageT)
#define NODE_CLASS_GEOMETRY
#define GEO_NODE_CURVE_TO_POINTS
General operations for point clouds.
#define NOD_REGISTER_NODE(REGISTER_FUNC)
#define NOD_storage_enum_accessors(member)
constexpr IndexRange()=default
constexpr int64_t size() const
constexpr void fill(const T &value) const
constexpr int64_t size() const
constexpr IndexRange index_range() const
constexpr bool is_empty() const
void foreach_attribute(const FunctionRef< void(const AttributeIter &)> fn) const
GAttributeReader lookup(const StringRef name) const
bool is_builtin(const StringRef name) const
GAttributeReader get() const
void replace(Instances *instances, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
bool add(const StringRef name, const AttrDomain domain, const AttrType data_type, const AttributeInit &initializer)
GSpanAttributeWriter lookup_or_add_for_write_only_span(StringRef name, AttrDomain domain, AttrType data_type)
const bke::CurvesGeometry & strokes() const
NodeAttributeFilter get_attribute_filter(const UString output_identifier) const
std::optional< std::string > get_output_anonymous_attribute_id_if_needed(const UString output_identifier, const bool force_create=false)
T extract_input(const UString identifier)
const bNode & node() const
void set_output(const UString identifier, T &&value)
static void remember_deformed_positions_if_necessary(GeometrySet &geometry)
#define storage(slot, qualifiers)
float length(VecOp< float, D >) RET
PointCloud * pointcloud_new_no_attributes(PointCloudType type, int totpoint)
void node_register_type(bNodeType &ntype)
void copy_attributes(const AttributeAccessor src_attributes, AttrDomain src_domain, AttrDomain dst_domain, const AttributeFilter &attribute_filter, MutableAttributeAccessor dst_attributes)
void node_type_storage(bNodeType &ntype, std::optional< StringRefNull > storagename, void(*freefunc)(bNode *node), void(*copyfunc)(bNodeTree *dest_ntree, bNode *dest_node, const bNode *src_node))
bke::GeometrySet join_geometries(Span< bke::GeometrySet > geometries, const bke::AttributeFilter &attribute_filter, const std::optional< Span< bke::GeometryComponent::Type > > &component_types_to_join=std::nullopt, bool allow_merging_instance_references=true)
void foreach_real_geometry(bke::GeometrySet &geometry, FunctionRef< void(bke::GeometrySet &geometry_set)> fn)
CurvesGeometry resample_to_count(const CurvesGeometry &src_curves, const IndexMask &selection, const VArray< int > &counts, const ResampleCurvesOutputAttributeIDs &output_ids={})
CurvesGeometry resample_to_evaluated(const CurvesGeometry &src_curves, const IndexMask &selection, const ResampleCurvesOutputAttributeIDs &output_ids={})
CurvesGeometry resample_to_length(const CurvesGeometry &src_curves, const IndexMask &selection, const VArray< float > &sample_lengths, const ResampleCurvesOutputAttributeIDs &output_ids={}, bool keep_last_segment=false)
QuaternionBase< float > Quaternion
static void node_register()
static PointCloud * curves_to_points(const bke::CurvesGeometry &curves, const AttributeFilter &attribute_filter, const geometry::ResampleCurvesOutputAttributeIDs &resample_attributes, const std::optional< StringRef > &rotation_id)
static void node_geo_exec(GeoNodeExecParams params)
static void node_declare(NodeDeclarationBuilder &b)
static void copy_curve_domain_attributes(const AttributeAccessor curve_attributes, const AttributeFilter &attribute_filter, MutableAttributeAccessor point_attributes)
static void node_layout(ui::Layout &layout, bContext *, PointerRNA *ptr)
static void node_init(bNodeTree *, bNode *node)
static void fill_rotation_attribute(const Span< float3 > tangents, const Span< float3 > normals, MutableSpan< math::Quaternion > rotations)
static void layer_pointclouds_to_instances(const Span< PointCloud * > pointcloud_by_layer, const AttributeFilter &attribute_filter, GeometrySet &geometry)
static void node_rna(StructRNA *srna)
PropertyRNA * RNA_def_node_enum(StructRNA *srna, const char *identifier, const char *ui_name, const char *ui_description, const EnumPropertyItem *static_items, const EnumRNAAccessors accessors, std::optional< int > default_value, const EnumPropertyItemFunc item_func, const bool allow_animation)
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
BMesh const char void * data
void node_copy_standard_storage(bNodeTree *, bNode *dest_node, const bNode *src_node)
void node_free_standard_storage(bNode *node)
VecBase< float, 3 > float3
GeometryNodeCurveResampleMode
@ GEO_NODE_CURVE_RESAMPLE_LENGTH
@ GEO_NODE_CURVE_RESAMPLE_COUNT
@ GEO_NODE_CURVE_RESAMPLE_EVALUATED
void geo_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
static MatBase identity()
bool allow_skip(const StringRef name) const
void(*) draw_buttons(ui::Layout &, bContext *C, PointerRNA *ptr)
std::string ui_description
NodeGeometryExecFunction geometry_node_execute
void(*) initfunc(bNodeTree *ntree, bNode *node)
const char * enum_name_legacy
NodeDeclareFunction declare
std::optional< std::string > tangent_id
std::optional< std::string > normal_id
static GeometrySet from_instances(std::unique_ptr< Instances > instances)
static GeometrySet from_pointcloud(PointCloud *pointcloud, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< StringRef > name_opt, int icon, std::optional< StringRef > placeholder=std::nullopt)