22 {-1,
"DOWN", 0,
"Down",
""},
23 {1,
"UP", 0,
"Up",
""},
24 {0,
nullptr, 0,
nullptr,
nullptr},
42static void rna_GreasePencilDrawing_add_curves(
ID *grease_pencil_id,
51 if (!rna_CurvesGeometry_add_curves(curves, reports, sizes, sizes_num)) {
62 if (grease_pencil_id->
us > 0) {
68static void rna_GreasePencilDrawing_remove_curves(
ID *grease_pencil_id,
71 const int *indices_ptr,
72 const int indices_num)
77 if (!rna_CurvesGeometry_remove_curves(curves, reports, indices_ptr, indices_num)) {
84 if (grease_pencil_id->
us > 0) {
90static void rna_GreasePencilDrawing_resize_curves(
ID *grease_pencil_id,
95 const int *indices_ptr,
96 const int indices_num)
101 if (!rna_CurvesGeometry_resize_curves(
102 curves, reports, sizes_ptr, sizes_num, indices_ptr, indices_num))
110 if (grease_pencil_id->
us > 0) {
116static void rna_GreasePencilDrawing_reorder_curves(
ID *grease_pencil_id,
119 const int *reorder_indices_ptr,
120 const int reorder_indices_num)
125 if (!rna_CurvesGeometry_reorder_curves(
126 curves, reports, reorder_indices_ptr, reorder_indices_num))
134 if (grease_pencil_id->
us > 0) {
140static void rna_GreasePencilDrawing_set_types(
ID *grease_pencil_id,
144 const int *indices_ptr,
145 const int indices_num)
150 if (!rna_CurvesGeometry_set_types(curves, reports, type, indices_ptr, indices_num)) {
154 if (grease_pencil_id->
us > 0) {
162 drawing_ptr->wrap().tag_positions_changed();
165static void rna_GreasePencilDrawing_vertex_group_assign(
ID *
id,
168 const char *vgroup_name,
169 const int *indices_ptr,
176 if (vgroup_index == -1) {
191 const int dverts_size = dverts.
size();
195 if (
i < dverts_size) {
205static void rna_GreasePencilDrawing_vertex_group_remove(
ID *
id,
208 const char *vgroup_name,
209 const int *indices_ptr,
215 if (vgroup_index == -1) {
233 const int dverts_size = dverts.
size();
236 if (
i < dverts_size) {
248static void rna_GreasePencilDrawing_set_vertex_weights(
ID *grease_pencil_id,
251 const char *vertex_group_name,
252 const int *indices_ptr,
253 const int indices_num,
254 const float *weights_ptr,
255 const int weights_num,
256 const int assignmode)
260 const Span<float> weights(weights_ptr, weights_num);
261 if (
indices.size() != weights.size()) {
278 if (vgroup_index == -1) {
294 if (std::any_of(
indices.begin(),
indices.end(), [&](
const int index) {
295 return !dverts.index_range().contains(index);
303 for (const int i : range) {
304 const int dvert_index = indices[i];
305 const float weight = weights[i];
306 MDeformVert *dv = &dverts[dvert_index];
308 if (MDeformWeight *dw = BKE_defvert_find_index(dv, def_nr)) {
309 switch (assignmode) {
314 dw->weight += weight;
316 case WEIGHT_SUBTRACT:
317 dw->weight -= weight;
320 dw->weight = std::clamp(dw->weight, 0.0f, 1.0f);
324 switch (assignmode) {
325 case WEIGHT_SUBTRACT:
333 BKE_defvert_add_index_notest(dv, def_nr, std::clamp(weight, 0.0f, 1.0f));
351 Layer &layer = layer_in->wrap();
353 if (layer.
frames().contains(frame_number)) {
362 return layer.
frame_at(frame_number);
365static void rna_Frames_frame_remove(
ID *
id,
372 Layer &layer = layer_in->wrap();
374 if (!layer.
frames().contains(frame_number)) {
379 if (grease_pencil.remove_frames(layer, {frame_number})) {
391 int from_frame_number,
393 bool instance_drawing)
397 Layer &layer = layer_in->wrap();
399 if (!layer.
frames().contains(from_frame_number)) {
403 if (layer.
frames().contains(to_frame_number)) {
408 grease_pencil.insert_duplicate_frame(
409 layer, from_frame_number, to_frame_number, instance_drawing);
412 return layer.
frame_at(to_frame_number);
418 int from_frame_number,
423 Layer &layer = layer_in->wrap();
425 if (!layer.
frames().contains(from_frame_number)) {
429 if (layer.
frames().contains(to_frame_number)) {
434 grease_pencil.insert_duplicate_frame(layer, from_frame_number, to_frame_number,
true);
435 grease_pencil.remove_frames(layer, {from_frame_number});
441 return layer.
frame_at(to_frame_number);
448 return static_cast<Layer *
>(layer)->frame_at(frame_number);
456 return static_cast<Layer *
>(layer)->frame_at(scene->
r.
cfra);
461 const bool set_active,
466 if (layer_group_ptr && layer_group_ptr->
data) {
471 layer = &grease_pencil->add_layer(*layer_group,
name);
474 layer = &grease_pencil->add_layer(
name);
477 grease_pencil->set_active_layer(layer);
489 grease_pencil->remove_layer(layer);
496static void rna_GreasePencil_layer_move(
GreasePencil *grease_pencil,
500 if (direction == 0) {
508 grease_pencil->move_node_down(layer_node, 1);
511 grease_pencil->move_node_up(layer_node, 1);
523 grease_pencil->move_node_top(layer_node);
533 grease_pencil->move_node_bottom(layer_node);
539static void rna_GreasePencil_layer_move_to_layer_group(
GreasePencil *grease_pencil,
546 if (layer_group_ptr && layer_group_ptr->
data) {
550 layer_group = &grease_pencil->root_group();
552 if (layer_group ==
nullptr) {
555 grease_pencil->move_node_into(layer_node, *layer_group);
567 if (parent_group_ptr && parent_group_ptr->
data) {
571 parent_group = &grease_pencil->root_group();
573 LayerGroup *new_layer_group = &grease_pencil->add_layer_group(*parent_group,
name);
578 &grease_pencil->
id, &RNA_GreasePencilLayerGroup, new_layer_group);
582static void rna_GreasePencil_layer_group_remove(
GreasePencil *grease_pencil,
588 grease_pencil->remove_group(layer_group, keep_children);
595static void rna_GreasePencil_layer_group_move(
GreasePencil *grease_pencil,
599 if (direction == 0) {
607 grease_pencil->move_node_down(layer_group_node, 1);
610 grease_pencil->move_node_up(layer_group_node, 1);
618static void rna_GreasePencil_layer_group_move_top(
GreasePencil *grease_pencil,
623 grease_pencil->move_node_top(layer_group_node);
629static void rna_GreasePencil_layer_group_move_bottom(
GreasePencil *grease_pencil,
634 grease_pencil->move_node_bottom(layer_group_node);
640static void rna_GreasePencil_layer_group_move_to_layer_group(
GreasePencil *grease_pencil,
647 if (parent_group_ptr && parent_group_ptr->
data) {
651 parent_group = &grease_pencil->root_group();
653 grease_pencil->move_node_into(layer_group_node, *parent_group);
666 func =
RNA_def_function(srna,
"add_strokes",
"rna_GreasePencilDrawing_add_curves");
676 "The number of points in each stroke",
681 func =
RNA_def_function(srna,
"remove_strokes",
"rna_GreasePencilDrawing_remove_curves");
683 "Remove all strokes. If indices are provided, remove only the "
684 "strokes with the given indices.");
693 "The indices of the strokes to remove",
698 func =
RNA_def_function(srna,
"resize_strokes",
"rna_GreasePencilDrawing_resize_curves");
701 "Resize all existing strokes. If indices are provided, resize only the strokes with the "
702 "given indices. If the new size for a stroke is smaller, the stroke is trimmed. If "
703 "the new size for a stroke is larger, the new end values are default initialized.");
712 "The number of points in each stroke",
723 "The indices of the stroke to resize",
728 func =
RNA_def_function(srna,
"reorder_strokes",
"rna_GreasePencilDrawing_reorder_curves");
738 "The new index for each of the strokes",
743 func =
RNA_def_function(srna,
"set_types",
"rna_GreasePencilDrawing_set_types");
745 "Set the curve type. If indices are provided, set only the "
746 "types with the given curve indices.");
756 "The indices of the curves to resize",
762 srna,
"tag_positions_changed",
"rna_GreasePencilDrawing_tag_positions_changed");
764 func,
"Indicate that the positions of points in the drawing have changed");
767 srna,
"vertex_group_assign",
"rna_GreasePencilDrawing_vertex_group_assign");
771 func,
"vgroup_name",
"Group",
MAX_NAME,
"Vertex Group Name",
"Name of the vertex group");
780 "The point indices to assign the weight to",
784 parm =
RNA_def_float(func,
"weight", 0, 0.0f, 1.0f,
"",
"Vertex weight", 0.0f, 1.0f);
788 srna,
"vertex_group_remove",
"rna_GreasePencilDrawing_vertex_group_remove");
792 func,
"vgroup_name",
"Group",
MAX_NAME,
"Vertex Group Name",
"Name of the vertex group");
801 "The point indices to remove from the vertex group",
810 {0,
nullptr, 0,
nullptr,
nullptr},
813 srna,
"set_vertex_weights",
"rna_GreasePencilDrawing_set_vertex_weights");
821 "Name of the vertex group");
830 "The point indices in the vertex group to modify",
841 "The weight for each corresponding index in the indices array",
845 parm =
RNA_def_enum(func,
"assign_mode", assign_mode_items, 0,
"",
"");
862 "The frame on which the drawing appears",
866 parm =
RNA_def_pointer(func,
"frame",
"GreasePencilFrame",
"",
"The newly created frame");
878 "The frame number of the frame to remove",
891 "Source Frame Number",
892 "The frame number of the source frame",
901 "Frame Number of Copy",
902 "The frame number to copy the frame to",
910 "Let the copied frame use the same drawing as the source");
911 parm =
RNA_def_pointer(func,
"copy",
"GreasePencilFrame",
"",
"The newly copied frame");
922 "Source Frame Number",
923 "The frame number of the source frame",
932 "Target Frame Number",
933 "The frame number to move the frame to",
937 parm =
RNA_def_pointer(func,
"moved",
"GreasePencilFrame",
"",
"The moved frame");
946 func =
RNA_def_function(srna,
"get_frame_at",
"rna_GreasePencilLayer_get_frame_at");
951 parm =
RNA_def_pointer(func,
"frame",
"GreasePencilFrame",
"Frame",
"");
954 func =
RNA_def_function(srna,
"current_frame",
"rna_GreasePencilLayer_current_frame");
956 func,
"The Grease Pencil frame at the current scene time on this layer");
972 func,
"set_active",
true,
"Set Active",
"Set the newly created layer as the active layer");
976 "GreasePencilLayerGroup",
978 "The layer group the new layer will be created in (use None for the main stack)");
980 parm =
RNA_def_pointer(func,
"layer",
"GreasePencilLayer",
"",
"The newly created layer");
985 parm =
RNA_def_pointer(func,
"layer",
"GreasePencilLayer",
"",
"The layer to remove");
991 "Move a Grease Pencil layer in the layer group or main stack");
992 parm =
RNA_def_pointer(func,
"layer",
"GreasePencilLayer",
"",
"The layer to move");
999 func =
RNA_def_function(srna,
"move_top",
"rna_GreasePencil_layer_move_top");
1001 func,
"Move a Grease Pencil layer to the top of the layer group or main stack");
1002 parm =
RNA_def_pointer(func,
"layer",
"GreasePencilLayer",
"",
"The layer to move");
1006 func =
RNA_def_function(srna,
"move_bottom",
"rna_GreasePencil_layer_move_bottom");
1008 func,
"Move a Grease Pencil layer to the bottom of the layer group or main stack");
1009 parm =
RNA_def_pointer(func,
"layer",
"GreasePencilLayer",
"",
"The layer to move");
1014 srna,
"move_to_layer_group",
"rna_GreasePencil_layer_move_to_layer_group");
1016 parm =
RNA_def_pointer(func,
"layer",
"GreasePencilLayer",
"",
"The layer to move");
1022 "GreasePencilLayerGroup",
1024 "The layer group the layer will be moved into (use None for the main stack)");
1037 func,
"name",
"GreasePencilLayerGroup",
MAX_NAME,
"Name",
"Name of the layer group");
1041 "GreasePencilLayerGroup",
1043 "The parent layer group the new group will be created in (use None "
1044 "for the main stack)");
1047 func,
"layer_group",
"GreasePencilLayerGroup",
"",
"The newly created layer group");
1051 func =
RNA_def_function(srna,
"remove",
"rna_GreasePencil_layer_group_remove");
1054 func,
"layer_group",
"GreasePencilLayerGroup",
"",
"The layer group to remove");
1061 "Keep the children nodes of the group and only delete the group itself");
1063 func =
RNA_def_function(srna,
"move",
"rna_GreasePencil_layer_group_move");
1065 "Move a layer group in the parent layer group or main stack");
1067 func,
"layer_group",
"GreasePencilLayerGroup",
"",
"The layer group to move");
1074 func =
RNA_def_function(srna,
"move_top",
"rna_GreasePencil_layer_group_move_top");
1076 func,
"Move a layer group to the top of the parent layer group or main stack");
1078 func,
"layer_group",
"GreasePencilLayerGroup",
"",
"The layer group to move");
1082 func =
RNA_def_function(srna,
"move_bottom",
"rna_GreasePencil_layer_group_move_bottom");
1084 func,
"Move a layer group to the bottom of the parent layer group or main stack");
1086 func,
"layer_group",
"GreasePencilLayerGroup",
"",
"The layer group to move");
1091 srna,
"move_to_layer_group",
"rna_GreasePencil_layer_group_move_to_layer_group");
1094 func,
"layer_group",
"GreasePencilLayerGroup",
"",
"The layer group to move");
1099 "GreasePencilLayerGroup",
1101 "The parent layer group the layer group will be moved into (use "
1102 "None for the main stack)");
Scene * CTX_data_scene(const bContext *C)
Low-level operations for curves.
Low-level operations for grease pencil.
Utility functions for vertex groups in grease pencil objects.
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_report(ReportList *reports, eReportType type, const char *message)
void * BLI_findlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void DEG_id_tag_update(ID *id, unsigned int flags)
const Map< FramesMapKeyT, GreasePencilFrame > & frames() const
const GreasePencilFrame * frame_at(const int frame_number) const
constexpr int64_t size() const
MutableSpan< MDeformVert > deform_verts_for_write()
void update_curve_types()
MutableSpan< int8_t > curve_types_for_write()
bke::CurvesGeometry & strokes_for_write()
void tag_topology_changed()
int ensure_vertex_group(StringRef name, ListBase &vertex_group_names)
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
const EnumPropertyItem rna_enum_curves_type_items[]
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_int_array(StructOrFunctionRNA *cont_, const char *identifier, const int len, const int *default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
void RNA_def_parameter_clear_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, const float default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
PropertyRNA * RNA_def_pointer(StructOrFunctionRNA *cont_, const char *identifier, const char *type, const char *ui_name, const char *ui_description)
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
void RNA_def_function_flag(FunctionRNA *func, int flag)
PropertyRNA * RNA_def_float_array(StructOrFunctionRNA *cont_, const char *identifier, const int len, const float *default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
void RNA_api_grease_pencil_drawing(StructRNA *srna)
void RNA_api_grease_pencil_frames(StructRNA *srna)
const EnumPropertyItem rna_enum_tree_node_move_type_items[]
void RNA_api_grease_pencil_layer(StructRNA *srna)
void RNA_api_grease_pencil_layers(StructRNA *srna)
void RNA_api_grease_pencil_layer_groups(StructRNA *srna)
ListBase vertex_group_names
ListBase vertex_group_names
void WM_main_add_notifier(uint type, void *reference)