62 "Use a difference boolean operation"},
68 "Join the new mesh as separate geometry, without performing any boolean operation"},
69 {0,
nullptr, 0,
nullptr,
nullptr},
81 "Use the view to orientate the trimming shape"},
86 "Use the surface normal to orientate the trimming shape"},
87 {0,
nullptr, 0,
nullptr,
nullptr},
100 "Align trim geometry with the perspective of the current view for a tapered shape"},
105 "Align trim geometry orthogonally for a shape with 90 degree angles"},
106 {0,
nullptr, 0,
nullptr,
nullptr},
117 {0,
nullptr, 0,
nullptr,
nullptr},
144 Mesh *trim_mesh = trim_operation->
mesh;
154 bm_from_me_params.calc_vert_normal =
true;
160 "recalc_face_normals faces=%hf",
187 gesture_data.
vc.
obact->object_to_world().ptr(),
194 gesture_data.
vc.
obact->object_to_world().ptr(),
206 float &r_depth_front,
214 float shape_plane[4];
215 float shape_origin[3];
216 float shape_normal[3];
224 const float4x4 &object_to_world = vc.
obact->object_to_world();
226 for (
const int i : positions.index_range()) {
232 depth_front = std::min(dist, depth_front);
233 depth_back = std::max(dist, depth_back);
237 float world_space_gesture_initial_location[3];
239 object_to_world.
ptr(),
242 float mid_point_depth;
247 (depth_back + depth_front) * 0.5f;
253 mid_point_depth = trim_operation->
initial_hit ? 0.0f : (depth_back + depth_front) * 0.5f;
280 depth_front = mid_point_depth - depth_radius;
281 depth_back = mid_point_depth + depth_radius;
284 r_depth_front = depth_front;
285 r_depth_back = depth_back;
322 end = end + dir * expand_factor;
323 start = start - dir * expand_factor;
326 float2 perp(dir.y, -dir.x);
332 const float2 parallel_start = start + perp * expand_factor;
333 const float2 parallel_end = end + perp * expand_factor;
335 return {start, end, parallel_end, parallel_start};
347 const int trim_totverts = screen_points.
size() * 2;
348 const int trim_faces_nums = (2 * (screen_points.
size() - 2)) + (2 * screen_points.
size());
350 trim_totverts, 0, trim_faces_nums, trim_faces_nums * 3);
351 trim_operation->
true_mesh_co =
static_cast<float(*)[3]
>(
354 float shape_origin[3];
355 float shape_normal[3];
356 float shape_plane[4];
360 const float(*ob_imat)[4] = vc.
obact->world_to_object().ptr();
370 float pad_factor = (depth_back - depth_front) * 0.01f + 0.001f;
375 depth_front -= pad_factor;
376 depth_back += pad_factor;
379 float depth_point[3];
389 madd_v3_v3v3fl(depth_point, shape_origin, shape_normal, depth_front);
411 madd_v3_v3v3fl(depth_point, shape_origin, shape_normal, depth_back);
428 madd_v3_v3fl(new_point, shape_normal, depth_back - dist);
435 for (
int i = 0; i < screen_points.
size() * 2; i++) {
447 screen_points.
size(),
449 reinterpret_cast<uint(*)[3]
>(tris.
data()));
457 face_offsets[face_index] = loop_index;
458 corner_verts[loop_index + 0] = tris[i][0];
459 corner_verts[loop_index + 1] = tris[i][1];
460 corner_verts[loop_index + 2] = tris[i][2];
467 face_offsets[face_index] = loop_index;
468 corner_verts[loop_index + 0] = tris[i][0] + screen_points.
size();
469 corner_verts[loop_index + 1] = tris[i][1] + screen_points.
size();
470 corner_verts[loop_index + 2] = tris[i][2] + screen_points.
size();
477 face_offsets[face_index] = loop_index;
478 int current_index = i;
479 int next_index = current_index + 1;
480 if (next_index >= screen_points.
size()) {
483 corner_verts[loop_index + 0] = next_index + screen_points.
size();
484 corner_verts[loop_index + 1] = next_index;
485 corner_verts[loop_index + 2] = current_index;
491 face_offsets[face_index] = loop_index;
492 int current_index = i;
493 int next_index = current_index + 1;
494 if (next_index >= screen_points.
size()) {
497 corner_verts[loop_index + 0] = current_index;
498 corner_verts[loop_index + 1] = current_index + screen_points.
size();
499 corner_verts[loop_index + 2] = next_index + screen_points.
size();
516 switch (pbvh.
type()) {
540 Mesh *trim_mesh = trim_operation->
mesh;
550 bm_from_me_params.calc_vert_normal =
true;
560 const int i_faces_end = trim_mesh->
faces_num;
565 const short ob_src_totcol = trim_mesh->
totcol;
566 Array<short> material_remap(ob_src_totcol ? ob_src_totcol : 1);
577 if (efa->mat_nr < ob_src_totcol) {
578 efa->mat_nr = material_remap[efa->mat_nr];
581 if (++i == i_faces_end) {
588 int boolean_mode = 0;
589 switch (trim_operation->
mode) {
636 Mesh *trim_mesh = trim_operation->
mesh;
638 for (
int i = 0; i < trim_mesh->
verts_num; i++) {
720 "Use Cursor for Depth",
721 "Use cursor location and radius for the dimensions and position of the trimming shape");
772 if (
static_cast<const Mesh *
>(
object.data)->faces_num == 0) {
792 const float mval_fl[2] = {
float(mval[0]),
float(mval[1])};
814 MEM_cnew<TrimOperation>(__func__));
845 MEM_cnew<TrimOperation>(__func__));
876 MEM_cnew<TrimOperation>(__func__));
907 MEM_cnew<TrimOperation>(__func__));
928 ot->
name =
"Trim Lasso Gesture";
929 ot->
idname =
"SCULPT_OT_trim_lasso_gesture";
930 ot->
description =
"Execute a boolean operation on the mesh and a shape defined by the cursor";
949 ot->
name =
"Trim Box Gesture";
950 ot->
idname =
"SCULPT_OT_trim_box_gesture";
952 "Execute a boolean operation on the mesh and a rectangle defined by the cursor";
971 ot->
name =
"Trim Line Gesture";
972 ot->
idname =
"SCULPT_OT_trim_line_gesture";
973 ot->
description =
"Remove a portion of the mesh on one side of a line";
992 ot->
name =
"Trim Polyline Gesture";
993 ot->
idname =
"SCULPT_OT_trim_polyline_gesture";
995 "Execute a boolean operation on the mesh and a polygonal shape defined by the cursor";
float BKE_brush_unprojected_radius_get(const Scene *scene, const Brush *brush)
int BKE_brush_size_get(const Scene *scene, const Brush *brush)
bool BKE_brush_use_locked_size(const Scene *scene, const Brush *brush)
Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
Object * CTX_data_active_object(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
Base * CTX_data_active_base(const bContext *C)
ToolSettings * CTX_data_tool_settings(const bContext *C)
View3D * CTX_wm_view3d(const bContext *C)
bool BKE_base_is_visible(const View3D *v3d, const Base *base)
void BKE_id_free(Main *bmain, void *idv)
void BKE_mesh_batch_cache_dirty_tag(Mesh *mesh, eMeshBatchDirtyMode mode)
Mesh * BKE_mesh_from_bmesh_nomain(BMesh *bm, const BMeshToMeshParams *params, const Mesh *me_settings)
Mesh * BKE_mesh_new_nomain(int verts_num, int edges_num, int faces_num, int corners_num)
void BKE_mesh_nomain_to_mesh(Mesh *mesh_src, Mesh *mesh_dst, Object *ob)
Mesh * BKE_mesh_from_object(Object *ob)
@ BKE_MESH_BATCH_DIRTY_ALL
General operations, lookup, etc. for blender objects.
std::optional< blender::Bounds< blender::float3 > > BKE_object_boundbox_get(const Object *ob)
void BKE_sculpt_update_object_for_edit(Depsgraph *depsgraph, Object *ob_orig, bool is_paint_tool)
void BKE_sculptsession_free_pbvh(Object &object)
Brush * BKE_paint_brush(Paint *paint)
void BKE_report(ReportList *reports, eReportType type, const char *message)
#define BLI_assert_unreachable()
void plane_from_point_normal_v3(float r_plane[4], const float plane_co[3], const float plane_no[3])
float dist_signed_to_plane_v3(const float p[3], const float plane[4])
MINLINE int poly_to_tri_count(int poly_count, int corner_count)
void mul_v3_m4v3(float r[3], const float mat[4][4], const float vec[3])
void mul_mat3_m4_v3(const float mat[4][4], float r[3])
MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f)
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void negate_v3(float r[3])
MINLINE void madd_v3_v3v3fl(float r[3], const float a[3], const float b[3], float f)
MINLINE float normalize_v3(float n[3])
void BLI_polyfill_calc(const float(*coords)[2], unsigned int coords_num, int coords_sign, unsigned int(*r_tris)[3])
void DEG_id_tag_update(ID *id, unsigned int flags)
@ eBooleanModifierOp_Intersect
@ eBooleanModifierOp_Union
@ eBooleanModifierOp_Difference
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])
bool ED_view3d_win_to_3d_on_plane(const ARegion *region, const float plane[4], const float mval[2], bool do_clip, float r_out[3])
@ OPTYPE_DEPENDS_ON_CURSOR
bool BM_mesh_boolean(BMesh *, blender::Span< std::array< BMLoop *, 3 > > looptris, int(*test_fn)(BMFace *, void *), void *, const int, const bool, const bool, const bool, const int)
#define BM_elem_flag_test(ele, hflag)
#define BM_elem_flag_enable(ele, hflag)
bool BM_mesh_intersect(BMesh *bm, const blender::Span< std::array< BMLoop *, 3 > > looptris, int(*test_fn)(BMFace *f, void *user_data), void *user_data, const bool use_self, const bool use_separate, const bool use_dissolve, const bool use_island_connect, const bool use_partial_connect, const bool use_edge_tag, const int boolean_mode, const float eps)
#define BM_ITER_MESH(ele, iter, bm, itype)
ATTR_WARN_UNUSED_RESULT BMesh * bm
void BM_mesh_elem_hflag_enable_all(BMesh *bm, const char htype, const char hflag, const bool respecthide)
void BM_mesh_elem_hflag_disable_all(BMesh *bm, const char htype, const char hflag, const bool respecthide)
void BM_mesh_free(BMesh *bm)
BMesh Free Mesh.
BMesh * BM_mesh_create(const BMAllocTemplate *allocsize, const BMeshCreateParams *params)
BMesh Make Mesh.
#define BMALLOC_TEMPLATE_FROM_ME(...)
void BM_mesh_bm_from_me(BMesh *bm, const Mesh *mesh, const BMeshFromMeshParams *params)
void BM_mesh_calc_tessellation_beauty(BMesh *bm, MutableSpan< std::array< BMLoop *, 3 > > looptris)
bool BMO_op_callf(BMesh *bm, int flag, const char *fmt,...)
#define BMO_FLAG_DEFAULTS
IndexRange index_range() const
const Depsgraph * depsgraph
draw_view in_light_buf[] float
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
void *(* MEM_malloc_arrayN)(size_t len, size_t size, const char *str)
void MEM_freeN(void *vmemh)
int face_triangles_num(const int face_size)
pbvh::Tree * pbvh_get(Object &object)
Span< float3 > vert_positions_eval(const Depsgraph &depsgraph, const Object &object_orig)
void mesh_smooth_set(Mesh &mesh, bool use_smooth, bool keep_sharp_edges=false)
void mesh_calc_edges(Mesh &mesh, bool keep_existing_edges, bool select_new_edges)
int find_next_available_id(Object &object)
bool create_face_sets_mesh(Object &object)
void initialize_none_to_id(Mesh *mesh, int new_id)
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 apply(bContext &C, GestureData &gesture_data, wmOperator &op)
std::unique_ptr< GestureData > init_from_lasso(bContext *C, wmOperator *op)
void invalidate(SculptSession &ss)
void SCULPT_OT_trim_lasso_gesture(wmOperatorType *ot)
static int gesture_box_exec(bContext *C, wmOperator *op)
static EnumPropertyItem solver_modes[]
static void init_operation(gesture::GestureData &gesture_data, wmOperator &op)
static void operator_properties(wmOperatorType *ot)
static void generate_geometry(gesture::GestureData &gesture_data)
static void initialize_cursor_info(bContext &C, const wmOperator &op, gesture::GestureData &gesture_data)
static EnumPropertyItem extrude_modes[]
static void get_origin_and_normal(gesture::GestureData &gesture_data, float *r_origin, float *r_normal)
static void gesture_end(bContext &, gesture::GestureData &gesture_data)
static void gesture_begin(bContext &C, wmOperator &op, gesture::GestureData &gesture_data)
static void apply_trim(gesture::GestureData &gesture_data)
static int gesture_polyline_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static int bm_face_isect_pair(BMFace *f, void *)
static bool can_exec(const bContext &C, ReportList &reports)
void SCULPT_OT_trim_box_gesture(wmOperatorType *ot)
static float calc_expand_factor(const gesture::GestureData &gesture_data)
static int gesture_box_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static void report_invalid_mode(const blender::bke::pbvh::Type pbvh_type, ReportList &reports)
static void gesture_apply_for_symmetry_pass(bContext &, gesture::GestureData &gesture_data)
static int gesture_lasso_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static bool can_invoke(const bContext &C)
static void calculate_depth(gesture::GestureData &gesture_data, float &r_depth_front, float &r_depth_back)
static int gesture_line_exec(bContext *C, wmOperator *op)
static void free_geometry(gesture::GestureData &gesture_data)
static EnumPropertyItem operation_types[]
static int gesture_line_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void SCULPT_OT_trim_line_gesture(wmOperatorType *ot)
static EnumPropertyItem orientation_types[]
static int gesture_polyline_exec(bContext *C, wmOperator *op)
static int gesture_lasso_exec(bContext *C, wmOperator *op)
void SCULPT_OT_trim_polyline_gesture(wmOperatorType *ot)
static void update_normals(gesture::GestureData &gesture_data)
static Array< float2 > gesture_to_screen_points(gesture::GestureData &gesture_data)
void geometry_begin(const Scene &scene, Object &ob, const wmOperator *op)
void geometry_end(Object &ob)
float3 symmetry_flip(const float3 &src, const ePaintSymmetryFlags symm)
T distance(const T &a, const T &b)
MatBase< T, NumCol, NumRow > normalize(const MatBase< T, NumCol, NumRow > &a)
VecBase< T, 3 > transform_point(const CartesianBasis &basis, const VecBase< T, 3 > &v)
bool paint_convert_bb_to_rect(rcti *rect, const float bb_min[3], const float bb_max[3], const ARegion ®ion, const RegionView3D &rv3d, const Object &ob)
float paint_calc_object_space_radius(const ViewContext &vc, const blender::float3 ¢er, float pixel_radius)
void RNA_int_set_array(PointerRNA *ptr, const char *name, const int *values)
void RNA_int_get_array(PointerRNA *ptr, const char *name, int *values)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
int RNA_enum_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_int_vector(StructOrFunctionRNA *cont_, const char *identifier, const int len, const int *default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
bool SCULPT_cursor_geometry_info_update(bContext *C, SculptCursorGeometryInfo *out, const float mval[2], bool use_sampled_normal)
void SCULPT_vertex_random_access_ensure(Object &object)
bool SCULPT_mode_poll_view3d(bContext *C)
const c_style_mat & ptr() const
ePaintSymmetryFlags symmpass
Array< float2 > gesture_points
float3 world_space_view_normal
void(* end)(bContext &, GestureData &)
void(* begin)(bContext &, wmOperator &, GestureData &)
void(* apply_for_symmetry_pass)(bContext &, GestureData &)
blender::float3 initial_location
OrientationType orientation
blender::float3 initial_normal
bool(* poll)(bContext *C) ATTR_WARN_UNUSED_RESULT
int(* modal)(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
int(* invoke)(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
int(* exec)(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
struct ReportList * reports
int WM_gesture_polyline_invoke(bContext *C, wmOperator *op, const wmEvent *event)
int WM_gesture_box_invoke(bContext *C, wmOperator *op, const wmEvent *event)
int WM_gesture_polyline_modal(bContext *C, wmOperator *op, const wmEvent *event)
int WM_gesture_box_modal(bContext *C, wmOperator *op, const wmEvent *event)
int WM_gesture_lasso_modal(bContext *C, wmOperator *op, const wmEvent *event)
int WM_gesture_lasso_invoke(bContext *C, wmOperator *op, const wmEvent *event)
int WM_gesture_straightline_oneshot_modal(bContext *C, wmOperator *op, const wmEvent *event)
int WM_gesture_straightline_active_side_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void WM_operator_properties_gesture_straightline(wmOperatorType *ot, int cursor)
void WM_operator_properties_border(wmOperatorType *ot)
void WM_operator_properties_gesture_lasso(wmOperatorType *ot)
void WM_operator_properties_gesture_polyline(wmOperatorType *ot)