Cleanup: Sculpt/Paint, use correct types and iterator variable declaration
Reviewed By: brecht Differential Revision: https://developer.blender.org/D6788
This commit is contained in:
@@ -1099,8 +1099,11 @@ static bool ommit_cursor_drawing(Paint *paint, ePaintMode mode, Brush *brush)
|
||||
return true;
|
||||
}
|
||||
|
||||
static void cursor_draw_point_screen_space(
|
||||
const uint gpuattr, const ARegion *ar, float true_location[3], float obmat[4][4], int size)
|
||||
static void cursor_draw_point_screen_space(const uint gpuattr,
|
||||
const ARegion *ar,
|
||||
const float true_location[3],
|
||||
const float obmat[4][4],
|
||||
const int size)
|
||||
{
|
||||
float translation_vertex_cursor[3], location[3];
|
||||
copy_v3_v3(location, true_location);
|
||||
@@ -1118,11 +1121,11 @@ static void cursor_draw_tiling_preview(const uint gpuattr,
|
||||
const float true_location[3],
|
||||
Sculpt *sd,
|
||||
Object *ob,
|
||||
float radius)
|
||||
const float radius)
|
||||
{
|
||||
BoundBox *bb = BKE_object_boundbox_get(ob);
|
||||
float orgLoc[3], location[3];
|
||||
int dim, tile_pass = 0;
|
||||
int tile_pass = 0;
|
||||
int start[3];
|
||||
int end[3];
|
||||
int cur[3];
|
||||
@@ -1131,7 +1134,7 @@ static void cursor_draw_tiling_preview(const uint gpuattr,
|
||||
const float *step = sd->paint.tile_offset;
|
||||
|
||||
copy_v3_v3(orgLoc, true_location);
|
||||
for (dim = 0; dim < 3; dim++) {
|
||||
for (int dim = 0; dim < 3; dim++) {
|
||||
if ((sd->paint.symmetry_flags & (PAINT_TILE_X << dim)) && step[dim] > 0) {
|
||||
start[dim] = (bbMin[dim] - orgLoc[dim] - radius) / step[dim];
|
||||
end[dim] = (bbMax[dim] - orgLoc[dim] + radius) / step[dim];
|
||||
@@ -1149,7 +1152,7 @@ static void cursor_draw_tiling_preview(const uint gpuattr,
|
||||
continue;
|
||||
}
|
||||
tile_pass++;
|
||||
for (dim = 0; dim < 3; dim++) {
|
||||
for (int dim = 0; dim < 3; dim++) {
|
||||
location[dim] = cur[dim] * step[dim] + orgLoc[dim];
|
||||
}
|
||||
cursor_draw_point_screen_space(gpuattr, ar, location, ob->obmat, 3);
|
||||
@@ -1163,7 +1166,7 @@ static void cursor_draw_point_with_symmetry(const uint gpuattr,
|
||||
const float true_location[3],
|
||||
Sculpt *sd,
|
||||
Object *ob,
|
||||
float radius)
|
||||
const float radius)
|
||||
{
|
||||
const char symm = sd->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL;
|
||||
float location[3], symm_rot_mat[4][4];
|
||||
@@ -1223,7 +1226,7 @@ static void sculpt_geometry_preview_lines_draw(const uint gpuattr, SculptSession
|
||||
static void sculpt_multiplane_scrape_preview_draw(const uint gpuattr,
|
||||
SculptSession *ss,
|
||||
const float outline_col[3],
|
||||
float outline_alpha)
|
||||
const float outline_alpha)
|
||||
{
|
||||
float local_mat_inv[4][4];
|
||||
invert_m4_m4(local_mat_inv, ss->cache->stroke_local_mat);
|
||||
|
||||
@@ -68,7 +68,7 @@ static bool is_effected(PartialVisArea area,
|
||||
const float mask)
|
||||
{
|
||||
if (area == PARTIALVIS_ALL) {
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
else if (area == PARTIALVIS_MASKED) {
|
||||
return mask > 0.5f;
|
||||
@@ -137,7 +137,7 @@ static void partialvis_update_grids(Depsgraph *depsgraph,
|
||||
{
|
||||
CCGElem **grids;
|
||||
BLI_bitmap **grid_hidden;
|
||||
int *grid_indices, totgrid, i;
|
||||
int *grid_indices, totgrid;
|
||||
bool any_changed = false, any_visible = false;
|
||||
|
||||
/* Get PBVH data. */
|
||||
@@ -147,9 +147,9 @@ static void partialvis_update_grids(Depsgraph *depsgraph,
|
||||
|
||||
sculpt_undo_push_node(ob, node, SCULPT_UNDO_HIDDEN);
|
||||
|
||||
for (i = 0; i < totgrid; i++) {
|
||||
for (int i = 0; i < totgrid; i++) {
|
||||
int any_hidden = 0;
|
||||
int g = grid_indices[i], x, y;
|
||||
int g = grid_indices[i];
|
||||
BLI_bitmap *gh = grid_hidden[g];
|
||||
|
||||
if (!gh) {
|
||||
@@ -172,8 +172,8 @@ static void partialvis_update_grids(Depsgraph *depsgraph,
|
||||
continue;
|
||||
}
|
||||
|
||||
for (y = 0; y < key.grid_size; y++) {
|
||||
for (x = 0; x < key.grid_size; x++) {
|
||||
for (int y = 0; y < key.grid_size; y++) {
|
||||
for (int x = 0; x < key.grid_size; x++) {
|
||||
CCGElem *elem = CCG_grid_elem(&key, grids[g], x, y);
|
||||
const float *co = CCG_elem_co(&key, elem);
|
||||
float mask = key.has_mask ? *CCG_elem_mask(&key, elem) : 0.0f;
|
||||
@@ -349,7 +349,7 @@ static int hide_show_exec(bContext *C, wmOperator *op)
|
||||
PBVHType pbvh_type;
|
||||
float clip_planes[4][4];
|
||||
rcti rect;
|
||||
int totnode, i;
|
||||
int totnode;
|
||||
|
||||
/* Read operator properties. */
|
||||
action = RNA_enum_get(op->ptr, "action");
|
||||
@@ -376,7 +376,7 @@ static int hide_show_exec(bContext *C, wmOperator *op)
|
||||
break;
|
||||
}
|
||||
|
||||
for (i = 0; i < totnode; i++) {
|
||||
for (int i = 0; i < totnode; i++) {
|
||||
switch (pbvh_type) {
|
||||
case PBVH_FACES:
|
||||
partialvis_update_mesh(ob, pbvh, nodes[i], action, area, clip_planes);
|
||||
|
||||
@@ -446,9 +446,9 @@ static unsigned short *brush_painter_curve_mask_new(BrushPainter *painter,
|
||||
float len = len_v2(xy_rot);
|
||||
float p = len / radius;
|
||||
if (hardness < 1.0f) {
|
||||
p = (p - hardness) / (1 - hardness);
|
||||
p = (p - hardness) / (1.0f - hardness);
|
||||
p = 1.0f - p;
|
||||
CLAMP(p, 0, 1);
|
||||
CLAMP(p, 0.0f, 1.0f);
|
||||
}
|
||||
else {
|
||||
p = 1.0;
|
||||
@@ -574,7 +574,7 @@ static void brush_painter_imbuf_update(BrushPainter *painter,
|
||||
/* get brush color */
|
||||
if (brush->imagepaint_tool == PAINT_TOOL_DRAW) {
|
||||
paint_brush_color_get(
|
||||
scene, brush, use_color_correction, cache->invert, 0.0, 1.0, brush_rgb, display);
|
||||
scene, brush, use_color_correction, cache->invert, 0.0f, 1.0f, brush_rgb, display);
|
||||
}
|
||||
else {
|
||||
brush_rgb[0] = 1.0f;
|
||||
|
||||
@@ -732,7 +732,7 @@ static bool project_paint_PickColor(const ProjPaintState *ps,
|
||||
tri_index = project_paint_PickFace(ps, pt, w);
|
||||
|
||||
if (tri_index == -1) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
lt = &ps->mlooptri_eval[tri_index];
|
||||
@@ -807,7 +807,7 @@ static bool project_paint_PickColor(const ProjPaintState *ps,
|
||||
}
|
||||
}
|
||||
BKE_image_release_ibuf(ima, ibuf, NULL);
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1052,8 +1052,9 @@ static bool cmp_uv(const float vec2a[2], const float vec2b[2])
|
||||
yb += 1.0f;
|
||||
}
|
||||
|
||||
return ((fabsf(xa - xb) < PROJ_GEOM_TOLERANCE) && (fabsf(ya - yb) < PROJ_GEOM_TOLERANCE)) ? 1 :
|
||||
0;
|
||||
return ((fabsf(xa - xb) < PROJ_GEOM_TOLERANCE) && (fabsf(ya - yb) < PROJ_GEOM_TOLERANCE)) ?
|
||||
true :
|
||||
false;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1084,7 +1085,7 @@ static bool pixel_bounds_uv(const float uv_quad[4][2],
|
||||
/*printf("%d %d %d %d\n", min_px[0], min_px[1], max_px[0], max_px[1]);*/
|
||||
|
||||
/* face uses no UV area when quantized to pixels? */
|
||||
return (bounds_px->xmin == bounds_px->xmax || bounds_px->ymin == bounds_px->ymax) ? 0 : 1;
|
||||
return (bounds_px->xmin == bounds_px->xmax || bounds_px->ymin == bounds_px->ymax) ? false : true;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1095,7 +1096,7 @@ static bool pixel_bounds_array(
|
||||
float min_uv[2], max_uv[2];
|
||||
|
||||
if (tot == 0) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
INIT_MINMAX2(min_uv, max_uv);
|
||||
@@ -1114,7 +1115,7 @@ static bool pixel_bounds_array(
|
||||
/*printf("%d %d %d %d\n", min_px[0], min_px[1], max_px[0], max_px[1]);*/
|
||||
|
||||
/* face uses no UV area when quantized to pixels? */
|
||||
return (bounds_px->xmin == bounds_px->xmax || bounds_px->ymin == bounds_px->ymax) ? 0 : 1;
|
||||
return (bounds_px->xmin == bounds_px->xmax || bounds_px->ymin == bounds_px->ymax) ? false : true;
|
||||
}
|
||||
|
||||
#ifndef PROJ_DEBUG_NOSEAMBLEED
|
||||
@@ -1197,22 +1198,22 @@ static bool check_seam(const ProjPaintState *ps,
|
||||
* they are on the same side so edge is boundary */
|
||||
if ((ps->faceWindingFlags[tri_index] & PROJ_FACE_WINDING_CW) !=
|
||||
(ps->faceWindingFlags[orig_face] & PROJ_FACE_WINDING_CW)) {
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
// printf("SEAM (NONE)\n");
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
// printf("SEAM (UV GAP)\n");
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// printf("SEAM (NO FACE)\n");
|
||||
*other_face = -1;
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
static VertSeam *find_adjacent_seam(const ProjPaintState *ps,
|
||||
@@ -2068,11 +2069,11 @@ static bool line_clip_rect2f(const rctf *cliprect,
|
||||
if (fabsf(l1[1] - l2[1]) < PROJ_PIXEL_TOLERANCE) {
|
||||
/* is the line out of range on its Y axis? */
|
||||
if (l1[1] < rect->ymin || l1[1] > rect->ymax) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
/* line is out of range on its X axis */
|
||||
if ((l1[0] < rect->xmin && l2[0] < rect->xmin) || (l1[0] > rect->xmax && l2[0] > rect->xmax)) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* this is a single point (or close to)*/
|
||||
@@ -2080,10 +2081,10 @@ static bool line_clip_rect2f(const rctf *cliprect,
|
||||
if (BLI_rctf_isect_pt_v(rect, l1)) {
|
||||
copy_v2_v2(l1_clip, l1);
|
||||
copy_v2_v2(l2_clip, l2);
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2091,7 +2092,7 @@ static bool line_clip_rect2f(const rctf *cliprect,
|
||||
copy_v2_v2(l2_clip, l2);
|
||||
CLAMP(l1_clip[0], rect->xmin, rect->xmax);
|
||||
CLAMP(l2_clip[0], rect->xmin, rect->xmax);
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
else if (fabsf(l1[0] - l2[0]) < PROJ_PIXEL_TOLERANCE) {
|
||||
/* is the line out of range on its X axis? */
|
||||
@@ -2109,10 +2110,10 @@ static bool line_clip_rect2f(const rctf *cliprect,
|
||||
if (BLI_rctf_isect_pt_v(rect, l1)) {
|
||||
copy_v2_v2(l1_clip, l1);
|
||||
copy_v2_v2(l2_clip, l2);
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2120,7 +2121,7 @@ static bool line_clip_rect2f(const rctf *cliprect,
|
||||
copy_v2_v2(l2_clip, l2);
|
||||
CLAMP(l1_clip[1], rect->ymin, rect->ymax);
|
||||
CLAMP(l2_clip[1], rect->ymin, rect->ymax);
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
float isect;
|
||||
@@ -2161,7 +2162,7 @@ static bool line_clip_rect2f(const rctf *cliprect,
|
||||
}
|
||||
|
||||
if (ok1 && ok2) {
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (line_isect_y(l1, l2, rect->ymax, &isect) && (isect >= cliprect->xmin) &&
|
||||
@@ -2179,7 +2180,7 @@ static bool line_clip_rect2f(const rctf *cliprect,
|
||||
}
|
||||
|
||||
if (ok1 && ok2) {
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* left/right */
|
||||
@@ -2198,7 +2199,7 @@ static bool line_clip_rect2f(const rctf *cliprect,
|
||||
}
|
||||
|
||||
if (ok1 && ok2) {
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (line_isect_x(l1, l2, rect->xmax, &isect) && (isect >= cliprect->ymin) &&
|
||||
@@ -2216,10 +2217,10 @@ static bool line_clip_rect2f(const rctf *cliprect,
|
||||
}
|
||||
|
||||
if (ok1 && ok2) {
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2279,13 +2280,13 @@ static bool project_bucket_isect_circle(const float cent[2],
|
||||
*/
|
||||
#if 0
|
||||
if (BLI_rctf_isect_pt_v(bucket_bounds, cent)) {
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((bucket_bounds->xmin <= cent[0] && bucket_bounds->xmax >= cent[0]) ||
|
||||
(bucket_bounds->ymin <= cent[1] && bucket_bounds->ymax >= cent[1])) {
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* out of bounds left */
|
||||
@@ -2294,15 +2295,15 @@ static bool project_bucket_isect_circle(const float cent[2],
|
||||
if (cent[1] < bucket_bounds->ymin) {
|
||||
return (len_squared_v2v2_alt(cent, bucket_bounds->xmin, bucket_bounds->ymin) <
|
||||
radius_squared) ?
|
||||
1 :
|
||||
0;
|
||||
true :
|
||||
false;
|
||||
}
|
||||
/* top left test */
|
||||
else if (cent[1] > bucket_bounds->ymax) {
|
||||
return (len_squared_v2v2_alt(cent, bucket_bounds->xmin, bucket_bounds->ymax) <
|
||||
radius_squared) ?
|
||||
1 :
|
||||
0;
|
||||
true :
|
||||
false;
|
||||
}
|
||||
}
|
||||
else if (cent[0] > bucket_bounds->xmax) {
|
||||
@@ -2310,19 +2311,19 @@ static bool project_bucket_isect_circle(const float cent[2],
|
||||
if (cent[1] < bucket_bounds->ymin) {
|
||||
return (len_squared_v2v2_alt(cent, bucket_bounds->xmax, bucket_bounds->ymin) <
|
||||
radius_squared) ?
|
||||
1 :
|
||||
0;
|
||||
true :
|
||||
false;
|
||||
}
|
||||
/* top right test */
|
||||
else if (cent[1] > bucket_bounds->ymax) {
|
||||
return (len_squared_v2v2_alt(cent, bucket_bounds->xmax, bucket_bounds->ymax) <
|
||||
radius_squared) ?
|
||||
1 :
|
||||
0;
|
||||
true :
|
||||
false;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Note for rect_to_uvspace_ortho() and rect_to_uvspace_persp()
|
||||
@@ -2951,29 +2952,28 @@ static bool IsectPoly2Df(const float pt[2], float uv[][2], const int tot)
|
||||
{
|
||||
int i;
|
||||
if (line_point_side_v2(uv[tot - 1], uv[0], pt) < 0.0f) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
for (i = 1; i < tot; i++) {
|
||||
if (line_point_side_v2(uv[i - 1], uv[i], pt) < 0.0f) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
static bool IsectPoly2Df_twoside(const float pt[2], float uv[][2], const int tot)
|
||||
{
|
||||
int i;
|
||||
bool side = (line_point_side_v2(uv[tot - 1], uv[0], pt) > 0.0f);
|
||||
const bool side = (line_point_side_v2(uv[tot - 1], uv[0], pt) > 0.0f);
|
||||
|
||||
for (i = 1; i < tot; i++) {
|
||||
for (int i = 1; i < tot; i++) {
|
||||
if ((line_point_side_v2(uv[i - 1], uv[i], pt) > 0.0f) != side) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* One of the most important function for projection painting,
|
||||
@@ -3600,7 +3600,7 @@ static bool project_bucket_face_isect(ProjPaintState *ps,
|
||||
do {
|
||||
v = ps->screenCoords[lt_vtri[fidx]];
|
||||
if (BLI_rctf_isect_pt_v(&bucket_bounds, v)) {
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
} while (fidx--);
|
||||
|
||||
@@ -3624,10 +3624,10 @@ static bool project_bucket_face_isect(ProjPaintState *ps,
|
||||
(isect_seg_seg_v2(p2, p3, v1, v2) || isect_seg_seg_v2(p2, p3, v2, v3)) ||
|
||||
(isect_seg_seg_v2(p3, p4, v1, v2) || isect_seg_seg_v2(p3, p4, v2, v3)) ||
|
||||
(isect_seg_seg_v2(p4, p1, v1, v2) || isect_seg_seg_v2(p4, p1, v2, v3))) {
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Add faces to the bucket but don't initialize its pixels
|
||||
@@ -3939,8 +3939,6 @@ static void proj_paint_state_seam_bleed_init(ProjPaintState *ps)
|
||||
|
||||
static void proj_paint_state_thread_init(ProjPaintState *ps, const bool reset_threads)
|
||||
{
|
||||
int a;
|
||||
|
||||
/* Thread stuff
|
||||
*
|
||||
* very small brushes run a lot slower multi-threaded since the advantage with
|
||||
@@ -3964,7 +3962,7 @@ static void proj_paint_state_thread_init(ProjPaintState *ps, const bool reset_th
|
||||
ED_image_paint_tile_lock_init();
|
||||
}
|
||||
|
||||
for (a = 0; a < ps->thread_tot; a++) {
|
||||
for (int a = 0; a < ps->thread_tot; a++) {
|
||||
ps->arena_mt[a] = BLI_memarena_new(MEM_SIZE_OPTIMAL(1 << 16), "project paint arena");
|
||||
}
|
||||
}
|
||||
@@ -6041,14 +6039,13 @@ void paint_proj_stroke_done(void *ps_handle_p)
|
||||
{
|
||||
ProjStrokeHandle *ps_handle = ps_handle_p;
|
||||
Scene *scene = ps_handle->scene;
|
||||
int i;
|
||||
|
||||
if (ps_handle->is_clone_cursor_pick) {
|
||||
MEM_freeN(ps_handle);
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 1; i < ps_handle->ps_views_tot; i++) {
|
||||
for (int i = 1; i < ps_handle->ps_views_tot; i++) {
|
||||
PROJ_PAINT_STATE_SHARED_CLEAR(ps_handle->ps_views[i]);
|
||||
}
|
||||
|
||||
@@ -6056,7 +6053,7 @@ void paint_proj_stroke_done(void *ps_handle_p)
|
||||
|
||||
paint_brush_exit_tex(ps_handle->brush);
|
||||
|
||||
for (i = 0; i < ps_handle->ps_views_tot; i++) {
|
||||
for (int i = 0; i < ps_handle->ps_views_tot; i++) {
|
||||
ProjPaintState *ps;
|
||||
ps = ps_handle->ps_views[i];
|
||||
project_paint_end(ps);
|
||||
@@ -6376,11 +6373,10 @@ bool BKE_paint_proj_mesh_data_check(
|
||||
}
|
||||
else {
|
||||
/* there may be material slots but they may be empty, check */
|
||||
int i;
|
||||
hasmat = false;
|
||||
hastex = false;
|
||||
|
||||
for (i = 1; i < ob->totcol + 1; i++) {
|
||||
for (int i = 1; i < ob->totcol + 1; i++) {
|
||||
Material *ma = BKE_object_material_get(ob, i);
|
||||
|
||||
if (ma) {
|
||||
@@ -6771,7 +6767,7 @@ void PAINT_OT_add_texture_paint_slot(wmOperatorType *ot)
|
||||
ot->srna, "color", 4, NULL, 0.0f, FLT_MAX, "Color", "Default fill color", 0.0f, 1.0f);
|
||||
RNA_def_property_subtype(prop, PROP_COLOR_GAMMA);
|
||||
RNA_def_property_float_array_default(prop, default_color);
|
||||
RNA_def_boolean(ot->srna, "alpha", 1, "Alpha", "Create an image with an alpha channel");
|
||||
RNA_def_boolean(ot->srna, "alpha", true, "Alpha", "Create an image with an alpha channel");
|
||||
RNA_def_enum(ot->srna,
|
||||
"generated_type",
|
||||
rna_enum_image_generated_type_items,
|
||||
|
||||
@@ -209,13 +209,13 @@ void PAINT_OT_mask_flood_fill(struct wmOperatorType *ot)
|
||||
RNA_def_float(
|
||||
ot->srna,
|
||||
"value",
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0.0f,
|
||||
0.0f,
|
||||
1.0f,
|
||||
"Value",
|
||||
"Mask level to use when mode is 'Value'; zero means no masking and one is fully masked",
|
||||
0,
|
||||
1);
|
||||
0.0f,
|
||||
1.0f);
|
||||
}
|
||||
|
||||
/* Box select, operator is VIEW3D_OT_select_box, defined in view3d_select.c. */
|
||||
@@ -301,15 +301,14 @@ bool ED_sculpt_mask_box_select(struct bContext *C, ViewContext *vc, const rcti *
|
||||
ARegion *ar = vc->ar;
|
||||
Object *ob = vc->obact;
|
||||
PaintMaskFloodMode mode;
|
||||
float value;
|
||||
bool multires;
|
||||
PBVH *pbvh;
|
||||
PBVHNode **nodes;
|
||||
int totnode, symmpass;
|
||||
int totnode;
|
||||
int symm = sd->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL;
|
||||
|
||||
mode = PAINT_MASK_FLOOD_VALUE;
|
||||
value = select ? 1.0 : 0.0;
|
||||
float value = select ? 1.0f : 0.0f;
|
||||
|
||||
/* Transform the clip planes in object space. */
|
||||
ED_view3d_clipping_calc(&bb, clip_planes, vc->ar, vc->obact, rect);
|
||||
@@ -320,13 +319,12 @@ bool ED_sculpt_mask_box_select(struct bContext *C, ViewContext *vc, const rcti *
|
||||
|
||||
sculpt_undo_push_begin("Mask box fill");
|
||||
|
||||
for (symmpass = 0; symmpass <= symm; symmpass++) {
|
||||
for (int symmpass = 0; symmpass <= symm; symmpass++) {
|
||||
if (symmpass == 0 || (symm & symmpass && (symm != 5 || symmpass != 3) &&
|
||||
(symm != 6 || (symmpass != 3 && symmpass != 5)))) {
|
||||
int j = 0;
|
||||
|
||||
/* Flip the planes symmetrically as needed. */
|
||||
for (; j < 4; j++) {
|
||||
for (int j = 0; j < 4; j++) {
|
||||
flip_plane(clip_planes_final[j], clip_planes[j], symmpass);
|
||||
}
|
||||
|
||||
@@ -472,7 +470,7 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op)
|
||||
int symm = sd->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL;
|
||||
PBVH *pbvh;
|
||||
PBVHNode **nodes;
|
||||
int totnode, symmpass;
|
||||
int totnode;
|
||||
bool multires;
|
||||
PaintMaskFloodMode mode = RNA_enum_get(op->ptr, "mode");
|
||||
float value = RNA_float_get(op->ptr, "value");
|
||||
@@ -508,13 +506,12 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op)
|
||||
|
||||
sculpt_undo_push_begin("Mask lasso fill");
|
||||
|
||||
for (symmpass = 0; symmpass <= symm; symmpass++) {
|
||||
for (int symmpass = 0; symmpass <= symm; symmpass++) {
|
||||
if ((symmpass == 0) || (symm & symmpass && (symm != 5 || symmpass != 3) &&
|
||||
(symm != 6 || (symmpass != 3 && symmpass != 5)))) {
|
||||
int j = 0;
|
||||
|
||||
/* Flip the planes symmetrically as needed. */
|
||||
for (; j < 4; j++) {
|
||||
for (int j = 0; j < 4; j++) {
|
||||
flip_plane(clip_planes_final[j], clip_planes[j], symmpass);
|
||||
}
|
||||
|
||||
@@ -585,11 +582,11 @@ void PAINT_OT_mask_lasso_gesture(wmOperatorType *ot)
|
||||
RNA_def_float(
|
||||
ot->srna,
|
||||
"value",
|
||||
1.0,
|
||||
0,
|
||||
1.0,
|
||||
1.0f,
|
||||
0.0f,
|
||||
1.0f,
|
||||
"Value",
|
||||
"Mask level to use when mode is 'Value'; zero means no masking and one is fully masked",
|
||||
0,
|
||||
1);
|
||||
0.0f,
|
||||
1.0f);
|
||||
}
|
||||
|
||||
@@ -266,10 +266,9 @@ static void sculpt_vertex_neighbors_get_bmesh(SculptSession *ss,
|
||||
iter->capacity = SCULPT_VERTEX_NEIGHBOR_FIXED_CAPACITY;
|
||||
iter->neighbors = iter->neighbors_fixed;
|
||||
|
||||
int i = 0;
|
||||
BM_ITER_ELEM (l, &liter, v, BM_LOOPS_OF_VERT) {
|
||||
const BMVert *adj_v[2] = {l->prev->v, l->next->v};
|
||||
for (i = 0; i < ARRAY_SIZE(adj_v); i++) {
|
||||
for (int i = 0; i < ARRAY_SIZE(adj_v); i++) {
|
||||
const BMVert *v_other = adj_v[i];
|
||||
if (BM_elem_index_get(v_other) != (int)index) {
|
||||
sculpt_vertex_neighbor_add(iter, BM_elem_index_get(v_other));
|
||||
@@ -282,19 +281,17 @@ static void sculpt_vertex_neighbors_get_faces(SculptSession *ss,
|
||||
int index,
|
||||
SculptVertexNeighborIter *iter)
|
||||
{
|
||||
int i;
|
||||
MeshElemMap *vert_map = &ss->pmap[(int)index];
|
||||
iter->size = 0;
|
||||
iter->num_duplicates = 0;
|
||||
iter->capacity = SCULPT_VERTEX_NEIGHBOR_FIXED_CAPACITY;
|
||||
iter->neighbors = iter->neighbors_fixed;
|
||||
|
||||
for (i = 0; i < ss->pmap[(int)index].count; i++) {
|
||||
for (int i = 0; i < ss->pmap[(int)index].count; i++) {
|
||||
const MPoly *p = &ss->mpoly[vert_map->indices[i]];
|
||||
uint f_adj_v[2];
|
||||
if (poly_get_adj_loops_from_vert(p, ss->mloop, (int)index, f_adj_v) != -1) {
|
||||
int j;
|
||||
for (j = 0; j < ARRAY_SIZE(f_adj_v); j += 1) {
|
||||
for (int j = 0; j < ARRAY_SIZE(f_adj_v); j += 1) {
|
||||
if (f_adj_v[j] != (int)index) {
|
||||
sculpt_vertex_neighbor_add(iter, f_adj_v[j]);
|
||||
}
|
||||
@@ -605,11 +602,11 @@ static bool sculpt_has_active_modifiers(Scene *scene, Object *ob)
|
||||
/* Exception for shape keys because we can edit those. */
|
||||
for (; md; md = md->next) {
|
||||
if (modifier_isEnabled(scene, md, eModifierMode_Realtime)) {
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool sculpt_tool_needs_original(const char sculpt_tool)
|
||||
@@ -973,17 +970,17 @@ bool sculpt_get_redraw_rect(ARegion *ar, RegionView3D *rv3d, Object *ob, rcti *r
|
||||
float bb_min[3], bb_max[3];
|
||||
|
||||
if (!pbvh) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
BKE_pbvh_redraw_BB(pbvh, bb_min, bb_max);
|
||||
|
||||
/* Convert 3D bounding box to screen space. */
|
||||
if (!paint_convert_bb_to_rect(rect, bb_min, bb_max, ar, rv3d, ob)) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
void ED_sculpt_redraw_planes_get(float planes[4][4], ARegion *ar, Object *ob)
|
||||
@@ -1060,13 +1057,13 @@ bool sculpt_brush_test_sphere(SculptBrushTest *test, const float co[3])
|
||||
|
||||
if (distsq <= test->radius_squared) {
|
||||
if (sculpt_brush_test_clipping(test, co)) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
test->dist = sqrtf(distsq);
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1076,20 +1073,20 @@ bool sculpt_brush_test_sphere_sq(SculptBrushTest *test, const float co[3])
|
||||
|
||||
if (distsq <= test->radius_squared) {
|
||||
if (sculpt_brush_test_clipping(test, co)) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
test->dist = distsq;
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool sculpt_brush_test_sphere_fast(const SculptBrushTest *test, const float co[3])
|
||||
{
|
||||
if (sculpt_brush_test_clipping(test, co)) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
return len_squared_v3v3(co, test->location) <= test->radius_squared;
|
||||
}
|
||||
@@ -1102,13 +1099,13 @@ bool sculpt_brush_test_circle_sq(SculptBrushTest *test, const float co[3])
|
||||
|
||||
if (distsq <= test->radius_squared) {
|
||||
if (sculpt_brush_test_clipping(test, co)) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
test->dist = distsq;
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1118,7 +1115,7 @@ bool sculpt_brush_test_cube(SculptBrushTest *test, const float co[3], float loca
|
||||
float local_co[3];
|
||||
|
||||
if (sculpt_brush_test_clipping(test, co)) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
mul_v3_m4v3(local_co, local, co);
|
||||
@@ -1132,10 +1129,10 @@ bool sculpt_brush_test_cube(SculptBrushTest *test, const float co[3], float loca
|
||||
test->dist = ((powf(local_co[0], p) + powf(local_co[1], p) + powf(local_co[2], p)) /
|
||||
powf(side, p));
|
||||
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1185,10 +1182,10 @@ static float frontface(const Brush *br,
|
||||
else {
|
||||
dot = dot_v3v3(fno, sculpt_normal);
|
||||
}
|
||||
return dot > 0 ? dot : 0;
|
||||
return dot > 0.0f ? dot : 0.0f;
|
||||
}
|
||||
else {
|
||||
return 1;
|
||||
return 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1360,7 +1357,7 @@ static float calc_overlap(StrokeCache *cache, const char symm, const char axis,
|
||||
return (2.0f * (cache->radius) - sqrtf(distsq)) / (2.0f * (cache->radius));
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
return 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1369,12 +1366,10 @@ static float calc_radial_symmetry_feather(Sculpt *sd,
|
||||
const char symm,
|
||||
const char axis)
|
||||
{
|
||||
int i;
|
||||
float overlap;
|
||||
float overlap = 0.0f;
|
||||
|
||||
overlap = 0;
|
||||
for (i = 1; i < sd->radial_symm[axis - 'X']; i++) {
|
||||
const float angle = 2 * M_PI * i / sd->radial_symm[axis - 'X'];
|
||||
for (int i = 1; i < sd->radial_symm[axis - 'X']; i++) {
|
||||
const float angle = 2.0f * M_PI * i / sd->radial_symm[axis - 'X'];
|
||||
overlap += calc_overlap(cache, symm, axis, angle);
|
||||
}
|
||||
|
||||
@@ -1385,11 +1380,10 @@ static float calc_symmetry_feather(Sculpt *sd, StrokeCache *cache)
|
||||
{
|
||||
if (sd->paint.symmetry_flags & PAINT_SYMMETRY_FEATHER) {
|
||||
float overlap;
|
||||
int symm = cache->symmetry;
|
||||
int i;
|
||||
const int symm = cache->symmetry;
|
||||
|
||||
overlap = 0;
|
||||
for (i = 0; i <= symm; i++) {
|
||||
overlap = 0.0f;
|
||||
for (int i = 0; i <= symm; i++) {
|
||||
if (i == 0 || (symm & i && (symm != 5 || i != 3) && (symm != 6 || (i != 3 && i != 5)))) {
|
||||
|
||||
overlap += calc_overlap(cache, i, 0, 0);
|
||||
@@ -1400,10 +1394,10 @@ static float calc_symmetry_feather(Sculpt *sd, StrokeCache *cache)
|
||||
}
|
||||
}
|
||||
|
||||
return 1 / overlap;
|
||||
return 1.0f / overlap;
|
||||
}
|
||||
else {
|
||||
return 1;
|
||||
return 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1467,11 +1461,10 @@ static void calc_area_normal_and_center_task_cb(void *__restrict userdata,
|
||||
float(*orco_coords)[3];
|
||||
int(*orco_tris)[3];
|
||||
int orco_tris_num;
|
||||
int i;
|
||||
|
||||
BKE_pbvh_node_get_bm_orco_data(data->nodes[n], &orco_tris, &orco_tris_num, &orco_coords);
|
||||
|
||||
for (i = 0; i < orco_tris_num; i++) {
|
||||
for (int i = 0; i < orco_tris_num; i++) {
|
||||
const float *co_tri[3] = {
|
||||
orco_coords[orco_tris[i][0]],
|
||||
orco_coords[orco_tris[i][1]],
|
||||
@@ -1729,11 +1722,11 @@ static float brush_strength(const Sculpt *sd,
|
||||
|
||||
/* Primary strength input; square it to make lower values more sensitive. */
|
||||
const float root_alpha = BKE_brush_alpha_get(scene, brush);
|
||||
float alpha = root_alpha * root_alpha;
|
||||
float dir = (brush->flag & BRUSH_DIR_IN) ? -1 : 1;
|
||||
float pressure = BKE_brush_use_alpha_pressure(brush) ? cache->pressure : 1;
|
||||
float pen_flip = cache->pen_flip ? -1 : 1;
|
||||
float invert = cache->invert ? -1 : 1;
|
||||
const float alpha = root_alpha * root_alpha;
|
||||
const float dir = (brush->flag & BRUSH_DIR_IN) ? -1.0f : 1.0f;
|
||||
const float pressure = BKE_brush_use_alpha_pressure(brush) ? cache->pressure : 1.0f;
|
||||
const float pen_flip = cache->pen_flip ? -1.0f : 1.0f;
|
||||
const float invert = cache->invert ? -1.0f : 1.0f;
|
||||
float overlap = ups->overlap_factor;
|
||||
/* Spacing is integer percentage of radius, divide by 50 to get
|
||||
* normalized diameter. */
|
||||
@@ -1763,7 +1756,7 @@ static float brush_strength(const Sculpt *sd,
|
||||
return alpha * flip * final_pressure * overlap * feather * 0.3f;
|
||||
|
||||
case SCULPT_TOOL_MASK:
|
||||
overlap = (1 + overlap) / 2;
|
||||
overlap = (1.0f + overlap) / 2.0f;
|
||||
switch ((BrushMaskTool)brush->mask_tool) {
|
||||
case BRUSH_MASK_DRAW:
|
||||
return alpha * flip * pressure * overlap * feather;
|
||||
@@ -1778,7 +1771,7 @@ static float brush_strength(const Sculpt *sd,
|
||||
return alpha * flip * pressure * overlap * feather;
|
||||
|
||||
case SCULPT_TOOL_INFLATE:
|
||||
if (flip > 0) {
|
||||
if (flip > 0.0f) {
|
||||
return 0.250f * alpha * flip * pressure * overlap * feather;
|
||||
}
|
||||
else {
|
||||
@@ -1792,8 +1785,8 @@ static float brush_strength(const Sculpt *sd,
|
||||
case SCULPT_TOOL_FILL:
|
||||
case SCULPT_TOOL_SCRAPE:
|
||||
case SCULPT_TOOL_FLATTEN:
|
||||
if (flip > 0) {
|
||||
overlap = (1 + overlap) / 2;
|
||||
if (flip > 0.0f) {
|
||||
overlap = (1.0f + overlap) / 2.0f;
|
||||
return alpha * flip * pressure * overlap * feather;
|
||||
}
|
||||
else {
|
||||
@@ -1805,7 +1798,7 @@ static float brush_strength(const Sculpt *sd,
|
||||
return alpha * pressure * feather;
|
||||
|
||||
case SCULPT_TOOL_PINCH:
|
||||
if (flip > 0) {
|
||||
if (flip > 0.0f) {
|
||||
return alpha * flip * pressure * overlap * feather;
|
||||
}
|
||||
else {
|
||||
@@ -1813,7 +1806,7 @@ static float brush_strength(const Sculpt *sd,
|
||||
}
|
||||
|
||||
case SCULPT_TOOL_NUDGE:
|
||||
overlap = (1 + overlap) / 2;
|
||||
overlap = (1.0f + overlap) / 2.0f;
|
||||
return alpha * pressure * overlap * feather;
|
||||
|
||||
case SCULPT_TOOL_THUMB:
|
||||
@@ -1833,7 +1826,7 @@ static float brush_strength(const Sculpt *sd,
|
||||
return root_alpha * feather;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
return 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1851,14 +1844,14 @@ float tex_strength(SculptSession *ss,
|
||||
StrokeCache *cache = ss->cache;
|
||||
const Scene *scene = cache->vc->scene;
|
||||
const MTex *mtex = &br->mtex;
|
||||
float avg = 1;
|
||||
float avg = 1.0f;
|
||||
float rgba[4];
|
||||
float point[3];
|
||||
|
||||
sub_v3_v3v3(point, brush_point, cache->plane_offset);
|
||||
|
||||
if (!mtex->tex) {
|
||||
avg = 1;
|
||||
avg = 1.0f;
|
||||
}
|
||||
else if (mtex->brush_map_mode == MTEX_MAP_MODE_3D) {
|
||||
/* Get strength by feeding the vertex location directly into a texture. */
|
||||
@@ -1935,7 +1928,6 @@ bool sculpt_search_sphere_cb(PBVHNode *node, void *data_v)
|
||||
center = data->ss->cache ? data->ss->cache->location : data->ss->cursor_location;
|
||||
}
|
||||
float t[3], bb_min[3], bb_max[3];
|
||||
int i;
|
||||
|
||||
if (data->ignore_fully_masked) {
|
||||
if (BKE_pbvh_node_fully_masked_get(node)) {
|
||||
@@ -1950,7 +1942,7 @@ bool sculpt_search_sphere_cb(PBVHNode *node, void *data_v)
|
||||
BKE_pbvh_node_get_BB(node, bb_min, bb_max);
|
||||
}
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (bb_min[i] > center[i]) {
|
||||
nearest[i] = bb_min[i];
|
||||
}
|
||||
@@ -1990,15 +1982,15 @@ bool sculpt_search_circle_cb(PBVHNode *node, void *data_v)
|
||||
const float dist_sq = dist_squared_ray_to_aabb_v3(
|
||||
data->dist_ray_to_aabb_precalc, bb_min, bb_max, dummy_co, &dummy_depth);
|
||||
|
||||
return dist_sq < data->radius_squared || 1;
|
||||
/* Seems like debug code. Maybe this fucntion can just return true if the node is not fully
|
||||
* masked. */
|
||||
return dist_sq < data->radius_squared || true;
|
||||
}
|
||||
|
||||
/* Handles clipping against a mirror modifier and SCULPT_LOCK axis flags. */
|
||||
static void sculpt_clip(Sculpt *sd, SculptSession *ss, float co[3], const float val[3])
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (sd->flags & (SCULPT_LOCK_X << i)) {
|
||||
continue;
|
||||
}
|
||||
@@ -2084,15 +2076,15 @@ static void calc_sculpt_normal(
|
||||
break;
|
||||
|
||||
case SCULPT_DISP_DIR_X:
|
||||
ARRAY_SET_ITEMS(r_area_no, 1, 0, 0);
|
||||
ARRAY_SET_ITEMS(r_area_no, 1.0f, 0.0f, 0.0f);
|
||||
break;
|
||||
|
||||
case SCULPT_DISP_DIR_Y:
|
||||
ARRAY_SET_ITEMS(r_area_no, 0, 1, 0);
|
||||
ARRAY_SET_ITEMS(r_area_no, 0.0f, 1.0f, 0.0f);
|
||||
break;
|
||||
|
||||
case SCULPT_DISP_DIR_Z:
|
||||
ARRAY_SET_ITEMS(r_area_no, 0, 0, 1);
|
||||
ARRAY_SET_ITEMS(r_area_no, 0.0f, 0.0f, 1.0f);
|
||||
break;
|
||||
|
||||
case SCULPT_DISP_DIR_AREA:
|
||||
@@ -2160,10 +2152,10 @@ static void calc_brush_local_mat(const Brush *brush, Object *ob, float local_mat
|
||||
invert_m4_m4(ob->imat, ob->obmat);
|
||||
|
||||
/* Initialize last column of matrix. */
|
||||
mat[0][3] = 0;
|
||||
mat[1][3] = 0;
|
||||
mat[2][3] = 0;
|
||||
mat[3][3] = 1;
|
||||
mat[0][3] = 0.0f;
|
||||
mat[1][3] = 0.0f;
|
||||
mat[2][3] = 0.0f;
|
||||
mat[3][3] = 1.0f;
|
||||
|
||||
/* Get view's up vector in object-space. */
|
||||
calc_local_y(cache->vc, cache->location, up);
|
||||
@@ -2211,17 +2203,16 @@ static void neighbor_average(SculptSession *ss, float avg[3], uint vert)
|
||||
|
||||
/* Don't modify corner vertices. */
|
||||
if (vert_map->count > 1) {
|
||||
int i, total = 0;
|
||||
int total = 0;
|
||||
|
||||
zero_v3(avg);
|
||||
|
||||
for (i = 0; i < vert_map->count; i++) {
|
||||
for (int i = 0; i < vert_map->count; i++) {
|
||||
const MPoly *p = &ss->mpoly[vert_map->indices[i]];
|
||||
uint f_adj_v[2];
|
||||
|
||||
if (poly_get_adj_loops_from_vert(p, ss->mloop, vert, f_adj_v) != -1) {
|
||||
int j;
|
||||
for (j = 0; j < ARRAY_SIZE(f_adj_v); j += 1) {
|
||||
for (int j = 0; j < ARRAY_SIZE(f_adj_v); j += 1) {
|
||||
if (vert_map->count != 2 || ss->pmap[f_adj_v[j]].count <= 2) {
|
||||
add_v3_v3(avg, deform_co ? deform_co[f_adj_v[j]] : mvert[f_adj_v[j]].co);
|
||||
|
||||
@@ -2246,16 +2237,15 @@ static void neighbor_average(SculptSession *ss, float avg[3], uint vert)
|
||||
static float neighbor_average_mask(SculptSession *ss, uint vert)
|
||||
{
|
||||
const float *vmask = ss->vmask;
|
||||
float avg = 0;
|
||||
int i, total = 0;
|
||||
float avg = 0.0f;
|
||||
int total = 0;
|
||||
|
||||
for (i = 0; i < ss->pmap[vert].count; i++) {
|
||||
for (int i = 0; i < ss->pmap[vert].count; i++) {
|
||||
const MPoly *p = &ss->mpoly[ss->pmap[vert].indices[i]];
|
||||
uint f_adj_v[2];
|
||||
|
||||
if (poly_get_adj_loops_from_vert(p, ss->mloop, vert, f_adj_v) != -1) {
|
||||
int j;
|
||||
for (j = 0; j < ARRAY_SIZE(f_adj_v); j += 1) {
|
||||
for (int j = 0; j < ARRAY_SIZE(f_adj_v); j += 1) {
|
||||
avg += vmask[f_adj_v[j]];
|
||||
total++;
|
||||
}
|
||||
@@ -2280,14 +2270,14 @@ static void bmesh_neighbor_average(float avg[3], BMVert *v)
|
||||
if (vfcount > 1) {
|
||||
BMIter liter;
|
||||
BMLoop *l;
|
||||
int i, total = 0;
|
||||
int total = 0;
|
||||
|
||||
zero_v3(avg);
|
||||
|
||||
BM_ITER_ELEM (l, &liter, v, BM_LOOPS_OF_VERT) {
|
||||
const BMVert *adj_v[2] = {l->prev->v, l->next->v};
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(adj_v); i++) {
|
||||
for (int i = 0; i < ARRAY_SIZE(adj_v); i++) {
|
||||
const BMVert *v_other = adj_v[i];
|
||||
if (vfcount != 2 || BM_vert_face_count_at_most(v_other, 2) <= 2) {
|
||||
add_v3_v3(avg, v_other->co);
|
||||
@@ -2310,8 +2300,8 @@ static void bmesh_neighbor_average(float avg[3], BMVert *v)
|
||||
static void bmesh_four_neighbor_average(float avg[3], float direction[3], BMVert *v)
|
||||
{
|
||||
|
||||
float avg_co[3] = {0, 0, 0};
|
||||
float tot_co = 0;
|
||||
float avg_co[3] = {0.0f, 0.0f, 0.0f};
|
||||
float tot_co = 0.0f;
|
||||
|
||||
BMIter eiter;
|
||||
BMEdge *e;
|
||||
@@ -2337,7 +2327,7 @@ static void bmesh_four_neighbor_average(float avg[3], float direction[3], BMVert
|
||||
}
|
||||
|
||||
/* In case vert has no Edge s. */
|
||||
if (tot_co > 0) {
|
||||
if (tot_co > 0.0f) {
|
||||
mul_v3_v3fl(avg, avg_co, 1.0f / tot_co);
|
||||
|
||||
/* Preserve volume. */
|
||||
@@ -2357,14 +2347,14 @@ static float bmesh_neighbor_average_mask(BMVert *v, const int cd_vert_mask_offse
|
||||
{
|
||||
BMIter liter;
|
||||
BMLoop *l;
|
||||
float avg = 0;
|
||||
int i, total = 0;
|
||||
float avg = 0.0f;
|
||||
int total = 0;
|
||||
|
||||
BM_ITER_ELEM (l, &liter, v, BM_LOOPS_OF_VERT) {
|
||||
/* Skip this vertex. */
|
||||
const BMVert *adj_v[2] = {l->prev->v, l->next->v};
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(adj_v); i++) {
|
||||
for (int i = 0; i < ARRAY_SIZE(adj_v); i++) {
|
||||
const BMVert *v_other = adj_v[i];
|
||||
const float *vmask = BM_ELEM_CD_GET_VOID_P(v_other, cd_vert_mask_offset);
|
||||
avg += (*vmask);
|
||||
@@ -3262,8 +3252,8 @@ static void do_crease_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod
|
||||
}
|
||||
|
||||
/* We always want crease to pinch or blob to relax even when draw is negative. */
|
||||
flippedbstrength = (bstrength < 0) ? -crease_correction * bstrength :
|
||||
crease_correction * bstrength;
|
||||
flippedbstrength = (bstrength < 0.0f) ? -crease_correction * bstrength :
|
||||
crease_correction * bstrength;
|
||||
|
||||
if (brush->sculpt_tool == SCULPT_TOOL_BLOB) {
|
||||
flippedbstrength *= -1.0f;
|
||||
@@ -4053,7 +4043,7 @@ static void pose_brush_init_task_cb_ex(void *__restrict userdata,
|
||||
{
|
||||
SculptVertexNeighborIter ni;
|
||||
float avg = 0.0f;
|
||||
int total = 0.0f;
|
||||
int total = 0;
|
||||
sculpt_vertex_neighbors_iter_begin(ss, vd.index, ni)
|
||||
{
|
||||
avg += data->pose_factor[ni.index];
|
||||
@@ -4372,7 +4362,7 @@ static void do_snake_hook_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int to
|
||||
|
||||
copy_v3_v3(grab_delta, ss->cache->grab_delta_symmetry);
|
||||
|
||||
if (bstrength < 0) {
|
||||
if (bstrength < 0.0f) {
|
||||
negate_v3(grab_delta);
|
||||
}
|
||||
|
||||
@@ -4558,7 +4548,7 @@ static void do_layer_brush_task_cb_ex(void *__restrict userdata,
|
||||
SculptOrigVertData orig_data;
|
||||
float *layer_disp;
|
||||
const float bstrength = ss->cache->bstrength;
|
||||
const float lim = (bstrength < 0) ? -data->brush->height : data->brush->height;
|
||||
const float lim = (bstrength < 0.0f) ? -data->brush->height : data->brush->height;
|
||||
/* XXX: layer brush needs conversion to proxy but its more complicated */
|
||||
/* proxy = BKE_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co; */
|
||||
|
||||
@@ -4725,15 +4715,15 @@ static void calc_sculpt_plane(
|
||||
break;
|
||||
|
||||
case SCULPT_DISP_DIR_X:
|
||||
ARRAY_SET_ITEMS(r_area_no, 1, 0, 0);
|
||||
ARRAY_SET_ITEMS(r_area_no, 1.0f, 0.0f, 0.0f);
|
||||
break;
|
||||
|
||||
case SCULPT_DISP_DIR_Y:
|
||||
ARRAY_SET_ITEMS(r_area_no, 0, 1, 0);
|
||||
ARRAY_SET_ITEMS(r_area_no, 0.0f, 1.0f, 0.0f);
|
||||
break;
|
||||
|
||||
case SCULPT_DISP_DIR_Z:
|
||||
ARRAY_SET_ITEMS(r_area_no, 0, 0, 1);
|
||||
ARRAY_SET_ITEMS(r_area_no, 0.0f, 0.0f, 1.0f);
|
||||
break;
|
||||
|
||||
case SCULPT_DISP_DIR_AREA:
|
||||
@@ -5318,13 +5308,13 @@ static void do_multiplane_scrape_brush(Sculpt *sd, Object *ob, PBVHNode **nodes,
|
||||
|
||||
/* Init brush local space matrix. */
|
||||
cross_v3_v3v3(mat[0], area_no, ss->cache->grab_delta_symmetry);
|
||||
mat[0][3] = 0;
|
||||
mat[0][3] = 0.0f;
|
||||
cross_v3_v3v3(mat[1], area_no, mat[0]);
|
||||
mat[1][3] = 0;
|
||||
mat[1][3] = 0.0f;
|
||||
copy_v3_v3(mat[2], area_no);
|
||||
mat[2][3] = 0;
|
||||
mat[2][3] = 0.0f;
|
||||
copy_v3_v3(mat[3], ss->cache->location);
|
||||
mat[3][3] = 1;
|
||||
mat[3][3] = 1.0f;
|
||||
normalize_m4(mat);
|
||||
invert_m4(mat);
|
||||
|
||||
@@ -5460,7 +5450,7 @@ static void do_clay_strips_brush_task_cb_ex(void *__restrict userdata,
|
||||
PBVHVertexIter vd;
|
||||
SculptBrushTest test;
|
||||
float(*proxy)[3];
|
||||
const bool flip = (ss->cache->bstrength < 0);
|
||||
const bool flip = (ss->cache->bstrength < 0.0f);
|
||||
const float bstrength = flip ? -ss->cache->bstrength : ss->cache->bstrength;
|
||||
|
||||
proxy = BKE_pbvh_node_add_proxy(ss->pbvh, data->nodes[n])->co;
|
||||
@@ -5508,7 +5498,7 @@ static void do_clay_strips_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int t
|
||||
SculptSession *ss = ob->sculpt;
|
||||
Brush *brush = BKE_paint_brush(&sd->paint);
|
||||
|
||||
const bool flip = (ss->cache->bstrength < 0);
|
||||
const bool flip = (ss->cache->bstrength < 0.0f);
|
||||
const float radius = flip ? -ss->cache->radius : ss->cache->radius;
|
||||
const float offset = get_offset(sd, ss);
|
||||
const float displace = radius * (0.25f + offset);
|
||||
@@ -5549,13 +5539,13 @@ static void do_clay_strips_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int t
|
||||
|
||||
/* Init brush local space matrix. */
|
||||
cross_v3_v3v3(mat[0], area_no, ss->cache->grab_delta_symmetry);
|
||||
mat[0][3] = 0;
|
||||
mat[0][3] = 0.0f;
|
||||
cross_v3_v3v3(mat[1], area_no, mat[0]);
|
||||
mat[1][3] = 0;
|
||||
mat[1][3] = 0.0f;
|
||||
copy_v3_v3(mat[2], area_no);
|
||||
mat[2][3] = 0;
|
||||
mat[2][3] = 0.0f;
|
||||
copy_v3_v3(mat[3], ss->cache->location);
|
||||
mat[3][3] = 1;
|
||||
mat[3][3] = 1.0f;
|
||||
normalize_m4(mat);
|
||||
|
||||
/* Scale brush local space matrix. */
|
||||
@@ -6107,8 +6097,12 @@ static void do_brush_action(Sculpt *sd, Object *ob, Brush *brush, UnifiedPaintSe
|
||||
if (!ELEM(brush->sculpt_tool, SCULPT_TOOL_SMOOTH, SCULPT_TOOL_MASK) &&
|
||||
brush->autosmooth_factor > 0) {
|
||||
if (brush->flag & BRUSH_INVERSE_SMOOTH_PRESSURE) {
|
||||
smooth(
|
||||
sd, ob, nodes, totnode, brush->autosmooth_factor * (1 - ss->cache->pressure), false);
|
||||
smooth(sd,
|
||||
ob,
|
||||
nodes,
|
||||
totnode,
|
||||
brush->autosmooth_factor * (1.0f - ss->cache->pressure),
|
||||
false);
|
||||
}
|
||||
else {
|
||||
smooth(sd, ob, nodes, totnode, brush->autosmooth_factor, false);
|
||||
@@ -6187,7 +6181,6 @@ static void sculpt_combine_proxies_task_cb(void *__restrict userdata,
|
||||
BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
|
||||
{
|
||||
float val[3];
|
||||
int p;
|
||||
|
||||
if (use_orco) {
|
||||
if (ss->bm) {
|
||||
@@ -6201,7 +6194,7 @@ static void sculpt_combine_proxies_task_cb(void *__restrict userdata,
|
||||
copy_v3_v3(val, vd.co);
|
||||
}
|
||||
|
||||
for (p = 0; p < proxy_count; p++) {
|
||||
for (int p = 0; p < proxy_count; p++) {
|
||||
add_v3_v3(val, proxies[p].co[vd.i]);
|
||||
}
|
||||
|
||||
@@ -6360,11 +6353,11 @@ void sculpt_cache_calc_brushdata_symm(StrokeCache *cache,
|
||||
#if 0
|
||||
if (sd->paint.symmetry_flags & PAINT_SYMMETRY_FEATHER) {
|
||||
float frac = 1.0f / max_overlap_count(sd);
|
||||
float reduce = (feather - frac) / (1 - frac);
|
||||
float reduce = (feather - frac) / (1.0f - frac);
|
||||
|
||||
printf("feather: %f frac: %f reduce: %f\n", feather, frac, reduce);
|
||||
|
||||
if (frac < 1) {
|
||||
if (frac < 1.0f) {
|
||||
mul_v3_fl(cache->grab_delta_symmetry, reduce);
|
||||
}
|
||||
}
|
||||
@@ -6405,7 +6398,6 @@ static void do_tiled(
|
||||
const float *bbMin = bb->vec[0];
|
||||
const float *bbMax = bb->vec[6];
|
||||
const float *step = sd->paint.tile_offset;
|
||||
int dim;
|
||||
|
||||
/* These are integer locations, for real location: multiply with step and add orgLoc.
|
||||
* So 0,0,0 is at orgLoc. */
|
||||
@@ -6417,7 +6409,7 @@ static void do_tiled(
|
||||
float orgLoc[3];
|
||||
copy_v3_v3(orgLoc, cache->location);
|
||||
|
||||
for (dim = 0; dim < 3; dim++) {
|
||||
for (int dim = 0; dim < 3; dim++) {
|
||||
if ((sd->paint.symmetry_flags & (PAINT_TILE_X << dim)) && step[dim] > 0) {
|
||||
start[dim] = (bbMin[dim] - orgLoc[dim] - radius) / step[dim];
|
||||
end[dim] = (bbMax[dim] - orgLoc[dim] + radius) / step[dim];
|
||||
@@ -6443,7 +6435,7 @@ static void do_tiled(
|
||||
|
||||
++cache->tile_pass;
|
||||
|
||||
for (dim = 0; dim < 3; dim++) {
|
||||
for (int dim = 0; dim < 3; dim++) {
|
||||
cache->location[dim] = cur[dim] * step[dim] + orgLoc[dim];
|
||||
cache->plane_offset[dim] = cur[dim] * step[dim];
|
||||
}
|
||||
@@ -6463,10 +6455,9 @@ static void do_radial_symmetry(Sculpt *sd,
|
||||
const float UNUSED(feather))
|
||||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
int i;
|
||||
|
||||
for (i = 1; i < sd->radial_symm[axis - 'X']; i++) {
|
||||
const float angle = 2 * M_PI * i / sd->radial_symm[axis - 'X'];
|
||||
for (int i = 1; i < sd->radial_symm[axis - 'X']; i++) {
|
||||
const float angle = 2.0f * M_PI * i / sd->radial_symm[axis - 'X'];
|
||||
ss->cache->radial_symmetry_pass = i;
|
||||
sculpt_cache_calc_brushdata_symm(ss->cache, symm, axis, angle);
|
||||
do_tiled(sd, ob, brush, ups, action);
|
||||
@@ -6496,7 +6487,6 @@ static void do_symmetrical_brush_actions(Sculpt *sd,
|
||||
SculptSession *ss = ob->sculpt;
|
||||
StrokeCache *cache = ss->cache;
|
||||
const char symm = sd->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL;
|
||||
int i;
|
||||
|
||||
float feather = calc_symmetry_feather(sd, ss->cache);
|
||||
|
||||
@@ -6505,7 +6495,7 @@ static void do_symmetrical_brush_actions(Sculpt *sd,
|
||||
|
||||
/* symm is a bit combination of XYZ -
|
||||
* 1 is mirror X; 2 is Y; 3 is XY; 4 is Z; 5 is XZ; 6 is YZ; 7 is XYZ */
|
||||
for (i = 0; i <= symm; i++) {
|
||||
for (int i = 0; i <= symm; i++) {
|
||||
if (i == 0 || (symm & i && (symm != 5 || i != 3) && (symm != 6 || (i != 3 && i != 5)))) {
|
||||
cache->mirror_symmetry_pass = i;
|
||||
cache->radial_symmetry_pass = 0;
|
||||
@@ -6642,7 +6632,6 @@ void sculpt_cache_free(StrokeCache *cache)
|
||||
static void sculpt_init_mirror_clipping(Object *ob, SculptSession *ss)
|
||||
{
|
||||
ModifierData *md;
|
||||
int i;
|
||||
|
||||
for (md = ob->modifiers.first; md; md = md->next) {
|
||||
if (md->type == eModifierType_Mirror && (md->mode & eModifierMode_Realtime)) {
|
||||
@@ -6650,7 +6639,7 @@ static void sculpt_init_mirror_clipping(Object *ob, SculptSession *ss)
|
||||
|
||||
if (mmd->flag & MOD_MIR_CLIPPING) {
|
||||
/* Check each axis for mirroring. */
|
||||
for (i = 0; i < 3; i++) {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (mmd->flag & (MOD_MIR_AXIS_X << i)) {
|
||||
/* Enable sculpt clipping. */
|
||||
ss->cache->flag |= CLIP_X << i;
|
||||
@@ -6680,7 +6669,6 @@ static void sculpt_update_cache_invariants(
|
||||
float mat[3][3];
|
||||
float viewDir[3] = {0.0f, 0.0f, 1.0f};
|
||||
float max_scale;
|
||||
int i;
|
||||
int mode;
|
||||
|
||||
ss->cache = cache;
|
||||
@@ -6691,7 +6679,7 @@ static void sculpt_update_cache_invariants(
|
||||
}
|
||||
else {
|
||||
max_scale = 0.0f;
|
||||
for (i = 0; i < 3; i++) {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
max_scale = max_ff(max_scale, fabsf(ob->scale[i]));
|
||||
}
|
||||
}
|
||||
@@ -6794,8 +6782,8 @@ static void sculpt_update_cache_invariants(
|
||||
copy_v3_v3(cache->true_gravity_direction, gravity_object->obmat[2]);
|
||||
}
|
||||
else {
|
||||
cache->true_gravity_direction[0] = cache->true_gravity_direction[1] = 0.0;
|
||||
cache->true_gravity_direction[2] = 1.0;
|
||||
cache->true_gravity_direction[0] = cache->true_gravity_direction[1] = 0.0f;
|
||||
cache->true_gravity_direction[2] = 1.0f;
|
||||
}
|
||||
|
||||
/* Transform to sculpted object space. */
|
||||
@@ -6815,7 +6803,7 @@ static void sculpt_update_cache_invariants(
|
||||
memcpy(ss->layer_co, ss->deform_cos, ss->totvert);
|
||||
}
|
||||
else {
|
||||
for (i = 0; i < ss->totvert; i++) {
|
||||
for (int i = 0; i < ss->totvert; i++) {
|
||||
copy_v3_v3(ss->layer_co[i], ss->mvert[i].co);
|
||||
}
|
||||
}
|
||||
@@ -6849,7 +6837,7 @@ static void sculpt_update_cache_invariants(
|
||||
}
|
||||
}
|
||||
|
||||
cache->first_time = 1;
|
||||
cache->first_time = true;
|
||||
|
||||
#define PIXEL_INPUT_THRESHHOLD 5
|
||||
if (brush->sculpt_tool == SCULPT_TOOL_ROTATE) {
|
||||
@@ -7163,7 +7151,7 @@ static void sculpt_raycast_cb(PBVHNode *node, void *data_v, float *tmin)
|
||||
&srd->depth,
|
||||
&srd->active_vertex_index,
|
||||
srd->face_normal)) {
|
||||
srd->hit = 1;
|
||||
srd->hit = true;
|
||||
*tmin = srd->depth;
|
||||
}
|
||||
}
|
||||
@@ -7196,7 +7184,7 @@ static void sculpt_find_nearest_to_ray_cb(PBVHNode *node, void *data_v, float *t
|
||||
srd->ray_normal,
|
||||
&srd->depth,
|
||||
&srd->dist_sq_to_ray)) {
|
||||
srd->hit = 1;
|
||||
srd->hit = true;
|
||||
*tmin = srd->dist_sq_to_ray;
|
||||
}
|
||||
}
|
||||
@@ -7208,7 +7196,7 @@ static void sculpt_raycast_detail_cb(PBVHNode *node, void *data_v, float *tmin)
|
||||
SculptDetailRaycastData *srd = data_v;
|
||||
if (BKE_pbvh_bmesh_node_raycast_detail(
|
||||
node, srd->ray_start, &srd->isect_precalc, &srd->depth, &srd->edge_length)) {
|
||||
srd->hit = 1;
|
||||
srd->hit = true;
|
||||
*tmin = srd->depth;
|
||||
}
|
||||
}
|
||||
@@ -7291,7 +7279,7 @@ bool sculpt_cursor_geometry_info_update(bContext *C,
|
||||
SculptRaycastData srd = {
|
||||
.original = original,
|
||||
.ss = ob->sculpt,
|
||||
.hit = 0,
|
||||
.hit = false,
|
||||
.ray_start = ray_start,
|
||||
.ray_normal = ray_normal,
|
||||
.depth = depth,
|
||||
@@ -7404,7 +7392,7 @@ bool sculpt_stroke_get_location(bContext *C, float out[3], const float mouse[2])
|
||||
srd.ss = ob->sculpt;
|
||||
srd.ray_start = ray_start;
|
||||
srd.ray_normal = ray_normal;
|
||||
srd.hit = 0;
|
||||
srd.hit = false;
|
||||
srd.depth = depth;
|
||||
srd.original = original;
|
||||
srd.face_normal = face_normal;
|
||||
@@ -7419,12 +7407,12 @@ bool sculpt_stroke_get_location(bContext *C, float out[3], const float mouse[2])
|
||||
}
|
||||
}
|
||||
|
||||
if (hit == false) {
|
||||
if (!hit) {
|
||||
if (ELEM(brush->falloff_shape, PAINT_FALLOFF_SHAPE_TUBE)) {
|
||||
SculptFindNearestToRayData srd = {
|
||||
.original = original,
|
||||
.ss = ob->sculpt,
|
||||
.hit = 0,
|
||||
.hit = false,
|
||||
.ray_start = ray_start,
|
||||
.ray_normal = ray_normal,
|
||||
.depth = FLT_MAX,
|
||||
@@ -7661,10 +7649,10 @@ static bool sculpt_stroke_test_start(bContext *C, struct wmOperator *op, const f
|
||||
|
||||
sculpt_undo_push_begin(sculpt_tool_name(sd));
|
||||
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8167,7 +8155,7 @@ static int sculpt_dynamic_topology_toggle_exec(bContext *C, wmOperator *UNUSED(o
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
SculptSession *ss = ob->sculpt;
|
||||
|
||||
WM_cursor_wait(1);
|
||||
WM_cursor_wait(true);
|
||||
|
||||
if (ss->bm) {
|
||||
sculpt_dynamic_topology_disable_with_undo(bmain, depsgraph, scene, ob);
|
||||
@@ -8176,7 +8164,7 @@ static int sculpt_dynamic_topology_toggle_exec(bContext *C, wmOperator *UNUSED(o
|
||||
sculpt_dynamic_topology_enable_with_undo(bmain, depsgraph, scene, ob);
|
||||
}
|
||||
|
||||
WM_cursor_wait(0);
|
||||
WM_cursor_wait(false);
|
||||
WM_main_add_notifier(NC_SCENE | ND_TOOLSETTINGS, NULL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
@@ -8734,7 +8722,7 @@ static int sculpt_detail_flood_fill_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
SculptSession *ss = ob->sculpt;
|
||||
float size;
|
||||
float bb_min[3], bb_max[3], center[3], dim[3];
|
||||
int i, totnodes;
|
||||
int totnodes;
|
||||
PBVHNode **nodes;
|
||||
|
||||
BKE_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &totnodes);
|
||||
@@ -8743,7 +8731,7 @@ static int sculpt_detail_flood_fill_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
for (i = 0; i < totnodes; i++) {
|
||||
for (int i = 0; i < totnodes; i++) {
|
||||
BKE_pbvh_node_mark_topology_update(nodes[i]);
|
||||
}
|
||||
/* Get the bounding box, it's center and size. */
|
||||
@@ -8762,7 +8750,7 @@ static int sculpt_detail_flood_fill_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
|
||||
while (BKE_pbvh_bmesh_update_topology(
|
||||
ss->pbvh, PBVH_Collapse | PBVH_Subdivide, center, NULL, size, false, false)) {
|
||||
for (i = 0; i < totnodes; i++) {
|
||||
for (int i = 0; i < totnodes; i++) {
|
||||
BKE_pbvh_node_mark_topology_update(nodes[i]);
|
||||
}
|
||||
}
|
||||
@@ -9180,7 +9168,7 @@ static void mesh_filter_task_cb(void *__restrict userdata,
|
||||
sculpt_orig_vert_data_update(&orig_data, &vd);
|
||||
float orig_co[3], val[3], avg[3], normal[3], disp[3], disp2[3], transform[3][3], final_pos[3];
|
||||
float fade = vd.mask ? *vd.mask : 0.0f;
|
||||
fade = 1 - fade;
|
||||
fade = 1.0f - fade;
|
||||
fade *= data->filter_strength;
|
||||
|
||||
if (fade == 0.0f) {
|
||||
@@ -9217,14 +9205,14 @@ static void mesh_filter_task_cb(void *__restrict userdata,
|
||||
break;
|
||||
case MESH_FILTER_SCALE:
|
||||
unit_m3(transform);
|
||||
scale_m3_fl(transform, 1 + fade);
|
||||
scale_m3_fl(transform, 1.0f + fade);
|
||||
copy_v3_v3(val, orig_co);
|
||||
mul_m3_v3(transform, val);
|
||||
sub_v3_v3v3(disp, val, orig_co);
|
||||
break;
|
||||
case MESH_FILTER_SPHERE:
|
||||
normalize_v3_v3(disp, orig_co);
|
||||
if (fade > 0) {
|
||||
if (fade > 0.0f) {
|
||||
mul_v3_v3fl(disp, disp, fade);
|
||||
}
|
||||
else {
|
||||
@@ -9232,11 +9220,11 @@ static void mesh_filter_task_cb(void *__restrict userdata,
|
||||
}
|
||||
|
||||
unit_m3(transform);
|
||||
if (fade > 0) {
|
||||
scale_m3_fl(transform, 1 - fade);
|
||||
if (fade > 0.0f) {
|
||||
scale_m3_fl(transform, 1.0f - fade);
|
||||
}
|
||||
else {
|
||||
scale_m3_fl(transform, 1 + fade);
|
||||
scale_m3_fl(transform, 1.0f + fade);
|
||||
}
|
||||
copy_v3_v3(val, orig_co);
|
||||
mul_m3_v3(transform, val);
|
||||
@@ -9482,7 +9470,7 @@ static void mask_filter_task_cb(void *__restrict userdata,
|
||||
else {
|
||||
*vd.mask -= 0.05f;
|
||||
}
|
||||
*vd.mask += val / 2;
|
||||
*vd.mask += val / 2.0f;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -9519,7 +9507,7 @@ static void mask_filter_task_cb(void *__restrict userdata,
|
||||
offset = gain * (-delta);
|
||||
}
|
||||
else {
|
||||
delta *= -1;
|
||||
delta *= -1.0f;
|
||||
offset = gain * (delta);
|
||||
}
|
||||
*vd.mask = gain * (*vd.mask) + offset;
|
||||
@@ -9681,7 +9669,7 @@ static float neighbor_dirty_mask(SculptSession *ss, PBVHVertexIter *vd)
|
||||
float angle = max_ff(saacosf(dot), 0.0f);
|
||||
return angle;
|
||||
}
|
||||
return 0;
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
typedef struct DirtyMaskRangeData {
|
||||
@@ -9732,7 +9720,7 @@ static void dirty_mask_apply_task_cb(void *__restrict userdata,
|
||||
|
||||
float range = max - min;
|
||||
if (range < 0.0001f) {
|
||||
range = 0;
|
||||
range = 0.0f;
|
||||
}
|
||||
else {
|
||||
range = 1.0f / range;
|
||||
@@ -9741,7 +9729,7 @@ static void dirty_mask_apply_task_cb(void *__restrict userdata,
|
||||
BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE)
|
||||
{
|
||||
float dirty_mask = neighbor_dirty_mask(ss, &vd);
|
||||
float mask = *vd.mask + (1 - ((dirty_mask - min) * range));
|
||||
float mask = *vd.mask + (1.0f - ((dirty_mask - min) * range));
|
||||
if (dirty_only) {
|
||||
mask = fminf(mask, 0.5f) * 2.0f;
|
||||
}
|
||||
@@ -10159,7 +10147,7 @@ static int sculpt_mask_expand_invoke(bContext *C, wmOperator *op, const wmEvent
|
||||
if (use_normals) {
|
||||
for (int repeat = 0; repeat < 2; repeat++) {
|
||||
for (int i = 0; i < vertex_count; i++) {
|
||||
float avg = 0;
|
||||
float avg = 0.0f;
|
||||
SculptVertexNeighborIter ni;
|
||||
sculpt_vertex_neighbors_iter_begin(ss, i, ni)
|
||||
{
|
||||
|
||||
@@ -167,7 +167,7 @@ static bool sculpt_undo_restore_coords(bContext *C, Depsgraph *depsgraph, Sculpt
|
||||
}
|
||||
else {
|
||||
/* Key has been removed -- skip this undo node. */
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -250,7 +250,7 @@ static bool sculpt_undo_restore_coords(bContext *C, Depsgraph *depsgraph, Sculpt
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool sculpt_undo_restore_hidden(bContext *C, SculptUndoNode *unode)
|
||||
@@ -259,12 +259,11 @@ static bool sculpt_undo_restore_hidden(bContext *C, SculptUndoNode *unode)
|
||||
Object *ob = OBACT(view_layer);
|
||||
SculptSession *ss = ob->sculpt;
|
||||
SubdivCCG *subdiv_ccg = ss->subdiv_ccg;
|
||||
int i;
|
||||
|
||||
if (unode->maxvert) {
|
||||
MVert *mvert = ss->mvert;
|
||||
|
||||
for (i = 0; i < unode->totvert; i++) {
|
||||
for (int i = 0; i < unode->totvert; i++) {
|
||||
MVert *v = &mvert[unode->index[i]];
|
||||
if ((BLI_BITMAP_TEST(unode->vert_hidden, i) != 0) != ((v->flag & ME_HIDE) != 0)) {
|
||||
BLI_BITMAP_FLIP(unode->vert_hidden, i);
|
||||
@@ -276,12 +275,12 @@ static bool sculpt_undo_restore_hidden(bContext *C, SculptUndoNode *unode)
|
||||
else if (unode->maxgrid && subdiv_ccg != NULL) {
|
||||
BLI_bitmap **grid_hidden = subdiv_ccg->grid_hidden;
|
||||
|
||||
for (i = 0; i < unode->totgrid; i++) {
|
||||
for (int i = 0; i < unode->totgrid; i++) {
|
||||
SWAP(BLI_bitmap *, unode->grid_hidden[i], grid_hidden[unode->grids[i]]);
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool sculpt_undo_restore_mask(bContext *C, SculptUndoNode *unode)
|
||||
@@ -292,7 +291,7 @@ static bool sculpt_undo_restore_mask(bContext *C, SculptUndoNode *unode)
|
||||
SubdivCCG *subdiv_ccg = ss->subdiv_ccg;
|
||||
MVert *mvert;
|
||||
float *vmask;
|
||||
int *index, i, j;
|
||||
int *index;
|
||||
|
||||
if (unode->maxvert) {
|
||||
/* Regular mesh restore. */
|
||||
@@ -301,7 +300,7 @@ static bool sculpt_undo_restore_mask(bContext *C, SculptUndoNode *unode)
|
||||
mvert = ss->mvert;
|
||||
vmask = ss->vmask;
|
||||
|
||||
for (i = 0; i < unode->totvert; i++) {
|
||||
for (int i = 0; i < unode->totvert; i++) {
|
||||
if (vmask[index[i]] != unode->mask[i]) {
|
||||
SWAP(float, vmask[index[i]], unode->mask[i]);
|
||||
mvert[index[i]].flag |= ME_VERT_PBVH_UPDATE;
|
||||
@@ -320,16 +319,16 @@ static bool sculpt_undo_restore_mask(bContext *C, SculptUndoNode *unode)
|
||||
BKE_subdiv_ccg_key_top_level(&key, subdiv_ccg);
|
||||
|
||||
mask = unode->mask;
|
||||
for (j = 0; j < unode->totgrid; j++) {
|
||||
for (int j = 0; j < unode->totgrid; j++) {
|
||||
grid = grids[unode->grids[j]];
|
||||
|
||||
for (i = 0; i < gridsize * gridsize; i++, mask++) {
|
||||
for (int i = 0; i < gridsize * gridsize; i++, mask++) {
|
||||
SWAP(float, *CCG_elem_offset_mask(&key, grid, i), *mask);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void sculpt_undo_bmesh_restore_generic_task_cb(
|
||||
|
||||
Reference in New Issue
Block a user