Blender V5.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
8
9#pragma once
10
11#include "BLI_array.hh"
12#include "BLI_bit_vector.hh"
13#include "BLI_index_mask.hh"
16
17#include "DNA_scene_enums.h"
18#include "DNA_vec_types.h"
19
20#include "ED_view3d.hh"
21
22namespace blender {
23
24struct SculptSession;
25struct wmOperatorType;
26namespace bke::pbvh {
27class Node;
28}
29
32 Box = 0,
33
34 /* In the context of a sculpt gesture, both lasso and polyline modal
35 * operators are handled as the same general shape. */
36 Lasso = 1,
37 Line = 2,
38};
39
40enum class SelectionType {
41 Inside = 0,
42 Outside = 1,
43};
44
45/* Common data structure for both lasso and polyline. */
46struct LassoData {
48
50 int width;
51
52 /* 2D bitmap to test if a vertex is affected by the surrounding shape. */
54};
55
56struct LineData {
57 /* Plane aligned to the gesture line. */
60
61 /* Planes to limit the action to the length of the gesture segment at both sides of the affected
62 * area. */
63 std::array<float4, 2> side_plane;
64 std::array<float4, 2> true_side_plane;
66
67 bool flip;
68};
69
70struct Operation;
71
72/* Common data used for executing a gesture operation. */
74 const Paint *paint;
75 const Brush *brush;
76
79
80 /* Enabled and currently active symmetry. */
83
84 /* Operation parameters. */
88
90
91 /* Gesture data. */
92 /* Screen space points that represent the gesture shape. */
94
95 /* View parameters. */
98
101
102 float true_clip_planes[4][4];
103 float clip_planes[4][4];
104
105 /* These store the view origin and normal in world space, which is used in some gestures to
106 * generate geometry aligned from the view directly in world space. */
107 /* World space view origin and normal are not affected by object symmetry when doing symmetry
108 * passes, so there is no separate variables with the `true_` prefix to store their original
109 * values without symmetry modifications. */
112
113 /* Lasso & Polyline Gesture. */
115
116 /* Line Gesture. */
118
119 /* Task Callback Data. */
122
123 ~GestureData();
124};
125
126/* Common abstraction structure for gesture operations. */
127struct Operation {
128 /* Initial setup (data updates, special undo push...). */
130
131 /* Apply the gesture action for each symmetry pass. */
133
134 /* Remaining actions after finishing the symmetry passes iterations
135 * (updating data-layers, tagging bke::pbvh::Tree updates...). */
136 void (*end)(bContext &, GestureData &);
137};
138
139/* Determines whether or not a gesture action should be applied. */
140bool is_affected(const GestureData &gesture_data, const float3 &position, const float3 &normal);
141void filter_factors(const GestureData &gesture_data,
142 Span<float3> positions,
143 Span<float3> normals,
144 MutableSpan<float> factors);
145
146/* Initialization functions. */
147std::unique_ptr<GestureData> init_from_box(bContext *C, wmOperator *op);
148std::unique_ptr<GestureData> init_from_lasso(bContext *C, wmOperator *op);
149std::unique_ptr<GestureData> init_from_polyline(bContext *C, wmOperator *op);
150std::unique_ptr<GestureData> init_from_line(bContext *C, const wmOperator *op);
151
152/* Common gesture operator properties. */
153void operator_properties(wmOperatorType *ot, ShapeType shapeType);
154
155/* Apply the gesture action to the selected nodes. */
156void apply(bContext &C, GestureData &gesture_data, wmOperator &op);
157
158} // namespace ed::sculpt_paint::gesture
159
160} // namespace blender
#define C
Definition RandGen.cpp:29
#define position
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, const 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)
BMesh Iterators.
MatBase< float, 4, 4 > float4x4
VecBase< float, 4 > float4
VecBase< float, 3 > float3
void(*) end(bContext &, GestureData &)
void(*) apply_for_symmetry_pass(bContext &, GestureData &)
void(*) begin(bContext &, wmOperator &, GestureData &)