17 b.add_input<
decl::Geometry>(
"Curves").description(
"Either plain curves or curve instances");
22 .description(
"Either a curve or instance selection");
25 .
description(
"Create a separate layer for each instance");
47 grease_pencil->add_layers_with_empty_drawings_for_eval(1);
49 layer.set_name(layer_name);
54 const int materials_num = curves_id.
totcol;
72 if (instances_num == 0) {
82 const int layer_num = instance_selection.
size();
90 grease_pencil->add_layers_with_empty_drawings_for_eval(layer_num);
96 layer.set_name(reference.
name());
102 if (!instance_curves) {
107 strokes = instance_curves->
geometry.wrap();
118 for (
int &material_index : material_indices.
span) {
119 if (material_index >= 0 && material_index < new_material_indices.
size()) {
120 material_index = new_material_indices[material_index];
123 material_indices.
finish();
146 if (instance_selection.
size() == instances_num && src_attribute.
varray.
is_span() &&
150 grease_pencil_attributes.
add(
155 *src_attribute.sharing_info});
158 if (!grease_pencil_attributes.
add(
173 "opacity", AttrDomain::Instance, 1.0f);
174 instance_selection.
foreach_index([&](
const int instance_i,
const int layer_i) {
175 grease_pencil->layer(layer_i).opacity = opacities[instance_i];
179 return grease_pencil;
186 const bool instances_as_layers =
params.extract_input<
bool>(
"Instances as Layers");
190 if (instances_as_layers) {
196 params.set_default_remaining_outputs();
200 *instances, selection_field, attribute_filter);
208 params.set_default_remaining_outputs();
212 *curves_id, selection_field, curves_geometry.
name, attribute_filter);
216 grease_pencil_geometry.
name = std::move(curves_geometry.
name);
217 params.set_output(
"Grease Pencil", std::move(grease_pencil_geometry));
224 ntype.
ui_name =
"Curves to Grease Pencil";
225 ntype.
ui_description =
"Convert the curves in each top-level instance into Grease Pencil layer";
Low-level operations for curves.
Low-level operations for grease pencil.
GreasePencil * BKE_grease_pencil_new_nomain()
#define NODE_CLASS_GEOMETRY
#define GEO_NODE_CURVES_TO_GREASE_PENCIL
#define NOD_REGISTER_NODE(REGISTER_FUNC)
int64_t index_of_or_add(const Key &key)
void append(const T &value)
GAttributeReader lookup_or_default(StringRef attribute_id, AttrDomain domain, AttrType data_type, const void *default_value=nullptr) const
bool is_builtin(const StringRef attribute_id) const
void foreach_attribute(const FunctionRef< void(const AttributeIter &)> fn) const
GAttributeReader get() const
IndexRange curves_range() const
MutableAttributeAccessor attributes_for_write()
void remove_curves(const IndexMask &curves_to_delete, const AttributeFilter &attribute_filter)
void to_geometry_set(GeometrySet &r_geometry_set) const
StringRefNull name() const
Span< int > reference_handles() const
Span< float4x4 > transforms() const
Span< InstanceReference > references() const
bke::AttributeAccessor attributes() const
int instances_num() const
bool add(const StringRef attribute_id, const AttrDomain domain, const AttrType data_type, const AttributeInit &initializer)
GSpanAttributeWriter lookup_or_add_for_write_span(StringRef attribute_id, AttrDomain domain, AttrType data_type, const AttributeInit &initializer=AttributeInitDefaultValue())
GSpanAttributeWriter lookup_for_write_span(StringRef attribute_id)
bke::CurvesGeometry & strokes_for_write()
void set_local_transform(const float4x4 &transform)
void set_selection(Field< bool > selection)
IndexMask get_evaluated_selection_as_mask() const
IndexMask complement(const IndexMask &universe, IndexMaskMemory &memory) const
void foreach_index(Fn &&fn) const
void * MEM_calloc_arrayN(size_t len, size_t size, const char *str)
void gather(const GVArray &src, const IndexMask &indices, GMutableSpan dst, int64_t grain_size=4096)
void node_type_size(bNodeType &ntype, int width, int minwidth, int maxwidth)
void node_register_type(bNodeType &ntype)
static GreasePencil * curve_instances_to_grease_pencil_layers(const bke::Instances &instances, const Field< bool > &selection_field, const AttributeFilter &attribute_filter)
static void node_register()
static void node_geo_exec(GeoNodeExecParams params)
static GreasePencil * curves_to_grease_pencil_with_one_layer(const Curves &curves_id, const Field< bool > &selection_field, const StringRefNull layer_name, const AttributeFilter &attribute_filter)
static void node_declare(NodeDeclarationBuilder &b)
void initialized_copy_n(const T *src, int64_t n, T *dst)
void geo_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
struct Material ** material_array
bool allow_skip(const StringRef name) const
const ImplicitSharingInfo * sharing_info
const Curves * get_curves() const
const Instances * get_instances() const
bool has_instances() const
MutableVArraySpan< T > span
std::string ui_description
NodeGeometryExecFunction geometry_node_execute
const char * enum_name_legacy
NodeDeclareFunction declare
static GeometrySet from_grease_pencil(GreasePencil *grease_pencil, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)