Blender V4.3
sculpt_gesture.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2024 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#pragma once
10
11#include "BLI_array.hh"
12#include "BLI_bit_vector.hh"
13#include "BLI_index_mask.hh"
14#include "BLI_math_matrix.hh"
15#include "BLI_vector.hh"
16
17#include "DNA_scene_enums.h"
18#include "DNA_vec_types.h"
19
20#include "ED_view3d.hh"
21
22struct SculptSession;
23struct wmOperatorType;
24namespace blender::bke::pbvh {
25class Node;
26}
27
30 Box = 0,
31
32 /* In the context of a sculpt gesture, both lasso and polyline modal
33 * operators are handled as the same general shape. */
34 Lasso = 1,
35 Line = 2,
36};
37
38enum class SelectionType {
39 Inside = 0,
40 Outside = 1,
41};
42
43/* Common data structure for both lasso and polyline. */
44struct LassoData {
46
48 int width;
49
50 /* 2D bitmap to test if a vertex is affected by the surrounding shape. */
52};
53
54struct LineData {
55 /* Plane aligned to the gesture line. */
56 float true_plane[4];
57 float plane[4];
58
59 /* Planes to limit the action to the length of the gesture segment at both sides of the affected
60 * area. */
61 float side_plane[2][4];
62 float true_side_plane[2][4];
64
65 bool flip;
66};
67
68struct Operation;
69
70/* Common data used for executing a gesture operation. */
74
75 /* Enabled and currently active symmetry. */
78
79 /* Operation parameters. */
83
85
86 /* Gesture data. */
87 /* Screen space points that represent the gesture shape. */
89
90 /* View parameters. */
93
96
97 float true_clip_planes[4][4];
98 float clip_planes[4][4];
99
100 /* These store the view origin and normal in world space, which is used in some gestures to
101 * generate geometry aligned from the view directly in world space. */
102 /* World space view origin and normal are not affected by object symmetry when doing symmetry
103 * passes, so there is no separate variables with the `true_` prefix to store their original
104 * values without symmetry modifications. */
107
108 /* Lasso & Polyline Gesture. */
110
111 /* Line Gesture. */
113
114 /* Task Callback Data. */
117
118 ~GestureData();
119};
120
121/* Common abstraction structure for gesture operations. */
122struct Operation {
123 /* Initial setup (data updates, special undo push...). */
125
126 /* Apply the gesture action for each symmetry pass. */
128
129 /* Remaining actions after finishing the symmetry passes iterations
130 * (updating data-layers, tagging bke::pbvh::Tree updates...). */
131 void (*end)(bContext &, GestureData &);
132};
133
134/* Determines whether or not a gesture action should be applied. */
135bool is_affected(const GestureData &gesture_data, const float3 &position, const float3 &normal);
136void filter_factors(const GestureData &gesture_data,
137 Span<float3> positions,
138 Span<float3> normals,
139 MutableSpan<float> factors);
140
141/* Initialization functions. */
142std::unique_ptr<GestureData> init_from_box(bContext *C, wmOperator *op);
143std::unique_ptr<GestureData> init_from_lasso(bContext *C, wmOperator *op);
144std::unique_ptr<GestureData> init_from_polyline(bContext *C, wmOperator *op);
145std::unique_ptr<GestureData> init_from_line(bContext *C, wmOperator *op);
146
147/* Common gesture operator properties. */
149
150/* Apply the gesture action to the selected nodes. */
151void apply(bContext &C, GestureData &gesture_data, wmOperator &op);
152
153} // namespace blender::ed::sculpt_paint::gesture
ePaintSymmetryFlags
std::unique_ptr< GestureData > init_from_box(bContext *C, wmOperator *op)
void operator_properties(wmOperatorType *ot, ShapeType shapeType)
std::unique_ptr< GestureData > init_from_polyline(bContext *C, wmOperator *op)
std::unique_ptr< GestureData > init_from_line(bContext *C, wmOperator *op)
void filter_factors(const GestureData &gesture_data, const Span< float3 > positions, const Span< float3 > normals, const MutableSpan< float > factors)
void apply(bContext &C, GestureData &gesture_data, wmOperator &op)
std::unique_ptr< GestureData > init_from_lasso(bContext *C, wmOperator *op)
bool is_affected(const GestureData &gesture_data, const float3 &position, const float3 &normal)
void(* begin)(bContext &, wmOperator &, GestureData &)
void(* apply_for_symmetry_pass)(bContext &, GestureData &)
wmOperatorType * ot
Definition wm_files.cc:4125