46 .make_available([](
bNode &node) {
54 const bNode *node =
b.node_or_null();
55 if (node !=
nullptr) {
82 for (const int i : range) {
83 rotations[i] = math::to_quaternion(
84 math::from_orthonormal_axes<float4x4>(normals[i], tangents[i]));
96 if (iter.
domain != AttrDomain::Curve) {
102 point_attributes.
add(iter.
name,
110 const std::optional<StringRef> &tangent_id,
111 const std::optional<StringRef> &
normal_id,
115 pointcloud->
totpoint = curves.points_num();
119 const VArraySpan tangents = *attributes.lookup<
float3>(*tangent_id, AttrDomain::Point);
130 pointcloud->
pdata = curves.point_data;
142 const std::optional<StringRef> &rotation_anonymous_id)
148 if (
const Curves *src_curves_id = geometry.get_curves()) {
154 fn::make_constant_field<bool>(
true),
156 resample_attributes);
160 rotation_anonymous_id);
161 geometry.remove_geometry_during_modify();
162 geometry.replace_pointcloud(pointcloud);
170 if (
const Curves *src_curves_id = geometry.get_curves()) {
176 fn::make_constant_field<bool>(
true),
178 resample_attributes);
182 rotation_anonymous_id);
183 geometry.remove_geometry_during_modify();
184 geometry.replace_pointcloud(pointcloud);
191 if (
const Curves *src_curves_id = geometry.get_curves()) {
195 src_curves, field_context, fn::make_constant_field<bool>(
true), resample_attributes);
199 rotation_anonymous_id);
200 geometry.remove_geometry_during_modify();
201 geometry.replace_pointcloud(pointcloud);
213 const std::optional<StringRef> &rotation_anonymous_id,
232 if (geometry.has_grease_pencil()) {
233 const GreasePencil &grease_pencil = *geometry.get_grease_pencil();
235 for (
const int layer_index : grease_pencil.layers().index_range()) {
236 const Drawing *drawing = grease_pencil.get_eval_drawing(grease_pencil.layer(layer_index));
237 if (drawing ==
nullptr) {
242 grease_pencil, AttrDomain::Curve, layer_index);
247 dst_curves = geometry::resample_to_count(src_curves,
249 fn::make_constant_field<bool>(
true),
251 resample_attributes);
255 dst_curves = geometry::resample_to_length(src_curves,
257 fn::make_constant_field<bool>(
true),
259 resample_attributes);
263 dst_curves = geometry::resample_to_evaluated(src_curves,
265 fn::make_constant_field<bool>(
true),
266 resample_attributes);
273 rotation_anonymous_id);
275 if (!pointcloud_by_layer.
is_empty()) {
277 for (
PointCloud *pointcloud : pointcloud_by_layer) {
283 instances->add_instance(handle, float4x4::identity());
286 GeometrySet temp_set = GeometrySet::from_pointcloud(pointcloud);
288 instances->add_instance(handle, float4x4::identity());
290 GeometrySet::propagate_attributes_from_layer_to_instances(
291 geometry.get_grease_pencil()->attributes(),
292 instances->attributes_for_write(),
295 GeometrySet new_instances = geometry::join_geometries(
296 {GeometrySet::from_instances(dst_component.
release()),
297 GeometrySet::from_instances(instances)},
313 GeometryComponentEditData::remember_deformed_positions_if_necessary(geometry_set);
315 std::optional<std::string> rotation_anonymous_id =
316 params.get_output_anonymous_attribute_id_if_needed(
"Rotation");
317 const bool need_tangent_and_normal = bool(rotation_anonymous_id);
318 std::optional<std::string> tangent_anonymous_id =
319 params.get_output_anonymous_attribute_id_if_needed(
"Tangent", need_tangent_and_normal);
320 std::optional<std::string> normal_anonymous_id =
321 params.get_output_anonymous_attribute_id_if_needed(
"Normal", need_tangent_and_normal);
324 resample_attributes.
tangent_id = tangent_anonymous_id;
325 resample_attributes.
normal_id = normal_anonymous_id;
333 geometry_set,
params, mode, resample_attributes, rotation_anonymous_id, attribute_filter);
336 params.set_output(
"Points", std::move(geometry_set));
346 "Create points from the curve's evaluated points, based on the resolution attribute for "
347 "NURBS and Bézier splines"},
352 "Sample each spline by evenly distributing the specified number of points"},
357 "Sample each spline by splitting it into segments with the specified length"},
358 {0,
nullptr, 0,
nullptr,
nullptr},
364 "How to generate points from the input curve",
CustomData interface, see also DNA_customdata_types.h.
void CustomData_reset(CustomData *data)
void CustomData_free(CustomData *data, int totelem)
Low-level operations for grease pencil.
#define NODE_STORAGE_FUNCS(StorageT)
#define NODE_CLASS_GEOMETRY
General operations for point clouds.
PointCloud * BKE_pointcloud_new_nomain(int totpoint)
GeometryNodeCurveResampleMode
@ GEO_NODE_CURVE_RESAMPLE_LENGTH
@ GEO_NODE_CURVE_RESAMPLE_EVALUATED
@ GEO_NODE_CURVE_RESAMPLE_COUNT
#define NOD_REGISTER_NODE(REGISTER_FUNC)
#define NOD_storage_enum_accessors(member)
void uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, eUI_Item_Flag flag, const char *name, int icon)
SIMD_FORCE_INLINE btScalar length() const
Return the length of the vector.
constexpr int64_t size() const
void foreach_attribute(const FunctionRef< void(const AttributeIter &)> fn) const
eCustomDataType data_type
GAttributeReader get() const
void replace(Instances *instances, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
bool add(const StringRef attribute_id, const AttrDomain domain, const eCustomDataType data_type, const AttributeInit &initializer)
const bke::CurvesGeometry & strokes() const
void make_available(bNode &node) const
local_group_size(16, 16) .push_constant(Type b
void node_type_storage(bNodeType *ntype, const char *storagename, void(*freefunc)(bNode *node), void(*copyfunc)(bNodeTree *dest_ntree, bNode *dest_node, const bNode *src_node))
void node_register_type(bNodeType *ntype)
static void node_register()
static void node_geo_exec(GeoNodeExecParams params)
static void node_declare(NodeDeclarationBuilder &b)
static void copy_curve_domain_attributes(const AttributeAccessor curve_attributes, MutableAttributeAccessor point_attributes)
static void node_init(bNodeTree *, bNode *node)
static void grease_pencil_to_points(GeometrySet &geometry_set, GeoNodeExecParams params, const GeometryNodeCurveResampleMode mode, geometry::ResampleCurvesOutputAttributeIDs resample_attributes, const std::optional< StringRef > &rotation_anonymous_id, const AttributeFilter &attribute_filter)
static void fill_rotation_attribute(const Span< float3 > tangents, const Span< float3 > normals, MutableSpan< math::Quaternion > rotations)
static void curve_to_points(GeometrySet &geometry_set, GeoNodeExecParams params, const GeometryNodeCurveResampleMode mode, geometry::ResampleCurvesOutputAttributeIDs resample_attributes, const std::optional< StringRef > &rotation_anonymous_id)
static PointCloud * pointcloud_from_curves(bke::CurvesGeometry curves, const std::optional< StringRef > &tangent_id, const std::optional< StringRef > &normal_id, const std::optional< StringRef > &rotation_id)
static void node_rna(StructRNA *srna)
static void node_layout(uiLayout *layout, bContext *, PointerRNA *ptr)
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))
std::optional< std::string > rotation_id
std::optional< std::string > normal_id
void geo_node_type_base(blender::bke::bNodeType *ntype, int type, const char *name, short nclass)
void node_free_standard_storage(bNode *node)
void node_copy_standard_storage(bNodeTree *, bNode *dest_node, const bNode *src_node)
bool has_grease_pencil() const
void modify_geometry_sets(ForeachSubGeometryCallback callback)
void replace_grease_pencil(GreasePencil *grease_pencil, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
void(* initfunc)(bNodeTree *ntree, bNode *node)
NodeGeometryExecFunction geometry_node_execute
void(* draw_buttons)(uiLayout *, bContext *C, PointerRNA *ptr)
NodeDeclareFunction declare
std::optional< std::string > tangent_id
std::optional< std::string > normal_id