[Bf-blender-cvs] [d570feeffca] sculpt-dev: Cleanup: Clang format
Pablo Dobarro
noreply at git.blender.org
Fri Feb 26 14:59:02 CET 2021
Commit: d570feeffca75fb88d881921238b3a48e2649af8
Author: Pablo Dobarro
Date: Fri Feb 26 01:36:13 2021 +0100
Branches: sculpt-dev
https://developer.blender.org/rBd570feeffca75fb88d881921238b3a48e2649af8
Cleanup: Clang format
===================================================================
M source/blender/blenloader/intern/versioning_290.c
M source/blender/editors/sculpt_paint/sculpt_filter_mask.c
M source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
M source/blender/editors/sculpt_paint/sculpt_intern.h
===================================================================
diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c
index dc0d836f7fa..50f53439bb4 100644
--- a/source/blender/blenloader/intern/versioning_290.c
+++ b/source/blender/blenloader/intern/versioning_290.c
@@ -1763,7 +1763,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
Sculpt *sd = scene->toolsettings->sculpt;
if (sd) {
- sd->smooth_strength_factor = 1.0f;
+ sd->smooth_strength_factor = 1.0f;
}
}
}
diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_mask.c b/source/blender/editors/sculpt_paint/sculpt_filter_mask.c
index 66ad13521c7..3714d036579 100644
--- a/source/blender/editors/sculpt_paint/sculpt_filter_mask.c
+++ b/source/blender/editors/sculpt_paint/sculpt_filter_mask.c
@@ -317,11 +317,9 @@ void SCULPT_OT_mask_filter(struct wmOperatorType *ot)
"Use a automatic number of iterations based on the number of vertices of the sculpt");
}
-
/******************************************************************************************/
/* Interactive Preview Mask Filter */
-
#define SCULPT_IPMASK_FILTER_MIN_MULTITHREAD 1000
#define SCULPT_IPMASK_FILTER_GRANULARITY 1000
@@ -334,47 +332,56 @@ typedef enum eSculptIPMaskFilterType {
} eSculptIPMaskFilterType;
static EnumPropertyItem prop_ipmask_filter_types[] = {
- {IPMASK_FILTER_SMOOTH_SHARPEN, "SMOOTH_SHARPEN", 0, "Smooth/Sharpen", "Smooth and sharpen the mask"},
+ {IPMASK_FILTER_SMOOTH_SHARPEN,
+ "SMOOTH_SHARPEN",
+ 0,
+ "Smooth/Sharpen",
+ "Smooth and sharpen the mask"},
{IPMASK_FILTER_GROW_SHRINK, "GROW_SHRINK", 0, "Grow/Shrink", "Grow and shirnk the mask"},
{0, NULL, 0, NULL, NULL},
};
-
typedef enum MaskFilterStepDirectionType {
- MASK_FILTER_STEP_DIRECTION_FORWARD,
- MASK_FILTER_STEP_DIRECTION_BACKWARD,
+ MASK_FILTER_STEP_DIRECTION_FORWARD,
+ MASK_FILTER_STEP_DIRECTION_BACKWARD,
} MaskFilterStepDirectionType;
-
/* Grown/Shrink vertex callbacks. */
-static float sculpt_ipmask_vertex_grow_cb(SculptSession *ss, const int vertex, float *current_mask) {
- float max = 0.0f;
- SculptVertexNeighborIter ni;
- SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, vertex, ni) {
- float vmask_f = current_mask[ni.index];
- if (vmask_f > max) {
- max = vmask_f;
- }
- }
- SCULPT_VERTEX_NEIGHBORS_ITER_END(ni);
- return max;
+static float sculpt_ipmask_vertex_grow_cb(SculptSession *ss, const int vertex, float *current_mask)
+{
+ float max = 0.0f;
+ SculptVertexNeighborIter ni;
+ SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, vertex, ni) {
+ float vmask_f = current_mask[ni.index];
+ if (vmask_f > max) {
+ max = vmask_f;
+ }
+ }
+ SCULPT_VERTEX_NEIGHBORS_ITER_END(ni);
+ return max;
}
-static float sculpt_ipmask_vertex_shrink_cb(SculptSession *ss, const int vertex, float *current_mask) {
- float min = 1.0f;
- SculptVertexNeighborIter ni;
- SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, vertex, ni) {
- float vmask_f = current_mask[ni.index];
- if (vmask_f < min) {
- min = vmask_f;
- }
- }
- SCULPT_VERTEX_NEIGHBORS_ITER_END(ni);
- return min;
+static float sculpt_ipmask_vertex_shrink_cb(SculptSession *ss,
+ const int vertex,
+ float *current_mask)
+{
+ float min = 1.0f;
+ SculptVertexNeighborIter ni;
+ SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, vertex, ni) {
+ float vmask_f = current_mask[ni.index];
+ if (vmask_f < min) {
+ min = vmask_f;
+ }
+ }
+ SCULPT_VERTEX_NEIGHBORS_ITER_END(ni);
+ return min;
}
/* Smooth/Sharpen vertex callbacks. */
-static float sculpt_ipmask_vertex_smooth_cb(SculptSession *ss, const int vertex, float *current_mask) {
+static float sculpt_ipmask_vertex_smooth_cb(SculptSession *ss,
+ const int vertex,
+ float *current_mask)
+{
float accum = 0.0f;
int total = 0;
SculptVertexNeighborIter ni;
@@ -383,10 +390,13 @@ static float sculpt_ipmask_vertex_smooth_cb(SculptSession *ss, const int vertex,
total++;
}
SCULPT_VERTEX_NEIGHBORS_ITER_END(ni);
- return total > 0? accum/total : current_mask[vertex];
+ return total > 0 ? accum / total : current_mask[vertex];
}
-static float sculpt_ipmask_vertex_sharpen_cb(SculptSession *ss, const int vertex, float *current_mask) {
+static float sculpt_ipmask_vertex_sharpen_cb(SculptSession *ss,
+ const int vertex,
+ float *current_mask)
+{
float accum = 0.0f;
int total = 0;
float vmask = current_mask[vertex];
@@ -396,101 +406,109 @@ static float sculpt_ipmask_vertex_sharpen_cb(SculptSession *ss, const int vertex
total++;
}
SCULPT_VERTEX_NEIGHBORS_ITER_END(ni);
- const float avg = total > 0? accum/total : current_mask[vertex];
+ const float avg = total > 0 ? accum / total : current_mask[vertex];
const float val = avg - vmask;
float new_mask;
- if (vmask > 0.5f) {
- new_mask = vmask + 0.03f;
- }
- else {
- new_mask = vmask - 0.03f;
- }
- new_mask += val / 2.0f;
- return clamp_f(new_mask, 0.0f, 1.0f);
-
+ if (vmask > 0.5f) {
+ new_mask = vmask + 0.03f;
+ }
+ else {
+ new_mask = vmask - 0.03f;
+ }
+ new_mask += val / 2.0f;
+ return clamp_f(new_mask, 0.0f, 1.0f);
}
-
-static MaskFilterDeltaStep *sculpt_ipmask_filter_delta_create(const float *current_mask, const float *next_mask, const int totvert) {
- int tot_modified_values = 0;
- for (int i = 0; i < totvert; i++) {
- if (current_mask[i] == next_mask[i]) {
- continue;
- }
- tot_modified_values++;
+static MaskFilterDeltaStep *sculpt_ipmask_filter_delta_create(const float *current_mask,
+ const float *next_mask,
+ const int totvert)
+{
+ int tot_modified_values = 0;
+ for (int i = 0; i < totvert; i++) {
+ if (current_mask[i] == next_mask[i]) {
+ continue;
}
+ tot_modified_values++;
+ }
- MaskFilterDeltaStep *delta_step = MEM_callocN(sizeof (MaskFilterDeltaStep), "mask filter delta step");
- delta_step->totelem = tot_modified_values;
- delta_step->index = MEM_malloc_arrayN(sizeof (int), tot_modified_values, "delta indices");
- delta_step->delta = MEM_malloc_arrayN(sizeof (float), tot_modified_values, "delta values");
+ MaskFilterDeltaStep *delta_step = MEM_callocN(sizeof(MaskFilterDeltaStep),
+ "mask filter delta step");
+ delta_step->totelem = tot_modified_values;
+ delta_step->index = MEM_malloc_arrayN(sizeof(int), tot_modified_values, "delta indices");
+ delta_step->delta = MEM_malloc_arrayN(sizeof(float), tot_modified_values, "delta values");
- int delta_step_index = 0;
- for (int i = 0; i < totvert; i++) {
- if (current_mask[i] == next_mask[i]) {
- continue;
- }
- delta_step->index[delta_step_index] = i;
- delta_step->delta[delta_step_index] = next_mask[i] - current_mask[i];
- delta_step_index++;
+ int delta_step_index = 0;
+ for (int i = 0; i < totvert; i++) {
+ if (current_mask[i] == next_mask[i]) {
+ continue;
}
- printf("DELTA STEP SIZE %d\n", delta_step->totelem);
- return delta_step;
+ delta_step->index[delta_step_index] = i;
+ delta_step->delta[delta_step_index] = next_mask[i] - current_mask[i];
+ delta_step_index++;
+ }
+ printf("DELTA STEP SIZE %d\n", delta_step->totelem);
+ return delta_step;
}
typedef struct SculptIPMaskFilterTaskData {
- SculptSession *ss;
- float *next_mask;
- float *current_mask;
- MaskFilterStepDirectionType direction;
+ SculptSession *ss;
+ float *next_mask;
+ float *current_mask;
+ MaskFilterStepDirectionType direction;
} SculptIPMaskFilterTaskData;
static void ipmask_filter_compute_step_task_cb(void *__restrict userdata,
- const int i,
- const TaskParallelTLS *__restrict UNUSED(tls))
+ const int i,
+ const TaskParallelTLS *__restrict UNUSED(tls))
{
SculptIPMaskFilterTaskData *data = userdata;
- if (data->direction == MASK_FILTER_STEP_DIRECTION_FORWARD) {
- data->next_mask[i] = data->ss->filter_cache->mask_filter_step_forward(data->ss, i, data->current_mask);
- }
- else {
- data->next_mask[i] = data->ss->filter_cache->mask_filter_step_backward(data->ss, i, data->current_mask);
- }
+ if (data->direction == MASK_FILTER_STEP_DIRECTION_FORWARD) {
+ data->next_mask[i] = data->ss->filter_cache->mask_filter_step_forward(
+ data->ss, i, data->current_mask);
+ }
+ else {
+ data->next_mask[i] = data->ss->filter_cache->mask_filter_step_backward(
+ data->ss, i, data->current_mask);
+ }
}
-static float *sculpt_ipmask_step_compute(SculptSession *ss, float *current_mask, MaskFilterStepDirectionType direction) {
- const int totvert = SCULPT_vertex_count_get(ss);
- float *next_mask = MEM_malloc_arrayN(sizeof (float), totvert, "delta values");
-
- SculptIPMaskFilterTaskData data = {
- .ss = ss,
- .next_mask = next_mask,
- .current_mask = current_mask,
- .direction = direction,
- };
- TaskParallelSettings settings;
- memset(&settings, 0, sizeof(TaskParallelSettings));
- settings.use_threading = totvert > SCULPT_IPMASK_FILTER_MIN_MULTITHREAD;
- BLI_task_parallel_range(0, totvert, &data, ipmask_filter_compute_step_task_cb, &settings);
+static float *sculpt_ipmask_step_compute(SculptSession *ss,
+ float *current_mask,
+ MaskFilterStepDirectionType
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list