103 for (
int axis = 0; axis < 3; axis++) {
130 const float center[3] = {0.0f};
134 .radius_squared = FLT_MAX,
135 .ignore_fully_ineffective =
true,
158 .filter_undo_type = undo_type,
222 "Smooth the edges of all the Face Sets"},
227 "Smooth the surface of the mesh, preserving the volume"},
233 "Enhance the high frequency surface detail"},
235 "ERASE_DISCPLACEMENT",
237 "Erase Displacement",
238 "Deletes the displacement of the Multires Modifier"},
260 "Use the local axis to limit the displacement"},
265 "Use the global axis to limit the displacement"},
270 "Use the view axis to limit the displacement"},
276 return ELEM(filter_type,
307 float orig_co[3], val[3], avg[3],
normal[3], disp[3], disp2[3],
transform[3][3], final_pos[3];
334 switch (filter_type) {
378 const uint *hash_co = (
const uint *)orig_co;
411 float disp_sharpen[3] = {0.0f, 0.0f, 0.0f};
435 float detail_strength[3];
458 for (
int it = 0; it < 3; it++) {
487 totvert,
sizeof(
float[3]),
"detail directions");
488 for (
int i = 0; i < totvert; i++) {
496 const float shape_preservation,
497 const float current_vertex_displacement)
503 totvert,
sizeof(
float[3]),
"surface smooth displacement");
514 sizeof(
float[3]), totvert,
"limit surface co");
515 for (
int i = 0; i < totvert; i++) {
521 const float smooth_ratio,
522 const float intensify_detail_strength,
523 const int curvature_smooth_iterations)
533 totvert,
sizeof(
float[3]),
"sharpen detail direction");
535 for (
int i = 0; i < totvert; i++) {
542 float max_factor = 0.0f;
543 for (
int i = 0; i < totvert; i++) {
549 max_factor = 1.0f / max_factor;
550 for (
int i = 0; i < totvert; i++) {
556 for (
int smooth_iterations = 0;
558 smooth_iterations++) {
559 for (
int i = 0; i < totvert; i++) {
560 float direction_avg[3] = {0.0f, 0.0f, 0.0f};
561 float sharpen_avg = 0;
627 const float len =
event->prevclickx -
event->x;
628 filter_strength = filter_strength * -
len * 0.001f *
UI_DPI_FAC;
639 .filter_type = filter_type,
640 .filter_strength = filter_strength,
683 if (deform_axis == 0) {
688 if (use_automasking) {
693 mouse[0] =
event->mval[0];
694 mouse[1] =
event->mval[1];
700 if (needs_topology_info) {
712 switch (filter_type) {
714 const float shape_preservation =
RNA_float_get(op->
ptr,
"surface_smooth_shape_preservation");
716 "surface_smooth_current_vertex");
723 "sharpen_intensify_detail_strength");
725 "sharpen_curvature_smooth_iterations");
727 ss, smooth_ratio, intensify_detail_strength, curvature_smooth_iterations);
757 ot->
idname =
"SCULPT_OT_mesh_filter";
758 ot->
description =
"Applies a filter to modify the current mesh";
773 "Operation that is going to be applied to the mesh");
775 ot->
srna,
"strength", 1.0f, -10.0f, 10.0f,
"Strength",
"Filter strength", -10.0f, 10.0f);
781 "Apply the deformation in the selected axis");
787 "Orientation of the axis to limit the filter displacement");
791 "surface_smooth_shape_preservation",
795 "Shape Preservation",
796 "How much of the original shape is preserved when smoothing",
800 "surface_smooth_current_vertex",
804 "Per Vertex Displacement",
805 "How much the position of each individual vertex influences the final result",
809 "sharpen_smooth_ratio",
814 "How much smoothing is applied to polished surfaces",
819 "sharpen_intensify_detail_strength",
824 "How much creases and valleys are intensified",
829 "sharpen_curvature_smooth_iterations",
833 "Curvature Smooth Iterations",
834 "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 need_colors)
#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_update_normals(PBVH *pbvh, struct SubdivCCG *subdiv_ccg)
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 normal_short_to_float_v3(float r[3], const short n[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(const int start, const 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)
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_boundary_info_ensure(Object *object)
bool SCULPT_cursor_geometry_info_update(bContext *C, SculptCursorGeometryInfo *out, const float mouse[2], bool use_sampled_normal)
bool SCULPT_vertex_has_unique_face_set(SculptSession *ss, int index)
void SCULPT_relax_vertex(SculptSession *ss, PBVHVertexIter *vd, float factor, bool filter_boundary_face_sets, float *r_final_pos)
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_orig_vert_data_init(SculptOrigVertData *data, Object *ob, PBVHNode *node)
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_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_surface_smooth_laplacian_step(SculptSession *ss, float *disp, const float co[3], float(*laplacian_disp)[3], const int v_index, const float origco[3], const float alpha)
#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_neighbor_coords_average(SculptSession *ss, float result[3], int index)
void SCULPT_surface_smooth_displace_step(SculptSession *ss, float *co, float(*laplacian_disp)[3], const int v_index, const float beta, const float fade)
#define SCULPT_VERTEX_NEIGHBORS_ITER_END(neighbor_iterator)
void SCULPT_undo_push_end(void)
SculptUndoNode * SCULPT_undo_push_node(Object *ob, PBVHNode *node, SculptUndoType type)
void SCULPT_neighbor_coords_average_interior(SculptSession *ss, float result[3], int index)
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
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
CCL_NAMESPACE_BEGIN ccl_device float fade(float t)
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)