106 mesh_to_bm_params.calc_vert_normal =
true;
125 if (
params->add_boundary_loop) {
131 for (
int repeat = 0; repeat <
params->num_smooth_iterations; repeat++) {
136 for (
int i = 0; i < 3; i++) {
139 "smooth_vert verts=%hv factor=%f mirror_clip_x=%b mirror_clip_y=%b "
141 "clip_dist=%f use_axis_x=%b use_axis_y=%b use_axis_z=%b",
160 for (
int i = 0; i < 1; i++) {
163 "smooth_vert verts=%hv factor=%f mirror_clip_x=%b mirror_clip_y=%b "
165 "clip_dist=%f use_axis_x=%b use_axis_y=%b use_axis_z=%b",
191 new_mesh->attributes_for_write().remove(
".sculpt_face_set");
194 new_mesh->attributes_for_write().remove(
".sculpt_mask");
204 ushort local_view_bits = 0;
209 C,
OB_MESH,
nullptr, ob->
loc, ob->
rot,
false, local_view_bits);
212 if (
params->apply_shrinkwrap) {
216 if (
params->add_solidify) {
220 new_ob,
"mask_extract_solidify");
237 const float threshold =
params->mask_threshold;
246 bool keep_face =
true;
255 if (mask < threshold) {
266 const int tag_face_set_id =
params->active_face_set;
304 C, op,
e,
IFACE_(
"Create Mesh From Paint Mask"),
IFACE_(
"Extract"));
313 "Add an extra edge loop to better preserve the shape when applying a "
314 "subdivision surface modifier");
321 "Smooth iterations applied to the extracted mesh",
328 "Project the extracted mesh into the original sculpt");
333 "Extract the mask as a solid object with a solidify modifier");
338 ot->
name =
"Mask Extract";
339 ot->
description =
"Create a new mesh object from the current paint mask";
340 ot->
idname =
"MESH_OT_paint_mask_extract";
355 "Minimum mask value to consider the vertex valid to extract a face from the original mesh",
370 const float mval[2] = {
float(event->
xy[0] - region->winrct.xmin),
371 float(event->
xy[1] - region->winrct.ymin)};
374 const int face_set_id = sculpt_paint::face_set::active_update_and_get(C, ob, mval);
380 params.active_face_set = face_set_id;
381 params.num_smooth_iterations = 0;
382 params.add_boundary_loop =
false;
383 params.apply_shrinkwrap =
true;
384 params.add_solidify =
true;
390 ot->
name =
"Face Set Extract";
391 ot->
description =
"Create a new mesh object from the selected Face Set";
392 ot->
idname =
"MESH_OT_face_set_extract";
416 bool keep_face =
true;
419 if (mask < mask_threshold) {
429 keep_face = !keep_face;
443 "triangulate faces=%hf quad_method=%i ngon_method=%i",
451 "recalc_face_normals faces=%hf",
477 sculpt_paint::undo::geometry_begin(scene, ob, op);
496 if (create_new_object) {
497 ushort local_view_bits = 0;
502 C,
OB_MESH,
nullptr, ob.
loc, ob.
rot,
false, local_view_bits);
516 new_ob_mesh->attributes_for_write().remove(
".sculpt_mask");
527 mesh =
static_cast<Mesh *
>(ob.
data);
531 if (mesh->attributes().contains(
".sculpt_face_set")) {
533 const int next_face_set_id = sculpt_paint::face_set::find_next_available_id(ob);
534 sculpt_paint::face_set::initialize_none_to_id(mesh, next_face_set_id);
536 if (!create_new_object) {
537 sculpt_paint::undo::geometry_end(ob);
555 ot->
idname =
"MESH_OT_paint_mask_slice";
569 "Minimum mask value to consider the vertex valid to extract a face from the original mesh",
573 ot->
srna,
"fill_holes",
true,
"Fill Holes",
"Fill holes after slicing the mask");
578 "Slice to New Object",
579 "Create a new object from the sliced mask");
void CTX_wm_operator_poll_msg_set(bContext *C, const char *msg)
Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
Depsgraph * CTX_data_depsgraph_pointer(const bContext *C)
Object * CTX_data_active_object(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
Main * CTX_data_main(const bContext *C)
RegionView3D * CTX_wm_region_view3d(const bContext *C)
ARegion * CTX_wm_region(const bContext *C)
Depsgraph * CTX_data_depsgraph_on_load(const bContext *C)
View3D * CTX_wm_view3d(const bContext *C)
CustomData interface, see also DNA_customdata_types.h.
int CustomData_get_offset_named(const CustomData *data, eCustomDataType type, blender::StringRef name)
void BKE_editmesh_free_data(BMEditMesh *em)
BMEditMesh * BKE_editmesh_create(BMesh *bm)
void BKE_id_free(Main *bmain, void *idv)
ID * BKE_id_copy(Main *bmain, const ID *id)
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)
void BKE_mesh_nomain_to_mesh(Mesh *mesh_src, Mesh *mesh_dst, Object *ob)
@ BKE_MESH_BATCH_DIRTY_ALL
ModifierData * BKE_modifiers_findby_name(const Object *ob, const char *name)
#define SCULPT_FACE_SET_NONE
void BKE_sculptsession_free_pbvh(Object &object)
void BKE_sculpt_mask_layers_ensure(Depsgraph *depsgraph, Main *bmain, Object *ob, MultiresModifierData *mmd)
void BKE_shrinkwrap_mesh_nearest_surface_deform(Depsgraph *depsgraph, Scene *scene, Object *ob_source, Object *ob_target)
MINLINE void mul_v3_v3(float r[3], const float a[3])
void DEG_id_tag_update(ID *id, unsigned int flags)
void DEG_relations_tag_update(Main *bmain)
Object is a sort of wrapper for general info.
bool ED_operator_object_active_editable_mesh(bContext *C)
void ED_undo_push_op(bContext *C, wmOperator *op)
Read Guarded memory(de)allocation.
@ OPTYPE_DEPENDS_ON_CURSOR
#define BM_ELEM_CD_GET_FLOAT(ele, offset)
#define BM_ELEM_CD_GET_INT(ele, offset)
void BM_mesh_delete_hflag_context(BMesh *bm, const char hflag, const int type)
void BM_mesh_edgenet(BMesh *bm, const bool use_edge_tag, const bool use_new_face_tag)
#define BM_elem_flag_set(ele, hflag, val)
#define BM_elem_flag_test_bool(ele, hflag)
#define BM_ITER_ELEM(ele, iter, data, itype)
#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_normals_update(BMesh *bm)
bool BMO_op_callf(BMesh *bm, int flag, const char *fmt,...)
#define BMO_FLAG_DEFAULTS
bool BM_vert_is_boundary(const BMVert *v)
BLI_INLINE bool BM_edge_is_boundary(const BMEdge *e) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
ATTR_WARN_UNUSED_RESULT const BMVert * v
const Depsgraph * depsgraph
bool edbm_extrude_edges_indiv(BMEditMesh *em, wmOperator *op, const char hflag, const bool use_normal_flip)
bool EDBM_op_callf(BMEditMesh *em, wmOperator *op, const char *fmt,...)
draw_view in_light_buf[] float
CCL_NAMESPACE_BEGIN ccl_device float invert(float color, float factor)
ModifierData * modifier_add(ReportList *reports, Main *bmain, Scene *scene, Object *ob, const char *name, int type)
Object * add_type(bContext *C, int type, const char *name, const float loc[3], const float rot[3], bool enter_editmode, unsigned short local_view_bits) ATTR_NONNULL(1) ATTR_RETURNS_NONNULL
void object_sculpt_mode_exit(Main &bmain, Depsgraph &depsgraph, Scene &scene, Object &ob)
int RNA_int_get(PointerRNA *ptr, const char *name)
float RNA_float_get(PointerRNA *ptr, const char *name)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_float_factor(StructOrFunctionRNA *cont_, const char *identifier, const float default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, const float default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float 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)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
struct SculptSession * sculpt
unsigned short local_view_uid
bool(* poll)(bContext *C) 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
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
int WM_operator_props_popup_confirm_ex(bContext *C, wmOperator *op, const wmEvent *, std::optional< std::string > title, std::optional< std::string > confirm_text, const bool cancel_default)