86 for (
int axis = 0; axis < 3; axis++) {
117 const float center[3] = {0.0f};
121 .radius_squared = FLT_MAX,
122 .ignore_fully_ineffective =
true,
145 .filter_undo_type = undo_type,
210 "Smooth the edges of all the Face Sets"},
215 "Smooth the surface of the mesh, preserving the volume"},
221 "Enhance the high frequency surface detail"},
223 "ERASE_DISCPLACEMENT",
225 "Erase Displacement",
226 "Deletes the displacement of the Multires Modifier"},
248 "Use the local axis to limit the displacement"},
253 "Use the global axis to limit the displacement"},
258 "Use the view axis to limit the displacement"},
264 return ELEM(filter_type,
295 float orig_co[3], val[3], avg[3], disp[3], disp2[3],
transform[3][3], final_pos[3];
322 switch (filter_type) {
366 const uint *hash_co = (
const uint *)orig_co;
399 float disp_sharpen[3] = {0.0f, 0.0f, 0.0f};
423 float detail_strength[3];
445 for (
int it = 0; it < 3; it++) {
474 totvert,
sizeof(
float[3]),
"detail directions");
475 for (
int i = 0; i < totvert; i++) {
483 const float shape_preservation,
484 const float current_vertex_displacement)
490 totvert,
sizeof(
float[3]),
"surface smooth displacement");
501 totvert,
sizeof(
float[3]),
"limit surface co");
502 for (
int i = 0; i < totvert; i++) {
508 const float smooth_ratio,
509 const float intensify_detail_strength,
510 const int curvature_smooth_iterations)
520 totvert,
sizeof(
float[3]),
"sharpen detail direction");
522 for (
int i = 0; i < totvert; i++) {
529 float max_factor = 0.0f;
530 for (
int i = 0; i < totvert; i++) {
536 max_factor = 1.0f / max_factor;
537 for (
int i = 0; i < totvert; i++) {
543 for (
int smooth_iterations = 0;
545 smooth_iterations++) {
546 for (
int i = 0; i < totvert; i++) {
547 float direction_avg[3] = {0.0f, 0.0f, 0.0f};
548 float sharpen_avg = 0;
614 const float len =
event->prev_press_xy[0] -
event->xy[0];
615 filter_strength = filter_strength * -
len * 0.001f *
UI_DPI_FAC;
626 .filter_type = filter_type,
627 .filter_strength = filter_strength,
670 if (deform_axis == 0) {
675 if (use_automasking) {
685 if (needs_topology_info) {
697 switch (filter_type) {
699 const float shape_preservation =
RNA_float_get(op->
ptr,
"surface_smooth_shape_preservation");
701 "surface_smooth_current_vertex");
708 "sharpen_intensify_detail_strength");
710 "sharpen_curvature_smooth_iterations");
712 ss, smooth_ratio, intensify_detail_strength, curvature_smooth_iterations);
742 ot->
idname =
"SCULPT_OT_mesh_filter";
743 ot->
description =
"Applies a filter to modify the current mesh";
758 "Operation that is going to be applied to the mesh");
760 ot->
srna,
"strength", 1.0f, -10.0f, 10.0f,
"Strength",
"Filter strength", -10.0f, 10.0f);
766 "Apply the deformation in the selected axis");
772 "Orientation of the axis to limit the filter displacement");
776 "surface_smooth_shape_preservation",
780 "Shape Preservation",
781 "How much of the original shape is preserved when smoothing",
785 "surface_smooth_current_vertex",
789 "Per Vertex Displacement",
790 "How much the position of each individual vertex influences the final result",
794 "sharpen_smooth_ratio",
799 "How much smoothing is applied to polished surfaces",
804 "sharpen_intensify_detail_strength",
809 "How much creases and valleys are intensified",
814 "sharpen_curvature_smooth_iterations",
818 "Curvature Smooth Iterations",
819 "How much smooth the resulting shape is, ignoring high frequency details",
struct Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
struct Object * CTX_data_active_object(const bContext *C)
struct Depsgraph * CTX_data_depsgraph_pointer(const bContext *C)
struct ToolSettings * CTX_data_tool_settings(const bContext *C)
General operations, lookup, etc. for blender objects.
void BKE_sculpt_update_object_for_edit(struct Depsgraph *depsgraph, struct Object *ob_orig, bool need_pmap, bool need_mask, bool is_paint_tool)
#define SCULPT_FACE_SET_NONE
A BVH for high poly meshes.
void BKE_pbvh_node_mark_update(PBVHNode *node)
#define BKE_pbvh_vertex_iter_begin(pbvh, node, vi, mode)
PBVHType BKE_pbvh_type(const PBVH *pbvh)
void BKE_pbvh_node_mark_normals_update(PBVHNode *node)
#define BKE_pbvh_vertex_iter_end
void BKE_pbvh_vert_tag_update_normal(PBVH *pbvh, int index)
void BKE_pbvh_update_normals(PBVH *pbvh, struct SubdivCCG *subdiv_ccg)
void BKE_pbvh_ensure_node_loops(PBVH *pbvh)
void BKE_pbvh_parallel_range_settings(struct TaskParallelSettings *settings, bool use_threading, int totnode)
void BKE_pbvh_search_gather(PBVH *pbvh, BKE_pbvh_SearchCallback scb, void *search_data, PBVHNode ***array, int *tot)
BLI_INLINE unsigned int BLI_hash_int_2d(unsigned int kx, unsigned int ky)
MINLINE float pow2f(float x)
MINLINE float clamp_f(float value, float min, float max)
void mul_m3_v3(const float M[3][3], float r[3])
void unit_m3(float m[3][3])
void scale_m3_fl(float R[3][3], float scale)
void mul_mat3_m4_v3(const float M[4][4], float r[3])
bool invert_m4_m4(float R[4][4], const float A[4][4])
void copy_m4_m4(float m1[4][4], const float m2[4][4])
MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f)
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE float normalize_v3_v3(float r[3], const float a[3])
void mid_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void madd_v3_v3v3fl(float r[3], const float a[3], const float b[3], float f)
MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f)
MINLINE void add_v3_v3(float r[3], const float a[3])
MINLINE float len_v3(const float a[3]) ATTR_WARN_UNUSED_RESULT
void BLI_task_parallel_range(int start, int stop, void *userdata, TaskParallelRangeFunc func, const TaskParallelSettings *settings)
struct Depsgraph Depsgraph
void ED_view3d_viewcontext_init(struct bContext *C, struct ViewContext *vc, struct Depsgraph *depsgraph)
NSNotificationCenter * center
Read Guarded memory(de)allocation.
SIMD_FORCE_INLINE btVector3 transform(const btVector3 &point) const
const Depsgraph * depsgraph
IconTextureDrawCall normal
void *(* MEM_malloc_arrayN)(size_t len, size_t size, const char *str)
void *(* MEM_callocN)(size_t len, const char *str)
CCL_NAMESPACE_BEGIN ccl_device float fade(float t)
int RNA_int_get(PointerRNA *ptr, const char *name)
float RNA_float_get(PointerRNA *ptr, const char *name)
int RNA_enum_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, float default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
PropertyRNA * RNA_def_enum_flag(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, int default_value, int hardmin, int hardmax, const char *ui_name, const char *ui_description, int softmin, int softmax)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description)
const float * SCULPT_vertex_co_get(SculptSession *ss, int index)
int SCULPT_vertex_count_get(SculptSession *ss)
void SCULPT_orig_vert_data_update(SculptOrigVertData *orig_data, PBVHVertexIter *iter)
void SCULPT_orig_vert_data_init(SculptOrigVertData *data, Object *ob, PBVHNode *node, SculptUndoType type)
void SCULPT_boundary_info_ensure(Object *object)
bool SCULPT_cursor_geometry_info_update(bContext *C, SculptCursorGeometryInfo *out, const float mval[2], bool use_sampled_normal)
bool SCULPT_vertex_has_unique_face_set(SculptSession *ss, int index)
void SCULPT_vertex_random_access_ensure(SculptSession *ss)
void SCULPT_flush_update_done(const bContext *C, Object *ob, SculptUpdateType update_flags)
bool SCULPT_search_sphere_cb(PBVHNode *node, void *data_v)
void SCULPT_flush_update_step(bContext *C, SculptUpdateType update_flags)
void SCULPT_vertex_limit_surface_get(SculptSession *ss, int index, float r_co[3])
bool SCULPT_mode_poll(bContext *C)
void SCULPT_flush_stroke_deform(Sculpt *sd, Object *ob, bool is_proxy_used)
void SCULPT_automasking_cache_free(AutomaskingCache *automasking)
float SCULPT_automasking_factor_get(AutomaskingCache *automasking, SculptSession *ss, int vert)
AutomaskingCache * SCULPT_automasking_cache_init(Sculpt *sd, Brush *brush, Object *ob)
bool SCULPT_is_automasking_enabled(const Sculpt *sd, const SculptSession *ss, const Brush *br)
void SCULPT_relax_vertex(SculptSession *ss, PBVHVertexIter *vd, float factor, bool filter_boundary_face_sets, float *r_final_pos)
void SCULPT_cloth_simulation_free(struct SculptClothSimulation *cloth_sim)
static void mesh_filter_task_cb(void *__restrict userdata, const int i, const TaskParallelTLS *__restrict UNUSED(tls))
@ MESH_FILTER_ENHANCE_DETAILS
@ MESH_FILTER_SURFACE_SMOOTH
@ MESH_FILTER_ERASE_DISPLACEMENT
@ MESH_FILTER_RELAX_FACE_SETS
void SCULPT_filter_zero_disabled_axis_components(float r_v[3], struct FilterCache *filter_cache)
void SCULPT_filter_to_orientation_space(float r_v[3], struct FilterCache *filter_cache)
static void mesh_filter_enhance_details_init_directions(SculptSession *ss)
static void mesh_filter_init_limit_surface_co(SculptSession *ss)
static EnumPropertyItem prop_mesh_filter_deform_axis_items[]
static void mesh_filter_surface_smooth_displace_task_cb(void *__restrict userdata, const int i, const TaskParallelTLS *__restrict UNUSED(tls))
void SCULPT_OT_mesh_filter(struct wmOperatorType *ot)
static EnumPropertyItem prop_mesh_filter_types[]
void SCULPT_filter_to_object_space(float r_v[3], struct FilterCache *filter_cache)
static bool sculpt_mesh_filter_needs_pmap(eSculptMeshFilterType filter_type)
static void mesh_filter_surface_smooth_init(SculptSession *ss, const float shape_preservation, const float current_vertex_displacement)
void SCULPT_filter_cache_init(bContext *C, Object *ob, Sculpt *sd, const int undo_type)
static int sculpt_mesh_filter_modal(bContext *C, wmOperator *op, const wmEvent *event)
static void filter_cache_init_task_cb(void *__restrict userdata, const int i, const TaskParallelTLS *__restrict UNUSED(tls))
static void mesh_filter_sharpen_init(SculptSession *ss, const float smooth_ratio, const float intensify_detail_strength, const int curvature_smooth_iterations)
static int sculpt_mesh_filter_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static EnumPropertyItem prop_mesh_filter_orientation_items[]
void SCULPT_filter_cache_free(SculptSession *ss)
void SCULPT_undo_push_begin(struct Object *ob, const char *name)
void SCULPT_undo_push_end(struct Object *ob)
#define SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN(ss, v_index, neighbor_iterator)
@ SCULPT_FILTER_ORIENTATION_WORLD
@ SCULPT_FILTER_ORIENTATION_VIEW
@ SCULPT_FILTER_ORIENTATION_LOCAL
void SCULPT_surface_smooth_laplacian_step(SculptSession *ss, float *disp, const float co[3], float(*laplacian_disp)[3], int v_index, const float origco[3], float alpha)
void SCULPT_neighbor_coords_average(SculptSession *ss, float result[3], int index)
#define SCULPT_VERTEX_NEIGHBORS_ITER_END(neighbor_iterator)
SculptUndoNode * SCULPT_undo_push_node(Object *ob, PBVHNode *node, SculptUndoType type)
void SCULPT_neighbor_coords_average_interior(SculptSession *ss, float result[3], int index)
void SCULPT_surface_smooth_displace_step(SculptSession *ss, float *co, float(*laplacian_disp)[3], int v_index, float beta, float fade)
float surface_smooth_current_vertex
float(* detail_directions)[3]
AutomaskingCache * automasking
SculptFilterOrientation orientation
int sharpen_curvature_smooth_iterations
float(* surface_smooth_laplacian_disp)[3]
float sharpen_smooth_ratio
float(* limit_surface_co)[3]
float sharpen_intensify_detail_strength
float(* pre_smoothed_color)[4]
SculptClothSimulation * cloth_sim
float surface_smooth_shape_preservation
bool enabled_force_axis[3]
struct SculptSession * sculpt
struct SubdivCCG * subdiv_ccg
struct KeyBlock * shapekey_active
struct FilterCache * filter_cache
bool deform_modifiers_active
struct RegionView3D * rv3d
int(* invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
int(* modal)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)