97 if (!(smooth_position || smooth_radius || smooth_opacity)) {
102 bool changed =
false;
106 if (
curves.points_num() == 0) {
123 if (smooth_position) {
179 ot->name =
"Smooth Stroke";
180 ot->idname =
"GREASE_PENCIL_OT_stroke_smooth";
181 ot->description =
"Smooth selected strokes";
188 prop =
RNA_def_int(
ot->srna,
"iterations", 10, 1, 100,
"Iterations",
"", 1, 30);
190 RNA_def_float(
ot->srna,
"factor", 1.0f, 0.0f, 1.0f,
"Factor",
"", 0.0f, 1.0f);
211 if (dist1 + dist2 > 0) {
212 float interpolated_val =
interpf(valB, valA, dist1 / (dist1 + dist2));
224 int64_t total_points_to_delete = 0;
226 if (!curve_selection.
contains(
true)) {
227 return total_points_to_delete;
230 const bool is_last_segment_selected = (curve_selection.
first() && curve_selection.
last());
235 for (const IndexRange range : selection_ranges.as_span().slice(range_of_ranges)) {
236 total_points_to_delete += ramer_douglas_peucker_simplify(
237 range.shift(points.start()), epsilon, dist_function, points_to_delete);
242 if (cyclic && points.
size() > 2 && is_last_segment_selected) {
243 const float dist = dist_function(points.
last(1), points.
first(), points.
last());
244 if (dist <= epsilon) {
245 points_to_delete[points.
last()] =
true;
246 total_points_to_delete++;
250 return total_points_to_delete;
261 bool changed =
false;
265 if (
curves.points_num() == 0) {
280 const auto dist_function_positions =
283 positions[index], positions[first_index], positions[last_index]);
284 return dist_position;
286 const auto dist_function_positions_and_radii =
289 positions[index], positions[first_index], positions[last_index]);
291 positions[first_index],
292 positions[last_index],
296 return math::max(dist_position, dist_radii);
308 std::atomic<int64_t> total_points_to_delete = 0;
311 const IndexRange points = points_by_curve[curve_i];
315 dist_function_positions,
316 points_to_delete.as_mutable_span());
321 const IndexRange points = points_by_curve[curve_i];
325 dist_function_positions_and_radii,
326 points_to_delete.as_mutable_span());
330 if (total_points_to_delete > 0) {
349 ot->name =
"Simplify Stroke";
350 ot->idname =
"GREASE_PENCIL_OT_stroke_simplify";
351 ot->description =
"Simplify selected strokes";
358 prop =
RNA_def_float(
ot->srna,
"factor", 0.01f, 0.0f, 100.0f,
"Factor",
"", 0.0f, 100.0f);
376 const int total_points = points_to_delete.
as_span().count(
false);
379 if (total_points == 0) {
383 int curr_dst_point_id = 0;
389 for (
const int curve_i :
curves.curves_range()) {
390 const IndexRange points = points_by_curve[curve_i];
391 const Span<bool> curve_points_to_delete = points_to_delete.
as_span().slice(points);
392 const bool curve_cyclic = src_cyclic[curve_i];
402 const bool is_last_segment_selected = curve_cyclic && ranges_to_keep.
first().first() == 0 &&
403 ranges_to_keep.
last().last() == points.
size() - 1;
404 const bool is_curve_self_joined = is_last_segment_selected && ranges_to_keep.
size() != 1;
405 const bool is_cyclic = ranges_to_keep.
size() == 1 && is_last_segment_selected;
410 const IndexRange range = ranges_to_keep[range_i];
413 for (
const int src_point : range.
shift(points.
first())) {
414 dst_to_src_point[curr_dst_point_id++] = src_point;
418 if (is_curve_self_joined && range_i == range_ids.
last()) {
420 for (
const int src_point : first_range.
shift(points.
first())) {
421 dst_to_src_point[curr_dst_point_id++] = src_point;
427 dst_to_src_curve.
append(curve_i);
432 const int total_curves = dst_to_src_curve.
size();
446 gather_attributes(src_attributes,
455 gather_attributes(src_attributes,
477 bool changed =
false;
489 curves.remove_curves(elements, {});
508 ot->idname =
"GREASE_PENCIL_OT_delete";
509 ot->description =
"Delete selected strokes or points";
538 "Dissolve points between selected points"},
543 "Dissolve all unselected points"},
544 {0,
nullptr, 0,
nullptr,
nullptr},
558 return points_to_dissolve;
570 for (const int64_t curve_i : range) {
571 const IndexRange points = points_by_curve[curve_i];
572 const Span<bool> curve_selection = points_to_dissolve.as_span().slice(points);
574 if (!curve_selection.contains(true)) {
575 points_to_keep.slice(points).fill(true);
581 if (mode != DissolveMode::BETWEEN) {
585 const Vector<IndexRange> deselection_ranges = array_utils::find_all_ranges(curve_selection,
588 if (deselection_ranges.size() != 0) {
589 const IndexRange first_range = deselection_ranges.first().shift(points.first());
590 const IndexRange last_range = deselection_ranges.last().shift(points.first());
594 if (first_range.first() == points.first()) {
595 points_to_keep.slice(first_range).fill(true);
597 if (last_range.last() == points.last()) {
598 points_to_keep.slice(last_range).fill(true);
606 return points_to_dissolve;
617 bool changed =
false;
621 if (
curves.points_num() == 0) {
633 if (points_to_dissolve.
as_span().contains(
true)) {
651 ot->name =
"Dissolve";
652 ot->idname =
"GREASE_PENCIL_OT_dissolve";
653 ot->description =
"Delete selected points without splitting strokes";
666 "Method used for dissolving stroke points");
689 "Deletes current frame in the active layer"},
694 "Delete active frames for all layers"},
695 {0,
nullptr, 0,
nullptr,
nullptr},
703 const int current_frame = scene->
r.
cfra;
707 bool changed =
false;
711 changed |= grease_pencil.remove_frames(layer, {*layer.
start_frame_at(current_frame)});
716 if (layer->is_editable() && layer->start_frame_at(current_frame)) {
717 changed |= grease_pencil.remove_frames(*layer, {*layer->start_frame_at(current_frame)});
735 ot->name =
"Delete Frame";
736 ot->idname =
"GREASE_PENCIL_OT_delete_frame";
737 ot->description =
"Delete Grease Pencil Frame(s)";
750 "Method used for deleting Grease Pencil frames");
770 int material_index =
object->actcol - 1;
772 if (name[0] !=
'\0') {
783 if (material_index == -1) {
798 curves.attributes_for_write().lookup_or_add_for_write_span<
int>(
"material_index",
812 ot->name =
"Assign Material";
813 ot->idname =
"GREASE_PENCIL_OT_stroke_material_set";
814 ot->description =
"Assign the active material slot to the selected strokes";
822 ot->srna,
"material",
nullptr,
MAX_ID_NAME - 2,
"Material",
"Name of the material");
844 {0,
nullptr, 0,
nullptr,
nullptr},
855 bool changed =
false;
887 curves.attributes_for_write().remove(
"cyclic");
905 ot->name =
"Set Cyclical State";
906 ot->idname =
"GREASE_PENCIL_OT_cyclical_set";
907 ot->description =
"Close or open the selected stroke adding a segment from last to first point";
931 if (
object->totcol == 0) {
939 *
object, info.drawing, info.layer_index, memory);
947 object->actcol = materials[strokes.
first()] + 1;
958 ot->name =
"Set Active Material";
959 ot->idname =
"GREASE_PENCIL_OT_set_active_material";
960 ot->description =
"Set the selected stroke material as the active material";
982 bool changed =
false;
1009 ot->name =
"Set Uniform Thickness";
1010 ot->idname =
"GREASE_PENCIL_OT_set_uniform_thickness";
1011 ot->description =
"Set all stroke points to same thickness";
1019 ot->srna,
"thickness", 0.1f, 0.0f, 1000.0f,
"Thickness",
"Thickness", 0.0f, 1000.0f);
1035 bool changed =
false;
1062 ot->name =
"Set Uniform Opacity";
1063 ot->idname =
"GREASE_PENCIL_OT_set_uniform_opacity";
1064 ot->description =
"Set all stroke points to same opacity";
1071 ot->prop =
RNA_def_float(
ot->srna,
"opacity", 1.0f, 0.0f, 1.0f,
"Opacity",
"", 0.0f, 1.0f);
1086 bool changed =
false;
1098 curves.reverse_curves(strokes);
1114 ot->name =
"Switch Direction";
1115 ot->idname =
"GREASE_PENCIL_OT_stroke_switch_direction";
1116 ot->description =
"Change direction of the points of the selected strokes";
1162 bool changed =
false;
1230 {0,
nullptr, 0,
nullptr,
nullptr},
1233 ot->name =
"Set Curve Caps";
1234 ot->idname =
"GREASE_PENCIL_OT_caps_set";
1235 ot->description =
"Change curve caps mode (rounded or flat)";
1262 if (ob ==
nullptr) {
1269 item_tmp.identifier = ma->id.name + 2;
1270 item_tmp.name = ma->id.name + 2;
1271 item_tmp.value = i + 1;
1272 item_tmp.icon = ma->preview ? ma->preview->runtime->icon_id : ICON_NONE;
1290 if ((slot < 1) || (slot >
object->totcol)) {
1295 object->actcol = slot;
1304 ot->name =
"Set Active Material";
1305 ot->idname =
"GREASE_PENCIL_OT_set_material";
1306 ot->description =
"Set active material";
1332 std::atomic<bool> changed =
false;
1350 changed.store(
true, std::memory_order_relaxed);
1362 ot->name =
"Duplicate";
1363 ot->idname =
"GREASE_PENCIL_OT_duplicate";
1364 ot->description =
"Duplicate the selected points";
1390 editable_strokes,
GrainSize(4096), memory, [&](
const int i) {
1391 return points_by_curve[i].
size() <= limit;
1394 curves.remove_curves(curves_to_delete, {});
1406 C, op, event,
IFACE_(
"Remove Loose Points"),
IFACE_(
"Delete"));
1411 ot->name =
"Clean Loose Points";
1412 ot->idname =
"GREASE_PENCIL_OT_clean_loose";
1413 ot->description =
"Remove loose points";
1427 "Number of points to consider stroke as loose",
1443 std::atomic<bool> changed =
false;
1481 for (
const int curve :
curves.curves_range()) {
1484 for (
const int point : points_by_curve[curve].drop_back(1)) {
1491 use_cuts[
point] = cuts;
1495 if (cyclic[curve]) {
1496 const int first_point = points_by_curve[curve].first();
1497 const int last_point = points_by_curve[curve].last();
1499 use_cuts[last_point] = cuts;
1508 changed.store(
true, std::memory_order_relaxed);
1523 ot->name =
"Subdivide Stroke";
1524 ot->idname =
"GREASE_PENCIL_OT_stroke_subdivide";
1526 "Subdivide between continuous selected points of the stroke adding a point half way "
1535 prop =
RNA_def_int(
ot->srna,
"number_cuts", 1, 1, 32,
"Number of Cuts",
"", 1, 5);
1543 "Smooth only selected points in the stroke");
1602 A.to_indices(
indices.as_mutable_span().take_front(
A.size()));
1603 B.to_indices(
indices.as_mutable_span().take_back(
B.size()));
1608 if (curve_i !=
pos) {
1620 for (
const int i : selected_indices.
index_range()) {
1622 const int curve_i = selected_indices[
pos];
1625 if (curve_i != universe.
last(i)) {
1643 std::atomic<bool> changed =
false;
1663 changed.store(
true, std::memory_order_relaxed);
1682 {0,
nullptr, 0,
nullptr,
nullptr},
1685 ot->name =
"Reorder";
1686 ot->idname =
"GREASE_PENCIL_OT_reorder";
1687 ot->description =
"Change the display order of the selected strokes";
1708 bool changed =
false;
1713 int target_layer_name_length;
1715 op->
ptr,
"target_layer_name",
nullptr, 0, &target_layer_name_length);
1718 if (add_new_layer) {
1719 grease_pencil.add_layer(target_layer_name);
1722 TreeNode *target_node = grease_pencil.find_node_by_name(target_layer_name);
1723 if (target_node ==
nullptr || !target_node->
is_layer()) {
1729 if (layer_dst.is_locked()) {
1747 Drawing &drawing_dst = *grease_pencil.insert_frame(layer_dst, info.frame_number);
1749 curves_src, selected_strokes, {});
1754 else if (
Drawing *drawing_dst = grease_pencil.get_editable_drawing_at(layer_dst,
1759 curves_src, selected_strokes, {});
1769 drawing_dst->tag_topology_changed();
1772 info.drawing.tag_topology_changed();
1788 if (add_new_layer) {
1792 const std::string
unique_name = grease_pencil.unique_layer_name(
"Layer");
1796 C, op, event,
IFACE_(
"Move to New Layer"),
IFACE_(
"Create"));
1805 ot->name =
"Move to Layer";
1806 ot->idname =
"GREASE_PENCIL_OT_move_to_layer";
1807 ot->description =
"Move selected strokes to another layer";
1816 ot->srna,
"target_layer_name",
nullptr,
INT16_MAX,
"Name",
"Target Grease Pencil Layer");
1819 ot->srna,
"add_new_layer",
false,
"New Layer",
"Move selection to a new layer");
1842 {0,
nullptr, 0,
nullptr,
nullptr},
1847 int actcol =
object->actcol;
1848 for (
int slot = 1; slot <=
object->totcol; slot++) {
1850 object->actcol = slot;
1855 if (actcol >= slot) {
1860 object->actcol = actcol;
1884 const Layer &layer_src = grease_pencil_src.layer(layer_index);
1885 if (
TreeNode *node = grease_pencil_dst.find_node_by_name(layer_src.name())) {
1886 return node->as_layer();
1890 Layer &new_layer = grease_pencil_dst.add_layer(layer_src.name());
1897 Span({layer_index}),
1898 grease_pencil_dst.attributes_for_write());
1911 bool changed =
false;
1915 &bmain, &scene, &view_layer, &base_prev, grease_pencil_src);
1931 info.layer_index, grease_pencil_src, grease_pencil_dst);
1933 Drawing *drawing_dst = grease_pencil_dst.insert_frame(layer_dst, info.frame_number);
1939 curves_src, selected_points, {});
1942 info.drawing.tag_topology_changed();
1949 grease_pencil_dst.set_active_layer(
nullptr);
1973 bool changed =
false;
1978 for (
const int layer_i : grease_pencil_src.layers().index_range()) {
1979 Layer &layer_src = grease_pencil_src.layer(layer_i);
1980 if (layer_src.is_selected() || layer_src.is_locked()) {
1985 &bmain, &scene, &view_layer, &base_prev, grease_pencil_src);
1988 layer_i, grease_pencil_src, grease_pencil_dst);
1992 scene, grease_pencil_src, layer_src);
1997 object_src, info.drawing, info.layer_index, memory);
2010 Drawing *drawing_dst = grease_pencil_dst.insert_frame(layer_dst, info.frame_number);
2016 info.drawing.strokes(), strokes, {});
2019 info.drawing.tag_topology_changed();
2043 bool changed =
false;
2054 &bmain, &scene, &view_layer, &base_prev, grease_pencil_src);
2070 object_src, info.drawing, mat_i, memory);
2079 info.layer_index, grease_pencil_src, grease_pencil_dst);
2081 Drawing *drawing_dst = grease_pencil_dst.insert_frame(layer_dst, info.frame_number);
2089 info.drawing.tag_topology_changed();
2118 bool changed =
false;
2127 const bool has_selection = std::any_of(
2129 return ed::curves::has_anything_selected(info.drawing.strokes());
2131 if (!has_selection) {
2138 *
C, *bmain, *scene, *view_layer, *base_prev, *object_src);
2143 if (object_src->
totcol == 1) {
2150 *
C, *bmain, *scene, *view_layer, *base_prev, *object_src);
2155 if (grease_pencil_src.layers().size() == 1) {
2161 *
C, *bmain, *scene, *view_layer, *base_prev, *object_src);
2178 ot->name =
"Separate";
2179 ot->idname =
"GREASE_PENCIL_OT_separate";
2180 ot->description =
"Separate the selected geometry into a new grease pencil object";
2207} *grease_pencil_clipboard =
nullptr;
2234 if (!grease_pencil.has_active_layer()) {
2239 if (!active_layer.is_editable()) {
2245 bool inserted_keyframe =
false;
2252 if (target_drawing ==
nullptr) {
2263 selection_in_target.
finish();
2268 *bmain, *
object, *target_drawing, object_to_layer, keep_world_transform, paste_on_back);
2273 if (inserted_keyframe) {
2285 std::unique_ptr<bke::Instances> instances = std::make_unique<bke::Instances>();
2286 instances->resize(geometries.
size());
2287 instances->transforms_for_write().copy_from(transforms);
2294 options.keep_original_ids =
true;
2295 options.realize_instance_attributes =
false;
2311 bool anything_copied =
false;
2320 const Layer &layer = grease_pencil.layer(drawing_info.layer_index);
2323 if (
curves.curves_num() == 0) {
2348 set_of_transforms.
append(layer_to_object);
2349 anything_copied =
true;
2352 if (!anything_copied) {
2361 clipboard.
transform =
object->object_to_world();
2371 if (!material_indices.
contains(material_index)) {
2402 ot->name =
"Paste Strokes";
2403 ot->idname =
"GREASE_PENCIL_OT_paste";
2405 "Paste Grease Pencil points or strokes from the internal clipboard to the active layer";
2413 ot->srna,
"paste_back",
false,
"Paste on Back",
"Add pasted strokes behind all strokes");
2416 "keep_world_transform",
2418 "Keep World Transform",
2419 "Keep the world transform of strokes from the clipboard unchanged");
2424 ot->name =
"Copy Strokes";
2425 ot->idname =
"GREASE_PENCIL_OT_copy";
2426 ot->description =
"Copy the selected Grease Pencil points or strokes to the internal clipboard";
2459 scene_materials.
add(material->id.session_uid, material);
2472 clipboard_material_remap[clipboard.
materials[i].second] = target_index;
2478 clipboard_material_remap[clipboard.
materials[i].second] = target_index;
2481 return clipboard_material_remap;
2488 const bool keep_world_transform,
2489 const bool paste_back)
2503 const IndexRange pasted_curves_range = paste_back ?
2517 (keep_world_transform ?
2518 object.world_to_object() * clipboard_to_world :
2532 if (material_indices) {
2533 for (
const int i : pasted_curves_range) {
2534 material_indices.
span[i] = clipboard_material_remap[material_indices.
span[i]];
2536 material_indices.
finish();
2541 return pasted_curves_range;
2556 std::atomic<bool> changed =
false;
2562 const IndexMask points = use_unselected ?
2571 drawing.
strokes(), threshold, points, {});
2573 changed.store(
true, std::memory_order_relaxed);
2586 ot->name =
"Merge by Distance";
2587 ot->idname =
"GREASE_PENCIL_OT_stroke_merge_by_distance";
2588 ot->description =
"Merge points by distance";
2595 prop =
RNA_def_float(
ot->srna,
"threshold", 0.001f, 0.0f, 100.0f,
"Threshold",
"", 0.0f, 100.0f);
2603 "Use whole stroke, not only selected points");
2636 int point_offset = 0;
2638 const IndexRange curve_points = points_by_curve[curve_index];
2640 const bool curve_cyclic = src_cyclic[curve_index];
2642 curve_points_to_extrude.
foreach_index([&](
const int src_point_index) {
2643 if (!curve_cyclic && (src_point_index == curve_points.
first())) {
2646 dst_to_src_points.
insert(src_point_index + point_offset, src_point_index);
2647 dst_selected.
insert(src_point_index + point_offset,
true);
2648 ++dst_curve_counts[curve_index];
2652 if (!curve_cyclic && (src_point_index == curve_points.
last())) {
2655 dst_to_src_points.
insert(src_point_index + point_offset + 1, src_point_index);
2656 dst_selected.
insert(src_point_index + point_offset + 1,
true);
2657 ++dst_curve_counts[curve_index];
2665 dst_to_src_points.
append(src_point_index);
2666 dst_selected.
append(
false);
2667 dst_to_src_points.
append(src_point_index);
2668 dst_selected.
append(
true);
2669 dst_to_src_curves.
append(curve_index);
2670 dst_curve_counts.
append(2);
2674 const int new_points_num = dst_to_src_points.
size();
2675 const int new_curves_num = dst_to_src_curves.
size();
2725 std::atomic<bool> changed =
false;
2731 if (points_to_extrude.
is_empty()) {
2739 changed.store(
true, std::memory_order_relaxed);
2752 ot->name =
"Extrude Stroke Points";
2753 ot->idname =
"GREASE_PENCIL_OT_extrude";
2754 ot->description =
"Extrude the selected points";
2793 if (keep_original) {
2817 std::atomic<bool> changed =
false;
2821 if (drawings.is_empty()) {
2824 const int current_frame_number = drawings.first().frame_number;
2827 scene.
r.
cfra = current_frame_number;
2835 if (points_to_reproject.
is_empty()) {
2843 if (view_depths !=
nullptr) {
2848 scene, *region, *v3d, *
object, &layer, mode, offset, view_depths_copy);
2852 positions[point_i] = drawing_placement.
reproject(positions[point_i]);
2856 changed.store(
true, std::memory_order_relaxed);
2860 if (view_depths !=
nullptr) {
2865 scene.
r.
cfra = oldframe;
2904 "Reproject the strokes using the X-Z plane"},
2911 "Reproject the strokes to end up on the same plane, as if drawn from the current "
2913 "using 'Cursor' Stroke Placement"},
2918 "Reproject the strokes on to the scene geometry, as if drawn using 'Surface' placement"},
2923 "Reproject the strokes using the orientation of 3D cursor"},
2924 {0,
nullptr, 0,
nullptr,
nullptr},
2928 ot->name =
"Reproject Strokes";
2929 ot->idname =
"GREASE_PENCIL_OT_reproject";
2931 "Reproject the selected strokes from the current viewpoint as if they had been newly "
2933 "(e.g. to fix problems from accidental 3D cursor movement or accidental viewport changes, "
2934 "or for matching deforming geometry)";
2954 "Keep original strokes and create a copy before reprojecting");
2957 RNA_def_float(
ot->srna,
"offset", 0.0f, 0.0f, 10.0f,
"Surface Offset",
"", 0.0f, 10.0f);
2993 if (
curves.curves_num() == 0) {
3003 const Layer &layer = grease_pencil.layer(drawing_info.layer_index);
3010 const float3 pos_snapped = grid_size *
math::floor(pos_world / grid_size + 0.5f);
3014 drawing_info.drawing.tag_positions_changed();
3026 ot->name =
"Snap Selection to Grid";
3027 ot->idname =
"GREASE_PENCIL_OT_snap_to_grid";
3028 ot->description =
"Snap selected points to the nearest grid points";
3055 if (
curves.curves_num() == 0) {
3064 selected_points_memory);
3066 const Layer &layer = grease_pencil.layer(drawing_info.layer_index);
3076 curves, selected_curves_memory);
3079 const IndexRange points = points_by_curve[curve_i];
3082 const float3 offset = cursor_layer - positions[points.
first()];
3084 GrainSize(4096), [&](
const int point_i) { positions[point_i] += offset; });
3092 drawing_info.drawing.tag_positions_changed();
3105 ot->name =
"Snap Selection to Cursor";
3106 ot->idname =
"GREASE_PENCIL_OT_snap_to_cursor";
3107 ot->description =
"Snap selected points/strokes to the cursor";
3121 "Offset the entire stroke instead of selected points only");
3139 int num_selected = 0;
3140 r_centroid =
float3(0.0f);
3141 r_min =
float3(std::numeric_limits<float>::max());
3142 r_max =
float3(std::numeric_limits<float>::lowest());
3145 for (
const DrawingInfo &drawing_info : drawings) {
3146 const Layer &layer = grease_pencil.layer(drawing_info.layer_index);
3147 if (layer.is_locked()) {
3151 if (
curves.curves_num() == 0) {
3160 selected_points_memory);
3166 r_centroid += pos_world;
3169 num_selected += selected_points.
size();
3171 if (num_selected == 0) {
3172 r_min = r_max =
float3(0.0f);
3176 r_centroid /= num_selected;
3187 float3 centroid, points_min, points_max;
3189 scene,
object, grease_pencil, centroid, points_min, points_max))
3217 ot->name =
"Snap Cursor to Selected Points";
3218 ot->idname =
"GREASE_PENCIL_OT_snap_cursor_to_selected";
3219 ot->description =
"Snap cursor to center of selected points";
3243 strokemat4x3[2][2] = 0.0f;
3244 strokemat4x3[3][2] = 1.0f;
3246 return strokemat4x3;
3256 std::atomic<bool> changed =
false;
3272 const float2 screen_direction = screen_end - screen_start;
3273 const float2 screen_tangent = screen_start +
float2(-screen_direction[1], screen_direction[0]);
3285 const int material_index = materials[curve_i];
3288 material_index + 1);
3299 positions[points_by_curve[curve_i].first()]);
3312 const float3 origin = start;
3318 if (
math::dot(tangent - start, v_dir) < 0.0f) {
3330 offset_matrix *= 0.5f;
3331 offset_matrix[2] +=
float2(0.5f, 0.5f);
3335 offset_matrix[2] -=
float2(0.5f, 0.5f);
3338 offset_matrix = texture_rotation * offset_matrix;
3339 offset_matrix[2] -= texture_offset;
3342 layer_space_to_world_space;
3347 changed.store(
true, std::memory_order_relaxed);
3394 ot->name =
"Texture Gradient";
3395 ot->idname =
"GREASE_PENCIL_OT_texture_gradient";
3396 ot->description =
"Draw a line to set the fill material gradient for the selected strokes";
3426 bool changed =
false;
3438 options.convert_bezier_handles_to_poly_points = use_handles;
3439 options.convert_bezier_handles_to_catmull_rom_points = use_handles;
3440 options.keep_bezier_shape_as_nurbs = use_handles;
3441 options.keep_catmull_rom_shape_as_nurbs = use_handles;
3459 ot->name =
"Set Curve Type";
3460 ot->idname =
"GREASE_PENCIL_OT_set_curve_type";
3461 ot->description =
"Set type of selected curves";
3476 "Take handle information into account in the conversion");
3493 bool changed =
false;
3518 const IndexRange points = points_by_curve[curve_i];
3519 for (
const int point_i : points) {
3520 if (selection_left[point_i] ||
selection[point_i]) {
3521 handle_types_left[point_i] =
int8_t(dst_handle_type);
3523 if (selection_right[point_i] ||
selection[point_i]) {
3524 handle_types_right[point_i] =
int8_t(dst_handle_type);
3529 curves.calculate_bezier_auto_handles();
3530 curves.tag_topology_changed();
3546 ot->name =
"Set Handle Type";
3547 ot->idname =
"GREASE_PENCIL_OT_set_handle_type";
3548 ot->description =
"Set the handle type for bezier curves";
3574 bool changed =
false;
3604 ot->name =
"Set Curve Resolution";
3605 ot->idname =
"GREASE_PENCIL_OT_set_curve_resolution";
3606 ot->description =
"Set resolution of selected curves";
3619 "The resolution to use for each curve segment",
3636 bool changed =
false;
3648 if (attributes.
contains(
"uv_rotation")) {
3649 if (editable_strokes.
size() ==
curves.curves_num()) {
3650 attributes.
remove(
"uv_rotation");
3660 if (attributes.
contains(
"uv_translation")) {
3661 if (editable_strokes.
size() ==
curves.curves_num()) {
3662 attributes.
remove(
"uv_translation");
3668 uv_translations.
finish();
3672 if (attributes.
contains(
"uv_scale")) {
3673 if (editable_strokes.
size() ==
curves.curves_num()) {
3674 attributes.
remove(
"uv_scale");
3684 if (attributes.
contains(
"uv_shear")) {
3685 if (editable_strokes.
size() ==
curves.curves_num()) {
3686 attributes.
remove(
"uv_shear");
3711 ot->name =
"Reset UVs";
3712 ot->idname =
"GREASE_PENCIL_OT_reset_uvs";
3713 ot->description =
"Reset UV transformation to default values";
3778 Layer &layer_dst = grease_pencil_dst.add_layer(group_dst, layer_src.name());
3801 if (node->is_group()) {
3804 if (node->is_layer()) {
3805 Layer &layer_dst =
copy_layer(grease_pencil_dst, group_dst, node->as_layer());
3806 layer_name_map.
add_new(node->as_layer().name(), layer_dst.name());
3829 for (
const int i : material_index_map.
index_range()) {
3833 return material_index_map;
3845 for (const int curve_i : range) {
3846 material_writer.span[curve_i] = material_index_map[material_writer.span[curve_i]];
3849 material_writer.
finish();
3854 const ListBase &vertex_group_names)
3863 return vertex_group_map;
3870 STRNCPY(dg->name, vertex_group_map.
lookup(dg->name).c_str());
3894 const int orig_layers_num = grease_pencil_dst.layers().size();
3916 grease_pencil_dst.resize_drawings(0);
3924 grease_pencil_dst.root_group(),
3925 grease_pencil_src.root_group(),
3933 grease_pencil_dst.layers().size());
3938 grease_pencil_src.layers().size());
3941 for (
const int layer_index : grease_pencil_dst.layers().index_range()) {
3942 Layer &layer = *grease_pencil_dst.layers_for_write()[layer_index];
3943 const bool is_orig_layer = (layer_index < orig_layers_num);
3948 if (!is_orig_layer) {
3952 if (new_mask_name) {
3960 drawing_index = new_drawings_src[drawing_index];
3985 if (!is_orig_layer) {
3994 if (
id == &grease_pencil_src.
id && fcu->
rna_path && strstr(fcu->
rna_path,
"layers[")) {
3996 for (
auto [name_src, name_dst] : layer_name_map.
items()) {
3997 if (name_dst != name_src) {
3998 const char *old_path = fcu->
rna_path;
4000 id, fcu->
rna_path,
"layers", name_src.c_str(), name_dst.c_str(), 0, 0,
false);
4013 if (dtar->id != &grease_pencil_src.
id) {
4016 dtar->id = &grease_pencil_dst.
id;
4018 if (dtar->rna_path && strstr(dtar->rna_path,
"layers[")) {
4019 for (
auto [name_src, name_dst] : layer_name_map.
items()) {
4020 if (name_dst != name_src) {
4021 const char *old_path = fcu->
rna_path;
4023 id, dtar->rna_path,
"layers", name_src.c_str(), name_dst.c_str(), 0, 0,
false);
4024 if (old_path != dtar->rna_path) {
4038 if (ob_dst.
adt ==
nullptr) {
4049 if (grease_pencil_src.
adt) {
4050 if (grease_pencil_dst.
adt ==
nullptr) {
4079 if (ob_iter == ob_active) {
4091 Object *ob_dst = ob_active;
4096 *grease_pencil_dst, materials);
void BKE_animdata_merge_copy(Main *bmain, ID *dst_id, ID *src_id, eAnimData_MergeCopy_Modes action_mode, bool fix_drivers)
AnimData * BKE_animdata_copy(Main *bmain, AnimData *adt, int flag)
void BKE_fcurves_main_cb(struct Main *bmain, blender::FunctionRef< void(ID *, FCurve *)> func)
char * BKE_animsys_fix_rna_path_rename(struct ID *owner_id, char *old_path, const char *prefix, const char *oldName, const char *newName, int oldSubscript, int newSubscript, bool verify_paths)
#define CTX_DATA_BEGIN(C, Type, instance, member)
Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
ScrArea * CTX_wm_area(const bContext *C)
Object * CTX_data_active_object(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
Base * CTX_data_active_base(const bContext *C)
Main * CTX_data_main(const bContext *C)
ARegion * CTX_wm_region(const bContext *C)
View3D * CTX_wm_view3d(const bContext *C)
ViewLayer * CTX_data_view_layer(const bContext *C)
Low-level operations for curves.
CustomData interface, see also DNA_customdata_types.h.
void CustomData_copy_data(const CustomData *source, CustomData *dest, int source_index, int dest_index, int count)
bool CustomData_merge_layout(const CustomData *source, CustomData *dest, eCustomDataMask mask, eCDAllocType alloctype, int totelem)
#define DRIVER_TARGETS_USED_LOOPER_BEGIN(dvar)
#define DRIVER_TARGETS_LOOPER_END
Low-level operations for grease pencil.
void * BKE_grease_pencil_add(Main *bmain, const char *name)
Material * BKE_grease_pencil_object_material_new(Main *bmain, Object *ob, const char *name, int *r_index)
void BKE_grease_pencil_copy_layer_parameters(const blender::bke::greasepencil::Layer &src, blender::bke::greasepencil::Layer &dst)
void BKE_grease_pencil_copy_layer_group_parameters(const blender::bke::greasepencil::LayerGroup &src, blender::bke::greasepencil::LayerGroup &dst)
ID * BKE_libblock_find_name(Main *bmain, short type, const char *name, const std::optional< Library * > lib=std::nullopt) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
General operations, lookup, etc. for materials.
bool BKE_object_material_slot_remove(struct Main *bmain, struct Object *ob)
struct Material * BKE_object_material_get(struct Object *ob, short act)
bool BKE_object_material_slot_used(struct Object *object, short actcol)
short * BKE_object_material_len_p(struct Object *ob)
struct Material *** BKE_object_material_array_p(struct Object *ob)
int BKE_object_material_ensure(Main *bmain, Object *ob, Material *material)
void BKE_object_material_array_assign(struct Main *bmain, struct Object *ob, struct Material ***matar, int totcol, bool to_object_only)
struct MaterialGPencilStyle * BKE_gpencil_material_settings(struct Object *ob, short act)
int BKE_object_material_index_get(Object *ob, const Material *ma)
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 BKE_scene_graph_update_for_newframe(Depsgraph *depsgraph)
#define BLI_assert_unreachable()
#define LISTBASE_FOREACH(type, var, list)
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
MINLINE float interpf(float target, float origin, float t)
float dist_to_line_v3(const float p[3], const float l1[3], const float l2[3])
#define BLI_SCOPED_DEFER(function_to_defer)
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
#define STRNCPY(dst, src)
#define BLT_I18NCONTEXT_ID_GPENCIL
#define BLT_I18NCONTEXT_ID_MOVIECLIP
void DEG_id_tag_update(ID *id, unsigned int flags)
void DEG_relations_tag_update(Main *bmain)
float DEG_get_ctime(const Depsgraph *graph)
Object * DEG_get_original_object(Object *object)
@ ID_RECALC_ANIMATION_NO_FLUSH
@ GP_STROKE_CAP_TYPE_FLAT
@ GP_STROKE_CAP_TYPE_ROUND
@ GP_MATERIAL_GRADIENT_RADIAL
Object is a sort of wrapper for general info.
@ V3D_AROUND_CENTER_BOUNDS
@ V3D_AROUND_CENTER_MEDIAN
@ V3D_AROUND_LOCAL_ORIGINS
float ED_view3d_grid_view_scale(const Scene *scene, const View3D *v3d, const ARegion *region, const char **r_grid_unit)
void ED_view3d_depth_override(Depsgraph *depsgraph, ARegion *region, View3D *v3d, Object *obact, eV3DDepthOverrideMode mode, bool use_overlay, ViewDepths **r_depths)
void ED_view3d_depths_free(ViewDepths *depths)
bool ED_view3d_win_to_3d_on_plane(const ARegion *region, const float plane[4], const float mval[2], bool do_clip, float r_out[3])
MatBase< float, 2, 4 > float2x4
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Gabor Generate Gabor noise Gradient Generate interpolated color and intensity values based on the input vector Magic Generate a psychedelic color texture Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a point
#define RNA_ENUM_ITEM_SEPR
uiLayout * uiLayoutRow(uiLayout *layout, bool align)
void uiLayoutSetPropSep(uiLayout *layout, bool is_sep)
void uiLayoutSetPropDecorate(uiLayout *layout, bool is_sep)
void uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, eUI_Item_Flag flag, const char *name, int icon)
BPy_StructRNA * depsgraph
VecBase< float, 3 > float3
static IndexMask from_predicate(const IndexMask &universe, GrainSize grain_size, IndexMaskMemory &memory, Fn &&predicate)
static constexpr IndexRange from_begin_size(const int64_t begin, const int64_t size)
const Value & lookup(const Key &key) const
constexpr MutableSpan drop_front(const int64_t n) const
static VArray ForContainer(ContainerT container)
static VArray ForSingle(T value, const int64_t size)
void append(const T &value)
IndexRange index_range() const
Span< T > as_span() const
MutableSpan< T > as_mutable_span()
IndexRange index_range() const
static IndexMask from_bools(Span< bool > bools, IndexMaskMemory &memory)
constexpr int64_t first() const
constexpr IndexRange shift(int64_t n) const
constexpr int64_t last(const int64_t n=0) const
constexpr int64_t size() const
constexpr IndexRange drop_front(int64_t n) const
const Value * lookup_ptr(const Key &key) const
bool add(const Key &key, const Value &value)
const Value & lookup(const Key &key) const
Value lookup_default(const Key &key, const Value &default_value) const
void add_new(const Key &key, const Value &value)
ItemIterator items() const
constexpr MutableSpan slice(const int64_t start, const int64_t size) const
constexpr MutableSpan drop_back(const int64_t n) const
constexpr void fill(const T &value) const
constexpr const T & first() const
constexpr int64_t size() const
constexpr const T & last(const int64_t n=0) const
constexpr IndexRange index_range() const
constexpr bool contains(const T &value) const
constexpr const char * c_str() const
std::optional< T > get_if_single() const
int64_t index_of_or_add(const Key &key)
void append(const T &value)
void insert(const int64_t insert_index, const T &value)
const T & last(const int64_t n=0) const
IndexRange index_range() const
MutableSpan< T > as_mutable_span()
Span< T > as_span() const
GAttributeReader lookup_or_default(StringRef attribute_id, AttrDomain domain, eCustomDataType data_type, const void *default_value=nullptr) const
bool contains(const StringRef attribute_id) const
void remove_attributes_based_on_types()
OffsetIndices< int > points_by_curve() const
IndexRange curves_range() const
void update_curve_types()
MutableAttributeAccessor attributes_for_write()
void resize(int points_num, int curves_num)
void remove_curves(const IndexMask &curves_to_delete, const AttributeFilter &attribute_filter)
AttributeAccessor attributes() const
MutableSpan< int > offsets_for_write()
VArray< bool > cyclic() const
MutableSpan< bool > cyclic_for_write()
GSpanAttributeWriter lookup_or_add_for_write_span(StringRef attribute_id, AttrDomain domain, eCustomDataType data_type, const AttributeInit &initializer=AttributeInitDefaultValue())
bool remove(const StringRef attribute_id)
GSpanAttributeWriter lookup_for_write_span(StringRef attribute_id)
Span< float3 > curve_plane_normals() const
MutableSpan< float > opacities_for_write()
MutableSpan< float > radii_for_write()
bke::CurvesGeometry & strokes_for_write()
const bke::CurvesGeometry & strokes() const
VArray< float > radii() const
void tag_positions_changed()
void tag_topology_changed()
VArray< float > opacities() const
void set_texture_matrices(Span< float4x2 > matrices, const IndexMask &selection)
Span< const TreeNode * > nodes() const
float4x4 to_world_space(const Object &object) const
const Map< FramesMapKeyT, GreasePencilFrame > & frames() const
void tag_frames_map_changed()
bool has_drawing_at(const int frame_number) const
std::optional< int > start_frame_at(int frame_number) const
float4x4 to_object_space(const Object &object) const
Map< FramesMapKeyT, GreasePencilFrame > & frames_for_write()
const Layer & as_layer() const
float3 reproject(float3 pos) const
void to_indices(MutableSpan< T > r_indices) const
IndexMask slice_content(IndexRange range) const
void foreach_index_optimized(Fn &&fn) const
IndexMask complement(const IndexMask &universe, IndexMaskMemory &memory) const
void foreach_index(Fn &&fn) const
VecBase< float, 2 > float2
CCL_NAMESPACE_BEGIN struct Options options
static bool is_cyclic(const Nurb *nu)
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
static float normals[][3]
void ED_operatortypes_grease_pencil_edit()
int ED_grease_pencil_join_objects_exec(bContext *C, wmOperator *op)
blender::bke::AttrDomain ED_grease_pencil_edit_selection_domain_get(const ToolSettings *tool_settings)
void GREASE_PENCIL_OT_stroke_trim(wmOperatorType *ot)
void *(* MEM_malloc_arrayN)(size_t len, size_t size, const char *str)
void *(* MEM_dupallocN)(const void *vmemh)
ccl_device_inline float4 mask(const int4 mask, const float4 a)
void invert_booleans(MutableSpan< bool > span)
void copy(const GVArray &src, GMutableSpan dst, int64_t grain_size=4096)
Vector< IndexRange > find_all_ranges(const Span< T > span, const T &value)
BooleanMix booleans_mix_calc(const VArray< bool > &varray, IndexRange range_to_check)
void fill_index_range(MutableSpan< T > span, const T start=0)
void fill_points(OffsetIndices< int > points_by_curve, const IndexMask &curve_selection, GPointer value, GMutableSpan dst)
void copy_drawing_array(Span< const GreasePencilDrawingBase * > src_drawings, MutableSpan< GreasePencilDrawingBase * > dst_drawings)
CurvesGeometry curves_copy_curve_selection(const CurvesGeometry &curves, const IndexMask &curves_to_copy, const AttributeFilter &attribute_filter)
CurvesGeometry curves_copy_point_selection(const CurvesGeometry &curves, const IndexMask &points_to_copy, const AttributeFilter &attribute_filter)
auto attribute_filter_from_skip_ref(const Span< StringRef > skip)
void gather_attributes(AttributeAccessor src_attributes, AttrDomain src_domain, AttrDomain dst_domain, const AttributeFilter &attribute_filter, const IndexMask &selection, MutableAttributeAccessor dst_attributes)
Curves * curves_new_nomain(int points_num, int curves_num)
static bool has_anything_selected(const Span< Curves * > curves_ids)
IndexMask retrieve_selected_curves(const bke::CurvesGeometry &curves, IndexMaskMemory &memory)
void duplicate_curves(bke::CurvesGeometry &curves, const IndexMask &mask)
void duplicate_points(bke::CurvesGeometry &curves, const IndexMask &mask)
void fill_selection_false(GMutableSpan selection)
bke::GSpanAttributeWriter ensure_selection_attribute(bke::CurvesGeometry &curves, bke::AttrDomain selection_domain, eCustomDataType create_type, StringRef attribute_name)
IndexMask retrieve_selected_points(const bke::CurvesGeometry &curves, IndexMaskMemory &memory)
IndexMask retrieve_editable_and_selected_elements(Object &object, const bke::greasepencil::Drawing &drawing, int layer_index, const bke::AttrDomain selection_domain, IndexMaskMemory &memory)
static void GREASE_PENCIL_OT_extrude(wmOperatorType *ot)
static void GREASE_PENCIL_OT_texture_gradient(wmOperatorType *ot)
bool active_grease_pencil_poll(bContext *C)
static int grease_pencil_clean_loose_invoke(bContext *C, wmOperator *op, const wmEvent *event)
IndexMask retrieve_editable_and_selected_strokes(Object &object, const bke::greasepencil::Drawing &drawing, int layer_index, IndexMaskMemory &memory)
static int grease_pencil_set_material_exec(bContext *C, wmOperator *op)
static void GREASE_PENCIL_OT_caps_set(wmOperatorType *ot)
static int grease_pencil_move_to_layer_invoke(bContext *C, wmOperator *op, const wmEvent *event)
blender::bke::CurvesGeometry curves_merge_by_distance(const bke::CurvesGeometry &src_curves, const float merge_distance, const IndexMask &selection, const bke::AttributeFilter &attribute_filter)
static bke::greasepencil::Layer & copy_layer(GreasePencil &grease_pencil_dst, bke::greasepencil::LayerGroup &group_dst, const bke::greasepencil::Layer &layer_src)
static void grease_pencil_reproject_ui(bContext *, wmOperator *op)
IndexRange clipboard_paste_strokes(Main &bmain, Object &object, bke::greasepencil::Drawing &drawing, const float4x4 &transform, const bool keep_world_transform, const bool paste_back)
static void GREASE_PENCIL_OT_stroke_simplify(wmOperatorType *ot)
static int grease_pencil_stroke_merge_by_distance_exec(bContext *C, wmOperator *op)
static void join_object_with_active(Main &bmain, Object &ob_src, Object &ob_dst, VectorSet< Material * > &materials)
IndexMask retrieve_editable_points(Object &object, const bke::greasepencil::Drawing &drawing, int layer_index, IndexMaskMemory &memory)
static int grease_pencil_clean_loose_exec(bContext *C, wmOperator *op)
bool ensure_active_keyframe(const Scene &scene, GreasePencil &grease_pencil, bke::greasepencil::Layer &layer, const bool duplicate_previous_key, bool &r_inserted_keyframe)
const bke::CurvesGeometry & clipboard_curves()
static int grease_pencil_texture_gradient_modal(bContext *C, wmOperator *op, const wmEvent *event)
static int grease_pencil_copy_strokes_exec(bContext *C, wmOperator *op)
static void GREASE_PENCIL_OT_set_curve_type(wmOperatorType *ot)
static void toggle_caps(MutableSpan< int8_t > caps, const IndexMask &strokes)
static void GREASE_PENCIL_OT_snap_cursor_to_selected(wmOperatorType *ot)
static Array< int > clipboard_materials_remap(Main &bmain, Object &object)
static int grease_pencil_reproject_exec(bContext *C, wmOperator *op)
static bool grease_pencil_paste_strokes_poll(bContext *C)
bool editable_grease_pencil_point_selection_poll(bContext *C)
static bke::CurvesGeometry extrude_grease_pencil_curves(const bke::CurvesGeometry &src, const IndexMask &points_to_extrude)
static int grease_pencil_reset_uvs_exec(bContext *C, wmOperator *)
static void GREASE_PENCIL_OT_delete(wmOperatorType *ot)
static int grease_pencil_snap_to_grid_exec(bContext *C, wmOperator *)
static int grease_pencil_delete_exec(bContext *C, wmOperator *)
static bool grease_pencil_separate_material(bContext &C, Main &bmain, Scene &scene, ViewLayer &view_layer, Base &base_prev, Object &object_src)
static int grease_pencil_snap_cursor_to_sel_exec(bContext *C, wmOperator *)
static void remove_unused_materials(Main *bmain, Object *object)
static void GREASE_PENCIL_OT_stroke_switch_direction(wmOperatorType *ot)
static int grease_pencil_duplicate_exec(bContext *C, wmOperator *)
Vector< DrawingInfo > retrieve_visible_drawings(const Scene &scene, const GreasePencil &grease_pencil, const bool do_onion_skinning)
static void GREASE_PENCIL_OT_set_active_material(wmOperatorType *ot)
static Clipboard & ensure_grease_pencil_clipboard()
static int grease_pencil_stroke_switch_direction_exec(bContext *C, wmOperator *)
static void remap_material_indices(bke::greasepencil::Drawing &drawing, const Span< int > material_index_map)
static int grease_pencil_set_curve_resolution_exec(bContext *C, wmOperator *op)
IndexMask retrieve_editable_strokes_by_material(Object &object, const bke::greasepencil::Drawing &drawing, const int mat_i, IndexMaskMemory &memory)
static int grease_pencil_snap_to_cursor_exec(bContext *C, wmOperator *op)
static const EnumPropertyItem prop_separate_modes[]
static bke::greasepencil::Layer & find_or_create_layer_in_dst_by_name(const int layer_index, const GreasePencil &grease_pencil_src, GreasePencil &grease_pencil_dst)
static int grease_pencil_stroke_smooth_exec(bContext *C, wmOperator *op)
static void GREASE_PENCIL_OT_copy(wmOperatorType *ot)
static void GREASE_PENCIL_OT_separate(wmOperatorType *ot)
static int64_t stroke_simplify(const IndexRange points, const bool cyclic, const float epsilon, const FunctionRef< float(int64_t, int64_t, int64_t)> dist_function, MutableSpan< bool > points_to_delete)
static bool grease_pencil_separate_layer(bContext &C, Main &bmain, Scene &scene, ViewLayer &view_layer, Base &base_prev, Object &object_src)
static void GREASE_PENCIL_OT_delete_frame(wmOperatorType *ot)
static bke::greasepencil::LayerGroup & copy_layer_group_recursive(GreasePencil &grease_pencil_dst, bke::greasepencil::LayerGroup &parent_dst, const bke::greasepencil::LayerGroup &group_src, Map< StringRefNull, StringRefNull > &layer_name_map)
static void GREASE_PENCIL_OT_set_curve_resolution(wmOperatorType *ot)
static float4x3 expand_4x2_mat(float4x2 strokemat)
static int grease_pencil_delete_frame_exec(bContext *C, wmOperator *op)
bool editable_grease_pencil_poll(bContext *C)
static void remap_vertex_groups(bke::greasepencil::Drawing &drawing, const Map< StringRefNull, StringRefNull > &vertex_group_map)
static int grease_pencil_dissolve_exec(bContext *C, wmOperator *op)
static void GREASE_PENCIL_OT_set_uniform_opacity(wmOperatorType *ot)
static float dist_to_interpolated(float3 pos, float3 posA, float3 posB, float val, float valA, float valB)
static int grease_pencil_set_uniform_thickness_exec(bContext *C, wmOperator *op)
static int grease_pencil_cyclical_set_exec(bContext *C, wmOperator *op)
static void GREASE_PENCIL_OT_move_to_layer(wmOperatorType *ot)
static void GREASE_PENCIL_OT_snap_to_grid(wmOperatorType *ot)
static void GREASE_PENCIL_OT_clean_loose(wmOperatorType *ot)
static void GREASE_PENCIL_OT_stroke_smooth(wmOperatorType *ot)
static int grease_pencil_set_active_material_exec(bContext *C, wmOperator *)
IndexMask retrieve_editable_and_selected_points(Object &object, const bke::greasepencil::Drawing &drawing, int layer_index, IndexMaskMemory &memory)
static int grease_pencil_set_curve_type_exec(bContext *C, wmOperator *op)
static int grease_pencil_stroke_material_set_exec(bContext *C, wmOperator *op)
static void GREASE_PENCIL_OT_set_handle_type(wmOperatorType *ot)
static int grease_pencil_stroke_simplify_exec(bContext *C, wmOperator *op)
static void GREASE_PENCIL_OT_stroke_reorder(wmOperatorType *ot)
static void GREASE_PENCIL_OT_stroke_merge_by_distance(wmOperatorType *ot)
static int grease_pencil_stroke_reorder_exec(bContext *C, wmOperator *op)
static bool grease_pencil_snap_compute_centroid(const Scene &scene, const Object &object, const GreasePencil &grease_pencil, float3 &r_centroid, float3 &r_min, float3 &r_max)
static const EnumPropertyItem prop_dissolve_types[]
static int grease_pencil_caps_set_exec(bContext *C, wmOperator *op)
Vector< MutableDrawingInfo > retrieve_editable_drawings_from_layer(const Scene &scene, GreasePencil &grease_pencil, const blender::bke::greasepencil::Layer &layer)
static int grease_pencil_texture_gradient_exec(bContext *C, wmOperator *op)
static void GREASE_PENCIL_OT_stroke_subdivide(wmOperatorType *ot)
static bool grease_pencil_snap_poll(bContext *C)
static int grease_pencil_extrude_exec(bContext *C, wmOperator *)
static Array< int > add_materials_to_map(const GreasePencil &grease_pencil, VectorSet< Material * > &materials)
static int grease_pencil_set_handle_type_exec(bContext *C, wmOperator *op)
static void GREASE_PENCIL_OT_reproject(wmOperatorType *ot)
static int grease_pencil_move_to_layer_exec(bContext *C, wmOperator *op)
static Map< StringRefNull, StringRefNull > add_vertex_groups(Object &object, GreasePencil &grease_pencil, const ListBase &vertex_group_names)
static bke::CurvesGeometry remove_points_and_split(const bke::CurvesGeometry &curves, const IndexMask &mask)
static void copy_layer_group_content(GreasePencil &grease_pencil_dst, bke::greasepencil::LayerGroup &group_dst, const bke::greasepencil::LayerGroup &group_src, Map< StringRefNull, StringRefNull > &layer_name_map)
static int grease_pencil_separate_exec(bContext *C, wmOperator *op)
static void GREASE_PENCIL_OT_snap_to_cursor(wmOperatorType *ot)
IndexMask retrieve_editable_strokes(Object &object, const bke::greasepencil::Drawing &drawing, int layer_index, IndexMaskMemory &memory)
Vector< MutableDrawingInfo > retrieve_editable_drawings(const Scene &scene, GreasePencil &grease_pencil)
static struct blender::ed::greasepencil::Clipboard * grease_pencil_clipboard
static void GREASE_PENCIL_OT_stroke_material_set(wmOperatorType *ot)
static void GREASE_PENCIL_OT_set_uniform_thickness(wmOperatorType *ot)
static void GREASE_PENCIL_OT_reset_uvs(wmOperatorType *ot)
static void GREASE_PENCIL_OT_duplicate(wmOperatorType *ot)
static const EnumPropertyItem * material_enum_itemf(bContext *C, PointerRNA *, PropertyRNA *, bool *r_free)
static Object * duplicate_grease_pencil_object(Main *bmain, Scene *scene, ViewLayer *view_layer, Base *base_prev, const GreasePencil &grease_pencil_src)
static void GREASE_PENCIL_OT_paste(wmOperatorType *ot)
static int gpencil_stroke_subdivide_exec(bContext *C, wmOperator *op)
std::mutex grease_pencil_clipboard_lock
static bke::GeometrySet join_geometries_with_transform(Span< bke::GeometrySet > geometries, Span< float4x4 > transforms)
static int grease_pencil_texture_gradient_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static void GREASE_PENCIL_OT_cyclical_set(wmOperatorType *ot)
Array< Vector< MutableDrawingInfo > > retrieve_editable_drawings_grouped_per_frame(const Scene &scene, GreasePencil &grease_pencil)
static const EnumPropertyItem prop_cyclical_types[]
static void GREASE_PENCIL_OT_dissolve(wmOperatorType *ot)
bool active_grease_pencil_layer_poll(bContext *C)
static bool grease_pencil_separate_selected(bContext &C, Main &bmain, Scene &scene, ViewLayer &view_layer, Base &base_prev, Object &object_src)
static const EnumPropertyItem prop_greasepencil_deleteframe_types[]
static int grease_pencil_paste_strokes_exec(bContext *C, wmOperator *op)
static void GREASE_PENCIL_OT_set_material(wmOperatorType *ot)
static Array< bool > get_points_to_dissolve(bke::CurvesGeometry &curves, const IndexMask &mask, const DissolveMode mode)
static Array< int > get_reordered_indices(const IndexRange universe, const IndexMask &selected, const ReorderDirection direction)
static int grease_pencil_set_uniform_opacity_exec(bContext *C, wmOperator *op)
Base * add_duplicate(Main *bmain, Scene *scene, ViewLayer *view_layer, Base *base, eDupli_ID_Flags dupflag)
void base_free_and_unlink(Main *bmain, Scene *scene, Object *ob)
bke::CurvesGeometry reorder_curves_geometry(const bke::CurvesGeometry &src_curves, Span< int > old_by_new_map, const bke::AttributeFilter &attribute_filter)
void smooth_curve_attribute(const IndexMask &curves_to_smooth, const OffsetIndices< int > points_by_curve, const VArray< bool > &point_selection, const VArray< bool > &cyclic, int iterations, float influence, bool smooth_ends, bool keep_shape, GMutableSpan attribute_data)
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)
bke::CurvesGeometry subdivide_curves(const bke::CurvesGeometry &src_curves, const IndexMask &selection, const VArray< int > &cuts, const bke::AttributeFilter &attribute_filter={})
bke::CurvesGeometry convert_curves(const bke::CurvesGeometry &src_curves, const IndexMask &selection, CurveType dst_type, const bke::AttributeFilter &attribute_filter, const ConvertCurvesOptions &options={})
void masked_fill(MutableSpan< T > data, const T &value, const IndexMask &mask)
AngleRadianBase< float > AngleRadian
T length_squared(const VecBase< T, Size > &a)
MatBase< T, NumCol, NumRow > transpose(const MatBase< T, NumRow, NumCol > &mat)
T distance(const T &a, const T &b)
T dot(const QuaternionBase< T > &a, const QuaternionBase< T > &b)
CartesianBasis invert(const CartesianBasis &basis)
T midpoint(const T &a, const T &b)
AxisSigned cross(const AxisSigned a, const AxisSigned b)
MatT from_scale(const VecBase< typename MatT::base_type, ScaleDim > &scale)
void min_max(const T &value, T &min, T &max)
T distance_squared(const VecBase< T, Size > &a, const VecBase< T, Size > &b)
T max(const T &a, const T &b)
VecBase< T, 3 > transform_direction(const MatBase< T, 3, 3 > &mat, const VecBase< T, 3 > &direction)
MatT from_rotation(const RotationT &rotation)
VecBase< T, 3 > transform_point(const CartesianBasis &basis, const VecBase< T, 3 > &v)
void copy_group_sizes(OffsetIndices< int > offsets, const IndexMask &mask, MutableSpan< int > sizes)
OffsetIndices< int > accumulate_counts_to_offsets(MutableSpan< int > counts_to_offsets, int start_offset=0)
void parallel_for_each(Range &&range, const Function &function)
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
MatBase< float, 2, 2 > float2x2
MatBase< float, 4, 4 > float4x4
VecBase< float, 4 > float4
VecBase< float, 2 > float2
MatBase< float, 4, 2 > float4x2
MatBase< float, 3, 2 > float3x2
MatBase< float, 4, 3 > float4x3
VecBase< float, 3 > float3
float wrap(float value, float max, float min)
static void unique_name(bNode *node)
GPU_SHADER_INTERFACE_INFO(overlay_edit_curve_handle_iface, "vert").flat(Type pos vertex_in(1, Type::UINT, "data") .vertex_out(overlay_edit_curve_handle_iface) .geometry_layout(PrimitiveIn Frequency::GEOMETRY storage_buf(1, Qualifier::READ, "uint", "data[]", Frequency::GEOMETRY) .push_constant(Type Frequency::GEOMETRY selection[]
void RNA_string_set(PointerRNA *ptr, const char *name, const char *value)
void RNA_string_get(PointerRNA *ptr, const char *name, char *value)
int RNA_int_get(PointerRNA *ptr, const char *name)
char * RNA_string_get_alloc(PointerRNA *ptr, const char *name, char *fixedbuf, int fixedlen, int *r_len)
float RNA_float_get(PointerRNA *ptr, const char *name)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
int RNA_enum_get(PointerRNA *ptr, const char *name)
const EnumPropertyItem rna_enum_curves_handle_type_items[]
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_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)
void RNA_enum_item_end(EnumPropertyItem **items, int *totitem)
void RNA_enum_item_add(EnumPropertyItem **items, int *totitem, const EnumPropertyItem *item)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
void RNA_def_property_translation_context(PropertyRNA *prop, const char *context)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_enum_funcs(PropertyRNA *prop, EnumPropertyItemFunc itemfunc)
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)
const EnumPropertyItem rna_enum_dummy_DEFAULT_items[]
ListBase vertex_group_names
GreasePencilLayerTreeNode base
struct Material ** material_array
ListBase vertex_group_names
GreasePencilDrawingBase ** drawing_array
struct ToolSettings * toolsettings
static MatBase identity()
static GeometrySet from_instances(Instances *instances, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
static GeometrySet from_curves(Curves *curves, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
Curves * get_curves_for_write()
MutableVArraySpan< T > span
Vector< std::pair< uint, int > > materials
int materials_in_source_num
bke::CurvesGeometry curves
bke::greasepencil::Drawing & drawing
struct ReportList * reports
VecBase< float, 4 > float4
void WM_cursor_wait(bool val)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
int WM_gesture_straightline_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void WM_gesture_straightline_cancel(bContext *C, wmOperator *op)
int WM_gesture_straightline_modal(bContext *C, wmOperator *op, const wmEvent *event)
void WM_operator_properties_gesture_straightline(wmOperatorType *ot, int cursor)
void WM_operatortype_append(void(*opfunc)(wmOperatorType *))
int WM_menu_invoke(bContext *C, wmOperator *op, const wmEvent *)
int WM_operator_props_popup_confirm_ex(bContext *C, wmOperator *op, const wmEvent *, std::optional< std::string > title, std::optional< std::string > confirm_text, const bool cancel_default)