63 "Use a difference boolean operation"},
69 "Join the new mesh as separate geometry, without performing any boolean operation"},
70 {0,
nullptr, 0,
nullptr,
nullptr},
82 "Use the view to orientate the trimming shape"},
87 "Use the surface normal to orientate the trimming shape"},
88 {0,
nullptr, 0,
nullptr,
nullptr},
101 "Align trim geometry with the perspective of the current view for a tapered shape"},
106 "Align trim geometry orthogonally for a shape with 90 degree angles"},
107 {0,
nullptr, 0,
nullptr,
nullptr},
115 "Slower solver with the best results for coplanar faces"},
120 "Simple solver with good performance, without support for overlapping geometry"},
125 "Fastest solver that works only on manifold meshes but gives better results"},
126 {0,
nullptr, 0,
nullptr,
nullptr},
154 Mesh *trim_mesh = trim_operation->
mesh;
170 "recalc_face_normals faces=%hf",
197 gesture_data.
vc.
obact->object_to_world().ptr(),
204 gesture_data.
vc.
obact->object_to_world().ptr(),
216 float &r_depth_front,
224 float shape_plane[4];
225 float shape_origin[3];
226 float shape_normal[3];
234 const float4x4 &object_to_world = vc.
obact->object_to_world();
242 depth_front = std::min(dist, depth_front);
243 depth_back = std::max(dist, depth_back);
247 float world_space_gesture_initial_location[3];
249 object_to_world.ptr(),
252 float mid_point_depth;
257 (depth_back + depth_front) * 0.5f;
263 mid_point_depth = trim_operation->
initial_hit ? 0.0f : (depth_back + depth_front) * 0.5f;
281 depth_front = mid_point_depth - depth_radius;
282 depth_back = mid_point_depth + depth_radius;
285 r_depth_front = depth_front;
286 r_depth_back = depth_back;
295 const float bb_min[3],
296 const float bb_max[3],
306 if (bb_min[0] > bb_max[0] || bb_min[1] > bb_max[1] || bb_min[2] > bb_max[2]) {
312 for (i = 0; i < 2; i++) {
313 for (j = 0; j < 2; j++) {
314 for (k = 0; k < 2; k++) {
317 vec[0] = i ? bb_min[0] : bb_max[0];
318 vec[1] = j ? bb_min[1] : bb_max[1];
319 vec[2] = k ? bb_min[2] : bb_max[2];
371 end = end + dir * expand_factor;
372 start = start - dir * expand_factor;
375 float2 perp(dir.y, -dir.x);
381 const float2 parallel_start = start + perp * expand_factor;
382 const float2 parallel_end = end + perp * expand_factor;
384 return {start, end, parallel_end, parallel_start};
396 const int trim_totverts = screen_points.
size() * 2;
397 const int trim_faces_nums = (2 * (screen_points.
size() - 2)) + (2 * screen_points.
size());
399 trim_totverts, 0, trim_faces_nums, trim_faces_nums * 3);
402 float shape_origin[3];
403 float shape_normal[3];
404 float shape_plane[4];
408 const float (*ob_imat)[4] = vc.
obact->world_to_object().ptr();
418 float pad_factor = (depth_back - depth_front) * 0.01f + 0.001f;
423 depth_front -= pad_factor;
424 depth_back += pad_factor;
427 float depth_point[3];
437 madd_v3_v3v3fl(depth_point, shape_origin, shape_normal, depth_front);
459 madd_v3_v3v3fl(depth_point, shape_origin, shape_normal, depth_back);
476 madd_v3_v3fl(new_point, shape_normal, depth_back - dist);
483 for (
int i = 0; i < screen_points.
size() * 2; i++) {
495 screen_points.
size(),
497 reinterpret_cast<uint(*)[3]
>(tris.
data()));
505 face_offsets[face_index] = corner;
506 corner_verts[corner + 0] = tris[i][0];
507 corner_verts[corner + 1] = tris[i][1];
508 corner_verts[corner + 2] = tris[i][2];
515 face_offsets[face_index] = corner;
516 corner_verts[corner + 0] = tris[i][0] + screen_points.
size();
517 corner_verts[corner + 1] = tris[i][1] + screen_points.
size();
518 corner_verts[corner + 2] = tris[i][2] + screen_points.
size();
525 face_offsets[face_index] = corner;
526 int current_index = i;
527 int next_index = current_index + 1;
528 if (next_index >= screen_points.
size()) {
531 corner_verts[corner + 0] = next_index + screen_points.
size();
532 corner_verts[corner + 1] = next_index;
533 corner_verts[corner + 2] = current_index;
539 face_offsets[face_index] = corner;
540 int current_index = i;
541 int next_index = current_index + 1;
542 if (next_index >= screen_points.
size()) {
545 corner_verts[corner + 0] = current_index;
546 corner_verts[corner + 1] = current_index + screen_points.
size();
547 corner_verts[corner + 2] = next_index + screen_points.
size();
564 switch (
pbvh.type()) {
591 Mesh &sculpt_mesh = *id_cast<Mesh *>(
object->data);
592 Mesh &trim_mesh = *trim_operation->
mesh;
595 switch (trim_operation->
mode) {
617 {&sculpt_mesh, &trim_mesh},
630 trim_operation->
reports,
RPT_ERROR,
"Boolean result is too big for solver to handle");
635 trim_operation->
reports,
RPT_ERROR,
"Boolean solver not available (compiled without it)");
649 Mesh *trim_mesh = trim_operation->
mesh;
651 for (
int i = 0; i < trim_mesh->
verts_num; i++) {
734 "Use Cursor for Depth",
735 "Use cursor location and radius for the dimensions and position of the trimming shape");
791 if (id_cast<const Mesh *>(
object.
data)->faces_num == 0) {
810 const float mval_fl[2] = {
float(mval[0]),
float(mval[1])};
948 ot->
name =
"Trim Lasso Gesture";
949 ot->
idname =
"SCULPT_OT_trim_lasso_gesture";
950 ot->
description =
"Execute a boolean operation on the mesh and a shape defined by the cursor";
969 ot->
name =
"Trim Box Gesture";
970 ot->
idname =
"SCULPT_OT_trim_box_gesture";
972 "Execute a boolean operation on the mesh and a rectangle defined by the cursor";
991 ot->
name =
"Trim Line Gesture";
992 ot->
idname =
"SCULPT_OT_trim_line_gesture";
993 ot->
description =
"Remove a portion of the mesh on one side of a line";
1012 ot->
name =
"Trim Polyline Gesture";
1013 ot->
idname =
"SCULPT_OT_trim_polyline_gesture";
1015 "Execute a boolean operation on the mesh and a polygonal shape defined by the cursor";
General operations, lookup, etc. for blender objects.
#define BLI_assert_unreachable()
#define BMALLOC_TEMPLATE_FROM_ME(...)
#define BMO_FLAG_DEFAULTS
DBVT_INLINE bool Intersect(const btDbvtAabbMm &a, const btDbvtAabbMm &b)
Array(Allocator allocator={}) noexcept
IndexRange index_range() const
constexpr IndexRange index_range() const
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)
bool create_face_sets_mesh(Object &object)
void initialize_none_to_id(Mesh *mesh, int new_id)
int find_next_available_id(const Mesh &mesh)
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 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 void init_operation(gesture::GestureData &gesture_data, wmOperator &op)
static 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)
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 apply_join_operation(Object &object, Mesh &sculpt_mesh, Mesh &trim_mesh)
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 wmOperatorStatus gesture_line_invoke(bContext *C, wmOperator *op, const wmEvent *event)
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 void gesture_apply_for_symmetry_pass(bContext &, gesture::GestureData &gesture_data)
static bool can_invoke(const bContext &C)
static void calculate_depth(gesture::GestureData &gesture_data, float &r_depth_front, float &r_depth_back)
static void report_invalid_mode(const bke::pbvh::Type pbvh_type, ReportList &reports)
static void free_geometry(gesture::GestureData &gesture_data)
static EnumPropertyItem operation_types[]
static wmOperatorStatus gesture_box_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static wmOperatorStatus gesture_polyline_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void SCULPT_OT_trim_line_gesture(wmOperatorType *ot)
static wmOperatorStatus gesture_lasso_exec(bContext *C, wmOperator *op)
static wmOperatorStatus gesture_line_exec(bContext *C, wmOperator *op)
static wmOperatorStatus gesture_lasso_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static wmOperatorStatus gesture_box_exec(bContext *C, wmOperator *op)
static const EnumPropertyItem solver_items[]
static EnumPropertyItem orientation_types[]
static wmOperatorStatus gesture_polyline_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)
void vert_random_access_ensure(Object &object)
float3 symmetry_flip(const float3 &src, const ePaintSymmetryFlags symm)
bool sculpt_mode_poll_view3d(bContext *C)
float object_space_radius_get(const ViewContext &vc, const Paint &paint, const Brush &brush, const float3 &location, const float scale_factor)
std::optional< CursorGeometryInfo > cursor_geometry_info_update(bContext *C, const float2 &mval, const bool use_sampled_normal)
Mesh * mesh_boolean(Span< const Mesh * > meshes, Span< float4x4 > transforms, Span< Array< short > > material_remaps, BooleanOpParameters op_params, Solver solver, Vector< int > *r_intersecting_edges, BooleanError *r_error)
bke::GeometrySet join_geometries(Span< bke::GeometrySet > geometries, const bke::AttributeFilter &attribute_filter, const std::optional< Span< bke::GeometryComponent::Type > > &component_types_to_join=std::nullopt, bool allow_merging_instance_references=true)
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)
MINLINE void madd_v3_v3v3fl(float r[3], const float a[3], const float b[3], float f)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void BM_mesh_elem_hflag_enable_all(BMesh *bm, const char htype, const char hflag, const bool respecthide)
int RNA_enum_get(PointerRNA *ptr, const char *name)
wmOperatorStatus WM_gesture_polyline_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void BM_mesh_free(BMesh *bm)
BMesh Free Mesh.
wmOperatorStatus WM_gesture_box_invoke(bContext *C, wmOperator *op, const wmEvent *event)
MINLINE void copy_v3_v3(float r[3], const float a[3])
void * MEM_new_array_uninitialized(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
bool BKE_base_is_visible(const View3D *v3d, const Base *base)
float4x4 ED_view3d_ob_project_mat_get(const RegionView3D *rv3d, const Object *ob)
void mul_v3_m4v3(float r[3], const float mat[4][4], const float vec[3])
float dist_signed_to_plane_v3(const float p[3], const float plane[4])
void BLI_polyfill_calc(const float(*coords)[2], unsigned int coords_num, int coords_sign, unsigned int(*r_tris)[3])
void BKE_mesh_nomain_to_mesh(Mesh *mesh_src, Mesh *mesh_dst, Object *ob, bool process_shape_keys=true)
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)
Mesh * BKE_mesh_from_bmesh_nomain(BMesh *bm, const BMeshToMeshParams *params, const Mesh *me_settings)
void BLI_rcti_init_minmax(struct rcti *rect)
void WM_operator_properties_border(wmOperatorType *ot)
float2 ED_view3d_project_float_v2_m4(const ARegion *region, const float co[3], const float4x4 &mat)
void BM_mesh_elem_hflag_disable_all(BMesh *bm, const char htype, const char hflag, const bool respecthide)
wmOperatorStatus WM_gesture_straightline_active_side_invoke(bContext *C, wmOperator *op, const wmEvent *event)
wmOperatorStatus WM_gesture_lasso_modal(bContext *C, wmOperator *op, const wmEvent *event)
MatBase< float, 4, 4 > float4x4
void BLI_rcti_do_minmax_v(struct rcti *rect, const int xy[2])
Base * CTX_data_active_base(const bContext *C)
void plane_from_point_normal_v3(float r_plane[4], const float plane_co[3], const float plane_no[3])
void BKE_sculptsession_free_pbvh(Object &object)
void BM_mesh_bm_from_me(BMesh *bm, const Mesh *mesh, const BMeshFromMeshParams *params)
Mesh -> BMesh.
MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f)
void RNA_int_set_array(PointerRNA *ptr, const char *name, const int *values)
VecBase< float, 2 > float2
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
void DEG_id_tag_update(ID *id, unsigned int flags)
void BKE_report(ReportList *reports, eReportType type, const char *message)
BMesh const char void * data
void RNA_int_get_array(PointerRNA *ptr, const char *name, int *values)
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])
void BKE_mesh_batch_cache_dirty_tag(Mesh *mesh, eMeshBatchDirtyMode mode)
void WM_operator_properties_gesture_straightline(wmOperatorType *ot, int cursor)
Mesh * BKE_mesh_new_nomain(int verts_num, int edges_num, int faces_num, int corners_num)
MINLINE void negate_v3(float r[3])
bool BMO_op_callf(BMesh *bm, int flag, const char *fmt,...)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
void BKE_id_free(Main *bmain, void *idv)
wmOperatorStatus WM_gesture_polyline_modal(bContext *C, wmOperator *op, const wmEvent *event)
void mul_mat3_m4_v3(const float mat[4][4], float r[3])
wmOperatorStatus WM_gesture_box_modal(bContext *C, wmOperator *op, const wmEvent *event)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
wmOperatorStatus WM_gesture_lasso_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Scene * CTX_data_scene(const bContext *C)
std::optional< Bounds< float3 > > BKE_object_boundbox_get(const Object *ob)
wmOperatorStatus WM_gesture_straightline_oneshot_modal(bContext *C, wmOperator *op, const wmEvent *event)
@ OPTYPE_DEPENDS_ON_CURSOR
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 WM_operator_properties_gesture_polyline(wmOperatorType *ot)
@ BKE_MESH_BATCH_DIRTY_ALL
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])
BMesh * BM_mesh_create(const BMAllocTemplate *allocsize, const BMeshCreateParams *params)
BMesh Make Mesh.
Object * CTX_data_active_object(const bContext *C)
View3D * CTX_wm_view3d(const bContext *C)
void WM_operator_properties_gesture_lasso(wmOperatorType *ot)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
static MatBase identity()
GeometryComponent & get_component_for_write(GeometryComponent::Type component_type)
static GeometrySet from_mesh(Mesh *mesh, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
ePaintSymmetryFlags symmpass
Array< float2 > gesture_points
float3 world_space_view_normal
void(*) end(bContext &, GestureData &)
void(*) apply_for_symmetry_pass(bContext &, GestureData &)
void(*) begin(bContext &, wmOperator &, GestureData &)
OrientationType orientation
blender::geometry::boolean::Solver solver_mode
bool no_self_intersections
bool no_nested_components
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT
wmOperatorStatus(*) invoke(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
wmOperatorStatus(*) modal(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
struct ReportList * reports