46 "use_front_faces_only",
49 "Affect only faces facing towards the view");
53 "use_limit_to_segment",
56 "Apply the gesture action only to the area that is contained within the "
57 "segment without extending its effect to the entire line");
75 gesture_data.
ss =
object.runtime->sculpt_session;
93static void lasso_px_cb(
const int x,
const int x_end,
const int y,
void *user_data)
98 const int index_end = (
y * lasso->
width) + x_end;
101 }
while (++
index != index_end);
112 if (mcoords.
size() <= 1) {
116 std::unique_ptr<GestureData> gesture_data = std::make_unique<GestureData>();
122 gesture_data->vc.obact);
124 const int lasso_width = 1 + gesture_data->lasso.boundbox.xmax -
125 gesture_data->lasso.boundbox.xmin;
126 const int lasso_height = 1 + gesture_data->lasso.boundbox.ymax -
127 gesture_data->lasso.boundbox.ymin;
128 gesture_data->lasso.width = lasso_width;
129 gesture_data->lasso.mask_px.resize(lasso_width * lasso_height);
132 gesture_data->lasso.boundbox.ymin,
133 gesture_data->lasso.boundbox.xmax,
134 gesture_data->lasso.boundbox.ymax,
141 gesture_data->true_clip_planes,
142 gesture_data->vc.region,
143 gesture_data->vc.obact,
144 &gesture_data->lasso.boundbox);
146 gesture_data->gesture_points.reinitialize(mcoords.
size());
148 gesture_data->gesture_points[i][0] = mcoords[i][0];
149 gesture_data->gesture_points[i][1] = mcoords[i][1];
157 std::unique_ptr<GestureData> gesture_data = std::make_unique<GestureData>();
167 &bb, gesture_data->true_clip_planes, gesture_data->vc.region, gesture_data->vc.obact, &rect);
169 gesture_data->gesture_points.reinitialize(4);
171 gesture_data->gesture_points[0][0] = rect.
xmax;
172 gesture_data->gesture_points[0][1] = rect.
ymax;
174 gesture_data->gesture_points[1][0] = rect.
xmax;
175 gesture_data->gesture_points[1][1] = rect.
ymin;
177 gesture_data->gesture_points[2][0] = rect.
xmin;
178 gesture_data->gesture_points[2][1] = rect.
ymin;
180 gesture_data->gesture_points[3][0] = rect.
xmin;
181 gesture_data->gesture_points[3][1] = rect.
ymax;
200 gesture_data.
vc.
obact->world_to_object(), p1);
208 std::array<float3, 4> &r_plane_points,
209 std::array<float3, 2> &r_offset_plane_points)
213 gesture_data.
vc.
v3d, gesture_data.
vc.
region, depth_point, line_points[0], r_plane_points[0]);
215 gesture_data.
vc.
v3d, gesture_data.
vc.
region, depth_point, line_points[1], r_plane_points[3]);
231 normal_tri_v3(normal, r_plane_points[0], r_plane_points[1], r_plane_points[2]);
232 r_offset_plane_points[0] = r_plane_points[0] + normal;
233 r_offset_plane_points[1] = r_plane_points[3] + normal;
238 std::unique_ptr<GestureData> gesture_data = std::make_unique<GestureData>();
240 gesture_data->line.use_side_planes =
RNA_boolean_get(op->
ptr,
"use_limit_to_segment");
244 gesture_data->gesture_points.reinitialize(2);
252 std::array<float3, 4> plane_points;
253 std::array<float3, 2> offset_plane_points;
255 *gesture_data, gesture_data->gesture_points, plane_points, offset_plane_points);
258 const bool flip = gesture_data->line.flip ^ (!gesture_data->vc.rv3d->is_persp);
272 offset_plane_points[0]);
278 offset_plane_points[1]);
315 for (
int j = 0; j < 4; j++) {
331 std::array<float4, 3> clip_planes;
338 return bke::pbvh::node_frustum_contain_aabb(
339 node, Span(clip_planes).take_front(gesture_data.line.use_side_planes ? 3 : 1));
346 float clip_planes[4][4];
350 Span planes(
reinterpret_cast<float4 *
>(clip_planes), 4);
354 switch (gesture_data.selection_type) {
355 case SelectionType::Inside:
356 return bke::pbvh::node_frustum_contain_aabb(node, planes);
357 case SelectionType::Outside:
361 if (gesture_data.shape_type == ShapeType::Lasso) {
364 return bke::pbvh::node_frustum_exclude_aabb(node, planes);
392 int2 screen_coords = {int(scr_co_f[0]), int(scr_co_f[1])};
403 const bool bitmap_result =
404 lasso.
mask_px[screen_coords[1] * lasso.
width + screen_coords[0]].test();
406 case SelectionType::Inside:
407 return bitmap_result;
408 case SelectionType::Outside:
409 return !bitmap_result;
420 if (!is_affected_front_face) {
427 return ((is_contained && gesture_data.
selection_type == SelectionType::Inside) ||
428 (!is_contained && gesture_data.
selection_type == SelectionType::Outside));
449 if (!
is_affected(gesture_data, positions[i], normals[i])) {
459 operation->
begin(
C, op, gesture_data);
461 for (
int symmpass = 0; symmpass <= gesture_data.
symm; symmpass++) {
470 operation->
end(
C, gesture_data);
Read Blender memory allocation and freeing.
#define BLI_assert_unreachable()
IndexRange index_range() const
constexpr IndexRange index_range() const
float dot(VecOp< float, D >, VecOp< float, D >) RET
pbvh::Tree * pbvh_get(Object &object)
IndexMask search_nodes(const Tree &pbvh, IndexMaskMemory &memory, FunctionRef< bool(const Node &)> filter_fn)
static void update_affected_nodes_by_line_plane(GestureData &gesture_data)
static void init_common(bContext *C, const wmOperator *op, GestureData &gesture_data)
static void lasso_px_cb(const int x, const int x_end, const int y, void *user_data)
std::unique_ptr< GestureData > init_from_box(bContext *C, wmOperator *op)
void operator_properties(wmOperatorType *ot, ShapeType shapeType)
static void flip_plane(float out[4], const float in[4], const char symm)
std::unique_ptr< GestureData > init_from_polyline(bContext *C, wmOperator *op)
static void update_affected_nodes(GestureData &gesture_data)
std::unique_ptr< GestureData > init_from_line(bContext *C, const wmOperator *op)
static void line_plane_from_tri(float *r_plane, const GestureData &gesture_data, const bool flip, const float3 &p1, const float3 &p2, const float3 &p3)
static void flip_for_symmetry_pass(GestureData &gesture_data, const ePaintSymmetryFlags symmpass)
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)
static bool is_affected_lasso(const GestureData &gesture_data, const float3 &position)
std::unique_ptr< GestureData > init_from_lasso(bContext *C, wmOperator *op)
static void update_affected_nodes_by_clip_planes(GestureData &gesture_data)
bool is_affected(const GestureData &gesture_data, const float3 &position, const float3 &normal)
static void line_calculate_plane_points(const GestureData &gesture_data, const Span< float2 > line_points, std::array< float3, 4 > &r_plane_points, std::array< float3, 2 > &r_offset_plane_points)
float3 symmetry_flip(const float3 &src, const ePaintSymmetryFlags symm)
ePaintSymmetryFlags mesh_symmetry_xyz_get(const Object &object)
void tag_update_overlays(bContext *C)
bool is_symmetry_iteration_valid(const char i, const char symm)
T dot(const QuaternionBase< T > &a, const QuaternionBase< T > &b)
MatBase< T, NumCol, NumRow > normalize(const MatBase< T, NumCol, NumRow > &a)
VecBase< T, 3 > transform_direction(const MatBase< T, 3, 3 > &mat, const VecBase< T, 3 > &direction)
VecBase< T, 3 > transform_point(const CartesianBasis &basis, const VecBase< T, 3 > &v)
void negate_m4(float R[4][4])
ViewContext ED_view3d_viewcontext_init(bContext *C, Depsgraph *depsgraph)
float4x4 ED_view3d_ob_project_mat_get(const RegionView3D *rv3d, const Object *ob)
float2 ED_view3d_project_float_v2_m4(const ARegion *region, const float co[3], const float4x4 &mat)
int RNA_int_get(PointerRNA *ptr, const char *name)
float normal_tri_v3(float n[3], const float v1[3], const float v2[3], const float v3[3])
MatBase< float, 4, 4 > float4x4
void plane_from_point_normal_v3(float r_plane[4], const float plane_co[3], const float plane_no[3])
VecBase< float, 4 > float4
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
void BLI_bitmap_draw_2d_poly_v2i_n(int xmin, int ymin, int xmax, int ymax, Span< int2 > verts, void(*callback)(int x, int x_end, int y, void *), void *user_data)
Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C, bool rna_write_check=false)
void WM_operator_properties_border_to_rcti(wmOperator *op, rcti *r_rect)
MINLINE float plane_point_side_v3(const float plane[4], const float co[3])
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
MatBase< float, 3, 3 > float3x3
const Brush * BKE_paint_brush_for_read(const Paint *paint)
void ED_view3d_clipping_calc(BoundBox *bb, float planes[4][4], const ARegion *region, const Object *ob, const rcti *rect)
Paint * BKE_paint_get_active_from_context(const bContext *C)
Array< int2 > WM_gesture_lasso_path_to_array(bContext *, wmOperator *op)
bool isect_point_planes_v3(const float(*planes)[4], int totplane, const float p[3])
bool BLI_rcti_isect_pt_v(const struct rcti *rect, const int xy[2])
MINLINE void copy_v4_v4(float r[4], const float a[4])
void copy_m4_m4(float m1[4][4], const float m2[4][4])
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)
void ED_view3d_win_to_3d(const View3D *v3d, const ARegion *region, const float depth_pt[3], const float mval[2], float r_out[3])
void BLI_lasso_boundbox(rcti *rect, Span< int2 > mcoords)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
ePaintSymmetryFlags symmpass
float3 world_space_view_origin
SelectionType selection_type
IndexMaskMemory node_mask_memory
float3 world_space_view_normal
float true_clip_planes[4][4]
std::array< float4, 2 > true_side_plane
std::array< float4, 2 > side_plane
void(*) end(bContext &, GestureData &)
void(*) apply_for_symmetry_pass(bContext &, GestureData &)
void(*) begin(bContext &, wmOperator &, GestureData &)