68 "Increase the contrast of the paint mask"},
73 "Decrease the contrast of the paint mask"},
86 const int mode =
data->filter_type;
87 float contrast = 0.0f;
101 float prev_val = *vd.
mask;
114 if (*vd.
mask > 0.5f) {
120 *vd.
mask += val / 2.0f;
127 float vmask_f =
data->prev_mask[ni.
index];
138 float vmask_f =
data->prev_mask[ni.
index];
148 delta = contrast / 2.0f;
149 gain = 1.0f - delta * 2.0f;
151 gain = 1.0f / ((gain != 0.0f) ? gain : FLT_EPSILON);
162 if (*vd.
mask != prev_val) {
198 for (
int i = 0; i < totnode; i++) {
202 float *prev_mask =
NULL;
210 iterations = (int)(num_verts / 50000.0f) + 1;
213 for (
int i = 0; i < iterations; i++) {
215 prev_mask =
MEM_mallocN(num_verts *
sizeof(
float),
"prevmask");
216 for (
int j = 0; j < num_verts; j++) {
225 .filter_type = filter_type,
226 .prev_mask = prev_mask,
257 for (
int i = 0; i < smooth_iterations; i++) {
268 ot->
idname =
"SCULPT_OT_mask_filter";
269 ot->
description =
"Applies a filter to modify the current mask";
283 "Filter that is going to be applied to the mask");
290 "Number of times that the filter is going to be applied",
295 "auto_iteration_count",
297 "Auto Iteration Count",
298 "Use a automatic number of iterations based on the number of vertices of the sculpt");
349 void *__restrict chunk_join,
350 void *__restrict chunk)
367 const bool dirty_only =
data->dirty_mask_dirty_only;
368 const float min =
data->dirty_mask_min;
369 const float max =
data->dirty_mask_max;
372 if (range < 0.0001f) {
376 range = 1.0f / range;
381 float mask = *vd.
mask + (1.0f - ((dirty_mask -
min) * range));
413 for (
int i = 0; i < totnode; i++) {
436 data.dirty_mask_min = range.
min;
437 data.dirty_mask_max = range.
max;
457 ot->
idname =
"SCULPT_OT_dirty_mask";
458 ot->
description =
"Generates a mask based on the geometry cavity and pointiness";
468 ot->
srna,
"dirty_only",
false,
"Dirty Only",
"Don't calculate cleans for convex areas");
struct Object * CTX_data_active_object(const bContext *C)
struct ARegion * CTX_wm_region(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)
A BVH for high poly meshes.
#define BKE_pbvh_vertex_iter_begin(pbvh, node, vi, mode)
#define BKE_pbvh_vertex_iter_end
void BKE_pbvh_parallel_range_settings(struct TaskParallelSettings *settings, bool use_threading, int totnode)
void BKE_pbvh_update_vertex_data(PBVH *pbvh, int flags)
void BKE_pbvh_node_mark_update_mask(PBVHNode *node)
void BKE_pbvh_search_gather(PBVH *pbvh, BKE_pbvh_SearchCallback scb, void *search_data, PBVHNode ***array, int *tot)
MINLINE float max_ff(float a, float b)
MINLINE float clamp_f(float value, float min, float max)
MINLINE float min_ff(float a, float b)
MINLINE float saacosf(float f)
MINLINE float normalize_v3(float r[3])
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 float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void zero_v3(float r[3])
MINLINE void add_v3_v3(float r[3], const float a[3])
void BLI_task_parallel_range(int start, int stop, void *userdata, TaskParallelRangeFunc func, const TaskParallelSettings *settings)
struct Depsgraph Depsgraph
void ED_region_tag_redraw(struct ARegion *region)
Read Guarded memory(de)allocation.
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
SIMD_FORCE_INLINE btVector3 normalized() const
Return a normalized version of this vector.
const Depsgraph * depsgraph
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
void(* MEM_freeN)(void *vmemh)
void *(* MEM_mallocN)(size_t len, const char *str)
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)
static void update(bNodeTree *ntree)
int RNA_int_get(PointerRNA *ptr, const char *name)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
int RNA_enum_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, bool 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_vertex_random_access_ensure(SculptSession *ss)
bool SCULPT_mode_poll(bContext *C)
float SCULPT_vertex_mask_get(SculptSession *ss, int index)
void SCULPT_tag_update_overlays(bContext *C)
static EnumPropertyItem prop_mask_filter_types[]
static void dirty_mask_apply_task_cb(void *__restrict userdata, const int i, const TaskParallelTLS *__restrict UNUSED(tls))
void SCULPT_OT_mask_filter(struct wmOperatorType *ot)
static void mask_filter_task_cb(void *__restrict userdata, const int i, const TaskParallelTLS *__restrict UNUSED(tls))
static int sculpt_mask_filter_exec(bContext *C, wmOperator *op)
static int sculpt_dirty_mask_exec(bContext *C, wmOperator *op)
static float neighbor_dirty_mask(SculptSession *ss, PBVHVertexIter *vd)
void SCULPT_mask_filter_smooth_apply(Sculpt *sd, Object *ob, PBVHNode **nodes, const int totnode, const int smooth_iterations)
static void dirty_mask_compute_range_task_cb(void *__restrict userdata, const int i, const TaskParallelTLS *__restrict tls)
static void dirty_mask_compute_range_reduce(const void *__restrict UNUSED(userdata), void *__restrict chunk_join, void *__restrict chunk)
void SCULPT_OT_dirty_mask(struct wmOperatorType *ot)
struct DirtyMaskRangeData DirtyMaskRangeData
@ MASK_FILTER_CONTRAST_DECREASE
@ MASK_FILTER_CONTRAST_INCREASE
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)
float SCULPT_neighbor_mask_average(SculptSession *ss, int index)
#define SCULPT_VERTEX_NEIGHBORS_ITER_END(neighbor_iterator)
SculptUndoNode * SCULPT_undo_push_node(Object *ob, PBVHNode *node, SculptUndoType type)
struct SculptSession * sculpt
struct MeshElemMap * pmap
TaskParallelReduceFunc func_reduce
size_t userdata_chunk_size
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
int(* exec)(struct bContext *, struct wmOperator *) ATTR_WARN_UNUSED_RESULT
void WM_event_add_notifier(const bContext *C, uint type, void *reference)