73#include <fmt/format.h>
93 void redraw(
bool final)
override;
95 void done(
bool is_cancel,
bool stroke_started)
override;
101 return float3(mouse.x, mouse.y, 0);
122 switch (
brush.gpencil_brush_type) {
233 if (operation !=
nullptr) {
349 ot->
name =
"Grease Pencil Draw";
350 ot->
idname =
"GREASE_PENCIL_OT_brush_stroke";
351 ot->
description =
"Draw a new stroke in the active Grease Pencil object";
401 if (
brush ==
nullptr) {
406 bool inserted_keyframe =
false;
411 if (
layer->is_editable() &&
415 inserted_keyframe =
true;
418 if (!inserted_keyframe) {
466 ot->
name =
"Grease Pencil Sculpt";
467 ot->
idname =
"GREASE_PENCIL_OT_sculpt_paint";
468 ot->
description =
"Sculpt strokes in the active Grease Pencil object";
510 if (
brush ==
nullptr) {
565 ot->
name =
"Grease Pencil Paint Weight";
566 ot->
idname =
"GREASE_PENCIL_OT_weight_brush_stroke";
567 ot->
description =
"Draw weight on stroke points in the active Grease Pencil object";
614 if (
brush ==
nullptr) {
619 bool inserted_keyframe =
false;
624 if (
layer->is_editable() &&
628 inserted_keyframe =
true;
631 if (!inserted_keyframe) {
675 ot->
name =
"Grease Pencil Paint Vertex";
676 ot->
idname =
"GREASE_PENCIL_OT_vertex_brush_stroke";
677 ot->
description =
"Draw on vertex colors in the active Grease Pencil object";
743 brush.gpencil_settings->fill_extend_mode);
753 const bool brush_invert =
brush.gpencil_settings->fill_direction ==
BRUSH_DIR_IN;
755 const bool combined_invert = (
invert != brush_invert);
786 const IndexRange bvh_extension_range = extension_data.
lines.starts.index_range();
789 bvh_curve_offsets_data[i] = drawings[i].drawing.strokes().points_num();
792 bvh_curve_offsets_data, bvh_extension_range.
size());
796 const int max_bvh_lines = bvh_curve_offsets.
data().last();
806 for (
const int i_line : bvh_extension_range.
index_range()) {
811 const int bvh_index = bvh_extension_range[i_line];
812 view_starts[bvh_index] = start;
813 view_ends[bvh_index] = end;
815 const float bb[6] = {start.x, start.y, 0.0f, end.x, end.y, 0.0f};
820 for (
const int i_drawing : drawings.
index_range()) {
827 const float4x4 layer_to_view = view_matrix *
layer.to_world_space(
object);
829 for (
const int i_curve :
curves.curves_range()) {
830 const bool is_cyclic = cyclic[i_curve];
831 const IndexRange points = points_by_curve[i_curve];
833 for (
const int i_point : points.
drop_back(1)) {
837 const int bvh_index = bvh_curve_offsets[i_drawing][i_point];
838 view_starts[bvh_index] = start;
839 view_ends[bvh_index] = end;
841 const float bb[6] = {start.x, start.y, 0.0f, end.x, end.y, 0.0f};
849 const int bvh_index = bvh_curve_offsets[i_drawing][points.
last()];
850 view_starts[bvh_index] = start;
851 view_ends[bvh_index] = end;
853 const float bb[6] = {start.x, start.y, 0.0f, end.x, end.y, 0.0f};
873 const RaycastArgs &args = *
static_cast<const RaycastArgs *
>(userdata);
874 if (
ELEM(
index, args.ignore_index1, args.ignore_index2, args.ignore_index3)) {
879 const float2 ray_end = ray_start +
float2(ray->direction) * ray->radius;
887 if (dist >= hit->dist) {
894 hit->no[0] =
result.lambda;
900 for (
const int i_line : extension_data.
lines.starts.index_range()) {
907 const int bvh_index = i_line;
908 const int origin_drawing = origin_drawings[i_line];
909 const int origin_point = origin_points[i_line];
910 const int bvh_origin_index = bvh_curve_offsets[origin_drawing][origin_point];
913 int bvh_adjacent_index = -1;
914 if (origin_point > 0 && origin_point < bvh_curve_offsets[origin_drawing].size() - 1) {
916 bvh_adjacent_index = bvh_curve_offsets[origin_drawing][origin_point - 1];
919 RaycastArgs args = {view_starts, view_ends, bvh_index, bvh_origin_index, bvh_adjacent_index};
926 if (hit.
index >= 0) {
927 const float lambda = hit.
no[0];
929 extension_data.
lines.starts[i_line], extension_data.
lines.ends[i_line], lambda);
932 new_extension_ends[i_line] = extension_data.
lines.ends[i_line];
936 extension_data.
lines.ends = std::move(new_extension_ends);
960 feature_points_range.
size());
964 const int max_kd_entries = kd_points_range.
size();
972 for (
const int point_i : circles_range.
index_range()) {
976 extension_data.
circles.radii[point_i];
978 const int kd_index = circles_range[point_i];
979 view_centers[kd_index] = center;
980 view_radii[kd_index] = radius;
984 for (
const int i_point : feature_points_range.
index_range()) {
998 for (
const int point_i : circles_range.
index_range()) {
999 const int kd_index = circles_range[point_i];
1000 const float2 center = view_centers[kd_index];
1001 const float radius = view_radii[kd_index];
1008 [&](
const int other_point_i,
const float2 & ,
float ) {
1009 if (other_point_i == kd_index) {
1014 connection_lines.starts.append(extension_data.
circles.centers[point_i]);
1015 if (circles_range.
contains(other_point_i)) {
1016 connection_lines.ends.append(extension_data.
circles.centers[other_point_i]);
1018 else if (feature_points_range.
contains(other_point_i)) {
1020 connection_lines.ends.append(
float3(0));
1029 keep_circle_indices.
append(point_i);
1036 extension_data.
lines.starts.extend(connection_lines.starts);
1037 extension_data.
lines.ends.extend(connection_lines.ends);
1041 extension_data.
circles.centers.resize(keep_circle_indices.
size());
1042 extension_data.
circles.radii.resize(keep_circle_indices.
size());
1044 keep_circle_indices.
as_span(),
1045 extension_data.
circles.centers.as_mutable_span());
1047 keep_circle_indices.
as_span(),
1048 extension_data.
circles.radii.as_mutable_span());
1064 for (
const int i_drawing : drawings.
index_range()) {
1073 for (
const int i_curve :
curves.curves_range()) {
1074 const IndexRange points = points_by_curve[i_curve];
1076 if (cyclic[i_curve]) {
1080 if (points.
size() < 2) {
1088 positions[points.
last(1)]);
1096 extension_data.
lines.starts.append(pos_head);
1097 extension_data.
lines.ends.append(pos_head + dir_head *
length);
1098 origin_drawings.
append(i_drawing);
1101 extension_data.
lines.starts.append(pos_tail);
1102 extension_data.
lines.ends.append(pos_tail + dir_tail *
length);
1103 origin_drawings.
append(i_drawing);
1110 float distance_prev;
1111 float distance_next;
1114 for (
const int i : points.index_range().drop_front(2)) {
1115 tangent_prev = tangent_next;
1116 distance_prev = distance_next;
1117 pos_prev = pos_next;
1122 float curvature_length;
1131 const float stroke_radius = radii[points[i - 1]];
1132 const float min_radius = stroke_radius;
1138 if (distance_prev + distance_next < 2.0f * curvature_length * min_radius) {
1140 extension_data.
lines.starts.append(pos_prev);
1141 extension_data.
lines.ends.append(pos_prev + (-curvature *
length));
1142 origin_drawings.
append(i_drawing);
1143 origin_points.
append(points[i - 1]);
1149 extension_data.
circles.centers.append(pos_head);
1151 origin_drawings.
append(i_drawing);
1154 extension_data.
circles.centers.append(pos_tail);
1156 origin_drawings.
append(i_drawing);
1173 C, extension_data, origin_drawings, origin_points);
1177 return extension_data;
1186 status.
item(
IFACE_(
"Cancel"), ICON_EVENT_ESC);
1191 fmt::format(
"{} ({})",
IFACE_(
"Mode"), (is_extend ?
IFACE_(
"Extend") :
IFACE_(
"Radius"))),
1193 status.
item(fmt::format(
"{} ({:.3f})",
1196 ICON_MOUSE_MMB_SCROLL);
1228 const IndexMask curve_mask = info.drawing.strokes().curves_range();
1230 stroke_curves_color, info.drawing.strokes().points_num());
1232 const bool use_xray =
false;
1233 const float radius_scale = 1.0f;
1251 const float line_width = 2.0f;
1256 extension_lines_color, lines_range.
size());
1260 extensions.
lines.starts,
1261 extensions.
lines.ends,
1268 extension_circles_color, circles_range.
size());
1305 &bmain, &
object, &
brush);
1309 const float line_width = 2.0f;
1315 for (const int64_t point_i : range) {
1316 const float2 co = op_data.mouse_positions[point_i];
1318 ED_view3d_win_to_3d(&view3d, ®ion, float3(0.0f), co, line_positions[point_i]);
1322 if (line_positions.size() < 2) {
1330 world_to_view, line_positions.index_range(), line_positions, line_colors,
false, line_width);
1338 if (op_data.is_delaunay_method) {
1352 if (needs_overlay) {
1381 switch (fill_layer_mode) {
1384 return index != active_layer_index;
1388 return index != active_layer_index + 1;
1392 return index != active_layer_index - 1;
1396 return index <= active_layer_index;
1400 return index >= active_layer_index;
1404 return !grease_pencil.layers()[index]->is_visible();
1429 const bool use_multi_frame_editing = (toolsettings->
gpencil_flags &
1433 const int target_layer_index = *
grease_pencil.get_layer_index(target_layer);
1440 if (use_multi_frame_editing) {
1442 for (
const auto [frame_number, frame] :
layer->frames().items()) {
1443 if (frame.is_selected()) {
1444 target_frames.
add(frame_number);
1452 for (
const int frame_number : target_frames) {
1453 if (!target_layer.
frames().contains(frame_number)) {
1454 if (use_duplicate_frame) {
1456 target_layer, *target_layer.
start_frame_at(frame_number), frame_number,
false))
1458 new_keyframes.
add(frame_number);
1462 if (
grease_pencil.insert_frame(target_layer, frame_number)) {
1463 new_keyframes.
add(frame_number);
1471 for (
const int frame_number : target_frames) {
1475 MutableDrawingInfo target = {*target_drawing, target_layer_index, frame_number, 1.0f};
1482 const int source_layer_index = *
grease_pencil.get_layer_index(*source_layer);
1483 sources.
append({*source_drawing, source_layer_index, frame_number, 0});
1487 const bool is_new_keyframe = new_keyframes.
contains(frame_number);
1488 drawings.
append({std::move(target), std::move(sources), is_new_keyframe});
1497 const int iterations = 20;
1521 curves.tag_positions_changed();
1532 const int curve_i = point_to_curve_map[i];
1533 const IndexRange points = points_by_curve[curve_i];
1534 if (points.size() <= 2) {
1537 const int local_i = i - points.start();
1550 const int material_index,
1551 const float hardness)
1555 "curve_type",
"material_index",
"cyclic",
"hardness",
"fill_opacity"};
1556 Set<std::string> skip_point_attributes = {
"position",
"radius",
"opacity"};
1568 const float pressure = 1.0f;
1576 brush.gpencil_settings);
1584 attributes.
add<
int>(
1594 if (use_vertex_color) {
1597 vertex_color.
a =
brush.gpencil_settings->vertex_factor;
1599 skip_curve_attributes.
add(
"fill_color");
1603 fill_colors.
span.fill(vertex_color);
1607 skip_point_attributes.
add(
"vertex_color");
1611 vertex_colors.
span.fill(vertex_color);
1636 constexpr const bool keep_images =
false;
1655 const int simplify_levels =
brush.gpencil_settings->fill_simplylvl;
1656 const std::optional<float> opacity_threshold =
1659 std::make_optional(
brush.gpencil_settings->fill_threshold);
1661 const bool auto_remove_fill_guides = (
brush.gpencil_settings->flag &
1675 bool did_create_fill =
false;
1679 std::optional<bke::CurvesGeometry> op_fill_curves;
1681 if (!is_delaunay_method) {
1685 op_fill_curves = std::make_optional(pixel_fill_strokes(view_context,
1700 const Array<int> fill_point_offset = {0, int(op_data.mouse_positions.size())};
1705 const float gap_factor =
brush.gpencil_settings->fill_gap_factor;
1707 op_fill_curves = delaunay_fill_strokes(view_context,
1719 if (!op_fill_curves) {
1726 const float stroke_hardness = 1.0f;
1733 layer.to_world_space(
object),
1734 op_data.material_index,
1749 if (!is_delaunay_method) {
1752 if (simplify_levels > 0) {
1758 if (auto_remove_fill_guides) {
1779 const int num_new_curves = fill_curves.
curves_num();
1780 const IndexRange new_curves_range = (on_back ?
1787 info.target.drawing.tag_topology_changed();
1791 scene, region, *view_context.
v3d,
object, &
layer);
1793 &scene, ®ion, mouse_position, placement);
1795 info.target.drawing.set_texture_matrices(texture_matrices, new_curves_range);
1798 did_create_fill =
true;
1801 if (!did_create_fill) {
1804 if (info.is_new_keyframe) {
1815 brush.gpencil_settings->fill_extend_fac = op_data.extension_length /
1838 if (
layer ==
nullptr) {
1842 if (
brush.gpencil_settings ==
nullptr) {
1857 if (material->gp_style->fill_rgba[3] == 0.0f) {
1864 op.
customdata = MEM_new<GreasePencilFillOpData>(
1881 if (op_data.overlay_cb_handle) {
1883 op_data.overlay_cb_handle =
nullptr;
1911 brush.gpencil_settings->material ==
nullptr)
1963 const float extension_delta = (op_data.precision ? 0.002f : 0.02f);
1965 switch (event->
val) {
1971 if (op_data.is_extension_drag_active) {
1975 op_data.fill_mouse_pos =
float2(event->
mval);
1980 if (op_data.show_extension) {
1993 op_data.extension_length = op_data.extension_length + extension_delta;
1998 op_data.extension_length = std::max(op_data.extension_length - extension_delta, 0.0f);
2005 op_data.is_extension_drag_active =
true;
2009 constexpr const float gap = 300.0f;
2010 op_data.extension_mouse_pos = (
math::distance(base_pos, op_data.fill_mouse_pos) >= gap ?
2012 base_pos -
float2(gap, 0));
2017 op_data.is_extension_drag_active =
false;
2026 if (op_data.show_extension) {
2027 op_data.extension_cut = !op_data.extension_cut;
2033 op_data.invert = !op_data.invert;
2037 op_data.precision = !op_data.precision;
2054 if (op_data.is_delaunay_method) {
2055 op_data.mouse_positions.append(
float2(event->
mval));
2070 if (!op_data.show_extension) {
2072 op_data.fill_mouse_pos =
float2(event->
mval);
2082 switch (event->
type) {
2087 if (!op_data.is_extension_drag_active) {
2094 const float initial_dist =
math::distance(op_data.extension_mouse_pos,
2095 op_data.fill_mouse_pos);
2096 const float current_dist =
math::distance(mouse_pos, op_data.fill_mouse_pos);
2098 float delta = (current_dist - initial_dist) * pixel_size * 0.5f;
2099 op_data.extension_length = std::max(op_data.extension_length + delta, 0.0f);
2141 ot->
name =
"Grease Pencil Fill";
2142 ot->
idname =
"GREASE_PENCIL_OT_fill";
2143 ot->
description =
"Fill with color the shape formed by strokes";
2153 ot->
srna,
"invert",
false,
"Invert",
"Find boundary of unfilled instead of filled regions");
2157 ot->
srna,
"precision",
false,
"Precision",
"Use precision movement for extension lines");
2168 bool inserted_keyframe =
false;
2170 if (active_layer->is_editable()) {
2174 if (inserted_keyframe) {
2177 for (
auto [frame_number, frame] :
layer->frames_for_write().items()) {
2178 const bool select_keyframe = (frame_number == scene->
r.
cfra) && (
layer == active_layer);
2193 bool changed =
false;
2194 for (
const int drawing_i : drawings.
index_range()) {
2195 const MutableDrawingInfo &info = drawings[drawing_i];
2196 const IndexMask points_to_remove = points_to_remove_per_drawing[drawing_i];
2201 Drawing &drawing = info.drawing;
2203 drawing.
strokes(), points_to_remove);
2213 if (point.x <
bounds.min.x) {
2216 if (point.x >
bounds.max.x) {
2219 if (point.y <
bounds.min.y) {
2222 if (point.y >
bounds.max.y) {
2231 point,
reinterpret_cast<const int (*)[2]
>(lasso.
data()),
uint(lasso.
size()));
2260 for (const int drawing_i : range) {
2261 const MutableDrawingInfo &info = drawings[drawing_i];
2262 const bke::greasepencil::Layer &layer = grease_pencil.layer(info.layer_index);
2263 const bke::crazyspace::GeometryDeformation deformation =
2264 bke::crazyspace::get_evaluated_grease_pencil_drawing_deformation(
2265 ob_eval, *object, info.drawing);
2266 const float4x4 layer_to_world = layer.to_world_space(*ob_eval);
2268 const bke::CurvesGeometry &curves = info.drawing.strokes();
2269 Array<float2> screen_space_positions(curves.points_num(), float2(0));
2270 IndexMaskMemory &memory = memories[drawing_i];
2271 const IndexMask editable_points = retrieve_editable_points(
2272 *object, info.drawing, info.layer_index, memory);
2273 editable_points.foreach_index(
2274 [&](const int point) {
2275 const float3 pos = math::transform_point(layer_to_world, deformation.positions[point]);
2276 ED_view3d_project_float_global(
2277 region, pos, screen_space_positions[point], V3D_PROJ_TEST_NOP);
2279 exec_mode::grain_size(4096));
2281 const IndexMask editable_strokes = retrieve_editable_strokes(
2282 *object, info.drawing, info.layer_index, memory);
2283 const OffsetIndices<int> points_by_curve = curves.points_by_curve();
2284 Array<Bounds<float2>> screen_space_curve_bounds(curves.curves_num(),
2285 {float2(0.0f), float2(0.0f)});
2286 editable_strokes.foreach_index(
2287 [&](const int curve) {
2288 Bounds<float2> bounds = *bounds::min_max(
2289 screen_space_positions.as_span().slice(points_by_curve[curve]));
2293 screen_space_curve_bounds[curve] = bounds;
2295 exec_mode::grain_size(512));
2297 const IndexMask curve_selection = IndexMask::from_predicate(
2298 editable_strokes, memory, [&](const int64_t index) {
2299 return bounds::intersect(lasso_bounds, screen_space_curve_bounds[index]).has_value();
2302 if (curve_selection.is_empty()) {
2306 Array<bool> points_to_remove(curves.points_num(), false);
2307 curve_selection.foreach_index(
2308 [&](const int64_t curve_i) {
2309 for (const int point : points_by_curve[curve_i]) {
2310 points_to_remove[point] = is_point_inside_lasso(lasso,
2311 int2(screen_space_positions[point]));
2314 exec_mode::grain_size(512));
2315 points_to_remove_per_drawing[drawing_i] = IndexMask::from_bools(points_to_remove, memory);
2320 points_to_remove_per_drawing);
2331 ot->
name =
"Grease Pencil Erase Lasso";
2332 ot->
idname =
"GREASE_PENCIL_OT_erase_lasso";
2333 ot->
description =
"Erase points in the lasso region";
2369 for (const int drawing_i : range) {
2370 const MutableDrawingInfo &info = drawings[drawing_i];
2371 const bke::greasepencil::Layer &layer = grease_pencil.layer(info.layer_index);
2372 const bke::crazyspace::GeometryDeformation deformation =
2373 bke::crazyspace::get_evaluated_grease_pencil_drawing_deformation(
2374 ob_eval, *object, info.drawing);
2375 const float4x4 layer_to_world = layer.to_world_space(*ob_eval);
2377 const bke::CurvesGeometry &curves = info.drawing.strokes();
2378 Array<float2> screen_space_positions(curves.points_num(), float2(0));
2379 IndexMaskMemory &memory = memories[drawing_i];
2380 const IndexMask editable_points = retrieve_editable_points(
2381 *object, info.drawing, info.layer_index, memory);
2382 editable_points.foreach_index(
2383 [&](const int point) {
2384 const float3 pos = math::transform_point(layer_to_world, deformation.positions[point]);
2385 ED_view3d_project_float_global(
2386 region, pos, screen_space_positions[point], V3D_PROJ_TEST_NOP);
2388 exec_mode::grain_size(4096));
2390 points_to_remove_per_drawing[drawing_i] = IndexMask::from_predicate(
2391 editable_points, memory, [&](const int64_t index) {
2392 return is_point_inside_bounds(box_bounds, int2(screen_space_positions[index]));
2398 points_to_remove_per_drawing);
2409 ot->
name =
"Grease Pencil Box Erase";
2410 ot->
idname =
"GREASE_PENCIL_OT_erase_box";
2411 ot->
description =
"Erase points in the box region";
2453 "EXTENSION_MODE_TOGGLE",
2455 "Toggle Extension Mode",
2458 "EXTENSION_LENGTHEN",
2460 "Lengthen Extensions",
2467 {0,
nullptr, 0,
nullptr,
nullptr},
Functions to insert, delete or modify keyframes.
Low-level operations for curves.
Low-level operations for grease pencil.
General operations, lookup, etc. for materials.
A KD-tree for nearest neighbor search.
#define BLI_SCOPED_DEFER(function_to_defer)
#define ID_IS_EDITABLE(_id)
#define ID_IS_OVERRIDE_LIBRARY(_id)
#define OPERATOR_RETVAL_CHECK(ret)
#define REGION_DRAW_POST_VIEW
Read Blender memory allocation and freeing.
#define BLI_assert_unreachable()
#define SET_FLAG_FROM_TEST(value, test, flag)
Span< T > as_span() const
static IndexMask from_predicate(const IndexMask &universe, LinearAllocator<> &memory, Fn &&predicate, exec_mode::Mode mode=exec_mode::parallel)
constexpr int64_t first() const
constexpr IndexRange drop_back(int64_t n) const
constexpr int64_t last(const int64_t n=0) const
constexpr int64_t size() const
constexpr bool is_empty() const
constexpr IndexRange()=default
constexpr IndexRange after(int64_t n) const
constexpr bool contains(int64_t value) const
constexpr IndexRange index_range() const
constexpr IndexRange index_range() const
static VArray from_std_func(const int64_t size, std::function< T(int64_t index)> get_func)
static VArray from_single(T value, const int64_t size)
static VArray from_span(Span< T > values)
bool contains(const Key &key) const
void append(const T &value)
IndexRange index_range() const
void reserve(const int64_t min_capacity)
Span< T > as_span() const
void item(std::string text, int icon1, int icon2=0)
void item_bool(std::string text, bool inverted, int icon1, int icon2=0)
bool contains(StringRef name) const
AttributeAccessor attributes() const
Span< float3 > positions() const
IndexRange curves_range() const
IndexRange points_range() const
MutableAttributeAccessor attributes_for_write()
bool add(const StringRef name, const AttrDomain domain, const AttrType data_type, const AttributeInit &initializer)
GSpanAttributeWriter lookup_or_add_for_write_span(StringRef name, AttrDomain domain, AttrType data_type, const AttributeInit &initializer=AttributeInitDefaultValue())
GSpanAttributeWriter lookup_for_write_span(StringRef name)
bke::CurvesGeometry & strokes_for_write()
const bke::CurvesGeometry & strokes() const
VArray< float > radii() const
void tag_topology_changed()
const Map< FramesMapKeyT, GreasePencilFrame > & frames() const
std::optional< int > start_frame_at(int frame_number) const
constexpr IndexRange after(int64_t n) const
virtual void on_stroke_extended(const bContext &C, const InputSample &extension_sample)=0
virtual void on_stroke_done(const bContext &C)=0
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
float length(VecOp< float, D >) RET
float2x2 invert(float2x2 mat)
bool is_autokey_on(const Scene *scene)
void gather(const GVArray &src, const IndexMask &indices, GMutableSpan dst, exec_mode::Mode mode=exec_mode::parallel)
constexpr float LEGACY_RADIUS_CONVERSION_FACTOR
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 fill_attribute_range_default(MutableAttributeAccessor dst_attributes, AttrDomain domain, const AttributeFilter &attribute_filter, IndexRange range)
Curves * curves_new_nomain(int points_num, int curves_num)
std::optional< Bounds< T > > min_max(const std::optional< Bounds< T > > &a, const T &b)
void draw_lines(const float4x4 &transform, IndexRange indices, Span< float3 > start_positions, Span< float3 > end_positions, const VArray< ColorGeometry4f > &colors, float line_width)
void draw_grease_pencil_strokes(const RegionView3D &rv3d, const int2 &win_size, const Object &object, const bke::greasepencil::Drawing &drawing, const float4x4 &transform, const IndexMask &strokes_mask, const VArray< ColorGeometry4f > &colors, const bool use_xray, const float radius_scale)
void draw_circles(const float4x4 &transform, const IndexRange indices, Span< float3 > centers, const VArray< float > &radii, const VArray< ColorGeometry4f > &colors, const float2 &viewport_size, const float line_width, const bool fill)
void draw_polyline(const float4x4 &transform, const IndexRange indices, Span< float3 > positions, const VArray< ColorGeometry4f > &colors, const bool cyclic, const float line_width)
bool grease_pencil_draw_operator_begin(bContext *C, wmOperator *op, const bool use_duplicate_previous_key)
float opacity_from_input_sample(const float pressure, const Paint &paint, const Brush *brush, const BrushGpencilSettings *settings)
bool ensure_active_keyframe(const Scene &scene, GreasePencil &grease_pencil, bke::greasepencil::Layer &layer, const bool duplicate_previous_key, bool &r_inserted_keyframe)
bool grease_pencil_vertex_painting_poll(bContext *C)
Vector< DrawingInfo > retrieve_visible_drawings(const Scene &scene, const GreasePencil &grease_pencil, const bool do_onion_skinning)
bool check_brush_needs_new_material(Object *ob, const Brush *brush)
bool has_editable_layer(const GreasePencil &grease_pencil)
bool grease_pencil_sculpting_poll(bContext *C)
bool grease_pencil_weight_painting_poll(bContext *C)
bool remove_fill_guides(bke::CurvesGeometry &curves)
Vector< MutableDrawingInfo > retrieve_editable_drawings(const Scene &scene, GreasePencil &grease_pencil)
float4x2 calculate_texture_space(const Scene *scene, const ARegion *region, const float2 &mouse, const DrawingPlacement &placement)
bool grease_pencil_painting_poll(bContext *C)
float radius_from_input_sample(const RegionView3D *rv3d, const ARegion *region, const Paint &paint, const Brush *brush, const float pressure, const float3 &location, const float4x4 &to_world, const BrushGpencilSettings *settings)
std::unique_ptr< GreasePencilStrokeOperation > new_vertex_replace_operation()
std::unique_ptr< GreasePencilStrokeOperation > new_erase_operation(const bool temp_eraser)
std::unique_ptr< GreasePencilStrokeOperation > new_weight_paint_average_operation()
std::unique_ptr< GreasePencilStrokeOperation > new_strength_operation(BrushStrokeMode stroke_mode)
std::unique_ptr< GreasePencilStrokeOperation > new_grab_operation(BrushStrokeMode stroke_mode)
std::unique_ptr< GreasePencilStrokeOperation > new_weight_paint_blur_operation()
std::unique_ptr< GreasePencilStrokeOperation > new_tint_operation(bool temp_eraser=false)
std::unique_ptr< GreasePencilStrokeOperation > new_vertex_paint_operation(BrushStrokeMode stroke_mode)
std::unique_ptr< GreasePencilStrokeOperation > new_paint_operation(bool do_fill_guides=false)
std::unique_ptr< GreasePencilStrokeOperation > new_clone_operation(BrushStrokeMode stroke_mode)
std::unique_ptr< GreasePencilStrokeOperation > new_randomize_operation(BrushStrokeMode stroke_mode)
std::unique_ptr< GreasePencilStrokeOperation > new_vertex_blur_operation()
bool brush_using_vertex_color(const GpPaint *gp_paint, const Brush *brush)
std::unique_ptr< GreasePencilStrokeOperation > new_weight_paint_draw_operation(const BrushStrokeMode &stroke_mode)
std::unique_ptr< GreasePencilStrokeOperation > new_thickness_operation(BrushStrokeMode stroke_mode)
std::unique_ptr< GreasePencilStrokeOperation > new_pinch_operation(BrushStrokeMode stroke_mode)
std::unique_ptr< GreasePencilStrokeOperation > new_push_operation(BrushStrokeMode stroke_mode)
std::unique_ptr< GreasePencilStrokeOperation > new_weight_paint_smear_operation()
std::unique_ptr< GreasePencilStrokeOperation > new_vertex_average_operation()
std::unique_ptr< GreasePencilStrokeOperation > new_twist_operation(BrushStrokeMode stroke_mode)
std::unique_ptr< GreasePencilStrokeOperation > new_smooth_operation(BrushStrokeMode stroke_mode, bool temp_smooth=false)
std::unique_ptr< GreasePencilStrokeOperation > new_vertex_smear_operation()
static void grease_pencil_fill_extension_lines_from_circles(const bContext &C, ed::greasepencil::ExtensionData &extension_data, Span< int >, Span< int >)
static bool is_point_inside_bounds(const Bounds< int2 > bounds, const int2 point)
static bool is_point_inside_lasso(const Array< int2 > lasso, const int2 point)
static bool grease_pencil_weight_brush_stroke_poll(bContext *C)
static void grease_pencil_sculpt_paint_cancel(bContext *C, wmOperator *op)
static wmOperatorStatus grease_pencil_weight_brush_stroke_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static void grease_pencil_fill_exit(bContext &C, wmOperator &op)
static wmOperatorStatus grease_pencil_vertex_brush_stroke_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static void GREASE_PENCIL_OT_erase_lasso(wmOperatorType *ot)
static wmOperatorStatus grease_pencil_brush_stroke_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static bool grease_pencil_sculpt_paint_poll(bContext *C)
static void grease_pencil_fill_cancel(bContext *C, wmOperator *op)
static wmOperatorStatus grease_pencil_sculpt_paint_modal(bContext *C, wmOperator *op, const wmEvent *event)
static void GREASE_PENCIL_OT_weight_brush_stroke(wmOperatorType *ot)
static wmOperatorStatus grease_pencil_vertex_brush_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event)
static void grease_pencil_brush_stroke_cancel(bContext *C, wmOperator *op)
static void GREASE_PENCIL_OT_brush_stroke(wmOperatorType *ot)
static void GREASE_PENCIL_OT_vertex_brush_stroke(wmOperatorType *ot)
static void GREASE_PENCIL_OT_sculpt_paint(wmOperatorType *ot)
static void grease_pencil_fill_overlay_delaunay_cb(const bContext &C, const GreasePencilFillOpData &op_data)
static void grease_pencil_fill_status_indicators(bContext &C, const GreasePencilFillOpData &op_data)
static wmOperatorStatus grease_pencil_fill_event_modal_map(bContext *C, wmOperator *op, const wmEvent *event)
static bool grease_pencil_vertex_brush_stroke_poll(bContext *C)
static void grease_pencil_vertex_brush_stroke_cancel(bContext *C, wmOperator *op)
static wmOperatorStatus grease_pencil_sculpt_paint_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static wmOperatorStatus grease_pencil_weight_brush_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event)
static bke::CurvesGeometry simplify_fixed(bke::CurvesGeometry &curves, const int step)
static wmOperatorStatus grease_pencil_erase_box_exec(bContext *C, wmOperator *op)
static void GREASE_PENCIL_OT_erase_box(wmOperatorType *ot)
static VArray< bool > get_fill_boundary_layers(const GreasePencil &grease_pencil, eGP_FillLayerModes fill_layer_mode)
static Vector< FillToolTargetInfo > ensure_editable_drawings(const Scene &scene, GreasePencil &grease_pencil, bke::greasepencil::Layer &target_layer)
static bool remove_points_and_split_from_drawings(const Span< ed::greasepencil::MutableDrawingInfo > drawings, const Span< IndexMask > points_to_remove_per_drawing)
static void grease_pencil_weight_brush_stroke_cancel(bContext *C, wmOperator *op)
static void set_fill_attributes(bke::CurvesGeometry &fill_curves, const ViewContext &view_context, const Paint &paint, const Brush &brush, const Scene &scene, const float4x4 &to_world, const int material_index, const float hardness)
static wmOperatorStatus grease_pencil_fill_invoke(bContext *C, wmOperator *op, const wmEvent *)
static void GREASE_PENCIL_OT_fill(wmOperatorType *ot)
static void grease_pencil_fill_overlay_cb(const bContext *C, ARegion *, void *arg)
static wmOperatorStatus grease_pencil_fill_modal(bContext *C, wmOperator *op, const wmEvent *event)
static bool use_duplicate_previous_key(bContext *C, wmOperator *op)
static wmOperatorStatus grease_pencil_erase_lasso_exec(bContext *C, wmOperator *op)
static bool grease_pencil_apply_fill(bContext &C, wmOperator &op, const wmEvent &event)
static wmOperatorStatus grease_pencil_brush_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event)
static void grease_pencil_fill_update_overlay(const ARegion ®ion, GreasePencilFillOpData &op_data)
static ed::greasepencil::ExtensionData grease_pencil_fill_get_extension_data(const bContext &C, const GreasePencilFillOpData &op_data)
static void grease_pencil_fill_extension_cut(const bContext &C, ed::greasepencil::ExtensionData &extension_data, Span< int > origin_drawings, Span< int > origin_points)
static void ensure_drawing_for_autokey(bContext *C, GreasePencil &grease_pencil)
static void smooth_fill_strokes(bke::CurvesGeometry &curves, const IndexMask &stroke_mask)
static std::unique_ptr< GreasePencilStrokeOperation > get_stroke_operation(bContext &C, wmOperator *op)
static void grease_pencil_fill_overlay_pixel_cb(const bContext &C, const GreasePencilFillOpData &op_data)
static bool grease_pencil_brush_stroke_poll(bContext *C)
static void grease_pencil_update_extend(bContext &C, GreasePencilFillOpData &op_data)
static wmOperatorStatus grease_pencil_brush_stroke_exec(bContext *C, wmOperator *op)
static bool grease_pencil_fill_init(bContext &C, wmOperator &op)
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 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::CurvesGeometry grease_pencil_remove_points_and_split(const bke::CurvesGeometry &curves, const IndexMask &mask)
T pow(const T &x, const T &power)
isect_result< VecBase< T, Size > > isect_seg_seg(const VecBase< T, Size > &v1, const VecBase< T, Size > &v2, const VecBase< T, Size > &v3, const VecBase< T, Size > &v4)
T distance(const T &a, const T &b)
QuaternionBase< T > normalize_and_get_length(const QuaternionBase< T > &q, T &out_length)
T average(const VecBase< T, Size > &a)
T interpolate(const T &a, const T &b, const FactorT &t)
MatBase< T, NumCol, NumRow > normalize(const MatBase< T, NumCol, NumRow > &a)
VecBase< T, 3 > to_scale(const MatBase< T, NumCol, NumRow > &mat)
VecBase< T, 3 > transform_point(const CartesianBasis &basis, const VecBase< T, 3 > &v)
OffsetIndices< int > accumulate_counts_to_offsets(MutableSpan< int > counts_to_offsets, int start_offset=0)
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
void WM_main_add_notifier(uint type, void *reference)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void WM_operatortype_append(void(*opfunc)(wmOperatorType *))
void(*)(void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit) BVHTree_RayCastCallback
void kdtree_balance(KDTree< CoordT > *tree)
int RNA_enum_get(PointerRNA *ptr, const char *name)
@ GPWEIGHT_BRUSH_TYPE_SMEAR
@ GPWEIGHT_BRUSH_TYPE_DRAW
@ GPWEIGHT_BRUSH_TYPE_BLUR
@ GPWEIGHT_BRUSH_TYPE_AVERAGE
wmKeyMap * WM_modalkeymap_find(wmKeyConfig *keyconf, const char *idname)
ViewContext ED_view3d_viewcontext_init(bContext *C, Depsgraph *depsgraph)
wmOperatorStatus WM_gesture_box_invoke(bContext *C, wmOperator *op, const wmEvent *event)
MINLINE void copy_v3_v3(float r[3], const float a[3])
bool isect_point_poly_v2_int(const int pt[2], const int verts[][2], unsigned int nr)
Depsgraph * CTX_data_depsgraph_pointer(const bContext *C)
float ED_view3d_pixel_size(const RegionView3D *rv3d, const float co[3])
Material * BKE_object_material_get(Object *ob, short act)
void BLI_bvhtree_free(BVHTree *tree)
void WM_gesture_lasso_cancel(bContext *C, wmOperator *op)
void WM_cursor_modal_set(wmWindow *win, int val)
void kdtree_range_search_cb(const KDTree< CoordT > *tree, const CoordT &co, typename KDTree< CoordT >::ValueType range, Fn &&search_cb)
void BLI_bvhtree_balance(BVHTree *tree)
void WM_operator_properties_border(wmOperatorType *ot)
void BKE_brush_init_gpencil_settings(Brush *brush)
wmWindow * CTX_wm_window(const bContext *C)
void RNA_enum_set(PointerRNA *ptr, const char *name, int value)
wmOperatorStatus WM_gesture_lasso_modal(bContext *C, wmOperator *op, const wmEvent *event)
MatBase< float, 4, 4 > float4x4
@ GP_FILL_SOLVER_DELAUNAY
int BLI_bvhtree_ray_cast(const BVHTree *tree, const float co[3], const float dir[3], float radius, BVHTreeRayHit *hit, BVHTree_RayCastCallback callback, void *userdata)
void ED_region_tag_redraw(ARegion *region)
@ GPSCULPT_BRUSH_TYPE_CLONE
@ GPSCULPT_BRUSH_TYPE_PINCH
@ GPSCULPT_BRUSH_TYPE_PUSH
@ GPSCULPT_BRUSH_TYPE_THICKNESS
@ GPSCULPT_BRUSH_TYPE_RANDOMIZE
@ GPSCULPT_BRUSH_TYPE_GRAB
@ GPSCULPT_BRUSH_TYPE_STRENGTH
@ GPSCULPT_BRUSH_TYPE_SMOOTH
@ GPSCULPT_BRUSH_TYPE_TWIST
void BKE_brush_tag_unsaved_changes(Brush *brush)
VecBase< float, 4 > float4
KDTree< CoordT > * kdtree_new(uint nodes_len_capacity)
void BKE_curvemapping_init(CurveMapping *cumap)
void ED_operatortypes_grease_pencil_draw()
@ GP_FILL_GPLMODE_VISIBLE
@ GP_FILL_GPLMODE_ALL_ABOVE
@ GP_FILL_GPLMODE_ALL_BELOW
@ GPAINT_BRUSH_TYPE_ERASE
@ GP_TOOL_FLAG_PAINT_ONBACK
@ GP_TOOL_FLAG_RETAIN_LAST
@ GP_USE_MULTI_FRAME_EDITING
void * ED_region_draw_cb_activate(ARegionType *art, void(*draw)(const bContext *, ARegion *, void *), void *customdata, int type)
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
bool ED_region_draw_cb_exit(ARegionType *art, void *handle)
void DEG_id_tag_update(ID *id, unsigned int flags)
void BKE_report(ReportList *reports, eReportType type, const char *message)
BMesh const char void * data
T * DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
MatBase< float, 4, 2 > float4x2
void kdtree_insert(KDTree< CoordT > *tree, int index, const CoordT &co)
BVHTree * BLI_bvhtree_new(int maxsize, float epsilon, char tree_type, char axis)
void WM_cursor_modal_restore(wmWindow *win)
RegionView3D * CTX_wm_region_view3d(const bContext *C)
ToolSettings * CTX_data_tool_settings(const bContext *C)
int BKE_object_material_index_get(Object *ob, const Material *ma)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void paint_stroke_operator_properties(wmOperatorType *ot)
const Brush * BKE_paint_brush_for_read(const Paint *paint)
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
void kdtree_free(KDTree< CoordT > *tree)
wmOperatorStatus WM_gesture_box_modal(bContext *C, wmOperator *op, const wmEvent *event)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
@ GPVERTEX_BRUSH_TYPE_REPLACE
@ GPVERTEX_BRUSH_TYPE_BLUR
@ GPVERTEX_BRUSH_TYPE_AVERAGE
@ GPVERTEX_BRUSH_TYPE_TINT
@ GPVERTEX_BRUSH_TYPE_SMEAR
@ GPVERTEX_BRUSH_TYPE_DRAW
Main * CTX_data_main(const bContext *C)
wmOperatorStatus WM_gesture_lasso_invoke(bContext *C, wmOperator *op, const wmEvent *event)
bool WM_toolsystem_active_tool_is_brush(const bContext *C)
Paint * BKE_paint_get_active_from_context(const bContext *C)
bool BKE_object_defgroup_active_is_locked(const struct Object *ob)
Array< int2 > WM_gesture_lasso_path_to_array(bContext *, wmOperator *op)
void WM_gesture_box_cancel(bContext *C, wmOperator *op)
void BLI_bvhtree_insert(BVHTree *tree, int index, const float co[3], int numpoints)
void WM_modalkeymap_assign(wmKeyMap *km, const char *opname)
Brush * BKE_paint_brush(Paint *paint)
Material * BKE_grease_pencil_object_material_ensure_from_brush(Main *bmain, Object *ob, Brush *brush)
Scene * CTX_data_scene(const bContext *C)
float3 BKE_brush_color_get(const Paint *paint, const Brush *brush)
ColorSceneLinear4f< eAlpha::Premultiplied > ColorGeometry4f
void WM_cursor_set(wmWindow *win, int curs)
bool BLI_rcti_isect_pt_v(const struct rcti *rect, const int xy[2])
wmKeyMap * WM_modalkeymap_ensure(wmKeyConfig *keyconf, const char *idname, const EnumPropertyItem *items)
VecBase< float, 3 > float3
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
@ GP_BRUSH_FILL_SHOW_EXTENDLINES
@ GP_BRUSH_FILL_SHOW_HELPLINES
@ GP_BRUSH_FILL_STROKE_COLLIDE
@ GP_BRUSH_FILL_AUTO_REMOVE_FILL_GUIDES
@ GP_BRUSH_FILL_INTERNAL_GAPS
@ GP_BRUSH_MATERIAL_PINNED
void ED_filltool_modal_keymap(wmKeyConfig *keyconf)
Object * CTX_data_active_object(const bContext *C)
ARegion * CTX_wm_region(const bContext *C)
void ED_workspace_status_text(bContext *C, const char *str)
PaintMode BKE_paintmode_get_active_from_context(const bContext *C)
View3D * CTX_wm_view3d(const bContext *C)
void WM_operator_properties_gesture_lasso(wmOperatorType *ot)
Bounds< int2 > WM_operator_properties_border_to_bounds(wmOperator *op)
int BKE_object_defgroup_active_index_get(const Object *ob)
bke::ARegionRuntime * runtime
struct ToolSettings * toolsettings
struct ARegionType * type
static GeometrySet from_curves(Curves *curves, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
Curves * get_curves_for_write()
MutableVArraySpan< T > span
const bke::greasepencil::Drawing & drawing
struct blender::ed::greasepencil::ExtensionData::@147343236172247015273153246111172323157377245354 lines
struct blender::ed::greasepencil::ExtensionData::@265020321004141327021164373252125002104130321223 circles
Vector< float2 > mouse_positions
bool is_extension_drag_active
eGP_FillExtendModes extension_mode
static GreasePencilFillOpData from_context(bContext &C, bke::greasepencil::Layer &layer, const int material_index, const bool invert, const bool precision)
bke::greasepencil::Layer & layer
float2 extension_mouse_pos
std::optional< float3 > get_location(float2 mouse, bool force_original) override
bool test_cancel() override
void done(bool is_cancel, bool stroke_started) override
void update_step(wmOperator *op, const StrokeStep &stroke_step) override
void redraw(bool final) override
bool test_start(wmOperator *op, float2 mouse) override
GreasePencilPaintStroke(bContext *C, wmOperator *op, const wmEvent *event, PaintMode mode)
wmOperatorStatus modal(bContext *C, wmOperator *op, const wmEvent *event)
wmOperatorStatus exec(bContext *C, wmOperator *op)
std::unique_ptr< PaintModeData > mode_data_
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
void(*) cancel(bContext *C, wmOperator *op)
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT
wmOperatorStatus(*) invoke(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
wmOperatorStatus(*) modal(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
struct ReportList * reports
struct wmOperatorType * type