45 "use_front_faces_only",
48 "Affect only faces facing towards the view");
52 "use_limit_to_segment",
55 "Apply the gesture action only to the area that is contained within the "
56 "segment without extending its effect to the entire line");
71 gesture_data.
ss =
object.sculpt;
89static void lasso_px_cb(
const int x,
const int x_end,
const int y,
void *user_data)
93 int index = (
y * lasso->
width) +
x;
94 const int index_end = (
y * lasso->
width) + x_end;
97 }
while (++index != index_end);
108 if (mcoords.
size() <= 1) {
112 std::unique_ptr<GestureData> gesture_data = std::make_unique<GestureData>();
118 gesture_data->vc.obact);
120 const int lasso_width = 1 + gesture_data->lasso.boundbox.xmax -
121 gesture_data->lasso.boundbox.xmin;
122 const int lasso_height = 1 + gesture_data->lasso.boundbox.ymax -
123 gesture_data->lasso.boundbox.ymin;
124 gesture_data->lasso.width = lasso_width;
125 gesture_data->lasso.mask_px.resize(lasso_width * lasso_height);
128 gesture_data->lasso.boundbox.ymin,
129 gesture_data->lasso.boundbox.xmax,
130 gesture_data->lasso.boundbox.ymax,
137 gesture_data->true_clip_planes,
138 gesture_data->vc.region,
139 gesture_data->vc.obact,
140 &gesture_data->lasso.boundbox);
142 gesture_data->gesture_points.reinitialize(mcoords.
size());
144 gesture_data->gesture_points[
i][0] = mcoords[
i][0];
145 gesture_data->gesture_points[
i][1] = mcoords[
i][1];
153 std::unique_ptr<GestureData> gesture_data = std::make_unique<GestureData>();
163 &bb, gesture_data->true_clip_planes, gesture_data->vc.region, gesture_data->vc.obact, &rect);
165 gesture_data->gesture_points.reinitialize(4);
167 gesture_data->gesture_points[0][0] = rect.
xmax;
168 gesture_data->gesture_points[0][1] = rect.
ymax;
170 gesture_data->gesture_points[1][0] = rect.
xmax;
171 gesture_data->gesture_points[1][1] = rect.
ymin;
173 gesture_data->gesture_points[2][0] = rect.
xmin;
174 gesture_data->gesture_points[2][1] = rect.
ymin;
176 gesture_data->gesture_points[3][0] = rect.
xmin;
177 gesture_data->gesture_points[3][1] = rect.
ymax;
196 gesture_data.
vc.
obact->world_to_object(), p1);
204 std::array<float3, 4> &r_plane_points,
205 std::array<float3, 2> &r_offset_plane_points)
209 gesture_data.
vc.
v3d, gesture_data.
vc.
region, depth_point, line_points[0], r_plane_points[0]);
211 gesture_data.
vc.
v3d, gesture_data.
vc.
region, depth_point, line_points[1], r_plane_points[3]);
227 normal_tri_v3(normal, r_plane_points[0], r_plane_points[1], r_plane_points[2]);
228 r_offset_plane_points[0] = r_plane_points[0] + normal;
229 r_offset_plane_points[1] = r_plane_points[3] + normal;
234 std::unique_ptr<GestureData> gesture_data = std::make_unique<GestureData>();
236 gesture_data->line.use_side_planes =
RNA_boolean_get(op->
ptr,
"use_limit_to_segment");
240 gesture_data->gesture_points.reinitialize(2);
248 std::array<float3, 4> plane_points;
249 std::array<float3, 2> offset_plane_points;
251 *gesture_data, gesture_data->gesture_points, plane_points, offset_plane_points);
254 const bool flip = gesture_data->line.flip ^ (!gesture_data->vc.rv3d->is_persp);
268 offset_plane_points[0]);
274 offset_plane_points[1]);
311 for (
int j = 0; j < 4; j++) {
327 std::array<float4, 3> clip_planes;
334 return bke::pbvh::node_frustum_contain_aabb(
335 node, Span(clip_planes).take_front(gesture_data.line.use_side_planes ? 3 : 1));
342 float clip_planes[4][4];
346 Span planes(
reinterpret_cast<float4 *
>(clip_planes), 4);
350 switch (gesture_data.selection_type) {
351 case SelectionType::Inside:
352 return bke::pbvh::node_frustum_contain_aabb(node, planes);
353 case SelectionType::Outside:
357 if (gesture_data.shape_type == ShapeType::Lasso) {
360 return bke::pbvh::node_frustum_exclude_aabb(node, planes);
388 int2 screen_coords = {int(scr_co_f[0]), int(scr_co_f[1])};
399 const bool bitmap_result =
400 lasso.
mask_px[screen_coords[1] * lasso.
width + screen_coords[0]].test();
403 return bitmap_result;
405 return !bitmap_result;
416 if (!is_affected_front_face) {
455 operation->
begin(
C, op, gesture_data);
457 for (
int symmpass = 0; symmpass <= gesture_data.
symm; symmpass++) {
466 operation->
end(
C, gesture_data);
Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
#define BLI_assert_unreachable()
void BLI_bitmap_draw_2d_poly_v2i_n(int xmin, int ymin, int xmax, int ymax, blender::Span< blender::int2 > verts, void(*callback)(int x, int x_end, int y, void *), void *user_data)
void BLI_lasso_boundbox(rcti *rect, blender::Span< blender::int2 > mcoords)
bool isect_point_planes_v3(const float(*planes)[4], int totplane, const float p[3])
void plane_from_point_normal_v3(float r_plane[4], const float plane_co[3], const float plane_no[3])
MINLINE float plane_point_side_v3(const float plane[4], const float co[3])
float normal_tri_v3(float n[3], const float v1[3], const float v2[3], const float v3[3])
void copy_m4_m4(float m1[4][4], const float m2[4][4])
void negate_m4(float R[4][4])
MINLINE void copy_v4_v4(float r[4], const float a[4])
bool BLI_rcti_isect_pt_v(const struct rcti *rect, const int xy[2])
blender::float2 ED_view3d_project_float_v2_m4(const ARegion *region, const float co[3], const blender::float4x4 &mat)
void ED_view3d_clipping_calc(BoundBox *bb, float planes[4][4], const ARegion *region, const Object *ob, const rcti *rect)
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])
ViewContext ED_view3d_viewcontext_init(bContext *C, Depsgraph *depsgraph)
blender::float4x4 ED_view3d_ob_project_mat_get(const RegionView3D *rv3d, const Object *ob)
Read Guarded memory(de)allocation.
BPy_StructRNA * depsgraph
IndexRange index_range() const
constexpr IndexRange index_range() const
dot(value.rgb, luminance_coefficients)") DEFINE_VALUE("REDUCE(lhs
static float normals[][3]
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)
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)
MatBase< float, 4, 4 > float4x4
VecBase< float, 4 > float4
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
MatBase< float, 3, 3 > float3x3
VecBase< float, 3 > float3
int RNA_int_get(PointerRNA *ptr, const char *name)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
ePaintSymmetryFlags SCULPT_mesh_symmetry_xyz_get(const Object &object)
void SCULPT_tag_update_overlays(bContext *C)
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]
blender::BitVector mask_px
std::array< float4, 2 > true_side_plane
std::array< float4, 2 > side_plane
void(* end)(bContext &, GestureData &)
void(* begin)(bContext &, wmOperator &, GestureData &)
void(* apply_for_symmetry_pass)(bContext &, GestureData &)
Array< int2 > WM_gesture_lasso_path_to_array(bContext *, wmOperator *op)
void WM_operator_properties_border_to_rcti(wmOperator *op, rcti *r_rect)