Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-03-28 07:47:33 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-03-28 07:47:33 +0400
commitc9f677d24d9600d9ba07f1b258c49455bc348554 (patch)
treeb9a0cc4941e42321dcab9acff4102bcbbd1ef895 /source
parent274e243a67285ce71ee3b29ce0ea1aeb7bc7429c (diff)
style cleanup: mainly whitespace around operators and indentation - paint/sculpt tools
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/sculpt_paint/paint_cursor.c152
-rw-r--r--source/blender/editors/sculpt_paint/paint_hide.c118
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c1912
-rw-r--r--source/blender/editors/sculpt_paint/paint_ops.c170
-rw-r--r--source/blender/editors/sculpt_paint/paint_stroke.c44
-rw-r--r--source/blender/editors/sculpt_paint/paint_undo.c62
-rw-r--r--source/blender/editors/sculpt_paint/paint_utils.c130
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.c112
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c951
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_undo.c212
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_uv.c105
11 files changed, 1986 insertions, 1982 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c
index be50b842914..5d4710accad 100644
--- a/source/blender/editors/sculpt_paint/paint_cursor.c
+++ b/source/blender/editors/sculpt_paint/paint_cursor.c
@@ -76,26 +76,26 @@ typedef struct Snapshot {
int curve_changed_timestamp;
} Snapshot;
-static int same_snap(Snapshot* snap, Brush* brush, ViewContext* vc)
+static int same_snap(Snapshot *snap, Brush *brush, ViewContext *vc)
{
- MTex* mtex = &brush->mtex;
+ MTex *mtex = &brush->mtex;
return (((mtex->tex) &&
- equals_v3v3(mtex->ofs, snap->ofs) &&
- equals_v3v3(mtex->size, snap->size) &&
- mtex->rot == snap->rot) &&
-
- /* make brush smaller shouldn't cause a resample */
- ((mtex->brush_map_mode == MTEX_MAP_MODE_FIXED &&
- (brush_size(vc->scene, brush) <= snap->brush_size)) ||
- (brush_size(vc->scene, brush) == snap->brush_size)) &&
-
- (mtex->brush_map_mode == snap->brush_map_mode) &&
- (vc->ar->winx == snap->winx) &&
- (vc->ar->winy == snap->winy));
+ equals_v3v3(mtex->ofs, snap->ofs) &&
+ equals_v3v3(mtex->size, snap->size) &&
+ mtex->rot == snap->rot) &&
+
+ /* make brush smaller shouldn't cause a resample */
+ ((mtex->brush_map_mode == MTEX_MAP_MODE_FIXED &&
+ (brush_size(vc->scene, brush) <= snap->brush_size)) ||
+ (brush_size(vc->scene, brush) == snap->brush_size)) &&
+
+ (mtex->brush_map_mode == snap->brush_map_mode) &&
+ (vc->ar->winx == snap->winx) &&
+ (vc->ar->winy == snap->winy));
}
-static void make_snap(Snapshot* snap, Brush* brush, ViewContext* vc)
+static void make_snap(Snapshot *snap, Brush *brush, ViewContext *vc)
{
if (brush->mtex.tex) {
snap->brush_map_mode = brush->mtex.brush_map_mode;
@@ -105,8 +105,8 @@ static void make_snap(Snapshot* snap, Brush* brush, ViewContext* vc)
}
else {
snap->brush_map_mode = -1;
- snap->ofs[0]= snap->ofs[1]= snap->ofs[2]= -1;
- snap->size[0]= snap->size[1]= snap->size[2]= -1;
+ snap->ofs[0] = snap->ofs[1] = snap->ofs[2] = -1;
+ snap->size[0] = snap->size[1] = snap->size[2] = -1;
snap->rot = -1;
}
@@ -115,7 +115,7 @@ static void make_snap(Snapshot* snap, Brush* brush, ViewContext* vc)
snap->winy = vc->ar->winy;
}
-static int load_tex(Sculpt *sd, Brush* br, ViewContext* vc)
+static int load_tex(Sculpt *sd, Brush *br, ViewContext *vc)
{
static GLuint overlay_texture = 0;
static int init = 0;
@@ -124,7 +124,7 @@ static int load_tex(Sculpt *sd, Brush* br, ViewContext* vc)
static Snapshot snap;
static int old_size = -1;
- GLubyte* buffer = NULL;
+ GLubyte *buffer = NULL;
int size;
int j;
@@ -137,13 +137,13 @@ static int load_tex(Sculpt *sd, Brush* br, ViewContext* vc)
if (br->mtex.brush_map_mode == MTEX_MAP_MODE_TILED && !br->mtex.tex) return 0;
refresh =
- !overlay_texture ||
- (br->mtex.tex &&
- (!br->mtex.tex->preview ||
- br->mtex.tex->preview->changed_timestamp[0] != tex_changed_timestamp)) ||
- !br->curve ||
- br->curve->changed_timestamp != curve_changed_timestamp ||
- !same_snap(&snap, br, vc);
+ !overlay_texture ||
+ (br->mtex.tex &&
+ (!br->mtex.tex->preview ||
+ br->mtex.tex->preview->changed_timestamp[0] != tex_changed_timestamp)) ||
+ !br->curve ||
+ br->curve->changed_timestamp != curve_changed_timestamp ||
+ !same_snap(&snap, br, vc);
if (refresh) {
if (br->mtex.tex && br->mtex.tex->preview)
@@ -161,7 +161,7 @@ static int load_tex(Sculpt *sd, Brush* br, ViewContext* vc)
for (s >>= 1; s > 0; s >>= 1)
r++;
- size = (1<<r);
+ size = (1 << r);
if (size < 256)
size = 256;
@@ -183,26 +183,26 @@ static int load_tex(Sculpt *sd, Brush* br, ViewContext* vc)
old_size = size;
}
- buffer = MEM_mallocN(sizeof(GLubyte)*size*size, "load_tex");
+ buffer = MEM_mallocN(sizeof(GLubyte) * size * size, "load_tex");
#pragma omp parallel for schedule(static) if (sd->flags & SCULPT_USE_OPENMP)
- for (j= 0; j < size; j++) {
+ for (j = 0; j < size; j++) {
int i;
float y;
float len;
- for (i= 0; i < size; i++) {
+ for (i = 0; i < size; i++) {
// largely duplicated from tex_strength
const float rotation = -br->mtex.rot;
float radius = brush_size(vc->scene, br);
- int index = j*size + i;
+ int index = j * size + i;
float x;
float avg;
- x = (float)i/size;
- y = (float)j/size;
+ x = (float)i / size;
+ y = (float)j / size;
x -= 0.5f;
y -= 0.5f;
@@ -216,7 +216,7 @@ static int load_tex(Sculpt *sd, Brush* br, ViewContext* vc)
y *= 2;
}
- len = sqrtf(x*x + y*y);
+ len = sqrtf(x * x + y * y);
if ((br->mtex.brush_map_mode == MTEX_MAP_MODE_TILED) || len <= 1) {
/* it is probably worth optimizing for those cases where
@@ -240,9 +240,9 @@ static int load_tex(Sculpt *sd, Brush* br, ViewContext* vc)
avg += br->texture_sample_bias;
if (br->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED)
- avg *= brush_curve_strength(br, len, 1); /* Falloff curve */
+ avg *= brush_curve_strength(br, len, 1); /* Falloff curve */
- buffer[index] = 255 - (GLubyte)(255*avg);
+ buffer[index] = 255 - (GLubyte)(255 * avg);
}
else {
buffer[index] = 0;
@@ -254,7 +254,7 @@ static int load_tex(Sculpt *sd, Brush* br, ViewContext* vc)
glGenTextures(1, &overlay_texture);
}
else {
- size= old_size;
+ size = old_size;
}
glBindTexture(GL_TEXTURE_2D, overlay_texture);
@@ -287,8 +287,8 @@ static int load_tex(Sculpt *sd, Brush* br, ViewContext* vc)
}
static int project_brush_radius(ViewContext *vc,
- float radius,
- const float location[3])
+ float radius,
+ const float location[3])
{
float view[3], nonortho[3], ortho[3], offset[3], p1[2], p2[2];
@@ -328,9 +328,9 @@ static int project_brush_radius(ViewContext *vc,
return len_v2v2(p1, p2);
}
-static int sculpt_get_brush_geometry(bContext* C, ViewContext *vc,
- int x, int y, int* pixel_radius,
- float location[3])
+static int sculpt_get_brush_geometry(bContext *C, ViewContext *vc,
+ int x, int y, int *pixel_radius,
+ float location[3])
{
Scene *scene = CTX_data_scene(C);
Paint *paint = paint_get_active(scene);
@@ -342,11 +342,11 @@ static int sculpt_get_brush_geometry(bContext* C, ViewContext *vc,
window[1] = y + vc->ar->winrct.ymin;
if (vc->obact->sculpt && vc->obact->sculpt->pbvh &&
- sculpt_stroke_get_location(C, location, window)) {
+ sculpt_stroke_get_location(C, location, window)) {
*pixel_radius =
- project_brush_radius(vc,
- brush_unprojected_radius(scene, brush),
- location);
+ project_brush_radius(vc,
+ brush_unprojected_radius(scene, brush),
+ location);
if (*pixel_radius == 0)
*pixel_radius = brush_size(scene, brush);
@@ -356,8 +356,8 @@ static int sculpt_get_brush_geometry(bContext* C, ViewContext *vc,
hit = 1;
}
else {
- Sculpt* sd = CTX_data_tool_settings(C)->sculpt;
- Brush* brush = paint_brush(&sd->paint);
+ Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
+ Brush *brush = paint_brush(&sd->paint);
*pixel_radius = brush_size(scene, brush);
hit = 0;
@@ -370,26 +370,26 @@ static int sculpt_get_brush_geometry(bContext* C, ViewContext *vc,
* have on brush strength */
/* TODO: sculpt only for now */
static void paint_draw_alpha_overlay(Sculpt *sd, Brush *brush,
- ViewContext *vc, int x, int y)
+ ViewContext *vc, int x, int y)
{
rctf quad;
/* check for overlay mode */
if (!(brush->flag & BRUSH_TEXTURE_OVERLAY) ||
- !(ELEM(brush->mtex.brush_map_mode, MTEX_MAP_MODE_FIXED, MTEX_MAP_MODE_TILED)))
+ !(ELEM(brush->mtex.brush_map_mode, MTEX_MAP_MODE_FIXED, MTEX_MAP_MODE_TILED)))
return;
/* save lots of GL state
* TODO: check on whether all of these are needed? */
- glPushAttrib(GL_COLOR_BUFFER_BIT|
- GL_CURRENT_BIT|
- GL_DEPTH_BUFFER_BIT|
- GL_ENABLE_BIT|
- GL_LINE_BIT|
- GL_POLYGON_BIT|
- GL_STENCIL_BUFFER_BIT|
- GL_TRANSFORM_BIT|
- GL_VIEWPORT_BIT|
+ glPushAttrib(GL_COLOR_BUFFER_BIT |
+ GL_CURRENT_BIT |
+ GL_DEPTH_BUFFER_BIT |
+ GL_ENABLE_BIT |
+ GL_LINE_BIT |
+ GL_POLYGON_BIT |
+ GL_STENCIL_BUFFER_BIT |
+ GL_TRANSFORM_BIT |
+ GL_VIEWPORT_BIT |
GL_TEXTURE_BIT);
if (load_tex(sd, brush, vc)) {
@@ -408,26 +408,26 @@ static void paint_draw_alpha_overlay(Sculpt *sd, Brush *brush,
glTranslatef(0.5, 0.5, 0);
glRotatef((double)RAD2DEGF((brush->flag & BRUSH_RAKE) ?
sd->last_angle : sd->special_rotation),
- 0.0, 0.0, 1.0);
+ 0.0, 0.0, 1.0);
glTranslatef(-0.5f, -0.5f, 0);
/* scale based on tablet pressure */
if (sd->draw_pressure && brush_use_size_pressure(vc->scene, brush)) {
glTranslatef(0.5f, 0.5f, 0);
- glScalef(1.0f/sd->pressure_value, 1.0f/sd->pressure_value, 1);
+ glScalef(1.0f / sd->pressure_value, 1.0f / sd->pressure_value, 1);
glTranslatef(-0.5f, -0.5f, 0);
}
if (sd->draw_anchored) {
const float *aim = sd->anchored_initial_mouse;
const rcti *win = &vc->ar->winrct;
- quad.xmin = aim[0]-sd->anchored_size - win->xmin;
- quad.ymin = aim[1]-sd->anchored_size - win->ymin;
- quad.xmax = aim[0]+sd->anchored_size - win->xmin;
- quad.ymax = aim[1]+sd->anchored_size - win->ymin;
+ quad.xmin = aim[0] - sd->anchored_size - win->xmin;
+ quad.ymin = aim[1] - sd->anchored_size - win->ymin;
+ quad.xmax = aim[0] + sd->anchored_size - win->xmin;
+ quad.ymax = aim[1] + sd->anchored_size - win->ymin;
}
else {
- const int radius= brush_size(vc->scene, brush);
+ const int radius = brush_size(vc->scene, brush);
quad.xmin = x - radius;
quad.ymin = y - radius;
quad.xmax = x + radius;
@@ -468,7 +468,7 @@ static void paint_draw_alpha_overlay(Sculpt *sd, Brush *brush,
/* Special actions taken when paint cursor goes over mesh */
/* TODO: sculpt only for now */
static void paint_cursor_on_hit(Sculpt *sd, Brush *brush, ViewContext *vc,
- const float location[3])
+ const float location[3])
{
float unprojected_radius, projected_radius;
@@ -486,7 +486,7 @@ static void paint_cursor_on_hit(Sculpt *sd, Brush *brush, ViewContext *vc,
/* convert brush radius from 2D to 3D */
unprojected_radius = paint_calc_object_space_radius(vc, location,
- projected_radius);
+ projected_radius);
/* scale 3D brush radius by pressure */
if (sd->draw_pressure && brush_use_size_pressure(vc->scene, brush))
@@ -541,11 +541,11 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
const float dx = sd->last_x - x;
const float dy = sd->last_y - y;
- if (dx*dx + dy*dy >= r*r) {
+ if (dx * dx + dy * dy >= r * r) {
sd->last_angle = atan2(dx, dy);
- sd->last_x = u*sd->last_x + v*x;
- sd->last_y = u*sd->last_y + v*y;
+ sd->last_x = u * sd->last_x + v * x;
+ sd->last_y = u * sd->last_y + v * y;
}
}
@@ -562,10 +562,10 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
/* TODO: no way currently to know state of pen flip or
* invert key modifier without starting a stroke */
if ((!(brush->flag & BRUSH_INVERTED) ^
- !(brush->flag & BRUSH_DIR_IN)) &&
- ELEM5(brush->sculpt_tool, SCULPT_TOOL_DRAW,
- SCULPT_TOOL_INFLATE, SCULPT_TOOL_CLAY,
- SCULPT_TOOL_PINCH, SCULPT_TOOL_CREASE))
+ !(brush->flag & BRUSH_DIR_IN)) &&
+ ELEM5(brush->sculpt_tool, SCULPT_TOOL_DRAW,
+ SCULPT_TOOL_INFLATE, SCULPT_TOOL_CLAY,
+ SCULPT_TOOL_PINCH, SCULPT_TOOL_CREASE))
outline_col = brush->sub_col;
/* only do if brush is over the mesh */
@@ -588,7 +588,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
/* draw brush outline */
glTranslatef(translation[0], translation[1], 0);
- glutil_draw_lined_arc(0.0, M_PI*2.0, final_radius, 40);
+ glutil_draw_lined_arc(0.0, M_PI * 2.0, final_radius, 40);
glTranslatef(-translation[0], -translation[1], 0);
/* restore GL state */
diff --git a/source/blender/editors/sculpt_paint/paint_hide.c b/source/blender/editors/sculpt_paint/paint_hide.c
index fcf7d2eba68..a3acce33683 100644
--- a/source/blender/editors/sculpt_paint/paint_hide.c
+++ b/source/blender/editors/sculpt_paint/paint_hide.c
@@ -84,24 +84,24 @@ static int planes_contain_v3(float (*planes)[4], int totplane, const float p[3])
/* return true if the element should be hidden/shown */
static int is_effected(PartialVisArea area,
- float planes[4][4],
- const float co[3])
+ float planes[4][4],
+ const float co[3])
{
if (area == PARTIALVIS_ALL)
return 1;
else {
int inside = planes_contain_v3(planes, 4, co);
return ((inside && area == PARTIALVIS_INSIDE) ||
- (!inside && area == PARTIALVIS_OUTSIDE));
+ (!inside && area == PARTIALVIS_OUTSIDE));
}
}
static void partialvis_update_mesh(Object *ob,
- PBVH *pbvh,
- PBVHNode *node,
- PartialVisAction action,
- PartialVisArea area,
- float planes[4][4])
+ PBVH *pbvh,
+ PBVHNode *node,
+ PartialVisAction action,
+ PartialVisArea area,
+ float planes[4][4])
{
MVert *mvert;
int *vert_indices;
@@ -137,11 +137,11 @@ static void partialvis_update_mesh(Object *ob,
/* Hide or show elements in multires grids with a special GridFlags
customdata layer. */
static void partialvis_update_grids(Object *ob,
- PBVH *pbvh,
- PBVHNode *node,
- PartialVisAction action,
- PartialVisArea area,
- float planes[4][4])
+ PBVH *pbvh,
+ PBVHNode *node,
+ PartialVisAction action,
+ PartialVisArea area,
+ float planes[4][4])
{
DMGridData **grids;
BLI_bitmap *grid_hidden;
@@ -150,8 +150,8 @@ static void partialvis_update_grids(Object *ob,
/* get PBVH data */
BLI_pbvh_node_get_grids(pbvh, node,
- &grid_indices, &totgrid, NULL, &gridsize,
- &grids, NULL);
+ &grid_indices, &totgrid, NULL, &gridsize,
+ &grids, NULL);
grid_hidden = BLI_pbvh_grid_hidden(pbvh);
sculpt_undo_push_node(ob, node, SCULPT_UNDO_HIDDEN);
@@ -163,15 +163,15 @@ static void partialvis_update_grids(Object *ob,
BLI_bitmap gh = grid_hidden[g];
if (!gh) {
- switch(action) {
- case PARTIALVIS_HIDE:
- /* create grid flags data */
- gh = grid_hidden[g] = BLI_BITMAP_NEW(gridsize * gridsize,
- "partialvis_update_grids");
- break;
- case PARTIALVIS_SHOW:
- /* entire grid is visible, nothing to show */
- continue;
+ switch (action) {
+ case PARTIALVIS_HIDE:
+ /* create grid flags data */
+ gh = grid_hidden[g] = BLI_BITMAP_NEW(gridsize * gridsize,
+ "partialvis_update_grids");
+ break;
+ case PARTIALVIS_SHOW:
+ /* entire grid is visible, nothing to show */
+ continue;
}
}
else if (action == PARTIALVIS_SHOW && area == PARTIALVIS_ALL) {
@@ -192,7 +192,7 @@ static void partialvis_update_grids(Object *ob,
if (is_effected(area, planes, co)) {
/* set or clear the hide flag */
BLI_BITMAP_MODIFY(gh, y * gridsize + x,
- action == PARTIALVIS_HIDE);
+ action == PARTIALVIS_HIDE);
any_changed = 1;
}
@@ -230,12 +230,12 @@ static void rect_from_props(rcti *rect, PointerRNA *ptr)
}
static void clip_planes_from_rect(bContext *C,
- float clip_planes[4][4],
- const rcti *rect)
+ float clip_planes[4][4],
+ const rcti *rect)
{
ViewContext vc;
BoundBox bb;
- bglMats mats= {{0}};
+ bglMats mats = {{0}};
view3d_operator_needs_opengl(C);
view3d_set_viewcontext(C, &vc);
@@ -249,23 +249,23 @@ static void clip_planes_from_rect(bContext *C,
that lie at least partially outside the volume. If showing all, get
all nodes. */
static void get_pbvh_nodes(PBVH *pbvh,
- PBVHNode ***nodes,
- int *totnode,
- float clip_planes[4][4],
- PartialVisArea mode)
+ PBVHNode ***nodes,
+ int *totnode,
+ float clip_planes[4][4],
+ PartialVisArea mode)
{
BLI_pbvh_SearchCallback cb;
/* select search callback */
- switch(mode) {
- case PARTIALVIS_INSIDE:
- cb = BLI_pbvh_node_planes_contain_AABB;
- break;
- case PARTIALVIS_OUTSIDE:
- cb = BLI_pbvh_node_planes_exclude_AABB;
- break;
- case PARTIALVIS_ALL:
- cb = NULL;
+ switch (mode) {
+ case PARTIALVIS_INSIDE:
+ cb = BLI_pbvh_node_planes_contain_AABB;
+ break;
+ case PARTIALVIS_OUTSIDE:
+ cb = BLI_pbvh_node_planes_exclude_AABB;
+ break;
+ case PARTIALVIS_ALL:
+ cb = NULL;
}
BLI_pbvh_search_gather(pbvh, cb, clip_planes, nodes, totnode);
@@ -301,23 +301,23 @@ static int hide_show_exec(bContext *C, wmOperator *op)
pbvh_type = BLI_pbvh_type(pbvh);
/* start undo */
- switch(action) {
- case PARTIALVIS_HIDE:
- sculpt_undo_push_begin("Hide area");
- break;
- case PARTIALVIS_SHOW:
- sculpt_undo_push_begin("Show area");
- break;
+ switch (action) {
+ case PARTIALVIS_HIDE:
+ sculpt_undo_push_begin("Hide area");
+ break;
+ case PARTIALVIS_SHOW:
+ sculpt_undo_push_begin("Show area");
+ break;
}
for (i = 0; i < totnode; i++) {
- switch(pbvh_type) {
- case PBVH_FACES:
- partialvis_update_mesh(ob, pbvh, nodes[i], action, area, clip_planes);
- break;
- case PBVH_GRIDS:
- partialvis_update_grids(ob, pbvh, nodes[i], action, area, clip_planes);
- break;
+ switch (pbvh_type) {
+ case PBVH_FACES:
+ partialvis_update_mesh(ob, pbvh, nodes[i], action, area, clip_planes);
+ break;
+ case PBVH_GRIDS:
+ partialvis_update_grids(ob, pbvh, nodes[i], action, area, clip_planes);
+ break;
}
}
@@ -331,8 +331,8 @@ static int hide_show_exec(bContext *C, wmOperator *op)
sculpt but it looks wrong when entering editmode otherwise) */
if (pbvh_type == PBVH_FACES) {
mesh_flush_hidden_from_verts(me->mvert, me->mloop,
- me->medge, me->totedge,
- me->mpoly, me->totpoly);
+ me->medge, me->totedge,
+ me->mpoly, me->totpoly);
}
ED_region_tag_redraw(ar);
@@ -381,9 +381,9 @@ void PAINT_OT_hide_show(struct wmOperatorType *ot)
/* rna */
RNA_def_enum(ot->srna, "action", action_items, PARTIALVIS_HIDE,
- "Action", "Whether to hide or show vertices");
+ "Action", "Whether to hide or show vertices");
RNA_def_enum(ot->srna, "area", area_items, PARTIALVIS_INSIDE,
- "Area", "Which vertices to hide or show");
+ "Area", "Which vertices to hide or show");
RNA_def_int(ot->srna, "xmin", 0, INT_MIN, INT_MAX, "X Min", "", INT_MIN, INT_MAX);
RNA_def_int(ot->srna, "xmax", 0, INT_MIN, INT_MAX, "X Max", "", INT_MIN, INT_MAX);
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index f761be741e9..f553084cfd9 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -111,7 +111,7 @@
/* Defines and Structs */
-#define IMAPAINT_CHAR_TO_FLOAT(c) ((c)/255.0f)
+#define IMAPAINT_CHAR_TO_FLOAT(c) ((c) / 255.0f)
#define IMAPAINT_FLOAT_RGB_TO_CHAR(c, f) { \
(c)[0]= FTOCHAR((f)[0]); \
@@ -138,9 +138,9 @@
#define IMAPAINT_FLOAT_RGB_COPY(a, b) copy_v3_v3(a, b)
-#define IMAPAINT_TILE_BITS 6
-#define IMAPAINT_TILE_SIZE (1 << IMAPAINT_TILE_BITS)
-#define IMAPAINT_TILE_NUMBER(size) (((size)+IMAPAINT_TILE_SIZE-1) >> IMAPAINT_TILE_BITS)
+#define IMAPAINT_TILE_BITS 6
+#define IMAPAINT_TILE_SIZE (1 << IMAPAINT_TILE_BITS)
+#define IMAPAINT_TILE_NUMBER(size) (((size) + IMAPAINT_TILE_SIZE - 1) >> IMAPAINT_TILE_BITS)
static void imapaint_image_update(SpaceImage *sima, Image *image, ImBuf *ibuf, short texpaint);
@@ -167,11 +167,11 @@ typedef struct ImagePaintState {
int do_facesel;
DerivedMesh *dm;
- int dm_totface;
- int dm_release;
+ int dm_totface;
+ int dm_release;
- MFace *dm_mface;
- MTFace *dm_mtface;
+ MFace *dm_mface;
+ MTFace *dm_mtface;
} ImagePaintState;
typedef struct ImagePaintPartialRedraw {
@@ -209,31 +209,31 @@ typedef struct ImagePaintRegion {
/* projectFaceSeamFlags options */
//#define PROJ_FACE_IGNORE (1<<0) /* When the face is hidden, backfacing or occluded */
//#define PROJ_FACE_INIT (1<<1) /* When we have initialized the faces data */
-#define PROJ_FACE_SEAM1 (1<<0) /* If this face has a seam on any of its edges */
-#define PROJ_FACE_SEAM2 (1<<1)
-#define PROJ_FACE_SEAM3 (1<<2)
-#define PROJ_FACE_SEAM4 (1<<3)
+#define PROJ_FACE_SEAM1 (1 << 0) /* If this face has a seam on any of its edges */
+#define PROJ_FACE_SEAM2 (1 << 1)
+#define PROJ_FACE_SEAM3 (1 << 2)
+#define PROJ_FACE_SEAM4 (1 << 3)
-#define PROJ_FACE_NOSEAM1 (1<<4)
-#define PROJ_FACE_NOSEAM2 (1<<5)
-#define PROJ_FACE_NOSEAM3 (1<<6)
-#define PROJ_FACE_NOSEAM4 (1<<7)
+#define PROJ_FACE_NOSEAM1 (1 << 4)
+#define PROJ_FACE_NOSEAM2 (1 << 5)
+#define PROJ_FACE_NOSEAM3 (1 << 6)
+#define PROJ_FACE_NOSEAM4 (1 << 7)
-#define PROJ_SRC_VIEW 1
-#define PROJ_SRC_IMAGE_CAM 2
-#define PROJ_SRC_IMAGE_VIEW 3
+#define PROJ_SRC_VIEW 1
+#define PROJ_SRC_IMAGE_CAM 2
+#define PROJ_SRC_IMAGE_VIEW 3
#define PROJ_VIEW_DATA_ID "view_data"
-#define PROJ_VIEW_DATA_SIZE (4*4 + 4*4 + 3) /* viewmat + winmat + clipsta + clipend + is_ortho */
+#define PROJ_VIEW_DATA_SIZE (4 * 4 + 4 * 4 + 3) /* viewmat + winmat + clipsta + clipend + is_ortho */
/* a slightly scaled down face is used to get fake 3D location for edge pixels in the seams
* as this number approaches 1.0f the likelihood increases of float precision errors where
* it is occluded by an adjacent face */
-#define PROJ_FACE_SCALE_SEAM 0.99f
+#define PROJ_FACE_SCALE_SEAM 0.99f
-#define PROJ_BUCKET_NULL 0
-#define PROJ_BUCKET_INIT (1<<0)
+#define PROJ_BUCKET_NULL 0
+#define PROJ_BUCKET_INIT (1 << 0)
// #define PROJ_BUCKET_CLONE_INIT (1<<1)
/* used for testing doubles, if a point is on a line etc */
@@ -269,67 +269,67 @@ typedef struct ProjPaintState {
/* end similarities with ImagePaintState */
DerivedMesh *dm;
- int dm_totface;
- int dm_totvert;
- int dm_release;
-
- MVert *dm_mvert;
- MFace *dm_mface;
- MTFace *dm_mtface;
- MTFace *dm_mtface_clone; /* other UV map, use for cloning between layers */
- MTFace *dm_mtface_stencil;
+ int dm_totface;
+ int dm_totvert;
+ int dm_release;
+
+ MVert *dm_mvert;
+ MFace *dm_mface;
+ MTFace *dm_mtface;
+ MTFace *dm_mtface_clone; /* other UV map, use for cloning between layers */
+ MTFace *dm_mtface_stencil;
/* projection painting only */
- MemArena *arena_mt[BLENDER_MAX_THREADS];/* for multithreading, the first item is sometimes used for non threaded cases too */
- LinkNode **bucketRect; /* screen sized 2D array, each pixel has a linked list of ProjPixel's */
- LinkNode **bucketFaces; /* bucketRect aligned array linkList of faces overlapping each bucket */
- unsigned char *bucketFlags; /* store if the bucks have been initialized */
+ MemArena *arena_mt[BLENDER_MAX_THREADS]; /* for multithreading, the first item is sometimes used for non threaded cases too */
+ LinkNode **bucketRect; /* screen sized 2D array, each pixel has a linked list of ProjPixel's */
+ LinkNode **bucketFaces; /* bucketRect aligned array linkList of faces overlapping each bucket */
+ unsigned char *bucketFlags; /* store if the bucks have been initialized */
#ifndef PROJ_DEBUG_NOSEAMBLEED
- char *faceSeamFlags; /* store info about faces, if they are initialized etc*/
- float (*faceSeamUVs)[4][2]; /* expanded UVs for faces to use as seams */
- LinkNode **vertFaces; /* Only needed for when seam_bleed_px is enabled, use to find UV seams */
+ char *faceSeamFlags; /* store info about faces, if they are initialized etc*/
+ float (*faceSeamUVs)[4][2]; /* expanded UVs for faces to use as seams */
+ LinkNode **vertFaces; /* Only needed for when seam_bleed_px is enabled, use to find UV seams */
#endif
- char *vertFlags; /* store options per vert, now only store if the vert is pointing away from the view */
- int buckets_x; /* The size of the bucket grid, the grid span's screenMin/screenMax so you can paint outsize the screen or with 2 brushes at once */
+ char *vertFlags; /* store options per vert, now only store if the vert is pointing away from the view */
+ int buckets_x; /* The size of the bucket grid, the grid span's screenMin/screenMax so you can paint outsize the screen or with 2 brushes at once */
int buckets_y;
ProjPaintImage *projImages;
- int image_tot; /* size of projectImages array */
+ int image_tot; /* size of projectImages array */
- float (*screenCoords)[4]; /* verts projected into floating point screen space */
+ float (*screenCoords)[4]; /* verts projected into floating point screen space */
- float screenMin[2]; /* 2D bounds for mesh verts on the screen's plane (screenspace) */
+ float screenMin[2]; /* 2D bounds for mesh verts on the screen's plane (screenspace) */
float screenMax[2];
- float screen_width; /* Calculated from screenMin & screenMax */
+ float screen_width; /* Calculated from screenMin & screenMax */
float screen_height;
- int winx, winy; /* from the carea or from the projection render */
+ int winx, winy; /* from the carea or from the projection render */
/* options for projection painting */
int do_layer_clone;
int do_layer_stencil;
int do_layer_stencil_inv;
- short do_occlude; /* Use raytraced occlusion? - ortherwise will paint right through to the back*/
- short do_backfacecull; /* ignore faces with normals pointing away, skips a lot of raycasts if your normals are correctly flipped */
- short do_mask_normal; /* mask out pixels based on their normals */
+ short do_occlude; /* Use raytraced occlusion? - ortherwise will paint right through to the back*/
+ short do_backfacecull; /* ignore faces with normals pointing away, skips a lot of raycasts if your normals are correctly flipped */
+ short do_mask_normal; /* mask out pixels based on their normals */
short do_new_shading_nodes; /* cache scene_use_new_shading_nodes value */
- float normal_angle; /* what angle to mask at*/
+ float normal_angle; /* what angle to mask at*/
float normal_angle_inner;
- float normal_angle_range; /* difference between normal_angle and normal_angle_inner, for easy access */
+ float normal_angle_range; /* difference between normal_angle and normal_angle_inner, for easy access */
short is_ortho;
- short is_airbrush; /* only to avoid using (ps.brush->flag & BRUSH_AIRBRUSH) */
- short is_texbrush; /* only to avoid running */
+ short is_airbrush; /* only to avoid using (ps.brush->flag & BRUSH_AIRBRUSH) */
+ short is_texbrush; /* only to avoid running */
#ifndef PROJ_DEBUG_NOSEAMBLEED
float seam_bleed_px;
#endif
/* clone vars */
float cloneOffset[2];
- float projectMat[4][4]; /* Projection matrix, use for getting screen coords */
- float viewDir[3]; /* View vector, use for do_backfacecull and for ray casting with an ortho viewport */
- float viewPos[3]; /* View location in object relative 3D space, so can compare to verts */
+ float projectMat[4][4]; /* Projection matrix, use for getting screen coords */
+ float viewDir[3]; /* View vector, use for do_backfacecull and for ray casting with an ortho viewport */
+ float viewPos[3]; /* View location in object relative 3D space, so can compare to verts */
float clipsta, clipend;
/* reproject vars */
@@ -344,15 +344,13 @@ typedef struct ProjPaintState {
int context_bucket_x, context_bucket_y; /* must lock threads while accessing these */
} ProjPaintState;
-typedef union pixelPointer
-{
- float *f_pt; /* float buffer */
+typedef union pixelPointer {
+ float *f_pt; /* float buffer */
unsigned int *uint_pt; /* 2 ways to access a char buffer */
unsigned char *ch_pt;
} PixelPointer;
-typedef union pixelStore
-{
+typedef union pixelStore {
unsigned char ch[4];
unsigned int uint;
float f[4];
@@ -390,7 +388,7 @@ typedef struct ProjPixelClone {
typedef struct UndoImageTile {
struct UndoImageTile *next, *prev;
- char idname[MAX_ID_NAME]; /* name instead of pointer*/
+ char idname[MAX_ID_NAME]; /* name instead of pointer*/
char ibufname[IB_FILENAME_SIZE];
void *rect;
@@ -407,51 +405,51 @@ static ImagePaintPartialRedraw imapaintpartial = {0, 0, 0, 0, 0};
static void undo_copy_tile(UndoImageTile *tile, ImBuf *tmpibuf, ImBuf *ibuf, int restore)
{
/* copy or swap contents of tile->rect and region in ibuf->rect */
- IMB_rectcpy(tmpibuf, ibuf, 0, 0, tile->x*IMAPAINT_TILE_SIZE,
- tile->y*IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE);
+ IMB_rectcpy(tmpibuf, ibuf, 0, 0, tile->x * IMAPAINT_TILE_SIZE,
+ tile->y * IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE);
if (ibuf->rect_float) {
- SWAP(void*, tmpibuf->rect_float, tile->rect);
+ SWAP(void *, tmpibuf->rect_float, tile->rect);
}
else {
- SWAP(void*, tmpibuf->rect, tile->rect);
+ SWAP(void *, tmpibuf->rect, tile->rect);
}
if (restore)
- IMB_rectcpy(ibuf, tmpibuf, tile->x*IMAPAINT_TILE_SIZE,
- tile->y*IMAPAINT_TILE_SIZE, 0, 0, IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE);
+ IMB_rectcpy(ibuf, tmpibuf, tile->x * IMAPAINT_TILE_SIZE,
+ tile->y * IMAPAINT_TILE_SIZE, 0, 0, IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE);
}
static void *image_undo_push_tile(Image *ima, ImBuf *ibuf, ImBuf **tmpibuf, int x_tile, int y_tile)
{
- ListBase *lb= undo_paint_push_get_list(UNDO_PAINT_IMAGE);
+ ListBase *lb = undo_paint_push_get_list(UNDO_PAINT_IMAGE);
UndoImageTile *tile;
int allocsize;
short use_float = ibuf->rect_float ? 1 : 0;
- for (tile=lb->first; tile; tile=tile->next)
+ for (tile = lb->first; tile; tile = tile->next)
if (tile->x == x_tile && tile->y == y_tile && ima->gen_type == tile->gen_type && ima->source == tile->source)
if (tile->use_float == use_float)
- if (strcmp(tile->idname, ima->id.name)==0 && strcmp(tile->ibufname, ibuf->name)==0)
+ if (strcmp(tile->idname, ima->id.name) == 0 && strcmp(tile->ibufname, ibuf->name) == 0)
return tile->rect;
- if (*tmpibuf==NULL)
- *tmpibuf = IMB_allocImBuf(IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE, 32, IB_rectfloat|IB_rect);
+ if (*tmpibuf == NULL)
+ *tmpibuf = IMB_allocImBuf(IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE, 32, IB_rectfloat | IB_rect);
- tile= MEM_callocN(sizeof(UndoImageTile), "UndoImageTile");
+ tile = MEM_callocN(sizeof(UndoImageTile), "UndoImageTile");
BLI_strncpy(tile->idname, ima->id.name, sizeof(tile->idname));
- tile->x= x_tile;
- tile->y= y_tile;
+ tile->x = x_tile;
+ tile->y = y_tile;
- allocsize= IMAPAINT_TILE_SIZE*IMAPAINT_TILE_SIZE*4;
- allocsize *= (ibuf->rect_float)? sizeof(float): sizeof(char);
- tile->rect= MEM_mapallocN(allocsize, "UndeImageTile.rect");
+ allocsize = IMAPAINT_TILE_SIZE * IMAPAINT_TILE_SIZE * 4;
+ allocsize *= (ibuf->rect_float) ? sizeof(float) : sizeof(char);
+ tile->rect = MEM_mapallocN(allocsize, "UndeImageTile.rect");
BLI_strncpy(tile->ibufname, ibuf->name, sizeof(tile->ibufname));
- tile->gen_type= ima->gen_type;
- tile->source= ima->source;
- tile->use_float= use_float;
+ tile->gen_type = ima->gen_type;
+ tile->source = ima->source;
+ tile->use_float = use_float;
undo_copy_tile(tile, *tmpibuf, ibuf, 0);
undo_paint_push_count_alloc(UNDO_PAINT_IMAGE, allocsize);
@@ -463,34 +461,34 @@ static void *image_undo_push_tile(Image *ima, ImBuf *ibuf, ImBuf **tmpibuf, int
static void image_undo_restore(bContext *C, ListBase *lb)
{
- Main *bmain= CTX_data_main(C);
+ Main *bmain = CTX_data_main(C);
Image *ima = NULL;
ImBuf *ibuf, *tmpibuf;
UndoImageTile *tile;
- tmpibuf= IMB_allocImBuf(IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE, 32,
- IB_rectfloat|IB_rect);
+ tmpibuf = IMB_allocImBuf(IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE, 32,
+ IB_rectfloat | IB_rect);
- for (tile=lb->first; tile; tile=tile->next) {
+ for (tile = lb->first; tile; tile = tile->next) {
short use_float;
/* find image based on name, pointer becomes invalid with global undo */
- if (ima && strcmp(tile->idname, ima->id.name)==0) {
+ if (ima && strcmp(tile->idname, ima->id.name) == 0) {
/* ima is valid */
}
else {
- ima= BLI_findstring(&bmain->image, tile->idname, offsetof(ID, name));
+ ima = BLI_findstring(&bmain->image, tile->idname, offsetof(ID, name));
}
- ibuf= BKE_image_get_ibuf(ima, NULL);
+ ibuf = BKE_image_get_ibuf(ima, NULL);
- if (ima && ibuf && strcmp(tile->ibufname, ibuf->name)!=0) {
+ if (ima && ibuf && strcmp(tile->ibufname, ibuf->name) != 0) {
/* current ImBuf filename was changed, probably current frame
* was changed when paiting on image sequence, rather than storing
* full image user (which isn't so obvious, btw) try to find ImBuf with
* matched file name in list of already loaded images */
- ibuf= BLI_findstring(&ima->ibufs, tile->ibufname, offsetof(ImBuf, name));
+ ibuf = BLI_findstring(&ima->ibufs, tile->ibufname, offsetof(ImBuf, name));
}
if (!ima || !ibuf || !(ibuf->rect || ibuf->rect_float))
@@ -510,7 +508,7 @@ static void image_undo_restore(bContext *C, ListBase *lb)
if (ibuf->rect_float)
ibuf->userflags |= IB_RECT_INVALID; /* force recreate of char rect */
if (ibuf->mipmap[0])
- ibuf->userflags |= IB_MIPMAP_INVALID; /* force mipmap recreatiom */
+ ibuf->userflags |= IB_MIPMAP_INVALID; /* force mipmap recreatiom */
}
@@ -521,7 +519,7 @@ static void image_undo_free(ListBase *lb)
{
UndoImageTile *tile;
- for (tile=lb->first; tile; tile=tile->next)
+ for (tile = lb->first; tile; tile = tile->next)
MEM_freeN(tile->rect);
}
@@ -548,7 +546,7 @@ static Image *project_paint_face_image(const ProjPaintState *ps, MTFace *dm_mtfa
Image *ima;
if (ps->do_new_shading_nodes) { /* cached scene_use_new_shading_nodes result */
- MFace *mf = ps->dm_mface+face_index;
+ MFace *mf = ps->dm_mface + face_index;
ED_object_get_active_image(ps->ob, mf->mat_nr, &ima, NULL, NULL);
}
else {
@@ -571,15 +569,15 @@ static int project_bucket_offset(const ProjPaintState *ps, const float projCoSS[
*
* Second multiplication does similar but for vertical offset
*/
- return ( (int)(((projCoSS[0] - ps->screenMin[0]) / ps->screen_width) * ps->buckets_x)) +
- ( ( (int)(((projCoSS[1] - ps->screenMin[1]) / ps->screen_height) * ps->buckets_y)) * ps->buckets_x);
+ return ( (int)(((projCoSS[0] - ps->screenMin[0]) / ps->screen_width) * ps->buckets_x)) +
+ ( ( (int)(((projCoSS[1] - ps->screenMin[1]) / ps->screen_height) * ps->buckets_y)) * ps->buckets_x);
}
static int project_bucket_offset_safe(const ProjPaintState *ps, const float projCoSS[2])
{
int bucket_index = project_bucket_offset(ps, projCoSS);
- if (bucket_index < 0 || bucket_index >= ps->buckets_x*ps->buckets_y) {
+ if (bucket_index < 0 || bucket_index >= ps->buckets_x * ps->buckets_y) {
return -1;
}
else {
@@ -595,23 +593,23 @@ static void barycentric_weights_v2_persp(float v1[4], float v2[4], float v3[4],
w[0] = area_tri_signed_v2(v2, v3, co) / v1[3];
w[1] = area_tri_signed_v2(v3, v1, co) / v2[3];
w[2] = area_tri_signed_v2(v1, v2, co) / v3[3];
- wtot = w[0]+w[1]+w[2];
+ wtot = w[0] + w[1] + w[2];
if (wtot != 0.0f) {
- wtot_inv = 1.0f/wtot;
+ wtot_inv = 1.0f / wtot;
- w[0] = w[0]*wtot_inv;
- w[1] = w[1]*wtot_inv;
- w[2] = w[2]*wtot_inv;
+ w[0] = w[0] * wtot_inv;
+ w[1] = w[1] * wtot_inv;
+ w[2] = w[2] * wtot_inv;
}
else /* dummy values for zero area face */
- w[0] = w[1] = w[2] = 1.0f/3.0f;
+ w[0] = w[1] = w[2] = 1.0f / 3.0f;
}
static float VecZDepthOrtho(float pt[2], float v1[3], float v2[3], float v3[3], float w[3])
{
barycentric_weights_v2(v1, v2, v3, pt, w);
- return (v1[2]*w[0]) + (v2[2]*w[1]) + (v3[2]*w[2]);
+ return (v1[2] * w[0]) + (v2[2] * w[1]) + (v3[2] * w[2]);
}
static float VecZDepthPersp(float pt[2], float v1[4], float v2[4], float v3[4], float w[3])
@@ -626,24 +624,24 @@ static float VecZDepthPersp(float pt[2], float v1[4], float v2[4], float v3[4],
*
* don't call barycentric_weights_v2() becaue our callers expect 'w'
* to be weighted from the perspective */
- w_tmp[0]= w[0] * v1[3];
- w_tmp[1]= w[1] * v2[3];
- w_tmp[2]= w[2] * v3[3];
+ w_tmp[0] = w[0] * v1[3];
+ w_tmp[1] = w[1] * v2[3];
+ w_tmp[2] = w[2] * v3[3];
- wtot = w_tmp[0]+w_tmp[1]+w_tmp[2];
+ wtot = w_tmp[0] + w_tmp[1] + w_tmp[2];
if (wtot != 0.0f) {
- wtot_inv = 1.0f/wtot;
+ wtot_inv = 1.0f / wtot;
- w_tmp[0] = w_tmp[0]*wtot_inv;
- w_tmp[1] = w_tmp[1]*wtot_inv;
- w_tmp[2] = w_tmp[2]*wtot_inv;
+ w_tmp[0] = w_tmp[0] * wtot_inv;
+ w_tmp[1] = w_tmp[1] * wtot_inv;
+ w_tmp[2] = w_tmp[2] * wtot_inv;
}
else /* dummy values for zero area face */
- w_tmp[0] = w_tmp[1] = w_tmp[2] = 1.0f/3.0f;
+ w_tmp[0] = w_tmp[1] = w_tmp[2] = 1.0f / 3.0f;
/* done mimicing barycentric_weights_v2() */
- return (v1[2]*w_tmp[0]) + (v2[2]*w_tmp[1]) + (v3[2]*w_tmp[2]);
+ return (v1[2] * w_tmp[0]) + (v2[2] * w_tmp[1]) + (v3[2] * w_tmp[2]);
}
@@ -661,7 +659,7 @@ static int project_paint_PickFace(const ProjPaintState *ps, float pt[2], float w
MFace *mf;
bucket_index = project_bucket_offset_safe(ps, pt);
- if (bucket_index==-1)
+ if (bucket_index == -1)
return -1;
@@ -669,17 +667,17 @@ static int project_paint_PickFace(const ProjPaintState *ps, float pt[2], float w
/* we could return 0 for 1 face buckets, as long as this function assumes
* that the point its testing is only every originated from an existing face */
- for (node= ps->bucketFaces[bucket_index]; node; node= node->next) {
+ for (node = ps->bucketFaces[bucket_index]; node; node = node->next) {
face_index = GET_INT_FROM_POINTER(node->link);
- mf= ps->dm_mface + face_index;
+ mf = ps->dm_mface + face_index;
- v1= ps->screenCoords[mf->v1];
- v2= ps->screenCoords[mf->v2];
- v3= ps->screenCoords[mf->v3];
+ v1 = ps->screenCoords[mf->v1];
+ v2 = ps->screenCoords[mf->v2];
+ v3 = ps->screenCoords[mf->v3];
if (isect_point_tri_v2(pt, v1, v2, v3)) {
- if (ps->is_ortho) z_depth= VecZDepthOrtho(pt, v1, v2, v3, w_tmp);
- else z_depth= VecZDepthPersp(pt, v1, v2, v3, w_tmp);
+ if (ps->is_ortho) z_depth = VecZDepthOrtho(pt, v1, v2, v3, w_tmp);
+ else z_depth = VecZDepthPersp(pt, v1, v2, v3, w_tmp);
if (z_depth < z_depth_best) {
best_face_index = face_index;
@@ -689,15 +687,15 @@ static int project_paint_PickFace(const ProjPaintState *ps, float pt[2], float w
}
}
else if (mf->v4) {
- v4= ps->screenCoords[mf->v4];
+ v4 = ps->screenCoords[mf->v4];
if (isect_point_tri_v2(pt, v1, v3, v4)) {
- if (ps->is_ortho) z_depth= VecZDepthOrtho(pt, v1, v3, v4, w_tmp);
- else z_depth= VecZDepthPersp(pt, v1, v3, v4, w_tmp);
+ if (ps->is_ortho) z_depth = VecZDepthOrtho(pt, v1, v3, v4, w_tmp);
+ else z_depth = VecZDepthPersp(pt, v1, v3, v4, w_tmp);
if (z_depth < z_depth_best) {
best_face_index = face_index;
- best_side= 1;
+ best_side = 1;
z_depth_best = z_depth;
copy_v3_v3(w, w_tmp);
}
@@ -784,10 +782,10 @@ static int project_paint_PickColor(const ProjPaintState *ps, float pt[2], float
//if (xi<0 || xi>=ibuf->x || yi<0 || yi>=ibuf->y) return 0;
/* wrap */
- xi = ((int)(uv[0]*ibuf->x)) % ibuf->x;
- if (xi<0) xi += ibuf->x;
- yi = ((int)(uv[1]*ibuf->y)) % ibuf->y;
- if (yi<0) yi += ibuf->y;
+ xi = ((int)(uv[0] * ibuf->x)) % ibuf->x;
+ if (xi < 0) xi += ibuf->x;
+ yi = ((int)(uv[1] * ibuf->y)) % ibuf->y;
+ if (yi < 0) yi += ibuf->y;
if (rgba) {
@@ -805,7 +803,7 @@ static int project_paint_PickColor(const ProjPaintState *ps, float pt[2], float
copy_v4_v4(rgba_fp, ((float *)ibuf->rect_float + ((xi + yi * ibuf->x) * 4)));
}
else {
- char *tmp_ch= ((char *)ibuf->rect) + ((xi + yi * ibuf->x) * 4);
+ char *tmp_ch = ((char *)ibuf->rect) + ((xi + yi * ibuf->x) * 4);
IMAPAINT_CHAR_RGBA_TO_FLOAT(rgba_fp, tmp_ch);
}
}
@@ -828,7 +826,7 @@ static int project_paint_occlude_ptv(float pt[3], float v1[4], float v2[4], floa
/* do a 2D point in try intersection */
if (!isect_point_tri_v2(pt, v1, v2, v3))
- return 0; /* we know there is */
+ return 0; /* we know there is */
/* From here on we know there IS an intersection */
@@ -850,10 +848,9 @@ static int project_paint_occlude_ptv(float pt[3], float v1[4], float v2[4], floa
}
-static int project_paint_occlude_ptv_clip(
- const ProjPaintState *ps, const MFace *mf,
- float pt[3], float v1[4], float v2[4], float v3[4],
- const int side )
+static int project_paint_occlude_ptv_clip(const ProjPaintState *ps, const MFace *mf,
+ float pt[3], float v1[4], float v2[4], float v3[4],
+ const int side)
{
float w[3], wco[3];
int ret = project_paint_occlude_ptv(pt, v1, v2, v3, w, ps->is_ortho);
@@ -861,14 +858,14 @@ static int project_paint_occlude_ptv_clip(
if (ret <= 0)
return ret;
- if (ret==1) { /* weights not calculated */
- if (ps->is_ortho) barycentric_weights_v2(v1, v2, v3, pt, w);
- else barycentric_weights_v2_persp(v1, v2, v3, pt, w);
+ if (ret == 1) { /* weights not calculated */
+ if (ps->is_ortho) barycentric_weights_v2(v1, v2, v3, pt, w);
+ else barycentric_weights_v2_persp(v1, v2, v3, pt, w);
}
/* Test if we're in the clipped area, */
- if (side) interp_v3_v3v3v3(wco, ps->dm_mvert[mf->v1].co, ps->dm_mvert[mf->v3].co, ps->dm_mvert[mf->v4].co, w);
- else interp_v3_v3v3v3(wco, ps->dm_mvert[mf->v1].co, ps->dm_mvert[mf->v2].co, ps->dm_mvert[mf->v3].co, w);
+ if (side) interp_v3_v3v3v3(wco, ps->dm_mvert[mf->v1].co, ps->dm_mvert[mf->v3].co, ps->dm_mvert[mf->v4].co, w);
+ else interp_v3_v3v3v3(wco, ps->dm_mvert[mf->v1].co, ps->dm_mvert[mf->v2].co, ps->dm_mvert[mf->v3].co, w);
if (!ED_view3d_clipping_test(ps->rv3d, wco, TRUE)) {
return 1;
@@ -887,7 +884,7 @@ static int project_bucket_point_occluded(const ProjPaintState *ps, LinkNode *buc
int face_index;
int isect_ret;
float w[3]; /* not needed when clipping */
- const short do_clip= ps->rv3d ? ps->rv3d->rflag & RV3D_CLIPPING : 0;
+ const short do_clip = ps->rv3d ? ps->rv3d->rflag & RV3D_CLIPPING : 0;
/* we could return 0 for 1 face buckets, as long as this function assumes
* that the point its testing is only every originated from an existing face */
@@ -903,13 +900,13 @@ static int project_bucket_point_occluded(const ProjPaintState *ps, LinkNode *buc
isect_ret = project_paint_occlude_ptv(pixelScreenCo, ps->screenCoords[mf->v1], ps->screenCoords[mf->v2], ps->screenCoords[mf->v3], w, ps->is_ortho);
/* Note, if isect_ret==-1 then we don't want to test the other side of the quad */
- if (isect_ret==0 && mf->v4) {
+ if (isect_ret == 0 && mf->v4) {
if (do_clip)
isect_ret = project_paint_occlude_ptv_clip(ps, mf, pixelScreenCo, ps->screenCoords[mf->v1], ps->screenCoords[mf->v3], ps->screenCoords[mf->v4], 1);
else
isect_ret = project_paint_occlude_ptv(pixelScreenCo, ps->screenCoords[mf->v1], ps->screenCoords[mf->v3], ps->screenCoords[mf->v4], w, ps->is_ortho);
}
- if (isect_ret>=1) {
+ if (isect_ret >= 1) {
/* TODO - we may want to cache the first hit,
* it is not possible to swap the face order in the list anymore */
return 1;
@@ -928,28 +925,28 @@ static int line_isect_y(const float p1[2], const float p2[2], const float y_leve
{
float y_diff;
- if (y_level==p1[1]) { /* are we touching the first point? - no interpolation needed */
+ if (y_level == p1[1]) { /* are we touching the first point? - no interpolation needed */
*x_isect = p1[0];
return ISECT_TRUE_P1;
}
- if (y_level==p2[1]) { /* are we touching the second point? - no interpolation needed */
+ if (y_level == p2[1]) { /* are we touching the second point? - no interpolation needed */
*x_isect = p2[0];
return ISECT_TRUE_P2;
}
- y_diff= fabsf(p1[1]-p2[1]); /* yuck, horizontal line, we cant do much here */
+ y_diff = fabsf(p1[1] - p2[1]); /* yuck, horizontal line, we cant do much here */
if (y_diff < 0.000001f) {
- *x_isect = (p1[0]+p2[0]) * 0.5f;
+ *x_isect = (p1[0] + p2[0]) * 0.5f;
return ISECT_TRUE;
}
if (p1[1] > y_level && p2[1] < y_level) {
- *x_isect = (p2[0]*(p1[1]-y_level) + p1[0]*(y_level-p2[1])) / y_diff; /*(p1[1]-p2[1]);*/
+ *x_isect = (p2[0] * (p1[1] - y_level) + p1[0] * (y_level - p2[1])) / y_diff; /*(p1[1]-p2[1]);*/
return ISECT_TRUE;
}
else if (p1[1] < y_level && p2[1] > y_level) {
- *x_isect = (p2[0]*(y_level-p1[1]) + p1[0]*(p2[1]-y_level)) / y_diff; /*(p2[1]-p1[1]);*/
+ *x_isect = (p2[0] * (y_level - p1[1]) + p1[0] * (p2[1] - y_level)) / y_diff; /*(p2[1]-p1[1]);*/
return ISECT_TRUE;
}
else {
@@ -961,28 +958,28 @@ static int line_isect_x(const float p1[2], const float p2[2], const float x_leve
{
float x_diff;
- if (x_level==p1[0]) { /* are we touching the first point? - no interpolation needed */
+ if (x_level == p1[0]) { /* are we touching the first point? - no interpolation needed */
*y_isect = p1[1];
return ISECT_TRUE_P1;
}
- if (x_level==p2[0]) { /* are we touching the second point? - no interpolation needed */
+ if (x_level == p2[0]) { /* are we touching the second point? - no interpolation needed */
*y_isect = p2[1];
return ISECT_TRUE_P2;
}
- x_diff= fabsf(p1[0]-p2[0]); /* yuck, horizontal line, we cant do much here */
+ x_diff = fabsf(p1[0] - p2[0]); /* yuck, horizontal line, we cant do much here */
if (x_diff < 0.000001f) { /* yuck, vertical line, we cant do much here */
- *y_isect = (p1[0]+p2[0]) * 0.5f;
+ *y_isect = (p1[0] + p2[0]) * 0.5f;
return ISECT_TRUE;
}
if (p1[0] > x_level && p2[0] < x_level) {
- *y_isect = (p2[1]*(p1[0]-x_level) + p1[1]*(x_level-p2[0])) / x_diff; /*(p1[0]-p2[0]);*/
+ *y_isect = (p2[1] * (p1[0] - x_level) + p1[1] * (x_level - p2[0])) / x_diff; /*(p1[0]-p2[0]);*/
return ISECT_TRUE;
}
else if (p1[0] < x_level && p2[0] > x_level) {
- *y_isect = (p2[1]*(x_level-p1[0]) + p1[1]*(p2[0]-x_level)) / x_diff; /*(p2[0]-p1[0]);*/
+ *y_isect = (p2[1] * (x_level - p1[0]) + p1[1] * (p2[0] - x_level)) / x_diff; /*(p2[0]-p1[0]);*/
return ISECT_TRUE;
}
else {
@@ -1010,7 +1007,7 @@ static int cmp_uv(const float vec2a[2], const float vec2b[2])
if (xb < 0.0f) xb += 1.0f;
if (yb < 0.0f) 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)) ? 1 : 0;
}
#endif
@@ -1018,11 +1015,12 @@ static int cmp_uv(const float vec2a[2], const float vec2b[2])
* return zero if there is no area in the returned rectangle */
#ifndef PROJ_DEBUG_NOSEAMBLEED
static int pixel_bounds_uv(
- const float uv1[2], const float uv2[2], const float uv3[2], const float uv4[2],
- rcti *bounds_px,
- const int ibuf_x, const int ibuf_y,
- int is_quad
-) {
+ const float uv1[2], const float uv2[2], const float uv3[2], const float uv4[2],
+ rcti *bounds_px,
+ const int ibuf_x, const int ibuf_y,
+ int is_quad
+ )
+{
float min_uv[2], max_uv[2]; /* UV bounds */
INIT_MINMAX2(min_uv, max_uv);
@@ -1036,8 +1034,8 @@ static int pixel_bounds_uv(
bounds_px->xmin = (int)(ibuf_x * min_uv[0]);
bounds_px->ymin = (int)(ibuf_y * min_uv[1]);
- bounds_px->xmax = (int)(ibuf_x * max_uv[0]) +1;
- bounds_px->ymax = (int)(ibuf_y * max_uv[1]) +1;
+ bounds_px->xmax = (int)(ibuf_x * max_uv[0]) + 1;
+ bounds_px->ymax = (int)(ibuf_y * max_uv[1]) + 1;
/*printf("%d %d %d %d \n", min_px[0], min_px[1], max_px[0], max_px[1]);*/
@@ -1046,11 +1044,11 @@ static int pixel_bounds_uv(
}
#endif
-static int pixel_bounds_array(float (* uv)[2], rcti *bounds_px, const int ibuf_x, const int ibuf_y, int tot)
+static int pixel_bounds_array(float (*uv)[2], rcti *bounds_px, const int ibuf_x, const int ibuf_y, int tot)
{
float min_uv[2], max_uv[2]; /* UV bounds */
- if (tot==0) {
+ if (tot == 0) {
return 0;
}
@@ -1064,8 +1062,8 @@ static int pixel_bounds_array(float (* uv)[2], rcti *bounds_px, const int ibuf_x
bounds_px->xmin = (int)(ibuf_x * min_uv[0]);
bounds_px->ymin = (int)(ibuf_y * min_uv[1]);
- bounds_px->xmax = (int)(ibuf_x * max_uv[0]) +1;
- bounds_px->ymax = (int)(ibuf_y * max_uv[1]) +1;
+ bounds_px->xmax = (int)(ibuf_x * max_uv[0]) + 1;
+ bounds_px->ymax = (int)(ibuf_y * max_uv[1]) + 1;
/*printf("%d %d %d %d \n", min_px[0], min_px[1], max_px[0], max_px[1]);*/
@@ -1103,15 +1101,15 @@ static int check_seam(const ProjPaintState *ps, const int orig_face, const int o
/* We need to know the order of the verts in the adjacent face
* set the i1_fidx and i2_fidx to (0,1,2,3) */
- if (mf->v1==i1) i1_fidx = 0;
- else if (mf->v2==i1) i1_fidx = 1;
- else if (mf->v3==i1) i1_fidx = 2;
- else if (mf->v4 && mf->v4==i1) i1_fidx = 3;
-
- if (mf->v1==i2) i2_fidx = 0;
- else if (mf->v2==i2) i2_fidx = 1;
- else if (mf->v3==i2) i2_fidx = 2;
- else if (mf->v4 && mf->v4==i2) i2_fidx = 3;
+ if (mf->v1 == i1) i1_fidx = 0;
+ else if (mf->v2 == i1) i1_fidx = 1;
+ else if (mf->v3 == i1) i1_fidx = 2;
+ else if (mf->v4 && mf->v4 == i1) i1_fidx = 3;
+
+ if (mf->v1 == i2) i2_fidx = 0;
+ else if (mf->v2 == i2) i2_fidx = 1;
+ else if (mf->v3 == i2) i2_fidx = 2;
+ else if (mf->v4 && mf->v4 == i2) i2_fidx = 3;
/* Only need to check if 'i2_fidx' is valid because we know i1_fidx is the same vert on both faces */
if (i2_fidx != -1) {
@@ -1126,9 +1124,9 @@ static int check_seam(const ProjPaintState *ps, const int orig_face, const int o
*orig_fidx = (i1_fidx < i2_fidx) ? i1_fidx : i2_fidx;
/* first test if they have the same image */
- if ( (orig_tpage == tpage) &&
- cmp_uv(orig_tf->uv[orig_i1_fidx], tf->uv[i1_fidx]) &&
- cmp_uv(orig_tf->uv[orig_i2_fidx], tf->uv[i2_fidx]) )
+ if ((orig_tpage == tpage) &&
+ cmp_uv(orig_tf->uv[orig_i1_fidx], tf->uv[i1_fidx]) &&
+ cmp_uv(orig_tf->uv[orig_i2_fidx], tf->uv[i2_fidx]) )
{
// printf("SEAM (NONE)\n");
return 0;
@@ -1151,14 +1149,14 @@ static int check_seam(const ProjPaintState *ps, const int orig_face, const int o
* note that the image aspect is taken into account */
static void uv_image_outset(float (*orig_uv)[2], float (*outset_uv)[2], const float scaler, const int ibuf_x, const int ibuf_y, const int is_quad)
{
- float a1, a2, a3, a4=0.0f;
+ float a1, a2, a3, a4 = 0.0f;
float puv[4][2]; /* pixelspace uv's */
float no1[2], no2[2], no3[2], no4[2]; /* normals */
float dir1[2], dir2[2], dir3[2], dir4[2];
float ibuf_inv[2];
- ibuf_inv[0]= 1.0f / (float)ibuf_x;
- ibuf_inv[1]= 1.0f / (float)ibuf_y;
+ ibuf_inv[0] = 1.0f / (float)ibuf_x;
+ ibuf_inv[1] = 1.0f / (float)ibuf_y;
/* make UV's in pixel space so we can */
puv[0][0] = orig_uv[0][0] * ibuf_x;
@@ -1196,15 +1194,15 @@ static void uv_image_outset(float (*orig_uv)[2], float (*outset_uv)[2], const fl
* This is incorrect. Its already given radians but without it wont work.
* need to look into a fix - campbell */
if (is_quad) {
- a1 = shell_angle_to_dist(angle_normalized_v2v2(dir4, dir1) * ((float)M_PI/180.0f));
- a2 = shell_angle_to_dist(angle_normalized_v2v2(dir1, dir2) * ((float)M_PI/180.0f));
- a3 = shell_angle_to_dist(angle_normalized_v2v2(dir2, dir3) * ((float)M_PI/180.0f));
- a4 = shell_angle_to_dist(angle_normalized_v2v2(dir3, dir4) * ((float)M_PI/180.0f));
+ a1 = shell_angle_to_dist(angle_normalized_v2v2(dir4, dir1) * ((float)M_PI / 180.0f));
+ a2 = shell_angle_to_dist(angle_normalized_v2v2(dir1, dir2) * ((float)M_PI / 180.0f));
+ a3 = shell_angle_to_dist(angle_normalized_v2v2(dir2, dir3) * ((float)M_PI / 180.0f));
+ a4 = shell_angle_to_dist(angle_normalized_v2v2(dir3, dir4) * ((float)M_PI / 180.0f));
}
else {
- a1 = shell_angle_to_dist(angle_normalized_v2v2(dir3, dir1) * ((float)M_PI/180.0f));
- a2 = shell_angle_to_dist(angle_normalized_v2v2(dir1, dir2) * ((float)M_PI/180.0f));
- a3 = shell_angle_to_dist(angle_normalized_v2v2(dir2, dir3) * ((float)M_PI/180.0f));
+ a1 = shell_angle_to_dist(angle_normalized_v2v2(dir3, dir1) * ((float)M_PI / 180.0f));
+ a2 = shell_angle_to_dist(angle_normalized_v2v2(dir1, dir2) * ((float)M_PI / 180.0f));
+ a3 = shell_angle_to_dist(angle_normalized_v2v2(dir2, dir3) * ((float)M_PI / 180.0f));
}
if (is_quad) {
@@ -1216,10 +1214,10 @@ static void uv_image_outset(float (*orig_uv)[2], float (*outset_uv)[2], const fl
normalize_v2(no2);
normalize_v2(no3);
normalize_v2(no4);
- mul_v2_fl(no1, a1*scaler);
- mul_v2_fl(no2, a2*scaler);
- mul_v2_fl(no3, a3*scaler);
- mul_v2_fl(no4, a4*scaler);
+ mul_v2_fl(no1, a1 * scaler);
+ mul_v2_fl(no2, a2 * scaler);
+ mul_v2_fl(no3, a3 * scaler);
+ mul_v2_fl(no4, a4 * scaler);
add_v2_v2v2(outset_uv[0], puv[0], no1);
add_v2_v2v2(outset_uv[1], puv[1], no2);
add_v2_v2v2(outset_uv[2], puv[2], no3);
@@ -1236,9 +1234,9 @@ static void uv_image_outset(float (*orig_uv)[2], float (*outset_uv)[2], const fl
normalize_v2(no1);
normalize_v2(no2);
normalize_v2(no3);
- mul_v2_fl(no1, a1*scaler);
- mul_v2_fl(no2, a2*scaler);
- mul_v2_fl(no3, a3*scaler);
+ mul_v2_fl(no1, a1 * scaler);
+ mul_v2_fl(no2, a2 * scaler);
+ mul_v2_fl(no3, a3 * scaler);
add_v2_v2v2(outset_uv[0], puv[0], no1);
add_v2_v2v2(outset_uv[1], puv[1], no2);
add_v2_v2v2(outset_uv[2], puv[2], no3);
@@ -1262,16 +1260,16 @@ static void project_face_seams_init(const ProjPaintState *ps, const int face_ind
int fidx2 = 0; /* next fidx in the face (0,1,2,3) -> (1,2,3,0) or (0,1,2) -> (1,2,0) for a tri */
do {
- if ((ps->faceSeamFlags[face_index] & (1<<fidx1|16<<fidx1)) == 0) {
+ if ((ps->faceSeamFlags[face_index] & (1 << fidx1 | 16 << fidx1)) == 0) {
if (check_seam(ps, face_index, fidx1, fidx2, &other_face, &other_fidx)) {
- ps->faceSeamFlags[face_index] |= 1<<fidx1;
+ ps->faceSeamFlags[face_index] |= 1 << fidx1;
if (other_face != -1)
- ps->faceSeamFlags[other_face] |= 1<<other_fidx;
+ ps->faceSeamFlags[other_face] |= 1 << other_fidx;
}
else {
- ps->faceSeamFlags[face_index] |= 16<<fidx1;
+ ps->faceSeamFlags[face_index] |= 16 << fidx1;
if (other_face != -1)
- ps->faceSeamFlags[other_face] |= 16<<other_fidx; /* second 4 bits for disabled */
+ ps->faceSeamFlags[other_face] |= 16 << other_fidx; /* second 4 bits for disabled */
}
}
@@ -1286,11 +1284,11 @@ static void project_face_seams_init(const ProjPaintState *ps, const int face_ind
*
* This is used for finding a pixels location in screenspace for painting */
static void screen_px_from_ortho(
- float uv[2],
- float v1co[3], float v2co[3], float v3co[3], /* Screenspace coords */
- float uv1co[2], float uv2co[2], float uv3co[2],
- float pixelScreenCo[4],
- float w[3])
+ float uv[2],
+ float v1co[3], float v2co[3], float v3co[3], /* Screenspace coords */
+ float uv1co[2], float uv2co[2], float uv3co[2],
+ float pixelScreenCo[4],
+ float w[3])
{
barycentric_weights_v2(uv1co, uv2co, uv3co, uv, w);
interp_v3_v3v3v3(pixelScreenCo, v1co, v2co, v3co, w);
@@ -1299,11 +1297,11 @@ static void screen_px_from_ortho(
/* same as screen_px_from_ortho except we need to take into account
* the perspective W coord for each vert */
static void screen_px_from_persp(
- float uv[2],
- float v1co[4], float v2co[4], float v3co[4], /* screenspace coords */
- float uv1co[2], float uv2co[2], float uv3co[2],
- float pixelScreenCo[4],
- float w[3])
+ float uv[2],
+ float v1co[4], float v2co[4], float v3co[4], /* screenspace coords */
+ float uv1co[2], float uv2co[2], float uv3co[2],
+ float pixelScreenCo[4],
+ float w[3])
{
float wtot_inv, wtot;
@@ -1314,7 +1312,7 @@ static void screen_px_from_persp(
w[1] *= v2co[3];
w[2] *= v3co[3];
- wtot = w[0]+w[1]+w[2];
+ wtot = w[0] + w[1] + w[2];
if (wtot > 0.0f) {
wtot_inv = 1.0f / wtot;
@@ -1323,7 +1321,7 @@ static void screen_px_from_persp(
w[2] *= wtot_inv;
}
else {
- w[0] = w[1] = w[2] = 1.0f/3.0f; /* dummy values for zero area face */
+ w[0] = w[1] = w[2] = 1.0f / 3.0f; /* dummy values for zero area face */
}
/* done re-weighting */
@@ -1336,7 +1334,7 @@ static void project_face_pixel(const MTFace *tf_other, ImBuf *ibuf_other, const
float uv_other[2], x, y;
uvCo1 = (float *)tf_other->uv[0];
- if (side==1) {
+ if (side == 1) {
uvCo2 = (float *)tf_other->uv[2];
uvCo3 = (float *)tf_other->uv[3];
}
@@ -1345,7 +1343,7 @@ static void project_face_pixel(const MTFace *tf_other, ImBuf *ibuf_other, const
uvCo3 = (float *)tf_other->uv[2];
}
- interp_v2_v2v2v2(uv_other, uvCo1, uvCo2, uvCo3, (float*)w);
+ interp_v2_v2v2v2(uv_other, uvCo1, uvCo2, uvCo3, (float *)w);
/* use */
uvco_to_wrapped_pxco(uv_other, ibuf_other->x, ibuf_other->y, &x, &y);
@@ -1362,10 +1360,10 @@ static void project_face_pixel(const MTFace *tf_other, ImBuf *ibuf_other, const
/* run this outside project_paint_uvpixel_init since pixels with mask 0 don't need init */
static float project_paint_uvpixel_mask(
- const ProjPaintState *ps,
- const int face_index,
- const int side,
- const float w[3])
+ const ProjPaintState *ps,
+ const int face_index,
+ const int side,
+ const float w[3])
{
float mask;
@@ -1384,10 +1382,10 @@ static float project_paint_uvpixel_mask(
project_face_pixel(tf_other, ibuf_other, w, side, rgba_ub, rgba_f);
if (ibuf_other->rect_float) { /* from float to float */
- mask = ((rgba_f[0]+rgba_f[1]+rgba_f[2])/3.0f) * rgba_f[3];
+ mask = ((rgba_f[0] + rgba_f[1] + rgba_f[2]) / 3.0f) * rgba_f[3];
}
else { /* from char to float */
- mask = ((rgba_ub[0]+rgba_ub[1]+rgba_ub[2])/(256*3.0f)) * (rgba_ub[3]/256.0f);
+ mask = ((rgba_ub[0] + rgba_ub[1] + rgba_ub[2]) / (256 * 3.0f)) * (rgba_ub[3] / 256.0f);
}
if (!ps->do_layer_stencil_inv) /* matching the gimps layer mask black/white rules, white==full opacity */
@@ -1411,7 +1409,7 @@ static float project_paint_uvpixel_mask(
short *no1, *no2, *no3;
float no[3], angle;
no1 = ps->dm_mvert[mf->v1].no;
- if (side==1) {
+ if (side == 1) {
no2 = ps->dm_mvert[mf->v3].no;
no3 = ps->dm_mvert[mf->v4].no;
}
@@ -1420,9 +1418,9 @@ static float project_paint_uvpixel_mask(
no3 = ps->dm_mvert[mf->v3].no;
}
- no[0] = w[0]*no1[0] + w[1]*no2[0] + w[2]*no3[0];
- no[1] = w[0]*no1[1] + w[1]*no2[1] + w[2]*no3[1];
- no[2] = w[0]*no1[2] + w[1]*no2[2] + w[2]*no3[2];
+ no[0] = w[0] * no1[0] + w[1] * no2[0] + w[2] * no3[0];
+ no[1] = w[0] * no1[1] + w[1] * no2[1] + w[2] * no3[1];
+ no[2] = w[0] * no1[2] + w[1] * no2[2] + w[2] * no3[2];
normalize_v3(no);
/* now we can use the normal as a mask */
@@ -1434,7 +1432,7 @@ static float project_paint_uvpixel_mask(
float viewDirPersp[3];
float *co1, *co2, *co3;
co1 = ps->dm_mvert[mf->v1].co;
- if (side==1) {
+ if (side == 1) {
co2 = ps->dm_mvert[mf->v3].co;
co3 = ps->dm_mvert[mf->v4].co;
}
@@ -1444,9 +1442,9 @@ static float project_paint_uvpixel_mask(
}
/* Get the direction from the viewPoint to the pixel and normalize */
- viewDirPersp[0] = (ps->viewPos[0] - (w[0]*co1[0] + w[1]*co2[0] + w[2]*co3[0]));
- viewDirPersp[1] = (ps->viewPos[1] - (w[0]*co1[1] + w[1]*co2[1] + w[2]*co3[1]));
- viewDirPersp[2] = (ps->viewPos[2] - (w[0]*co1[2] + w[1]*co2[2] + w[2]*co3[2]));
+ viewDirPersp[0] = (ps->viewPos[0] - (w[0] * co1[0] + w[1] * co2[0] + w[2] * co3[0]));
+ viewDirPersp[1] = (ps->viewPos[1] - (w[0] * co1[1] + w[1] * co2[1] + w[2] * co3[1]));
+ viewDirPersp[2] = (ps->viewPos[2] - (w[0] * co1[2] + w[1] * co2[2] + w[2] * co3[2]));
normalize_v3(viewDirPersp);
angle = angle_normalized_v3v3(viewDirPersp, no);
@@ -1470,30 +1468,30 @@ static float project_paint_uvpixel_mask(
/* run this function when we know a bucket's, face's pixel can be initialized,
* return the ProjPixel which is added to 'ps->bucketRect[bucket_index]' */
static ProjPixel *project_paint_uvpixel_init(
- const ProjPaintState *ps,
- MemArena *arena,
- const ImBuf *ibuf,
- short x_px, short y_px,
- const float mask,
- const int face_index,
- const int image_index,
- const float pixelScreenCo[4],
- const int side,
- const float w[3])
+ const ProjPaintState *ps,
+ MemArena *arena,
+ const ImBuf *ibuf,
+ short x_px, short y_px,
+ const float mask,
+ const int face_index,
+ const int image_index,
+ const float pixelScreenCo[4],
+ const int side,
+ const float w[3])
{
ProjPixel *projPixel;
short size;
/* wrap pixel location */
x_px = x_px % ibuf->x;
- if (x_px<0) x_px += ibuf->x;
+ if (x_px < 0) x_px += ibuf->x;
y_px = y_px % ibuf->y;
- if (y_px<0) y_px += ibuf->y;
+ if (y_px < 0) y_px += ibuf->y;
- if (ps->tool==PAINT_TOOL_CLONE) {
+ if (ps->tool == PAINT_TOOL_CLONE) {
size = sizeof(ProjPixelClone);
}
- else if (ps->tool==PAINT_TOOL_SMEAR) {
+ else if (ps->tool == PAINT_TOOL_SMEAR) {
size = sizeof(ProjPixelClone);
}
else {
@@ -1529,7 +1527,7 @@ static ProjPixel *project_paint_uvpixel_init(
((int)(((float)y_px / (float)ibuf->y) * PROJ_BOUNDBOX_DIV)) * PROJ_BOUNDBOX_DIV;
/* done with view3d_project_float inline */
- if (ps->tool==PAINT_TOOL_CLONE) {
+ if (ps->tool == PAINT_TOOL_CLONE) {
if (ps->dm_mtface_clone) {
ImBuf *ibuf_other;
Image *other_tpage = project_paint_face_image(ps, ps->dm_mtface_clone, face_index);
@@ -1589,8 +1587,8 @@ static ProjPixel *project_paint_uvpixel_init(
}
#ifdef PROJ_DEBUG_PAINT
- if (ibuf->rect_float) projPixel->pixel.f_pt[0] = 0;
- else projPixel->pixel.ch_pt[0] = 0;
+ if (ibuf->rect_float) projPixel->pixel.f_pt[0] = 0;
+ else projPixel->pixel.ch_pt[0] = 0;
#endif
projPixel->image_index = image_index;
@@ -1598,13 +1596,13 @@ static ProjPixel *project_paint_uvpixel_init(
}
static int line_clip_rect2f(
- rctf *rect,
- const float l1[2], const float l2[2],
- float l1_clip[2], float l2_clip[2])
+ rctf *rect,
+ const float l1[2], const float l2[2],
+ float l1_clip[2], float l2_clip[2])
{
/* first account for horizontal, then vertical lines */
/* horiz */
- if (fabsf(l1[1]-l2[1]) < PROJ_GEOM_TOLERANCE) {
+ if (fabsf(l1[1] - l2[1]) < PROJ_GEOM_TOLERANCE) {
/* is the line out of range on its Y axis? */
if (l1[1] < rect->ymin || l1[1] > rect->ymax) {
return 0;
@@ -1615,7 +1613,7 @@ static int line_clip_rect2f(
}
- if (fabsf(l1[0]-l2[0]) < PROJ_GEOM_TOLERANCE) { /* this is a single point (or close to)*/
+ if (fabsf(l1[0] - l2[0]) < PROJ_GEOM_TOLERANCE) { /* this is a single point (or close to)*/
if (BLI_in_rctf(rect, l1[0], l1[1])) {
copy_v2_v2(l1_clip, l1);
copy_v2_v2(l2_clip, l2);
@@ -1632,7 +1630,7 @@ static int line_clip_rect2f(
CLAMP(l2_clip[0], rect->xmin, rect->xmax);
return 1;
}
- else if (fabsf(l1[0]-l2[0]) < PROJ_GEOM_TOLERANCE) {
+ else if (fabsf(l1[0] - l2[0]) < PROJ_GEOM_TOLERANCE) {
/* is the line out of range on its X axis? */
if (l1[0] < rect->xmin || l1[0] > rect->xmax) {
return 0;
@@ -1643,7 +1641,7 @@ static int line_clip_rect2f(
return 0;
}
- if (fabsf(l1[1]-l2[1]) < PROJ_GEOM_TOLERANCE) { /* this is a single point (or close to)*/
+ if (fabsf(l1[1] - l2[1]) < PROJ_GEOM_TOLERANCE) { /* this is a single point (or close to)*/
if (BLI_in_rctf(rect, l1[0], l1[1])) {
copy_v2_v2(l1_clip, l1);
copy_v2_v2(l2_clip, l2);
@@ -1805,9 +1803,9 @@ static float len_squared_v2v2_alt(const float *v1, const float v2_1, const float
{
float x, y;
- x = v1[0]-v2_1;
- y = v1[1]-v2_2;
- return x*x+y*y;
+ x = v1[0] - v2_1;
+ y = v1[1] - v2_2;
+ return x * x + y * y;
}
/* note, use a squared value so we can use len_squared_v2v2
@@ -1825,8 +1823,8 @@ static int project_bucket_isect_circle(const float cent[2], const float radius_s
return 1;
#endif
- if ( (bucket_bounds->xmin <= cent[0] && bucket_bounds->xmax >= cent[0]) ||
- (bucket_bounds->ymin <= cent[1] && bucket_bounds->ymax >= cent[1]) )
+ if ((bucket_bounds->xmin <= cent[0] && bucket_bounds->xmax >= cent[0]) ||
+ (bucket_bounds->ymin <= cent[1] && bucket_bounds->ymax >= cent[1]))
{
return 1;
}
@@ -1868,11 +1866,11 @@ static int project_bucket_isect_circle(const float cent[2], const float radius_s
* however switching back to this for ortho is always an option */
static void rect_to_uvspace_ortho(
- rctf *bucket_bounds,
- float *v1coSS, float *v2coSS, float *v3coSS,
- float *uv1co, float *uv2co, float *uv3co,
- float bucket_bounds_uv[4][2],
- const int flip)
+ rctf *bucket_bounds,
+ float *v1coSS, float *v2coSS, float *v3coSS,
+ float *uv1co, float *uv2co, float *uv3co,
+ float bucket_bounds_uv[4][2],
+ const int flip)
{
float uv[2];
float w[3];
@@ -1881,32 +1879,32 @@ static void rect_to_uvspace_ortho(
uv[0] = bucket_bounds->xmax;
uv[1] = bucket_bounds->ymin;
barycentric_weights_v2(v1coSS, v2coSS, v3coSS, uv, w);
- interp_v2_v2v2v2(bucket_bounds_uv[flip?3:0], uv1co, uv2co, uv3co, w);
+ interp_v2_v2v2v2(bucket_bounds_uv[flip ? 3 : 0], uv1co, uv2co, uv3co, w);
//uv[0] = bucket_bounds->xmax; // set above
uv[1] = bucket_bounds->ymax;
barycentric_weights_v2(v1coSS, v2coSS, v3coSS, uv, w);
- interp_v2_v2v2v2(bucket_bounds_uv[flip?2:1], uv1co, uv2co, uv3co, w);
+ interp_v2_v2v2v2(bucket_bounds_uv[flip ? 2 : 1], uv1co, uv2co, uv3co, w);
uv[0] = bucket_bounds->xmin;
//uv[1] = bucket_bounds->ymax; // set above
barycentric_weights_v2(v1coSS, v2coSS, v3coSS, uv, w);
- interp_v2_v2v2v2(bucket_bounds_uv[flip?1:2], uv1co, uv2co, uv3co, w);
+ interp_v2_v2v2v2(bucket_bounds_uv[flip ? 1 : 2], uv1co, uv2co, uv3co, w);
//uv[0] = bucket_bounds->xmin; // set above
uv[1] = bucket_bounds->ymin;
barycentric_weights_v2(v1coSS, v2coSS, v3coSS, uv, w);
- interp_v2_v2v2v2(bucket_bounds_uv[flip?0:3], uv1co, uv2co, uv3co, w);
+ interp_v2_v2v2v2(bucket_bounds_uv[flip ? 0 : 3], uv1co, uv2co, uv3co, w);
}
/* same as above but use barycentric_weights_v2_persp */
static void rect_to_uvspace_persp(
- rctf *bucket_bounds,
- float *v1coSS, float *v2coSS, float *v3coSS,
- float *uv1co, float *uv2co, float *uv3co,
- float bucket_bounds_uv[4][2],
- const int flip
- )
+ rctf *bucket_bounds,
+ float *v1coSS, float *v2coSS, float *v3coSS,
+ float *uv1co, float *uv2co, float *uv3co,
+ float bucket_bounds_uv[4][2],
+ const int flip
+ )
{
float uv[2];
float w[3];
@@ -1915,22 +1913,22 @@ static void rect_to_uvspace_persp(
uv[0] = bucket_bounds->xmax;
uv[1] = bucket_bounds->ymin;
barycentric_weights_v2_persp(v1coSS, v2coSS, v3coSS, uv, w);
- interp_v2_v2v2v2(bucket_bounds_uv[flip?3:0], uv1co, uv2co, uv3co, w);
+ interp_v2_v2v2v2(bucket_bounds_uv[flip ? 3 : 0], uv1co, uv2co, uv3co, w);
//uv[0] = bucket_bounds->xmax; // set above
uv[1] = bucket_bounds->ymax;
barycentric_weights_v2_persp(v1coSS, v2coSS, v3coSS, uv, w);
- interp_v2_v2v2v2(bucket_bounds_uv[flip?2:1], uv1co, uv2co, uv3co, w);
+ interp_v2_v2v2v2(bucket_bounds_uv[flip ? 2 : 1], uv1co, uv2co, uv3co, w);
uv[0] = bucket_bounds->xmin;
//uv[1] = bucket_bounds->ymax; // set above
barycentric_weights_v2_persp(v1coSS, v2coSS, v3coSS, uv, w);
- interp_v2_v2v2v2(bucket_bounds_uv[flip?1:2], uv1co, uv2co, uv3co, w);
+ interp_v2_v2v2v2(bucket_bounds_uv[flip ? 1 : 2], uv1co, uv2co, uv3co, w);
//uv[0] = bucket_bounds->xmin; // set above
uv[1] = bucket_bounds->ymin;
barycentric_weights_v2_persp(v1coSS, v2coSS, v3coSS, uv, w);
- interp_v2_v2v2v2(bucket_bounds_uv[flip?0:3], uv1co, uv2co, uv3co, w);
+ interp_v2_v2v2v2(bucket_bounds_uv[flip ? 0 : 3], uv1co, uv2co, uv3co, w);
}
/* This works as we need it to but we can save a few steps and not use it */
@@ -1940,24 +1938,24 @@ static float angle_2d_clockwise(const float p1[2], const float p2[2], const floa
{
float v1[2], v2[2];
- v1[0] = p1[0]-p2[0]; v1[1] = p1[1]-p2[1];
- v2[0] = p3[0]-p2[0]; v2[1] = p3[1]-p2[1];
+ v1[0] = p1[0] - p2[0]; v1[1] = p1[1] - p2[1];
+ v2[0] = p3[0] - p2[0]; v2[1] = p3[1] - p2[1];
- return -atan2(v1[0]*v2[1] - v1[1]*v2[0], v1[0]*v2[0]+v1[1]*v2[1]);
+ return -atan2(v1[0] * v2[1] - v1[1] * v2[0], v1[0] * v2[0] + v1[1] * v2[1]);
}
#endif
#define ISECT_1 (1)
-#define ISECT_2 (1<<1)
-#define ISECT_3 (1<<2)
-#define ISECT_4 (1<<3)
-#define ISECT_ALL3 ((1<<3)-1)
-#define ISECT_ALL4 ((1<<4)-1)
+#define ISECT_2 (1 << 1)
+#define ISECT_3 (1 << 2)
+#define ISECT_4 (1 << 3)
+#define ISECT_ALL3 ((1 << 3) - 1)
+#define ISECT_ALL4 ((1 << 4) - 1)
/* limit must be a fraction over 1.0f */
static int IsectPT2Df_limit(float pt[2], float v1[2], float v2[2], float v3[2], float limit)
{
- return ((area_tri_v2(pt,v1,v2) + area_tri_v2(pt,v2,v3) + area_tri_v2(pt,v3,v1)) / (area_tri_v2(v1,v2,v3))) < limit;
+ return ((area_tri_v2(pt, v1, v2) + area_tri_v2(pt, v2, v3) + area_tri_v2(pt, v3, v1)) / (area_tri_v2(v1, v2, v3))) < limit;
}
/* Clip the face by a bucket and set the uv-space bucket_bounds_uv
@@ -1965,21 +1963,21 @@ static int IsectPT2Df_limit(float pt[2], float v1[2], float v2[2], float v3[2],
* */
static int float_z_sort_flip(const void *p1, const void *p2)
{
- return (((float *)p1)[2] < ((float *)p2)[2] ? 1:-1);
+ return (((float *)p1)[2] < ((float *)p2)[2] ? 1 : -1);
}
static int float_z_sort(const void *p1, const void *p2)
{
- return (((float *)p1)[2] < ((float *)p2)[2] ?-1:1);
+ return (((float *)p1)[2] < ((float *)p2)[2] ? -1 : 1);
}
static void project_bucket_clip_face(
- const int is_ortho,
- rctf *bucket_bounds,
- float *v1coSS, float *v2coSS, float *v3coSS,
- float *uv1co, float *uv2co, float *uv3co,
- float bucket_bounds_uv[8][2],
- int *tot)
+ const int is_ortho,
+ rctf *bucket_bounds,
+ float *v1coSS, float *v2coSS, float *v3coSS,
+ float *uv1co, float *uv2co, float *uv3co,
+ float bucket_bounds_uv[8][2],
+ int *tot)
{
int inside_bucket_flag = 0;
int inside_face_flag = 0;
@@ -1989,8 +1987,8 @@ static void project_bucket_clip_face(
/* get the UV space bounding box */
inside_bucket_flag |= BLI_in_rctf(bucket_bounds, v1coSS[0], v1coSS[1]);
- inside_bucket_flag |= BLI_in_rctf(bucket_bounds, v2coSS[0], v2coSS[1]) << 1;
- inside_bucket_flag |= BLI_in_rctf(bucket_bounds, v3coSS[0], v3coSS[1]) << 2;
+ inside_bucket_flag |= BLI_in_rctf(bucket_bounds, v2coSS[0], v2coSS[1]) << 1;
+ inside_bucket_flag |= BLI_in_rctf(bucket_bounds, v3coSS[0], v3coSS[1]) << 2;
if (inside_bucket_flag == ISECT_ALL3) {
/* all screenspace points are inside the bucket bounding box, this means we don't need to clip and can simply return the UVs */
@@ -2013,25 +2011,25 @@ static void project_bucket_clip_face(
/* use IsectPT2Df_limit here so we catch points are are touching the tri edge (or a small fraction over) */
bucket_bounds_ss[0][0] = bucket_bounds->xmax;
bucket_bounds_ss[0][1] = bucket_bounds->ymin;
- inside_face_flag |= (IsectPT2Df_limit(bucket_bounds_ss[0], v1coSS, v2coSS, v3coSS, 1+PROJ_GEOM_TOLERANCE) ? ISECT_1 : 0);
+ inside_face_flag |= (IsectPT2Df_limit(bucket_bounds_ss[0], v1coSS, v2coSS, v3coSS, 1 + PROJ_GEOM_TOLERANCE) ? ISECT_1 : 0);
bucket_bounds_ss[1][0] = bucket_bounds->xmax;
bucket_bounds_ss[1][1] = bucket_bounds->ymax;
- inside_face_flag |= (IsectPT2Df_limit(bucket_bounds_ss[1], v1coSS, v2coSS, v3coSS, 1+PROJ_GEOM_TOLERANCE) ? ISECT_2 : 0);
+ inside_face_flag |= (IsectPT2Df_limit(bucket_bounds_ss[1], v1coSS, v2coSS, v3coSS, 1 + PROJ_GEOM_TOLERANCE) ? ISECT_2 : 0);
bucket_bounds_ss[2][0] = bucket_bounds->xmin;
bucket_bounds_ss[2][1] = bucket_bounds->ymax;
- inside_face_flag |= (IsectPT2Df_limit(bucket_bounds_ss[2], v1coSS, v2coSS, v3coSS, 1+PROJ_GEOM_TOLERANCE) ? ISECT_3 : 0);
+ inside_face_flag |= (IsectPT2Df_limit(bucket_bounds_ss[2], v1coSS, v2coSS, v3coSS, 1 + PROJ_GEOM_TOLERANCE) ? ISECT_3 : 0);
bucket_bounds_ss[3][0] = bucket_bounds->xmin;
bucket_bounds_ss[3][1] = bucket_bounds->ymin;
- inside_face_flag |= (IsectPT2Df_limit(bucket_bounds_ss[3], v1coSS, v2coSS, v3coSS, 1+PROJ_GEOM_TOLERANCE) ? ISECT_4 : 0);
+ inside_face_flag |= (IsectPT2Df_limit(bucket_bounds_ss[3], v1coSS, v2coSS, v3coSS, 1 + PROJ_GEOM_TOLERANCE) ? ISECT_4 : 0);
if (inside_face_flag == ISECT_ALL4) {
/* bucket is totally inside the screenspace face, we can safely use weights */
- if (is_ortho) rect_to_uvspace_ortho(bucket_bounds, v1coSS, v2coSS, v3coSS, uv1co, uv2co, uv3co, bucket_bounds_uv, flip);
- else rect_to_uvspace_persp(bucket_bounds, v1coSS, v2coSS, v3coSS, uv1co, uv2co, uv3co, bucket_bounds_uv, flip);
+ if (is_ortho) rect_to_uvspace_ortho(bucket_bounds, v1coSS, v2coSS, v3coSS, uv1co, uv2co, uv3co, bucket_bounds_uv, flip);
+ else rect_to_uvspace_persp(bucket_bounds, v1coSS, v2coSS, v3coSS, uv1co, uv2co, uv3co, bucket_bounds_uv, flip);
*tot = 4;
return;
@@ -2066,33 +2064,33 @@ static void project_bucket_clip_face(
(*tot) = 0;
- if (inside_face_flag & ISECT_1) { copy_v2_v2(isectVCosSS[*tot], bucket_bounds_ss[0]); (*tot)++; }
- if (inside_face_flag & ISECT_2) { copy_v2_v2(isectVCosSS[*tot], bucket_bounds_ss[1]); (*tot)++; }
- if (inside_face_flag & ISECT_3) { copy_v2_v2(isectVCosSS[*tot], bucket_bounds_ss[2]); (*tot)++; }
- if (inside_face_flag & ISECT_4) { copy_v2_v2(isectVCosSS[*tot], bucket_bounds_ss[3]); (*tot)++; }
+ if (inside_face_flag & ISECT_1) { copy_v2_v2(isectVCosSS[*tot], bucket_bounds_ss[0]); (*tot)++; }
+ if (inside_face_flag & ISECT_2) { copy_v2_v2(isectVCosSS[*tot], bucket_bounds_ss[1]); (*tot)++; }
+ if (inside_face_flag & ISECT_3) { copy_v2_v2(isectVCosSS[*tot], bucket_bounds_ss[2]); (*tot)++; }
+ if (inside_face_flag & ISECT_4) { copy_v2_v2(isectVCosSS[*tot], bucket_bounds_ss[3]); (*tot)++; }
+
+ if (inside_bucket_flag & ISECT_1) { copy_v2_v2(isectVCosSS[*tot], v1coSS); (*tot)++; }
+ if (inside_bucket_flag & ISECT_2) { copy_v2_v2(isectVCosSS[*tot], v2coSS); (*tot)++; }
+ if (inside_bucket_flag & ISECT_3) { copy_v2_v2(isectVCosSS[*tot], v3coSS); (*tot)++; }
- if (inside_bucket_flag & ISECT_1) { copy_v2_v2(isectVCosSS[*tot], v1coSS); (*tot)++; }
- if (inside_bucket_flag & ISECT_2) { copy_v2_v2(isectVCosSS[*tot], v2coSS); (*tot)++; }
- if (inside_bucket_flag & ISECT_3) { copy_v2_v2(isectVCosSS[*tot], v3coSS); (*tot)++; }
-
- if ((inside_bucket_flag & (ISECT_1|ISECT_2)) != (ISECT_1|ISECT_2)) {
+ if ((inside_bucket_flag & (ISECT_1 | ISECT_2)) != (ISECT_1 | ISECT_2)) {
if (line_clip_rect2f(bucket_bounds, v1coSS, v2coSS, v1_clipSS, v2_clipSS)) {
- if ((inside_bucket_flag & ISECT_1)==0) { copy_v2_v2(isectVCosSS[*tot], v1_clipSS); (*tot)++; }
- if ((inside_bucket_flag & ISECT_2)==0) { copy_v2_v2(isectVCosSS[*tot], v2_clipSS); (*tot)++; }
+ if ((inside_bucket_flag & ISECT_1) == 0) { copy_v2_v2(isectVCosSS[*tot], v1_clipSS); (*tot)++; }
+ if ((inside_bucket_flag & ISECT_2) == 0) { copy_v2_v2(isectVCosSS[*tot], v2_clipSS); (*tot)++; }
}
}
- if ((inside_bucket_flag & (ISECT_2|ISECT_3)) != (ISECT_2|ISECT_3)) {
+ if ((inside_bucket_flag & (ISECT_2 | ISECT_3)) != (ISECT_2 | ISECT_3)) {
if (line_clip_rect2f(bucket_bounds, v2coSS, v3coSS, v1_clipSS, v2_clipSS)) {
- if ((inside_bucket_flag & ISECT_2)==0) { copy_v2_v2(isectVCosSS[*tot], v1_clipSS); (*tot)++; }
- if ((inside_bucket_flag & ISECT_3)==0) { copy_v2_v2(isectVCosSS[*tot], v2_clipSS); (*tot)++; }
+ if ((inside_bucket_flag & ISECT_2) == 0) { copy_v2_v2(isectVCosSS[*tot], v1_clipSS); (*tot)++; }
+ if ((inside_bucket_flag & ISECT_3) == 0) { copy_v2_v2(isectVCosSS[*tot], v2_clipSS); (*tot)++; }
}
}
- if ((inside_bucket_flag & (ISECT_3|ISECT_1)) != (ISECT_3|ISECT_1)) {
+ if ((inside_bucket_flag & (ISECT_3 | ISECT_1)) != (ISECT_3 | ISECT_1)) {
if (line_clip_rect2f(bucket_bounds, v3coSS, v1coSS, v1_clipSS, v2_clipSS)) {
- if ((inside_bucket_flag & ISECT_3)==0) { copy_v2_v2(isectVCosSS[*tot], v1_clipSS); (*tot)++; }
- if ((inside_bucket_flag & ISECT_1)==0) { copy_v2_v2(isectVCosSS[*tot], v2_clipSS); (*tot)++; }
+ if ((inside_bucket_flag & ISECT_3) == 0) { copy_v2_v2(isectVCosSS[*tot], v1_clipSS); (*tot)++; }
+ if ((inside_bucket_flag & ISECT_1) == 0) { copy_v2_v2(isectVCosSS[*tot], v2_clipSS); (*tot)++; }
}
}
@@ -2104,7 +2102,7 @@ static void project_bucket_clip_face(
/* now we have all points we need, collect their angles and sort them clockwise */
- for (i=0; i<(*tot); i++) {
+ for (i = 0; i < (*tot); i++) {
cent[0] += isectVCosSS[i][0];
cent[1] += isectVCosSS[i][1];
}
@@ -2116,8 +2114,8 @@ static void project_bucket_clip_face(
/* Collect angles for every point around the center point */
-#if 0 /* uses a few more cycles then the above loop */
- for (i=0; i<(*tot); i++) {
+#if 0 /* uses a few more cycles then the above loop */
+ for (i = 0; i < (*tot); i++) {
isectVCosSS[i][2] = angle_2d_clockwise(up, cent, isectVCosSS[i]);
}
#endif
@@ -2125,18 +2123,18 @@ static void project_bucket_clip_face(
v1_clipSS[0] = cent[0]; /* Abuse this var for the loop below */
v1_clipSS[1] = cent[1] + 1.0f;
- for (i=0; i<(*tot); i++) {
+ for (i = 0; i < (*tot); i++) {
v2_clipSS[0] = isectVCosSS[i][0] - cent[0];
v2_clipSS[1] = isectVCosSS[i][1] - cent[1];
- isectVCosSS[i][2] = atan2f(v1_clipSS[0]*v2_clipSS[1] - v1_clipSS[1]*v2_clipSS[0], v1_clipSS[0]*v2_clipSS[0]+v1_clipSS[1]*v2_clipSS[1]);
+ isectVCosSS[i][2] = atan2f(v1_clipSS[0] * v2_clipSS[1] - v1_clipSS[1] * v2_clipSS[0], v1_clipSS[0] * v2_clipSS[0] + v1_clipSS[1] * v2_clipSS[1]);
}
- if (flip) qsort(isectVCosSS, *tot, sizeof(float)*3, float_z_sort_flip);
- else qsort(isectVCosSS, *tot, sizeof(float)*3, float_z_sort);
+ if (flip) qsort(isectVCosSS, *tot, sizeof(float) * 3, float_z_sort_flip);
+ else qsort(isectVCosSS, *tot, sizeof(float) * 3, float_z_sort);
/* remove doubles */
/* first/last check */
- if (fabsf(isectVCosSS[0][0]-isectVCosSS[(*tot)-1][0]) < PROJ_GEOM_TOLERANCE && fabsf(isectVCosSS[0][1]-isectVCosSS[(*tot)-1][1]) < PROJ_GEOM_TOLERANCE) {
+ if (fabsf(isectVCosSS[0][0] - isectVCosSS[(*tot) - 1][0]) < PROJ_GEOM_TOLERANCE && fabsf(isectVCosSS[0][1] - isectVCosSS[(*tot) - 1][1]) < PROJ_GEOM_TOLERANCE) {
(*tot)--;
}
@@ -2148,16 +2146,16 @@ static void project_bucket_clip_face(
}
doubles = TRUE;
- while (doubles==TRUE) {
+ while (doubles == TRUE) {
doubles = FALSE;
- for (i=1; i<(*tot); i++) {
- if (fabsf(isectVCosSS[i-1][0]-isectVCosSS[i][0]) < PROJ_GEOM_TOLERANCE &&
- fabsf(isectVCosSS[i-1][1]-isectVCosSS[i][1]) < PROJ_GEOM_TOLERANCE)
+ for (i = 1; i < (*tot); i++) {
+ if (fabsf(isectVCosSS[i - 1][0] - isectVCosSS[i][0]) < PROJ_GEOM_TOLERANCE &&
+ fabsf(isectVCosSS[i - 1][1] - isectVCosSS[i][1]) < PROJ_GEOM_TOLERANCE)
{
int j;
- for (j=i+1; j<(*tot); j++) {
- isectVCosSS[j-1][0] = isectVCosSS[j][0];
- isectVCosSS[j-1][1] = isectVCosSS[j][1];
+ for (j = i + 1; j < (*tot); j++) {
+ isectVCosSS[j - 1][0] = isectVCosSS[j][0];
+ isectVCosSS[j - 1][1] = isectVCosSS[j][1];
}
doubles = TRUE; /* keep looking for more doubles */
(*tot)--;
@@ -2174,13 +2172,13 @@ static void project_bucket_clip_face(
if (is_ortho) {
- for (i=0; i<(*tot); i++) {
+ for (i = 0; i < (*tot); i++) {
barycentric_weights_v2(v1coSS, v2coSS, v3coSS, isectVCosSS[i], w);
interp_v2_v2v2v2(bucket_bounds_uv[i], uv1co, uv2co, uv3co, w);
}
}
else {
- for (i=0; i<(*tot); i++) {
+ for (i = 0; i < (*tot); i++) {
barycentric_weights_v2_persp(v1coSS, v2coSS, v3coSS, isectVCosSS[i], w);
interp_v2_v2v2v2(bucket_bounds_uv[i], uv1co, uv2co, uv3co, w);
}
@@ -2194,14 +2192,14 @@ static void project_bucket_clip_face(
/* If there are ever any problems, */
float test_uv[4][2];
int i;
- if (is_ortho) rect_to_uvspace_ortho(bucket_bounds, v1coSS, v2coSS, v3coSS, uv1co, uv2co, uv3co, test_uv, flip);
- else rect_to_uvspace_persp(bucket_bounds, v1coSS, v2coSS, v3coSS, uv1co, uv2co, uv3co, test_uv, flip);
+ if (is_ortho) rect_to_uvspace_ortho(bucket_bounds, v1coSS, v2coSS, v3coSS, uv1co, uv2co, uv3co, test_uv, flip);
+ else rect_to_uvspace_persp(bucket_bounds, v1coSS, v2coSS, v3coSS, uv1co, uv2co, uv3co, test_uv, flip);
printf("( [(%f,%f), (%f,%f), (%f,%f), (%f,%f)], ", test_uv[0][0], test_uv[0][1], test_uv[1][0], test_uv[1][1], test_uv[2][0], test_uv[2][1], test_uv[3][0], test_uv[3][1]);
printf(" [(%f,%f), (%f,%f), (%f,%f)], ", uv1co[0], uv1co[1], uv2co[0], uv2co[1], uv3co[0], uv3co[1]);
printf("[");
- for (i=0; i < (*tot); i++) {
+ for (i = 0; i < (*tot); i++) {
printf("(%f, %f),", bucket_bounds_uv[i][0], bucket_bounds_uv[i][1]);
}
printf("]),\\\n");
@@ -2269,11 +2267,11 @@ static void project_bucket_clip_face(
static int 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)
+ if (line_point_side_v2(uv[tot - 1], uv[0], pt) < 0.0f)
return 0;
- for (i=1; i<tot; i++) {
- if (line_point_side_v2(uv[i-1], uv[i], pt) < 0.0f)
+ for (i = 1; i < tot; i++) {
+ if (line_point_side_v2(uv[i - 1], uv[i], pt) < 0.0f)
return 0;
}
@@ -2283,10 +2281,10 @@ static int IsectPoly2Df(const float pt[2], float uv[][2], const int tot)
static int IsectPoly2Df_twoside(const float pt[2], float uv[][2], const int tot)
{
int i;
- int side = (line_point_side_v2(uv[tot-1], uv[0], pt) > 0.0f);
+ int side = (line_point_side_v2(uv[tot - 1], uv[0], pt) > 0.0f);
- for (i=1; i<tot; i++) {
- if ((line_point_side_v2(uv[i-1], uv[i], pt) > 0.0f) != side)
+ for (i = 1; i < tot; i++) {
+ if ((line_point_side_v2(uv[i - 1], uv[i], pt) > 0.0f) != side)
return 0;
}
@@ -2308,7 +2306,7 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i
/* UV/pixel seeking data */
int x; /* Image X-Pixel */
- int y;/* Image Y-Pixel */
+ int y; /* Image Y-Pixel */
float mask;
float uv[2]; /* Image floating point UV - same as x, y but from 0.0-1.0 */
@@ -2337,7 +2335,7 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i
int uv_clip_tot;
const short is_ortho = ps->is_ortho;
const short do_backfacecull = ps->do_backfacecull;
- const short do_clip= ps->rv3d ? ps->rv3d->rflag & RV3D_CLIPPING : 0;
+ const short do_clip = ps->rv3d ? ps->rv3d->rflag & RV3D_CLIPPING : 0;
vCo[0] = ps->dm_mvert[mf->v1].co;
vCo[1] = ps->dm_mvert[mf->v2].co;
@@ -2347,8 +2345,8 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i
/* Use tf_uv_pxoffset instead of tf->uv so we can offset the UV half a pixel
* this is done so we can avoid offseting all the pixels by 0.5 which causes
* problems when wrapping negative coords */
- xhalfpx = (0.5f+ (PROJ_GEOM_TOLERANCE/3.0f) ) / ibuf_xf;
- yhalfpx = (0.5f+ (PROJ_GEOM_TOLERANCE/4.0f) ) / ibuf_yf;
+ xhalfpx = (0.5f + (PROJ_GEOM_TOLERANCE / 3.0f) ) / ibuf_xf;
+ yhalfpx = (0.5f + (PROJ_GEOM_TOLERANCE / 4.0f) ) / ibuf_yf;
/* Note about (PROJ_GEOM_TOLERANCE/x) above...
* Needed to add this offset since UV coords are often quads aligned to pixels.
@@ -2371,7 +2369,7 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i
tf_uv_pxoffset[2][1] = tf->uv[2][1] - yhalfpx;
if (mf->v4) {
- vCo[3] = ps->dm_mvert[ mf->v4 ].co;
+ vCo[3] = ps->dm_mvert[mf->v4].co;
tf_uv_pxoffset[3][0] = tf->uv[3][0] - xhalfpx;
tf_uv_pxoffset[3][1] = tf->uv[3][1] - yhalfpx;
@@ -2382,32 +2380,32 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i
}
do {
- if (side==1) {
- i1=0; i2=2; i3=3;
+ if (side == 1) {
+ i1 = 0; i2 = 2; i3 = 3;
}
else {
- i1=0; i2=1; i3=2;
+ i1 = 0; i2 = 1; i3 = 2;
}
uv1co = tf_uv_pxoffset[i1]; // was tf->uv[i1];
uv2co = tf_uv_pxoffset[i2]; // was tf->uv[i2];
uv3co = tf_uv_pxoffset[i3]; // was tf->uv[i3];
- v1coSS = ps->screenCoords[ (*(&mf->v1 + i1)) ];
- v2coSS = ps->screenCoords[ (*(&mf->v1 + i2)) ];
- v3coSS = ps->screenCoords[ (*(&mf->v1 + i3)) ];
+ v1coSS = ps->screenCoords[(*(&mf->v1 + i1))];
+ v2coSS = ps->screenCoords[(*(&mf->v1 + i2))];
+ v3coSS = ps->screenCoords[(*(&mf->v1 + i3))];
/* This funtion gives is a concave polyline in UV space from the clipped quad and tri*/
project_bucket_clip_face(
- is_ortho, bucket_bounds,
- v1coSS, v2coSS, v3coSS,
- uv1co, uv2co, uv3co,
- uv_clip, &uv_clip_tot
- );
+ is_ortho, bucket_bounds,
+ v1coSS, v2coSS, v3coSS,
+ uv1co, uv2co, uv3co,
+ uv_clip, &uv_clip_tot
+ );
/* sometimes this happens, better just allow for 8 intersectiosn even though there should be max 6 */
#if 0
- if (uv_clip_tot>6) {
+ if (uv_clip_tot > 6) {
printf("this should never happen! %d\n", uv_clip_tot);
}
#endif
@@ -2438,17 +2436,18 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i
/* Note about IsectPoly2Df_twoside, checking the face or uv flipping doesnt work,
* could check the poly direction but better to do this */
- if ( (do_backfacecull && IsectPoly2Df(uv, uv_clip, uv_clip_tot)) ||
- (do_backfacecull==0 && IsectPoly2Df_twoside(uv, uv_clip, uv_clip_tot))) {
+ if ((do_backfacecull && IsectPoly2Df(uv, uv_clip, uv_clip_tot)) ||
+ (do_backfacecull == 0 && IsectPoly2Df_twoside(uv, uv_clip, uv_clip_tot)))
+ {
has_x_isect = has_isect = 1;
- if (is_ortho) screen_px_from_ortho(uv, v1coSS, v2coSS, v3coSS, uv1co, uv2co, uv3co, pixelScreenCo, w);
- else screen_px_from_persp(uv, v1coSS, v2coSS, v3coSS, uv1co, uv2co, uv3co, pixelScreenCo, w);
+ if (is_ortho) screen_px_from_ortho(uv, v1coSS, v2coSS, v3coSS, uv1co, uv2co, uv3co, pixelScreenCo, w);
+ else screen_px_from_persp(uv, v1coSS, v2coSS, v3coSS, uv1co, uv2co, uv3co, pixelScreenCo, w);
/* a pity we need to get the worldspace pixel location here */
if (do_clip) {
- interp_v3_v3v3v3(wco, ps->dm_mvert[ (*(&mf->v1 + i1)) ].co, ps->dm_mvert[ (*(&mf->v1 + i2)) ].co, ps->dm_mvert[ (*(&mf->v1 + i3)) ].co, w);
+ interp_v3_v3v3v3(wco, ps->dm_mvert[(*(&mf->v1 + i1))].co, ps->dm_mvert[(*(&mf->v1 + i2))].co, ps->dm_mvert[(*(&mf->v1 + i3))].co, w);
if (ED_view3d_clipping_test(ps->rv3d, wco, TRUE)) {
continue; /* Watch out that no code below this needs to run */
}
@@ -2457,16 +2456,16 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i
/* Is this UV visible from the view? - raytrace */
/* project_paint_PickFace is less complex, use for testing */
//if (project_paint_PickFace(ps, pixelScreenCo, w, &side) == face_index) {
- if (ps->do_occlude==0 || !project_bucket_point_occluded(ps, bucketFaceNodes, face_index, pixelScreenCo)) {
+ if (ps->do_occlude == 0 || !project_bucket_point_occluded(ps, bucketFaceNodes, face_index, pixelScreenCo)) {
mask = project_paint_uvpixel_mask(ps, face_index, side, w);
if (mask > 0.0f) {
BLI_linklist_prepend_arena(
- bucketPixelNodes,
- project_paint_uvpixel_init(ps, arena, ibuf, x, y, mask, face_index, image_index, pixelScreenCo, side, w),
- arena
- );
+ bucketPixelNodes,
+ project_paint_uvpixel_init(ps, arena, ibuf, x, y, mask, face_index, image_index, pixelScreenCo, side, w),
+ arena
+ );
}
}
@@ -2480,9 +2479,9 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i
}
-#if 0 /* TODO - investigate why this dosnt work sometimes! it should! */
+#if 0 /* TODO - investigate why this dosnt work sometimes! it should! */
/* no intersection for this entire row, after some intersection above means we can quit now */
- if (has_x_isect==0 && has_isect) {
+ if (has_x_isect == 0 && has_isect) {
break;
}
#endif
@@ -2497,25 +2496,25 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i
int face_seam_flag;
if (ps->thread_tot > 1)
- BLI_lock_thread(LOCK_CUSTOM1); /* Other threads could be modifying these vars */
+ BLI_lock_thread(LOCK_CUSTOM1); /* Other threads could be modifying these vars */
face_seam_flag = ps->faceSeamFlags[face_index];
/* are any of our edges un-initialized? */
- if ((face_seam_flag & (PROJ_FACE_SEAM1|PROJ_FACE_NOSEAM1))==0 ||
- (face_seam_flag & (PROJ_FACE_SEAM2|PROJ_FACE_NOSEAM2))==0 ||
- (face_seam_flag & (PROJ_FACE_SEAM3|PROJ_FACE_NOSEAM3))==0 ||
- (face_seam_flag & (PROJ_FACE_SEAM4|PROJ_FACE_NOSEAM4))==0
- ) {
+ if ((face_seam_flag & (PROJ_FACE_SEAM1 | PROJ_FACE_NOSEAM1)) == 0 ||
+ (face_seam_flag & (PROJ_FACE_SEAM2 | PROJ_FACE_NOSEAM2)) == 0 ||
+ (face_seam_flag & (PROJ_FACE_SEAM3 | PROJ_FACE_NOSEAM3)) == 0 ||
+ (face_seam_flag & (PROJ_FACE_SEAM4 | PROJ_FACE_NOSEAM4)) == 0)
+ {
project_face_seams_init(ps, face_index, mf->v4);
face_seam_flag = ps->faceSeamFlags[face_index];
//printf("seams - %d %d %d %d\n", flag&PROJ_FACE_SEAM1, flag&PROJ_FACE_SEAM2, flag&PROJ_FACE_SEAM3, flag&PROJ_FACE_SEAM4);
}
- if ((face_seam_flag & (PROJ_FACE_SEAM1|PROJ_FACE_SEAM2|PROJ_FACE_SEAM3|PROJ_FACE_SEAM4))==0) {
+ if ((face_seam_flag & (PROJ_FACE_SEAM1 | PROJ_FACE_SEAM2 | PROJ_FACE_SEAM3 | PROJ_FACE_SEAM4)) == 0) {
if (ps->thread_tot > 1)
- BLI_unlock_thread(LOCK_CUSTOM1); /* Other threads could be modifying these vars */
+ BLI_unlock_thread(LOCK_CUSTOM1); /* Other threads could be modifying these vars */
}
else {
@@ -2536,45 +2535,45 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i
float fac1, fac2, ftot;
- if (outset_uv[0][0]==FLT_MAX) /* first time initialize */
+ if (outset_uv[0][0] == FLT_MAX) /* first time initialize */
uv_image_outset(tf_uv_pxoffset, outset_uv, ps->seam_bleed_px, ibuf->x, ibuf->y, mf->v4);
/* ps->faceSeamUVs cant be modified when threading, now this is done we can unlock */
if (ps->thread_tot > 1)
- BLI_unlock_thread(LOCK_CUSTOM1); /* Other threads could be modifying these vars */
+ BLI_unlock_thread(LOCK_CUSTOM1); /* Other threads could be modifying these vars */
vCoSS[0] = ps->screenCoords[mf->v1];
vCoSS[1] = ps->screenCoords[mf->v2];
vCoSS[2] = ps->screenCoords[mf->v3];
if (mf->v4)
- vCoSS[3] = ps->screenCoords[ mf->v4 ];
+ vCoSS[3] = ps->screenCoords[mf->v4];
/* PROJ_FACE_SCALE_SEAM must be slightly less then 1.0f */
if (is_ortho) {
- if (mf->v4) scale_quad(insetCos, vCoSS, PROJ_FACE_SCALE_SEAM);
- else scale_tri(insetCos, vCoSS, PROJ_FACE_SCALE_SEAM);
+ if (mf->v4) scale_quad(insetCos, vCoSS, PROJ_FACE_SCALE_SEAM);
+ else scale_tri(insetCos, vCoSS, PROJ_FACE_SCALE_SEAM);
}
else {
- if (mf->v4) scale_quad(insetCos, vCo, PROJ_FACE_SCALE_SEAM);
- else scale_tri(insetCos, vCo, PROJ_FACE_SCALE_SEAM);
+ if (mf->v4) scale_quad(insetCos, vCo, PROJ_FACE_SCALE_SEAM);
+ else scale_tri(insetCos, vCo, PROJ_FACE_SCALE_SEAM);
}
side = 0; /* for triangles this wont need to change */
for (fidx1 = 0; fidx1 < (mf->v4 ? 4 : 3); fidx1++) {
- if (mf->v4) fidx2 = (fidx1==3) ? 0 : fidx1+1; /* next fidx in the face (0,1,2,3) -> (1,2,3,0) */
- else fidx2 = (fidx1==2) ? 0 : fidx1+1; /* next fidx in the face (0,1,2) -> (1,2,0) */
+ if (mf->v4) fidx2 = (fidx1 == 3) ? 0 : fidx1 + 1; /* next fidx in the face (0,1,2,3) -> (1,2,3,0) */
+ else fidx2 = (fidx1 == 2) ? 0 : fidx1 + 1; /* next fidx in the face (0,1,2) -> (1,2,0) */
- if ( (face_seam_flag & (1<<fidx1)) && /* 1<<fidx1 -> PROJ_FACE_SEAM# */
- line_clip_rect2f(bucket_bounds, vCoSS[fidx1], vCoSS[fidx2], bucket_clip_edges[0], bucket_clip_edges[1])
- ) {
+ if ((face_seam_flag & (1 << fidx1)) && /* 1<<fidx1 -> PROJ_FACE_SEAM# */
+ line_clip_rect2f(bucket_bounds, vCoSS[fidx1], vCoSS[fidx2], bucket_clip_edges[0], bucket_clip_edges[1]))
+ {
ftot = len_v2v2(vCoSS[fidx1], vCoSS[fidx2]); /* screenspace edge length */
if (ftot > 0.0f) { /* avoid div by zero */
if (mf->v4) {
- if (fidx1==2 || fidx2==2) side= 1;
- else side= 0;
+ if (fidx1 == 2 || fidx2 == 2) side = 1;
+ else side = 0;
}
fac1 = len_v2v2(vCoSS[fidx1], bucket_clip_edges[0]) / ftot;
@@ -2613,36 +2612,36 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i
* is not relevant, since we are outside the face, Use VecLerpf to find
* our location on the side of the face's UV */
#if 0
- if (is_ortho) screen_px_from_ortho(ps, uv, v1co, v2co, v3co, uv1co, uv2co, uv3co, pixelScreenCo);
- else screen_px_from_persp(ps, uv, v1co, v2co, v3co, uv1co, uv2co, uv3co, pixelScreenCo);
+ if (is_ortho) screen_px_from_ortho(ps, uv, v1co, v2co, v3co, uv1co, uv2co, uv3co, pixelScreenCo);
+ else screen_px_from_persp(ps, uv, v1co, v2co, v3co, uv1co, uv2co, uv3co, pixelScreenCo);
#endif
/* Since this is a seam we need to work out where on the line this pixel is */
//fac = line_point_factor_v2(uv, uv_seam_quad[0], uv_seam_quad[1]);
fac = line_point_factor_v2(uv, seam_subsection[0], seam_subsection[1]);
- if (fac < 0.0f) { copy_v3_v3(pixelScreenCo, edge_verts_inset_clip[0]); }
- else if (fac > 1.0f) { copy_v3_v3(pixelScreenCo, edge_verts_inset_clip[1]); }
- else { interp_v3_v3v3(pixelScreenCo, edge_verts_inset_clip[0], edge_verts_inset_clip[1], fac); }
+ if (fac < 0.0f) { copy_v3_v3(pixelScreenCo, edge_verts_inset_clip[0]); }
+ else if (fac > 1.0f) { copy_v3_v3(pixelScreenCo, edge_verts_inset_clip[1]); }
+ else { interp_v3_v3v3(pixelScreenCo, edge_verts_inset_clip[0], edge_verts_inset_clip[1], fac); }
if (!is_ortho) {
pixelScreenCo[3] = 1.0f;
mul_m4_v4((float(*)[4])ps->projectMat, pixelScreenCo); /* cast because of const */
- pixelScreenCo[0] = (float)(ps->winx/2.0f)+(ps->winx/2.0f)*pixelScreenCo[0]/pixelScreenCo[3];
- pixelScreenCo[1] = (float)(ps->winy/2.0f)+(ps->winy/2.0f)*pixelScreenCo[1]/pixelScreenCo[3];
- pixelScreenCo[2] = pixelScreenCo[2]/pixelScreenCo[3]; /* Use the depth for bucket point occlusion */
+ pixelScreenCo[0] = (float)(ps->winx / 2.0f) + (ps->winx / 2.0f) * pixelScreenCo[0] / pixelScreenCo[3];
+ pixelScreenCo[1] = (float)(ps->winy / 2.0f) + (ps->winy / 2.0f) * pixelScreenCo[1] / pixelScreenCo[3];
+ pixelScreenCo[2] = pixelScreenCo[2] / pixelScreenCo[3]; /* Use the depth for bucket point occlusion */
}
- if (ps->do_occlude==0 || !project_bucket_point_occluded(ps, bucketFaceNodes, face_index, pixelScreenCo)) {
+ if (ps->do_occlude == 0 || !project_bucket_point_occluded(ps, bucketFaceNodes, face_index, pixelScreenCo)) {
/* Only bother calculating the weights if we intersect */
if (ps->do_mask_normal || ps->dm_mtface_clone) {
#if 1
/* get the UV on the line since we want to copy the pixels from there for bleeding */
float uv_close[2];
- float fac= closest_to_line_v2(uv_close, uv, tf_uv_pxoffset[fidx1], tf_uv_pxoffset[fidx2]);
- if (fac < 0.0f) copy_v2_v2(uv_close, tf_uv_pxoffset[fidx1]);
- else if (fac > 1.0f) copy_v2_v2(uv_close, tf_uv_pxoffset[fidx2]);
+ float fac = closest_to_line_v2(uv_close, uv, tf_uv_pxoffset[fidx1], tf_uv_pxoffset[fidx2]);
+ if (fac < 0.0f) copy_v2_v2(uv_close, tf_uv_pxoffset[fidx1]);
+ else if (fac > 1.0f) copy_v2_v2(uv_close, tf_uv_pxoffset[fidx2]);
if (side) {
barycentric_weights_v2(tf_uv_pxoffset[0], tf_uv_pxoffset[2], tf_uv_pxoffset[3], uv_close, w);
@@ -2653,15 +2652,15 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i
#else /* this is buggy with quads, don't use for now */
/* Cheat, we know where we are along the edge so work out the weights from that */
- fac = fac1 + (fac * (fac2-fac1));
+ fac = fac1 + (fac * (fac2 - fac1));
- w[0]=w[1]=w[2]= 0.0;
+ w[0] = w[1] = w[2] = 0.0;
if (side) {
- w[fidx1?fidx1-1:0] = 1.0f-fac;
- w[fidx2?fidx2-1:0] = fac;
+ w[fidx1 ? fidx1 - 1 : 0] = 1.0f - fac;
+ w[fidx2 ? fidx2 - 1 : 0] = fac;
}
else {
- w[fidx1] = 1.0f-fac;
+ w[fidx1] = 1.0f - fac;
w[fidx2] = fac;
}
#endif
@@ -2669,8 +2668,8 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i
/* a pity we need to get the worldspace pixel location here */
if (do_clip) {
- if (side) interp_v3_v3v3v3(wco, ps->dm_mvert[mf->v1].co, ps->dm_mvert[mf->v3].co, ps->dm_mvert[mf->v4].co, w);
- else interp_v3_v3v3v3(wco, ps->dm_mvert[mf->v1].co, ps->dm_mvert[mf->v2].co, ps->dm_mvert[mf->v3].co, w);
+ if (side) interp_v3_v3v3v3(wco, ps->dm_mvert[mf->v1].co, ps->dm_mvert[mf->v3].co, ps->dm_mvert[mf->v4].co, w);
+ else interp_v3_v3v3v3(wco, ps->dm_mvert[mf->v1].co, ps->dm_mvert[mf->v2].co, ps->dm_mvert[mf->v3].co, w);
if (ED_view3d_clipping_test(ps->rv3d, wco, TRUE)) {
continue; /* Watch out that no code below this needs to run */
@@ -2681,10 +2680,10 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i
if (mask > 0.0f) {
BLI_linklist_prepend_arena(
- bucketPixelNodes,
- project_paint_uvpixel_init(ps, arena, ibuf, x, y, mask, face_index, image_index, pixelScreenCo, side, w),
- arena
- );
+ bucketPixelNodes,
+ project_paint_uvpixel_init(ps, arena, ibuf, x, y, mask, face_index, image_index, pixelScreenCo, side, w),
+ arena
+ );
}
}
@@ -2695,9 +2694,9 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i
}
}
-#if 0 /* TODO - investigate why this dosnt work sometimes! it should! */
+#if 0 /* TODO - investigate why this dosnt work sometimes! it should! */
/* no intersection for this entire row, after some intersection above means we can quit now */
- if (has_x_isect==0 && has_isect) {
+ if (has_x_isect == 0 && has_isect) {
break;
}
#endif
@@ -2734,11 +2733,11 @@ static void project_paint_bucket_bounds(const ProjPaintState *ps, const float mi
/* set bucket_bounds to a screen space-aligned floating point bound-box */
static void project_bucket_bounds(const ProjPaintState *ps, const int bucket_x, const int bucket_y, rctf *bucket_bounds)
{
- bucket_bounds->xmin = ps->screenMin[0]+((bucket_x)*(ps->screen_width / ps->buckets_x)); /* left */
- bucket_bounds->xmax = ps->screenMin[0]+((bucket_x+1)*(ps->screen_width / ps->buckets_x)); /* right */
+ bucket_bounds->xmin = ps->screenMin[0] + ((bucket_x) * (ps->screen_width / ps->buckets_x)); /* left */
+ bucket_bounds->xmax = ps->screenMin[0] + ((bucket_x + 1) * (ps->screen_width / ps->buckets_x)); /* right */
- bucket_bounds->ymin = ps->screenMin[1]+((bucket_y)*(ps->screen_height / ps->buckets_y)); /* bottom */
- bucket_bounds->ymax = ps->screenMin[1]+((bucket_y+1)*(ps->screen_height / ps->buckets_y)); /* top */
+ bucket_bounds->ymin = ps->screenMin[1] + ((bucket_y) * (ps->screen_height / ps->buckets_y)); /* bottom */
+ bucket_bounds->ymax = ps->screenMin[1] + ((bucket_y + 1) * (ps->screen_height / ps->buckets_y)); /* top */
}
/* Fill this bucket with pixels from the faces that intersect it.
@@ -2747,24 +2746,24 @@ static void project_bucket_bounds(const ProjPaintState *ps, const int bucket_x,
static void project_bucket_init(const ProjPaintState *ps, const int thread_index, const int bucket_index, rctf *bucket_bounds)
{
LinkNode *node;
- int face_index, image_index=0;
+ int face_index, image_index = 0;
ImBuf *ibuf = NULL;
Image *tpage_last = NULL, *tpage;
Image *ima = NULL;
- if (ps->image_tot==1) {
+ if (ps->image_tot == 1) {
/* Simple loop, no context switching */
ibuf = ps->projImages[0].ibuf;
ima = ps->projImages[0].ima;
- for (node = ps->bucketFaces[bucket_index]; node; node= node->next) {
+ for (node = ps->bucketFaces[bucket_index]; node; node = node->next) {
project_paint_face_init(ps, thread_index, bucket_index, GET_INT_FROM_POINTER(node->link), 0, bucket_bounds, ibuf, ima->tpageflag & IMA_CLAMP_U, ima->tpageflag & IMA_CLAMP_V);
}
}
else {
/* More complicated loop, switch between images */
- for (node = ps->bucketFaces[bucket_index]; node; node= node->next) {
+ for (node = ps->bucketFaces[bucket_index]; node; node = node->next) {
face_index = GET_INT_FROM_POINTER(node->link);
/* Image context switching */
@@ -2772,7 +2771,7 @@ static void project_bucket_init(const ProjPaintState *ps, const int thread_index
if (tpage_last != tpage) {
tpage_last = tpage;
- for (image_index=0; image_index < ps->image_tot; image_index++) {
+ for (image_index = 0; image_index < ps->image_tot; image_index++) {
if (ps->projImages[image_index].ima == tpage_last) {
ibuf = ps->projImages[image_index].ibuf;
ima = ps->projImages[image_index].ima;
@@ -2801,16 +2800,16 @@ static int project_bucket_face_isect(ProjPaintState *ps, int bucket_x, int bucke
/* TODO - replace this with a tricker method that uses sideofline for all screenCoords's edges against the closest bucket corner */
rctf bucket_bounds;
float p1[2], p2[2], p3[2], p4[2];
- float *v, *v1,*v2,*v3,*v4=NULL;
+ float *v, *v1, *v2, *v3, *v4 = NULL;
int fidx;
project_bucket_bounds(ps, bucket_x, bucket_y, &bucket_bounds);
/* Is one of the faces verts in the bucket bounds? */
- fidx = mf->v4 ? 3:2;
+ fidx = mf->v4 ? 3 : 2;
do {
- v = ps->screenCoords[ (*(&mf->v1 + fidx)) ];
+ v = ps->screenCoords[(*(&mf->v1 + fidx))];
if (BLI_in_rctf(&bucket_bounds, v[0], v[1])) {
return 1;
}
@@ -2824,36 +2823,36 @@ static int project_bucket_face_isect(ProjPaintState *ps, int bucket_x, int bucke
}
p1[0] = bucket_bounds.xmin; p1[1] = bucket_bounds.ymin;
- p2[0] = bucket_bounds.xmin; p2[1] = bucket_bounds.ymax;
- p3[0] = bucket_bounds.xmax; p3[1] = bucket_bounds.ymax;
- p4[0] = bucket_bounds.xmax; p4[1] = bucket_bounds.ymin;
+ p2[0] = bucket_bounds.xmin; p2[1] = bucket_bounds.ymax;
+ p3[0] = bucket_bounds.xmax; p3[1] = bucket_bounds.ymax;
+ p4[0] = bucket_bounds.xmax; p4[1] = bucket_bounds.ymin;
if (mf->v4) {
- if ( isect_point_quad_v2(p1, v1, v2, v3, v4) ||
- isect_point_quad_v2(p2, v1, v2, v3, v4) ||
- isect_point_quad_v2(p3, v1, v2, v3, v4) ||
- isect_point_quad_v2(p4, v1, v2, v3, v4) ||
-
- /* we can avoid testing v3,v1 because another intersection MUST exist if this intersects */
- (isect_line_line_v2(p1, p2, v1, v2) || isect_line_line_v2(p1, p2, v2, v3) || isect_line_line_v2(p1, p2, v3, v4)) ||
- (isect_line_line_v2(p2, p3, v1, v2) || isect_line_line_v2(p2, p3, v2, v3) || isect_line_line_v2(p2, p3, v3, v4)) ||
- (isect_line_line_v2(p3, p4, v1, v2) || isect_line_line_v2(p3, p4, v2, v3) || isect_line_line_v2(p3, p4, v3, v4)) ||
- (isect_line_line_v2(p4, p1, v1, v2) || isect_line_line_v2(p4, p1, v2, v3) || isect_line_line_v2(p4, p1, v3, v4))
- ) {
+ if (isect_point_quad_v2(p1, v1, v2, v3, v4) ||
+ isect_point_quad_v2(p2, v1, v2, v3, v4) ||
+ isect_point_quad_v2(p3, v1, v2, v3, v4) ||
+ isect_point_quad_v2(p4, v1, v2, v3, v4) ||
+
+ /* we can avoid testing v3,v1 because another intersection MUST exist if this intersects */
+ (isect_line_line_v2(p1, p2, v1, v2) || isect_line_line_v2(p1, p2, v2, v3) || isect_line_line_v2(p1, p2, v3, v4)) ||
+ (isect_line_line_v2(p2, p3, v1, v2) || isect_line_line_v2(p2, p3, v2, v3) || isect_line_line_v2(p2, p3, v3, v4)) ||
+ (isect_line_line_v2(p3, p4, v1, v2) || isect_line_line_v2(p3, p4, v2, v3) || isect_line_line_v2(p3, p4, v3, v4)) ||
+ (isect_line_line_v2(p4, p1, v1, v2) || isect_line_line_v2(p4, p1, v2, v3) || isect_line_line_v2(p4, p1, v3, v4)))
+ {
return 1;
}
}
else {
- if ( isect_point_tri_v2(p1, v1, v2, v3) ||
- isect_point_tri_v2(p2, v1, v2, v3) ||
- isect_point_tri_v2(p3, v1, v2, v3) ||
- isect_point_tri_v2(p4, v1, v2, v3) ||
- /* we can avoid testing v3,v1 because another intersection MUST exist if this intersects */
- (isect_line_line_v2(p1, p2, v1, v2) || isect_line_line_v2(p1, p2, v2, v3)) ||
- (isect_line_line_v2(p2, p3, v1, v2) || isect_line_line_v2(p2, p3, v2, v3)) ||
- (isect_line_line_v2(p3, p4, v1, v2) || isect_line_line_v2(p3, p4, v2, v3)) ||
- (isect_line_line_v2(p4, p1, v1, v2) || isect_line_line_v2(p4, p1, v2, v3))
- ) {
+ if (isect_point_tri_v2(p1, v1, v2, v3) ||
+ isect_point_tri_v2(p2, v1, v2, v3) ||
+ isect_point_tri_v2(p3, v1, v2, v3) ||
+ isect_point_tri_v2(p4, v1, v2, v3) ||
+ /* we can avoid testing v3,v1 because another intersection MUST exist if this intersects */
+ (isect_line_line_v2(p1, p2, v1, v2) || isect_line_line_v2(p1, p2, v2, v3)) ||
+ (isect_line_line_v2(p2, p3, v1, v2) || isect_line_line_v2(p2, p3, v2, v3)) ||
+ (isect_line_line_v2(p3, p4, v1, v2) || isect_line_line_v2(p3, p4, v2, v3)) ||
+ (isect_line_line_v2(p4, p1, v1, v2) || isect_line_line_v2(p4, p1, v2, v3)))
+ {
return 1;
}
}
@@ -2873,9 +2872,9 @@ static void project_paint_delayed_face_init(ProjPaintState *ps, const MFace *mf,
INIT_MINMAX2(min, max);
- fidx = mf->v4 ? 3:2;
+ fidx = mf->v4 ? 3 : 2;
do {
- vCoSS = ps->screenCoords[ *(&mf->v1 + fidx) ];
+ vCoSS = ps->screenCoords[*(&mf->v1 + fidx)];
DO_MINMAX2(vCoSS, min, max);
} while (fidx--);
@@ -2885,12 +2884,12 @@ static void project_paint_delayed_face_init(ProjPaintState *ps, const MFace *mf,
has_x_isect = 0;
for (bucket_x = bucketMin[0]; bucket_x < bucketMax[0]; bucket_x++) {
if (project_bucket_face_isect(ps, bucket_x, bucket_y, mf)) {
- int bucket_index= bucket_x + (bucket_y * ps->buckets_x);
+ int bucket_index = bucket_x + (bucket_y * ps->buckets_x);
BLI_linklist_prepend_arena(
- &ps->bucketFaces[ bucket_index ],
- SET_INT_IN_POINTER(face_index), /* cast to a pointer to shut up the compiler */
- arena
- );
+ &ps->bucketFaces[bucket_index],
+ SET_INT_IN_POINTER(face_index), /* cast to a pointer to shut up the compiler */
+ arena
+ );
has_x_isect = has_isect = 1;
}
@@ -2901,7 +2900,7 @@ static void project_paint_delayed_face_init(ProjPaintState *ps, const MFace *mf,
}
/* no intersection for this entire row, after some intersection above means we can quit now */
- if (has_x_isect==0 && has_isect) {
+ if (has_x_isect == 0 && has_isect) {
break;
}
}
@@ -2918,7 +2917,7 @@ static void project_paint_delayed_face_init(ProjPaintState *ps, const MFace *mf,
static int project_paint_view_clip(View3D *v3d, RegionView3D *rv3d, float *clipsta, float *clipend)
{
- int orth= ED_view3d_clip_range_get(v3d, rv3d, clipsta, clipend);
+ int orth = ED_view3d_clip_range_get(v3d, rv3d, clipsta, clipend);
if (orth) { /* only needed for ortho */
float fac = 2.0f / ((*clipend) - (*clipsta));
@@ -2957,31 +2956,31 @@ static void project_paint_begin(ProjPaintState *ps)
MemArena *arena; /* at the moment this is just ps->arena_mt[0], but use this to show were not multithreading */
- const int diameter= 2*brush_size(ps->scene, ps->brush);
+ const int diameter = 2 * brush_size(ps->scene, ps->brush);
/* ---- end defines ---- */
- if (ps->source==PROJ_SRC_VIEW)
- ED_view3d_clipping_local(ps->rv3d, ps->ob->obmat); /* faster clipping lookups */
+ if (ps->source == PROJ_SRC_VIEW)
+ ED_view3d_clipping_local(ps->rv3d, ps->ob->obmat); /* faster clipping lookups */
/* paint onto the derived mesh */
/* Workaround for subsurf selection, try the display mesh first */
- if (ps->source==PROJ_SRC_IMAGE_CAM) {
+ if (ps->source == PROJ_SRC_IMAGE_CAM) {
/* using render mesh, assume only camera was rendered from */
ps->dm = mesh_create_derived_render(ps->scene, ps->ob, ps->scene->customdata_mask | CD_MASK_MTFACE);
- ps->dm_release= TRUE;
+ ps->dm_release = TRUE;
}
- else if (ps->ob->derivedFinal && CustomData_has_layer( &ps->ob->derivedFinal->faceData, CD_MTFACE)) {
+ else if (ps->ob->derivedFinal && CustomData_has_layer(&ps->ob->derivedFinal->faceData, CD_MTFACE)) {
ps->dm = ps->ob->derivedFinal;
- ps->dm_release= FALSE;
+ ps->dm_release = FALSE;
}
else {
ps->dm = mesh_get_derived_final(ps->scene, ps->ob, ps->scene->customdata_mask | CD_MASK_MTFACE);
- ps->dm_release= TRUE;
+ ps->dm_release = TRUE;
}
- if ( !CustomData_has_layer( &ps->dm->faceData, CD_MTFACE) ) {
+ if (!CustomData_has_layer(&ps->dm->faceData, CD_MTFACE) ) {
if (ps->dm_release)
ps->dm->release(ps->dm);
@@ -2992,7 +2991,7 @@ static void project_paint_begin(ProjPaintState *ps)
ps->dm_mvert = ps->dm->getVertArray(ps->dm);
ps->dm_mface = ps->dm->getTessFaceArray(ps->dm);
- ps->dm_mtface= ps->dm->getTessFaceDataArray(ps->dm, CD_MTFACE);
+ ps->dm_mtface = ps->dm->getTessFaceDataArray(ps->dm, CD_MTFACE);
ps->dm_totvert = ps->dm->getNumVerts(ps->dm);
ps->dm_totface = ps->dm->getNumTessFaces(ps->dm);
@@ -3001,16 +3000,16 @@ static void project_paint_begin(ProjPaintState *ps)
/* Note, use the original mesh for getting the clone and mask layer index
- * this avoids re-generating the derived mesh just to get the new index */
+ * this avoids re-generating the derived mesh just to get the new index */
if (ps->do_layer_clone) {
//int layer_num = CustomData_get_clone_layer(&ps->dm->faceData, CD_MTFACE);
int layer_num = CustomData_get_clone_layer(&((Mesh *)ps->ob->data)->fdata, CD_MTFACE);
if (layer_num != -1)
ps->dm_mtface_clone = CustomData_get_layer_n(&ps->dm->faceData, CD_MTFACE, layer_num);
- if (ps->dm_mtface_clone==NULL || ps->dm_mtface_clone==ps->dm_mtface) {
+ if (ps->dm_mtface_clone == NULL || ps->dm_mtface_clone == ps->dm_mtface) {
ps->do_layer_clone = 0;
- ps->dm_mtface_clone= NULL;
+ ps->dm_mtface_clone = NULL;
printf("ACK!\n");
}
}
@@ -3021,7 +3020,7 @@ static void project_paint_begin(ProjPaintState *ps)
if (layer_num != -1)
ps->dm_mtface_stencil = CustomData_get_layer_n(&ps->dm->faceData, CD_MTFACE, layer_num);
- if (ps->dm_mtface_stencil==NULL || ps->dm_mtface_stencil==ps->dm_mtface) {
+ if (ps->dm_mtface_stencil == NULL || ps->dm_mtface_stencil == ps->dm_mtface) {
ps->do_layer_stencil = 0;
ps->dm_mtface_stencil = NULL;
}
@@ -3029,13 +3028,13 @@ static void project_paint_begin(ProjPaintState *ps)
/* when using subsurf or multires, mface arrays are thrown away, we need to keep a copy */
if (ps->dm->type != DM_TYPE_CDDM) {
- ps->dm_mvert= MEM_dupallocN(ps->dm_mvert);
- ps->dm_mface= MEM_dupallocN(ps->dm_mface);
+ ps->dm_mvert = MEM_dupallocN(ps->dm_mvert);
+ ps->dm_mface = MEM_dupallocN(ps->dm_mface);
/* looks like these are ok for now.*/
#if 0
- ps->dm_mtface= MEM_dupallocN(ps->dm_mtface);
- ps->dm_mtface_clone= MEM_dupallocN(ps->dm_mtface_clone);
- ps->dm_mtface_stencil= MEM_dupallocN(ps->dm_mtface_stencil);
+ ps->dm_mtface = MEM_dupallocN(ps->dm_mtface);
+ ps->dm_mtface_clone = MEM_dupallocN(ps->dm_mtface_clone);
+ ps->dm_mtface_stencil = MEM_dupallocN(ps->dm_mtface_stencil);
#endif
}
@@ -3049,44 +3048,44 @@ static void project_paint_begin(ProjPaintState *ps)
invert_m4_m4(ps->ob->imat, ps->ob->obmat);
- if (ps->source==PROJ_SRC_VIEW) {
+ if (ps->source == PROJ_SRC_VIEW) {
/* normal drawing */
- ps->winx= ps->ar->winx;
- ps->winy= ps->ar->winy;
+ ps->winx = ps->ar->winx;
+ ps->winy = ps->ar->winy;
copy_m4_m4(viewmat, ps->rv3d->viewmat);
copy_m4_m4(viewinv, ps->rv3d->viewinv);
ED_view3d_ob_project_mat_get(ps->rv3d, ps->ob, ps->projectMat);
- ps->is_ortho= project_paint_view_clip(ps->v3d, ps->rv3d, &ps->clipsta, &ps->clipend);
+ ps->is_ortho = project_paint_view_clip(ps->v3d, ps->rv3d, &ps->clipsta, &ps->clipend);
}
else {
/* re-projection */
float winmat[4][4];
float vmat[4][4];
- ps->winx= ps->reproject_ibuf->x;
- ps->winy= ps->reproject_ibuf->y;
+ ps->winx = ps->reproject_ibuf->x;
+ ps->winy = ps->reproject_ibuf->y;
- if (ps->source==PROJ_SRC_IMAGE_VIEW) {
+ if (ps->source == PROJ_SRC_IMAGE_VIEW) {
/* image stores camera data, tricky */
- IDProperty *idgroup= IDP_GetProperties(&ps->reproject_image->id, 0);
- IDProperty *view_data= IDP_GetPropertyFromGroup(idgroup, PROJ_VIEW_DATA_ID);
+ IDProperty *idgroup = IDP_GetProperties(&ps->reproject_image->id, 0);
+ IDProperty *view_data = IDP_GetPropertyFromGroup(idgroup, PROJ_VIEW_DATA_ID);
- float *array= (float *)IDP_Array(view_data);
+ float *array = (float *)IDP_Array(view_data);
/* use image array, written when creating image */
- memcpy(winmat, array, sizeof(winmat)); array += sizeof(winmat)/sizeof(float);
- memcpy(viewmat, array, sizeof(viewmat)); array += sizeof(viewmat)/sizeof(float);
- ps->clipsta= array[0];
- ps->clipend= array[1];
- ps->is_ortho= array[2] ? 1:0;
+ memcpy(winmat, array, sizeof(winmat)); array += sizeof(winmat) / sizeof(float);
+ memcpy(viewmat, array, sizeof(viewmat)); array += sizeof(viewmat) / sizeof(float);
+ ps->clipsta = array[0];
+ ps->clipend = array[1];
+ ps->is_ortho = array[2] ? 1 : 0;
invert_m4_m4(viewinv, viewmat);
}
- else if (ps->source==PROJ_SRC_IMAGE_CAM) {
- Object *cam_ob= ps->scene->camera;
+ else if (ps->source == PROJ_SRC_IMAGE_CAM) {
+ Object *cam_ob = ps->scene->camera;
CameraParams params;
/* viewmat & viewinv */
@@ -3101,9 +3100,9 @@ static void project_paint_begin(ProjPaintState *ps)
camera_params_compute_matrix(&params);
copy_m4_m4(winmat, params.winmat);
- ps->clipsta= params.clipsta;
- ps->clipend= params.clipend;
- ps->is_ortho= params.is_ortho;
+ ps->clipsta = params.clipsta;
+ ps->clipend = params.clipend;
+ ps->is_ortho = params.is_ortho;
}
/* same as view3d_get_object_project_mat */
@@ -3132,20 +3131,20 @@ static void project_paint_begin(ProjPaintState *ps)
INIT_MINMAX2(ps->screenMin, ps->screenMax);
ps->screenCoords = MEM_mallocN(sizeof(float) * ps->dm_totvert * 4, "ProjectPaint ScreenVerts");
- projScreenCo= *ps->screenCoords;
+ projScreenCo = *ps->screenCoords;
if (ps->is_ortho) {
- for (a=0, mv=ps->dm_mvert; a < ps->dm_totvert; a++, mv++, projScreenCo+=4) {
+ for (a = 0, mv = ps->dm_mvert; a < ps->dm_totvert; a++, mv++, projScreenCo += 4) {
mul_v3_m4v3(projScreenCo, ps->projectMat, mv->co);
/* screen space, not clamped */
- projScreenCo[0] = (float)(ps->winx/2.0f)+(ps->winx/2.0f)*projScreenCo[0];
- projScreenCo[1] = (float)(ps->winy/2.0f)+(ps->winy/2.0f)*projScreenCo[1];
+ projScreenCo[0] = (float)(ps->winx / 2.0f) + (ps->winx / 2.0f) * projScreenCo[0];
+ projScreenCo[1] = (float)(ps->winy / 2.0f) + (ps->winy / 2.0f) * projScreenCo[1];
DO_MINMAX2(projScreenCo, ps->screenMin, ps->screenMax);
}
}
else {
- for (a=0, mv=ps->dm_mvert; a < ps->dm_totvert; a++, mv++, projScreenCo+=4) {
+ for (a = 0, mv = ps->dm_mvert; a < ps->dm_totvert; a++, mv++, projScreenCo += 4) {
copy_v3_v3(projScreenCo, mv->co);
projScreenCo[3] = 1.0f;
@@ -3153,9 +3152,9 @@ static void project_paint_begin(ProjPaintState *ps)
if (projScreenCo[3] > ps->clipsta) {
/* screen space, not clamped */
- projScreenCo[0] = (float)(ps->winx/2.0f)+(ps->winx/2.0f)*projScreenCo[0]/projScreenCo[3];
- projScreenCo[1] = (float)(ps->winy/2.0f)+(ps->winy/2.0f)*projScreenCo[1]/projScreenCo[3];
- projScreenCo[2] = projScreenCo[2]/projScreenCo[3]; /* Use the depth for bucket point occlusion */
+ projScreenCo[0] = (float)(ps->winx / 2.0f) + (ps->winx / 2.0f) * projScreenCo[0] / projScreenCo[3];
+ projScreenCo[1] = (float)(ps->winy / 2.0f) + (ps->winy / 2.0f) * projScreenCo[1] / projScreenCo[3];
+ projScreenCo[2] = projScreenCo[2] / projScreenCo[3]; /* Use the depth for bucket point occlusion */
DO_MINMAX2(projScreenCo, ps->screenMin, ps->screenMax);
}
else {
@@ -3178,7 +3177,7 @@ static void project_paint_begin(ProjPaintState *ps)
ps->screenMax[1] += projMargin;
ps->screenMin[1] -= projMargin;
- if (ps->source==PROJ_SRC_VIEW) {
+ if (ps->source == PROJ_SRC_VIEW) {
#ifdef PROJ_DEBUG_WINCLIP
CLAMP(ps->screenMin[0], (float)(-diameter), (float)(ps->winx + diameter));
CLAMP(ps->screenMax[0], (float)(-diameter), (float)(ps->winx + diameter));
@@ -3188,11 +3187,11 @@ static void project_paint_begin(ProjPaintState *ps)
#endif
}
else { /* re-projection, use bounds */
- ps->screenMin[0]= 0;
- ps->screenMax[0]= (float)(ps->winx);
+ ps->screenMin[0] = 0;
+ ps->screenMax[0] = (float)(ps->winx);
- ps->screenMin[1]= 0;
- ps->screenMax[1]= (float)(ps->winy);
+ ps->screenMin[1] = 0;
+ ps->screenMax[1] = (float)(ps->winy);
}
/* only for convenience */
@@ -3210,14 +3209,14 @@ static void project_paint_begin(ProjPaintState *ps)
CLAMP(ps->buckets_y, PROJ_BUCKET_RECT_MIN, PROJ_BUCKET_RECT_MAX);
ps->bucketRect = (LinkNode **)MEM_callocN(sizeof(LinkNode *) * ps->buckets_x * ps->buckets_y, "paint-bucketRect");
- ps->bucketFaces= (LinkNode **)MEM_callocN(sizeof(LinkNode *) * ps->buckets_x * ps->buckets_y, "paint-bucketFaces");
+ ps->bucketFaces = (LinkNode **)MEM_callocN(sizeof(LinkNode *) * ps->buckets_x * ps->buckets_y, "paint-bucketFaces");
- ps->bucketFlags= (unsigned char *)MEM_callocN(sizeof(char) * ps->buckets_x * ps->buckets_y, "paint-bucketFaces");
+ ps->bucketFlags = (unsigned char *)MEM_callocN(sizeof(char) * ps->buckets_x * ps->buckets_y, "paint-bucketFaces");
#ifndef PROJ_DEBUG_NOSEAMBLEED
if (ps->seam_bleed_px > 0.0f) {
- ps->vertFaces= (LinkNode **)MEM_callocN(sizeof(LinkNode *) * ps->dm_totvert, "paint-vertFaces");
+ ps->vertFaces = (LinkNode **)MEM_callocN(sizeof(LinkNode *) * ps->dm_totvert, "paint-vertFaces");
ps->faceSeamFlags = (char *)MEM_callocN(sizeof(char) * ps->dm_totface, "paint-faceSeamFlags");
- ps->faceSeamUVs= MEM_mallocN(sizeof(float) * ps->dm_totface * 8, "paint-faceSeamUVs");
+ ps->faceSeamUVs = MEM_mallocN(sizeof(float) * ps->dm_totface * 8, "paint-faceSeamUVs");
}
#endif
@@ -3233,8 +3232,8 @@ static void project_paint_begin(ProjPaintState *ps)
else {
ps->thread_tot = BLI_system_thread_count();
}
- for (a=0; a<ps->thread_tot; a++) {
- ps->arena_mt[a] = BLI_memarena_new(1<<16, "project paint arena");
+ for (a = 0; a < ps->thread_tot; a++) {
+ ps->arena_mt[a] = BLI_memarena_new(1 << 16, "project paint arena");
}
arena = ps->arena_mt[0];
@@ -3244,7 +3243,7 @@ static void project_paint_begin(ProjPaintState *ps)
ps->vertFlags = MEM_callocN(sizeof(char) * ps->dm_totvert, "paint-vertFlags");
- for (a=0, mv=ps->dm_mvert; a < ps->dm_totvert; a++, mv++) {
+ for (a = 0, mv = ps->dm_mvert; a < ps->dm_totvert; a++, mv++) {
normal_short_to_float_v3(no, mv->no);
if (ps->is_ortho) {
@@ -3280,9 +3279,9 @@ static void project_paint_begin(ProjPaintState *ps)
tpage = project_paint_face_image(ps, ps->dm_mtface, face_index);
- if (tpage && ((((Mesh *)ps->ob->data)->editflag & ME_EDIT_PAINT_MASK)==0 || mf->flag & ME_FACE_SEL)) {
+ if (tpage && ((((Mesh *)ps->ob->data)->editflag & ME_EDIT_PAINT_MASK) == 0 || mf->flag & ME_FACE_SEL)) {
- float *v1coSS, *v2coSS, *v3coSS, *v4coSS=NULL;
+ float *v1coSS, *v2coSS, *v3coSS, *v4coSS = NULL;
v1coSS = ps->screenCoords[mf->v1];
v2coSS = ps->screenCoords[mf->v2];
@@ -3293,11 +3292,11 @@ static void project_paint_begin(ProjPaintState *ps)
if (!ps->is_ortho) {
- if ( v1coSS[0]==FLT_MAX ||
- v2coSS[0]==FLT_MAX ||
- v3coSS[0]==FLT_MAX ||
- (mf->v4 && v4coSS[0]==FLT_MAX)
- ) {
+ if (v1coSS[0] == FLT_MAX ||
+ v2coSS[0] == FLT_MAX ||
+ v3coSS[0] == FLT_MAX ||
+ (mf->v4 && v4coSS[0] == FLT_MAX))
+ {
continue;
}
}
@@ -3305,26 +3304,27 @@ static void project_paint_begin(ProjPaintState *ps)
#ifdef PROJ_DEBUG_WINCLIP
/* ignore faces outside the view */
if (
- (v1coSS[0] < ps->screenMin[0] &&
- v2coSS[0] < ps->screenMin[0] &&
- v3coSS[0] < ps->screenMin[0] &&
- (mf->v4 && v4coSS[0] < ps->screenMin[0])) ||
-
- (v1coSS[0] > ps->screenMax[0] &&
- v2coSS[0] > ps->screenMax[0] &&
- v3coSS[0] > ps->screenMax[0] &&
- (mf->v4 && v4coSS[0] > ps->screenMax[0])) ||
-
- (v1coSS[1] < ps->screenMin[1] &&
- v2coSS[1] < ps->screenMin[1] &&
- v3coSS[1] < ps->screenMin[1] &&
- (mf->v4 && v4coSS[1] < ps->screenMin[1])) ||
-
- (v1coSS[1] > ps->screenMax[1] &&
- v2coSS[1] > ps->screenMax[1] &&
- v3coSS[1] > ps->screenMax[1] &&
- (mf->v4 && v4coSS[1] > ps->screenMax[1]))
- ) {
+ (v1coSS[0] < ps->screenMin[0] &&
+ v2coSS[0] < ps->screenMin[0] &&
+ v3coSS[0] < ps->screenMin[0] &&
+ (mf->v4 && v4coSS[0] < ps->screenMin[0])) ||
+
+ (v1coSS[0] > ps->screenMax[0] &&
+ v2coSS[0] > ps->screenMax[0] &&
+ v3coSS[0] > ps->screenMax[0] &&
+ (mf->v4 && v4coSS[0] > ps->screenMax[0])) ||
+
+ (v1coSS[1] < ps->screenMin[1] &&
+ v2coSS[1] < ps->screenMin[1] &&
+ v3coSS[1] < ps->screenMin[1] &&
+ (mf->v4 && v4coSS[1] < ps->screenMin[1])) ||
+
+ (v1coSS[1] > ps->screenMax[1] &&
+ v2coSS[1] > ps->screenMax[1] &&
+ v3coSS[1] > ps->screenMax[1] &&
+ (mf->v4 && v4coSS[1] > ps->screenMax[1]))
+ )
+ {
continue;
}
@@ -3336,12 +3336,12 @@ static void project_paint_begin(ProjPaintState *ps)
/* Since we are interpolating the normals of faces, we want to make
* sure all the verts are pointing away from the view,
* not just the face */
- if ( (ps->vertFlags[mf->v1] & PROJ_VERT_CULL) &&
- (ps->vertFlags[mf->v2] & PROJ_VERT_CULL) &&
- (ps->vertFlags[mf->v3] & PROJ_VERT_CULL) &&
- (mf->v4==0 || ps->vertFlags[mf->v4] & PROJ_VERT_CULL)
-
- ) {
+ if ((ps->vertFlags[mf->v1] & PROJ_VERT_CULL) &&
+ (ps->vertFlags[mf->v2] & PROJ_VERT_CULL) &&
+ (ps->vertFlags[mf->v3] & PROJ_VERT_CULL) &&
+ (mf->v4 == 0 || ps->vertFlags[mf->v4] & PROJ_VERT_CULL)
+ )
+ {
continue;
}
}
@@ -3357,7 +3357,7 @@ static void project_paint_begin(ProjPaintState *ps)
image_index = BLI_linklist_index(image_LinkList, tpage);
- if (image_index==-1 && BKE_image_get_ibuf(tpage, NULL)) { /* MemArena dosnt have an append func */
+ if (image_index == -1 && BKE_image_get_ibuf(tpage, NULL)) { /* MemArena dosnt have an append func */
BLI_linklist_append(&image_LinkList, tpage);
image_index = ps->image_tot;
ps->image_tot++;
@@ -3377,7 +3377,7 @@ static void project_paint_begin(ProjPaintState *ps)
/* build an array of images we use*/
projIma = ps->projImages = (ProjPaintImage *)BLI_memarena_alloc(arena, sizeof(ProjPaintImage) * ps->image_tot);
- for (node= image_LinkList, i=0; node; node= node->next, i++, projIma++) {
+ for (node = image_LinkList, i = 0; node; node = node->next, i++, projIma++) {
projIma->ima = node->link;
projIma->touch = 0;
projIma->ibuf = BKE_image_get_ibuf(projIma->ima, NULL);
@@ -3399,8 +3399,8 @@ static void project_paint_begin_clone(ProjPaintState *ps, int mouse[2])
projCo[3] = 1.0f;
mul_m4_v4(ps->projectMat, projCo);
- ps->cloneOffset[0] = mouse[0] - ((float)(ps->winx/2.0f)+(ps->winx/2.0f)*projCo[0]/projCo[3]);
- ps->cloneOffset[1] = mouse[1] - ((float)(ps->winy/2.0f)+(ps->winy/2.0f)*projCo[1]/projCo[3]);
+ ps->cloneOffset[0] = mouse[0] - ((float)(ps->winx / 2.0f) + (ps->winx / 2.0f) * projCo[0] / projCo[3]);
+ ps->cloneOffset[1] = mouse[1] - ((float)(ps->winy / 2.0f) + (ps->winy / 2.0f) * projCo[1] / projCo[3]);
}
}
@@ -3426,9 +3426,9 @@ static void project_paint_end(ProjPaintState *ps)
/* context */
ProjPaintImage *last_projIma;
int last_image_index = -1;
- int last_tile_width=0;
+ int last_tile_width = 0;
- for (a=0, last_projIma=ps->projImages; a < ps->image_tot; a++, last_projIma++) {
+ for (a = 0, last_projIma = ps->projImages; a < ps->image_tot; a++, last_projIma++) {
int size = sizeof(void **) * IMAPAINT_TILE_NUMBER(last_projIma->ibuf->x) * IMAPAINT_TILE_NUMBER(last_projIma->ibuf->y);
last_projIma->undoRect = (void **) BLI_memarena_alloc(arena, size);
memset(last_projIma->undoRect, 0, size);
@@ -3437,28 +3437,28 @@ static void project_paint_end(ProjPaintState *ps)
for (bucket_index = 0; bucket_index < bucket_tot; bucket_index++) {
/* loop through all pixels */
- for (pixel_node= ps->bucketRect[bucket_index]; pixel_node; pixel_node= pixel_node->next) {
+ for (pixel_node = ps->bucketRect[bucket_index]; pixel_node; pixel_node = pixel_node->next) {
/* ok we have a pixel, was it modified? */
projPixel = (ProjPixel *)pixel_node->link;
if (last_image_index != projPixel->image_index) {
/* set the context */
- last_image_index = projPixel->image_index;
- last_projIma = ps->projImages + last_image_index;
- last_tile_width = IMAPAINT_TILE_NUMBER(last_projIma->ibuf->x);
- is_float = last_projIma->ibuf->rect_float ? 1 : 0;
+ last_image_index = projPixel->image_index;
+ last_projIma = ps->projImages + last_image_index;
+ last_tile_width = IMAPAINT_TILE_NUMBER(last_projIma->ibuf->x);
+ is_float = last_projIma->ibuf->rect_float ? 1 : 0;
}
- if ( (is_float == 0 && projPixel->origColor.uint != *projPixel->pixel.uint_pt) ||
-
- (is_float == 1 &&
- ( projPixel->origColor.f[0] != projPixel->pixel.f_pt[0] ||
- projPixel->origColor.f[1] != projPixel->pixel.f_pt[1] ||
- projPixel->origColor.f[2] != projPixel->pixel.f_pt[2] ||
- projPixel->origColor.f[3] != projPixel->pixel.f_pt[3] ))
- ) {
+ if ((is_float == 0 && projPixel->origColor.uint != *projPixel->pixel.uint_pt) ||
+ (is_float == 1 &&
+ (projPixel->origColor.f[0] != projPixel->pixel.f_pt[0] ||
+ projPixel->origColor.f[1] != projPixel->pixel.f_pt[1] ||
+ projPixel->origColor.f[2] != projPixel->pixel.f_pt[2] ||
+ projPixel->origColor.f[3] != projPixel->pixel.f_pt[3]))
+ )
+ {
x_tile = projPixel->x_px >> IMAPAINT_TILE_BITS;
y_tile = projPixel->y_px >> IMAPAINT_TILE_BITS;
@@ -3468,9 +3468,9 @@ static void project_paint_end(ProjPaintState *ps)
tile_index = x_tile + y_tile * last_tile_width;
- if (last_projIma->undoRect[tile_index]==NULL) {
+ if (last_projIma->undoRect[tile_index] == NULL) {
/* add the undo tile from the modified image, then write the original colors back into it */
- tilerect = last_projIma->undoRect[tile_index] = image_undo_push_tile(last_projIma->ima, last_projIma->ibuf, is_float ? (&tmpibuf_float):(&tmpibuf) , x_tile, y_tile);
+ tilerect = last_projIma->undoRect[tile_index] = image_undo_push_tile(last_projIma->ima, last_projIma->ibuf, is_float ? (&tmpibuf_float) : (&tmpibuf), x_tile, y_tile);
}
else {
tilerect = last_projIma->undoRect[tile_index];
@@ -3484,14 +3484,14 @@ static void project_paint_end(ProjPaintState *ps)
copy_v4_v4(rgba_fp, projPixel->origColor.f);
}
else {
- ((unsigned int *)tilerect)[ (projPixel->x_px - x_round) + (projPixel->y_px - y_round) * IMAPAINT_TILE_SIZE ] = projPixel->origColor.uint;
+ ((unsigned int *)tilerect)[(projPixel->x_px - x_round) + (projPixel->y_px - y_round) * IMAPAINT_TILE_SIZE] = projPixel->origColor.uint;
}
}
}
}
- if (tmpibuf) IMB_freeImBuf(tmpibuf);
- if (tmpibuf_float) IMB_freeImBuf(tmpibuf_float);
+ if (tmpibuf) IMB_freeImBuf(tmpibuf);
+ if (tmpibuf_float) IMB_freeImBuf(tmpibuf_float);
}
/* done calculating undo data */
@@ -3510,7 +3510,7 @@ static void project_paint_end(ProjPaintState *ps)
if (ps->vertFlags) MEM_freeN(ps->vertFlags);
- for (a=0; a<ps->thread_tot; a++) {
+ for (a = 0; a < ps->thread_tot; a++) {
BLI_memarena_free(ps->arena_mt[a]);
}
@@ -3550,7 +3550,7 @@ static void partial_redraw_array_init(ImagePaintPartialRedraw *pr)
static int partial_redraw_array_merge(ImagePaintPartialRedraw *pr, ImagePaintPartialRedraw *pr_other, int tot)
{
- int touch= 0;
+ int touch = 0;
while (tot--) {
pr->x1 = MIN2(pr->x1, pr_other->x1);
pr->y1 = MIN2(pr->y1, pr_other->y1);
@@ -3572,14 +3572,14 @@ static int project_image_refresh_tagged(ProjPaintState *ps)
{
ImagePaintPartialRedraw *pr;
ProjPaintImage *projIma;
- int a,i;
+ int a, i;
int redraw = 0;
- for (a=0, projIma=ps->projImages; a < ps->image_tot; a++, projIma++) {
+ for (a = 0, projIma = ps->projImages; a < ps->image_tot; a++, projIma++) {
if (projIma->touch) {
/* look over each bound cell */
- for (i=0; i<PROJ_BOUNDBOX_SQUARED; i++) {
+ for (i = 0; i < PROJ_BOUNDBOX_SQUARED; i++) {
pr = &(projIma->partRedrawRect[i]);
if (pr->x2 != -1) { /* TODO - use 'enabled' ? */
imapaintpartial = *pr;
@@ -3598,7 +3598,7 @@ static int project_image_refresh_tagged(ProjPaintState *ps)
/* run this per painting onto each mouse location */
static int project_bucket_iter_init(ProjPaintState *ps, const float mval_f[2])
{
- if (ps->source==PROJ_SRC_VIEW) {
+ if (ps->source == PROJ_SRC_VIEW) {
float min_brush[2], max_brush[2];
const float radius = (float)brush_size(ps->scene, ps->brush);
@@ -3615,7 +3615,7 @@ static int project_bucket_iter_init(ProjPaintState *ps, const float mval_f[2])
project_paint_bucket_bounds(ps, min_brush, max_brush, ps->bucketMin, ps->bucketMax);
/* mouse outside the model areas? */
- if (ps->bucketMin[0]==ps->bucketMax[0] || ps->bucketMin[1]==ps->bucketMax[1]) {
+ if (ps->bucketMin[0] == ps->bucketMax[0] || ps->bucketMin[1] == ps->bucketMax[1]) {
return 0;
}
@@ -3623,11 +3623,11 @@ static int project_bucket_iter_init(ProjPaintState *ps, const float mval_f[2])
ps->context_bucket_y = ps->bucketMin[1];
}
else { /* reproject: PROJ_SRC_* */
- ps->bucketMin[0]= 0;
- ps->bucketMin[1]= 0;
+ ps->bucketMin[0] = 0;
+ ps->bucketMin[1] = 0;
- ps->bucketMax[0]= ps->buckets_x;
- ps->bucketMax[1]= ps->buckets_y;
+ ps->bucketMax[0] = ps->buckets_x;
+ ps->bucketMax[1] = ps->buckets_y;
ps->context_bucket_x = 0;
ps->context_bucket_y = 0;
@@ -3638,22 +3638,22 @@ static int project_bucket_iter_init(ProjPaintState *ps, const float mval_f[2])
static int project_bucket_iter_next(ProjPaintState *ps, int *bucket_index, rctf *bucket_bounds, const float mval[2])
{
- const int diameter= 2*brush_size(ps->scene, ps->brush);
+ const int diameter = 2 * brush_size(ps->scene, ps->brush);
if (ps->thread_tot > 1)
BLI_lock_thread(LOCK_CUSTOM1);
//printf("%d %d \n", ps->context_bucket_x, ps->context_bucket_y);
- for ( ; ps->context_bucket_y < ps->bucketMax[1]; ps->context_bucket_y++) {
- for ( ; ps->context_bucket_x < ps->bucketMax[0]; ps->context_bucket_x++) {
+ for (; ps->context_bucket_y < ps->bucketMax[1]; ps->context_bucket_y++) {
+ for (; ps->context_bucket_x < ps->bucketMax[0]; ps->context_bucket_x++) {
/* use bucket_bounds for project_bucket_isect_circle and project_bucket_init*/
project_bucket_bounds(ps, ps->context_bucket_x, ps->context_bucket_y, bucket_bounds);
- if ( (ps->source != PROJ_SRC_VIEW) ||
- project_bucket_isect_circle(mval, (float)(diameter*diameter), bucket_bounds)
- ) {
+ if ((ps->source != PROJ_SRC_VIEW) ||
+ project_bucket_isect_circle(mval, (float)(diameter * diameter), bucket_bounds))
+ {
*bucket_index = ps->context_bucket_x + (ps->context_bucket_y * ps->buckets_x);
ps->context_bucket_x++;
@@ -3679,7 +3679,7 @@ typedef struct ProjectHandle {
float mval[2];
/* annoying but we need to have image bounds per thread, then merge into ps->projectPartialRedraws */
- ProjPaintImage *projImages; /* array of partial redraws */
+ ProjPaintImage *projImages; /* array of partial redraws */
/* thread settings */
int thread_index;
@@ -3690,21 +3690,21 @@ static void blend_color_mix(unsigned char *cp, const unsigned char *cp1, const u
/* this and other blending modes previously used >>8 instead of /255. both
* are not equivalent (>>8 is /256), and the former results in rounding
* errors that can turn colors black fast after repeated blending */
- const int mfac= 255-fac;
+ const int mfac = 255 - fac;
- cp[0]= (mfac*cp1[0]+fac*cp2[0])/255;
- cp[1]= (mfac*cp1[1]+fac*cp2[1])/255;
- cp[2]= (mfac*cp1[2]+fac*cp2[2])/255;
- cp[3]= (mfac*cp1[3]+fac*cp2[3])/255;
+ cp[0] = (mfac * cp1[0] + fac * cp2[0]) / 255;
+ cp[1] = (mfac * cp1[1] + fac * cp2[1]) / 255;
+ cp[2] = (mfac * cp1[2] + fac * cp2[2]) / 255;
+ cp[3] = (mfac * cp1[3] + fac * cp2[3]) / 255;
}
static void blend_color_mix_float(float *cp, const float *cp1, const float *cp2, const float fac)
{
- const float mfac= 1.0f-fac;
- cp[0]= mfac*cp1[0] + fac*cp2[0];
- cp[1]= mfac*cp1[1] + fac*cp2[1];
- cp[2]= mfac*cp1[2] + fac*cp2[2];
- cp[3]= mfac*cp1[3] + fac*cp2[3];
+ const float mfac = 1.0f - fac;
+ cp[0] = mfac * cp1[0] + fac * cp2[0];
+ cp[1] = mfac * cp1[1] + fac * cp2[1];
+ cp[2] = mfac * cp1[2] + fac * cp2[2];
+ cp[3] = mfac * cp1[3] + fac * cp2[3];
}
static void blend_color_mix_accum(unsigned char *cp, const unsigned char *cp1, const unsigned char *cp2, const int fac)
@@ -3712,34 +3712,34 @@ static void blend_color_mix_accum(unsigned char *cp, const unsigned char *cp1, c
/* this and other blending modes previously used >>8 instead of /255. both
* are not equivalent (>>8 is /256), and the former results in rounding
* errors that can turn colors black fast after repeated blending */
- const int mfac= 255-fac;
- const int alpha= cp1[3] + ((fac * cp2[3]) / 255);
+ const int mfac = 255 - fac;
+ const int alpha = cp1[3] + ((fac * cp2[3]) / 255);
- cp[0]= (mfac*cp1[0]+fac*cp2[0])/255;
- cp[1]= (mfac*cp1[1]+fac*cp2[1])/255;
- cp[2]= (mfac*cp1[2]+fac*cp2[2])/255;
- cp[3]= alpha > 255 ? 255 : alpha;
+ cp[0] = (mfac * cp1[0] + fac * cp2[0]) / 255;
+ cp[1] = (mfac * cp1[1] + fac * cp2[1]) / 255;
+ cp[2] = (mfac * cp1[2] + fac * cp2[2]) / 255;
+ cp[3] = alpha > 255 ? 255 : alpha;
}
static void do_projectpaint_clone(ProjPaintState *ps, ProjPixel *projPixel, float alpha, float mask)
{
- if (ps->is_airbrush==0 && mask < 1.0f) {
- projPixel->newColor.uint = IMB_blend_color(projPixel->newColor.uint, ((ProjPixelClone*)projPixel)->clonepx.uint, (int)(alpha*255), ps->blend);
- blend_color_mix(projPixel->pixel.ch_pt, projPixel->origColor.ch, projPixel->newColor.ch, (int)(mask*255));
+ if (ps->is_airbrush == 0 && mask < 1.0f) {
+ projPixel->newColor.uint = IMB_blend_color(projPixel->newColor.uint, ((ProjPixelClone *)projPixel)->clonepx.uint, (int)(alpha * 255), ps->blend);
+ blend_color_mix(projPixel->pixel.ch_pt, projPixel->origColor.ch, projPixel->newColor.ch, (int)(mask * 255));
}
else {
- *projPixel->pixel.uint_pt = IMB_blend_color(*projPixel->pixel.uint_pt, ((ProjPixelClone*)projPixel)->clonepx.uint, (int)(alpha*mask*255), ps->blend);
+ *projPixel->pixel.uint_pt = IMB_blend_color(*projPixel->pixel.uint_pt, ((ProjPixelClone *)projPixel)->clonepx.uint, (int)(alpha * mask * 255), ps->blend);
}
}
static void do_projectpaint_clone_f(ProjPaintState *ps, ProjPixel *projPixel, float alpha, float mask)
{
- if (ps->is_airbrush==0 && mask < 1.0f) {
+ if (ps->is_airbrush == 0 && mask < 1.0f) {
IMB_blend_color_float(projPixel->newColor.f, projPixel->newColor.f, ((ProjPixelClone *)projPixel)->clonepx.f, alpha, ps->blend);
blend_color_mix_float(projPixel->pixel.f_pt, projPixel->origColor.f, projPixel->newColor.f, mask);
}
else {
- IMB_blend_color_float(projPixel->pixel.f_pt, projPixel->pixel.f_pt, ((ProjPixelClone *)projPixel)->clonepx.f, alpha*mask, ps->blend);
+ IMB_blend_color_float(projPixel->pixel.f_pt, projPixel->pixel.f_pt, ((ProjPixelClone *)projPixel)->clonepx.f, alpha * mask, ps->blend);
}
}
@@ -3753,10 +3753,10 @@ static void do_projectpaint_smear(ProjPaintState *ps, ProjPixel *projPixel, floa
{
unsigned char rgba_ub[4];
- if (project_paint_PickColor(ps, co, NULL, rgba_ub, 1)==0)
+ if (project_paint_PickColor(ps, co, NULL, rgba_ub, 1) == 0)
return;
/* ((ProjPixelClone *)projPixel)->clonepx.uint = IMB_blend_color(*projPixel->pixel.uint_pt, *((unsigned int *)rgba_ub), (int)(alpha*mask*255), ps->blend); */
- blend_color_mix(((ProjPixelClone *)projPixel)->clonepx.ch, projPixel->pixel.ch_pt, rgba_ub, (int)(alpha*mask*255));
+ blend_color_mix(((ProjPixelClone *)projPixel)->clonepx.ch, projPixel->pixel.ch_pt, rgba_ub, (int)(alpha * mask * 255));
BLI_linklist_prepend_arena(smearPixels, (void *)projPixel, smearArena);
}
@@ -3764,11 +3764,11 @@ static void do_projectpaint_smear_f(ProjPaintState *ps, ProjPixel *projPixel, fl
{
float rgba[4];
- if (project_paint_PickColor(ps, co, rgba, NULL, 1)==0)
+ if (project_paint_PickColor(ps, co, rgba, NULL, 1) == 0)
return;
/* (ProjPixelClone *)projPixel)->clonepx.uint = IMB_blend_color(*((unsigned int *)rgba_smear), *((unsigned int *)rgba_ub), (int)(alpha*mask*255), ps->blend); */
- blend_color_mix_float(((ProjPixelClone *)projPixel)->clonepx.f, projPixel->pixel.f_pt, rgba, alpha*mask);
+ blend_color_mix_float(((ProjPixelClone *)projPixel)->clonepx.f, projPixel->pixel.f_pt, rgba, alpha * mask);
BLI_linklist_prepend_arena(smearPixels_f, (void *)projPixel, smearArena);
}
@@ -3787,12 +3787,12 @@ static void do_projectpaint_draw(ProjPaintState *ps, ProjPixel *projPixel, float
rgba_ub[3] = 255;
}
- if (ps->is_airbrush==0 && mask < 1.0f) {
- projPixel->newColor.uint = IMB_blend_color(projPixel->newColor.uint, *((unsigned int *)rgba_ub), (int)(alpha*255), ps->blend);
- blend_color_mix(projPixel->pixel.ch_pt, projPixel->origColor.ch, projPixel->newColor.ch, (int)(mask*255));
+ if (ps->is_airbrush == 0 && mask < 1.0f) {
+ projPixel->newColor.uint = IMB_blend_color(projPixel->newColor.uint, *((unsigned int *)rgba_ub), (int)(alpha * 255), ps->blend);
+ blend_color_mix(projPixel->pixel.ch_pt, projPixel->origColor.ch, projPixel->newColor.ch, (int)(mask * 255));
}
else {
- *projPixel->pixel.uint_pt = IMB_blend_color(*projPixel->pixel.uint_pt, *((unsigned int *)rgba_ub), (int)(alpha*mask*255), ps->blend);
+ *projPixel->pixel.uint_pt = IMB_blend_color(*projPixel->pixel.uint_pt, *((unsigned int *)rgba_ub), (int)(alpha * mask * 255), ps->blend);
}
}
@@ -3819,12 +3819,12 @@ static void do_projectpaint_draw_f(ProjPaintState *ps, ProjPixel *projPixel, flo
rgba[3] = 1.0;
}
- if (ps->is_airbrush==0 && mask < 1.0f) {
+ if (ps->is_airbrush == 0 && mask < 1.0f) {
IMB_blend_color_float(projPixel->newColor.f, projPixel->newColor.f, rgba, alpha, ps->blend);
blend_color_mix_float(projPixel->pixel.f_pt, projPixel->origColor.f, projPixel->newColor.f, mask);
}
else {
- IMB_blend_color_float(projPixel->pixel.f_pt, projPixel->pixel.f_pt, rgba, alpha*mask, ps->blend);
+ IMB_blend_color_float(projPixel->pixel.f_pt, projPixel->pixel.f_pt, rgba, alpha * mask, ps->blend);
}
}
@@ -3834,18 +3834,18 @@ static void do_projectpaint_draw_f(ProjPaintState *ps, ProjPixel *projPixel, flo
static void *do_projectpaint_thread(void *ph_v)
{
/* First unpack args from the struct */
- ProjPaintState *ps = ((ProjectHandle *)ph_v)->ps;
- ProjPaintImage *projImages = ((ProjectHandle *)ph_v)->projImages;
- const float *lastpos = ((ProjectHandle *)ph_v)->prevmval;
- const float *pos = ((ProjectHandle *)ph_v)->mval;
- const int thread_index = ((ProjectHandle *)ph_v)->thread_index;
+ ProjPaintState *ps = ((ProjectHandle *)ph_v)->ps;
+ ProjPaintImage *projImages = ((ProjectHandle *)ph_v)->projImages;
+ const float *lastpos = ((ProjectHandle *)ph_v)->prevmval;
+ const float *pos = ((ProjectHandle *)ph_v)->mval;
+ const int thread_index = ((ProjectHandle *)ph_v)->thread_index;
/* Done with args from ProjectHandle */
LinkNode *node;
ProjPixel *projPixel;
int last_index = -1;
- ProjPaintImage *last_projIma= NULL;
+ ProjPaintImage *last_projIma = NULL;
ImagePaintPartialRedraw *last_partial_redraw_cell;
float rgba[4], alpha, dist_nosqrt, dist;
@@ -3862,20 +3862,20 @@ static void *do_projectpaint_thread(void *ph_v)
float co[2];
float mask = 1.0f; /* airbrush wont use mask */
unsigned short mask_short;
- const float radius= (float)brush_size(ps->scene, ps->brush);
- const float radius_squared= radius*radius; /* avoid a square root with every dist comparison */
+ const float radius = (float)brush_size(ps->scene, ps->brush);
+ const float radius_squared = radius * radius; /* avoid a square root with every dist comparison */
- short lock_alpha= ELEM(ps->brush->blend, IMB_BLEND_ERASE_ALPHA, IMB_BLEND_ADD_ALPHA) ? 0 : ps->brush->flag & BRUSH_LOCK_ALPHA;
+ short lock_alpha = ELEM(ps->brush->blend, IMB_BLEND_ERASE_ALPHA, IMB_BLEND_ADD_ALPHA) ? 0 : ps->brush->flag & BRUSH_LOCK_ALPHA;
LinkNode *smearPixels = NULL;
LinkNode *smearPixels_f = NULL;
MemArena *smearArena = NULL; /* mem arena for this brush projection only */
- if (tool==PAINT_TOOL_SMEAR) {
+ if (tool == PAINT_TOOL_SMEAR) {
pos_ofs[0] = pos[0] - lastpos[0];
pos_ofs[1] = pos[1] - lastpos[1];
- smearArena = BLI_memarena_new(1<<16, "paint smear arena");
+ smearArena = BLI_memarena_new(1 << 16, "paint smear arena");
}
/* printf("brush bounds %d %d %d %d\n", bucketMin[0], bucketMin[1], bucketMax[0], bucketMax[1]); */
@@ -3897,8 +3897,8 @@ static void *do_projectpaint_thread(void *ph_v)
bicubic_interpolation_color(ps->reproject_ibuf, projPixel->newColor.ch, NULL, projPixel->projCoSS[0], projPixel->projCoSS[1]);
if (projPixel->newColor.ch[3]) {
- mask = ((float)projPixel->mask)/65535.0f;
- blend_color_mix_accum(projPixel->pixel.ch_pt, projPixel->origColor.ch, projPixel->newColor.ch, (int)(mask*projPixel->newColor.ch[3]));
+ mask = ((float)projPixel->mask) / 65535.0f;
+ blend_color_mix_accum(projPixel->pixel.ch_pt, projPixel->origColor.ch, projPixel->newColor.ch, (int)(mask * projPixel->newColor.ch[3]));
}
}
@@ -3914,7 +3914,7 @@ static void *do_projectpaint_thread(void *ph_v)
/*if (dist < radius) {*/ /* correct but uses a sqrtf */
if (dist_nosqrt <= radius_squared) {
- dist=sqrtf(dist_nosqrt);
+ dist = sqrtf(dist_nosqrt);
falloff = brush_curve_strength_clamp(ps->brush, dist, radius);
@@ -3931,7 +3931,7 @@ static void *do_projectpaint_thread(void *ph_v)
if (ps->is_airbrush) {
/* for an aurbrush there is no real mask, so just multiply the alpha by it */
alpha *= falloff * brush_alpha(ps->scene, ps->brush);
- mask = ((float)projPixel->mask)/65535.0f;
+ mask = ((float)projPixel->mask) / 65535.0f;
}
else {
/* This brush dosnt accumulate so add some curve to the brushes falloff */
@@ -3940,7 +3940,7 @@ static void *do_projectpaint_thread(void *ph_v)
mask_short = (unsigned short)(projPixel->mask * (brush_alpha(ps->scene, ps->brush) * falloff));
if (mask_short > projPixel->mask_max) {
- mask = ((float)mask_short)/65535.0f;
+ mask = ((float)mask_short) / 65535.0f;
projPixel->mask_max = mask_short;
}
else {
@@ -3966,39 +3966,39 @@ static void *do_projectpaint_thread(void *ph_v)
last_partial_redraw_cell->x1 = MIN2(last_partial_redraw_cell->x1, projPixel->x_px);
last_partial_redraw_cell->y1 = MIN2(last_partial_redraw_cell->y1, projPixel->y_px);
- last_partial_redraw_cell->x2 = MAX2(last_partial_redraw_cell->x2, projPixel->x_px+1);
- last_partial_redraw_cell->y2 = MAX2(last_partial_redraw_cell->y2, projPixel->y_px+1);
+ last_partial_redraw_cell->x2 = MAX2(last_partial_redraw_cell->x2, projPixel->x_px + 1);
+ last_partial_redraw_cell->y2 = MAX2(last_partial_redraw_cell->y2, projPixel->y_px + 1);
- switch(tool) {
- case PAINT_TOOL_CLONE:
- if (is_floatbuf) {
- if (((ProjPixelClone *)projPixel)->clonepx.f[3]) {
- do_projectpaint_clone_f(ps, projPixel, alpha, mask); /* rgba isn't used for cloning, only alpha */
+ switch (tool) {
+ case PAINT_TOOL_CLONE:
+ if (is_floatbuf) {
+ if (((ProjPixelClone *)projPixel)->clonepx.f[3]) {
+ do_projectpaint_clone_f(ps, projPixel, alpha, mask); /* rgba isn't used for cloning, only alpha */
+ }
}
- }
- else {
- if (((ProjPixelClone*)projPixel)->clonepx.ch[3]) {
- do_projectpaint_clone(ps, projPixel, alpha, mask); /* rgba isn't used for cloning, only alpha */
+ else {
+ if (((ProjPixelClone *)projPixel)->clonepx.ch[3]) {
+ do_projectpaint_clone(ps, projPixel, alpha, mask); /* rgba isn't used for cloning, only alpha */
+ }
}
- }
- break;
- case PAINT_TOOL_SMEAR:
- sub_v2_v2v2(co, projPixel->projCoSS, pos_ofs);
-
- if (is_floatbuf) do_projectpaint_smear_f(ps, projPixel, alpha, mask, smearArena, &smearPixels_f, co);
- else do_projectpaint_smear(ps, projPixel, alpha, mask, smearArena, &smearPixels, co);
- break;
- default:
- if (is_floatbuf) do_projectpaint_draw_f(ps, projPixel, rgba, alpha, mask, use_color_correction);
- else do_projectpaint_draw(ps, projPixel, rgba, alpha, mask);
- break;
+ break;
+ case PAINT_TOOL_SMEAR:
+ sub_v2_v2v2(co, projPixel->projCoSS, pos_ofs);
+
+ if (is_floatbuf) do_projectpaint_smear_f(ps, projPixel, alpha, mask, smearArena, &smearPixels_f, co);
+ else do_projectpaint_smear(ps, projPixel, alpha, mask, smearArena, &smearPixels, co);
+ break;
+ default:
+ if (is_floatbuf) do_projectpaint_draw_f(ps, projPixel, rgba, alpha, mask, use_color_correction);
+ else do_projectpaint_draw(ps, projPixel, rgba, alpha, mask);
+ break;
}
}
if (lock_alpha) {
- if (is_floatbuf) projPixel->pixel.f_pt[3]= projPixel->origColor.f[3];
- else projPixel->pixel.ch_pt[3]= projPixel->origColor.ch[3];
+ if (is_floatbuf) projPixel->pixel.f_pt[3] = projPixel->origColor.f[3];
+ else projPixel->pixel.ch_pt[3] = projPixel->origColor.ch[3];
}
/* done painting */
@@ -4009,14 +4009,14 @@ static void *do_projectpaint_thread(void *ph_v)
}
- if (tool==PAINT_TOOL_SMEAR) {
+ if (tool == PAINT_TOOL_SMEAR) {
- for (node= smearPixels; node; node= node->next) { /* this wont run for a float image */
+ for (node = smearPixels; node; node = node->next) { /* this wont run for a float image */
projPixel = node->link;
*projPixel->pixel.uint_pt = ((ProjPixelClone *)projPixel)->clonepx.uint;
}
- for (node= smearPixels_f; node; node= node->next) {
+ for (node = smearPixels_f; node; node = node->next) {
projPixel = node->link;
copy_v4_v4(projPixel->pixel.f_pt, ((ProjPixelClone *)projPixel)->clonepx.f);
}
@@ -4035,7 +4035,7 @@ static int project_paint_op(void *state, ImBuf *UNUSED(ibufb), const float lastp
ProjectHandle handles[BLENDER_MAX_THREADS];
ListBase threads;
- int a,i;
+ int a, i;
if (!project_bucket_iter_init(ps, pos)) {
return 0;
@@ -4045,7 +4045,7 @@ static int project_paint_op(void *state, ImBuf *UNUSED(ibufb), const float lastp
BLI_init_threads(&threads, do_projectpaint_thread, ps->thread_tot);
/* get the threads running */
- for (a=0; a < ps->thread_tot; a++) {
+ for (a = 0; a < ps->thread_tot; a++) {
/* set defaults in handles */
//memset(&handles[a], 0, sizeof(BakeShade));
@@ -4062,7 +4062,7 @@ static int project_paint_op(void *state, ImBuf *UNUSED(ibufb), const float lastp
memcpy(handles[a].projImages, ps->projImages, ps->image_tot * sizeof(ProjPaintImage));
/* image bounds */
- for (i=0; i< ps->image_tot; i++) {
+ for (i = 0; i < ps->image_tot; i++) {
handles[a].projImages[i].partRedrawRect = (ImagePaintPartialRedraw *)BLI_memarena_alloc(ps->arena_mt[a], sizeof(ImagePaintPartialRedraw) * PROJ_BOUNDBOX_SQUARED);
memcpy(handles[a].projImages[i].partRedrawRect, ps->projImages[i].partRedrawRect, sizeof(ImagePaintPartialRedraw) * PROJ_BOUNDBOX_SQUARED);
}
@@ -4078,9 +4078,9 @@ static int project_paint_op(void *state, ImBuf *UNUSED(ibufb), const float lastp
/* move threaded bounds back into ps->projectPartialRedraws */
- for (i=0; i < ps->image_tot; i++) {
+ for (i = 0; i < ps->image_tot; i++) {
int touch = 0;
- for (a=0; a < ps->thread_tot; a++) {
+ for (a = 0; a < ps->thread_tot; a++) {
touch |= partial_redraw_array_merge(ps->projImages[i].partRedrawRect, handles[a].projImages[i].partRedrawRect, PROJ_BOUNDBOX_SQUARED);
}
@@ -4117,10 +4117,10 @@ static int project_paint_stroke(ProjPaintState *ps, BrushPainter *painter, const
{
int a, redraw;
- for (a=0; a < ps->image_tot; a++)
+ for (a = 0; a < ps->image_tot; a++)
partial_redraw_array_init(ps->projImages[a].partRedrawRect);
- redraw= project_paint_sub_stroke(ps, painter, prevmval_i, mval_i, time, pressure);
+ redraw = project_paint_sub_stroke(ps, painter, prevmval_i, mval_i, time, pressure);
if (project_image_refresh_tagged(ps))
return redraw;
@@ -4138,7 +4138,7 @@ static void imapaint_clear_partial_redraw(void)
static void imapaint_dirty_region(Image *ima, ImBuf *ibuf, int x, int y, int w, int h)
{
ImBuf *tmpibuf = NULL;
- int srcx= 0, srcy= 0, origx;
+ int srcx = 0, srcy = 0, origx;
IMB_rectclip(ibuf, NULL, &x, &y, &srcx, &srcy, &w, &h);
@@ -4148,15 +4148,15 @@ static void imapaint_dirty_region(Image *ima, ImBuf *ibuf, int x, int y, int w,
if (!imapaintpartial.enabled) {
imapaintpartial.x1 = x;
imapaintpartial.y1 = y;
- imapaintpartial.x2 = x+w;
- imapaintpartial.y2 = y+h;
+ imapaintpartial.x2 = x + w;
+ imapaintpartial.y2 = y + h;
imapaintpartial.enabled = 1;
}
else {
imapaintpartial.x1 = MIN2(imapaintpartial.x1, x);
imapaintpartial.y1 = MIN2(imapaintpartial.y1, y);
- imapaintpartial.x2 = MAX2(imapaintpartial.x2, x+w);
- imapaintpartial.y2 = MAX2(imapaintpartial.y2, y+h);
+ imapaintpartial.x2 = MAX2(imapaintpartial.x2, x + w);
+ imapaintpartial.y2 = MAX2(imapaintpartial.y2, y + h);
}
w = ((x + w - 1) >> IMAPAINT_TILE_BITS);
@@ -4165,7 +4165,7 @@ static void imapaint_dirty_region(Image *ima, ImBuf *ibuf, int x, int y, int w,
y = (y >> IMAPAINT_TILE_BITS);
for (; y <= h; y++)
- for (x=origx; x <= w; x++)
+ for (x = origx; x <= w; x++)
image_undo_push_tile(ima, ibuf, &tmpibuf, x, y);
ibuf->userflags |= IB_BITMAPDIRTY;
@@ -4177,7 +4177,7 @@ static void imapaint_dirty_region(Image *ima, ImBuf *ibuf, int x, int y, int w,
static void imapaint_image_update(SpaceImage *sima, Image *image, ImBuf *ibuf, short texpaint)
{
if (ibuf->rect_float)
- ibuf->userflags |= IB_RECT_INVALID; /* force recreate of char rect */
+ ibuf->userflags |= IB_RECT_INVALID; /* force recreate of char rect */
if (ibuf->mipmap[0])
ibuf->userflags |= IB_MIPMAP_INVALID;
@@ -4187,7 +4187,7 @@ static void imapaint_image_update(SpaceImage *sima, Image *image, ImBuf *ibuf, s
int w = imapaintpartial.x2 - imapaintpartial.x1;
int h = imapaintpartial.y2 - imapaintpartial.y1;
/* Testing with partial update in uv editor too */
- GPU_paint_update_image(image, imapaintpartial.x1, imapaintpartial.y1, w, h, 0);//!texpaint);
+ GPU_paint_update_image(image, imapaintpartial.x1, imapaintpartial.y1, w, h, 0); //!texpaint);
}
}
@@ -4203,7 +4203,7 @@ static void imapaint_ibuf_get_set_rgb(ImBuf *ibuf, int x, int y, short torus, sh
}
if (ibuf->rect_float) {
- float *rrgbf = ibuf->rect_float + (ibuf->x*y + x)*4;
+ float *rrgbf = ibuf->rect_float + (ibuf->x * y + x) * 4;
if (set) {
IMAPAINT_FLOAT_RGB_COPY(rrgbf, rgb);
@@ -4213,7 +4213,7 @@ static void imapaint_ibuf_get_set_rgb(ImBuf *ibuf, int x, int y, short torus, sh
}
}
else {
- char *rrgb = (char*)ibuf->rect + (ibuf->x*y + x)*4;
+ char *rrgb = (char *)ibuf->rect + (ibuf->x * y + x) * 4;
if (set) {
IMAPAINT_FLOAT_RGB_TO_CHAR(rrgb, rgb)
@@ -4256,14 +4256,14 @@ static void imapaint_lift_soften(ImBuf *ibuf, ImBuf *ibufb, int *pos, short toru
if (!torus) {
IMB_rectclip(ibuf, ibufb, &in_off[0], &in_off[1], &out_off[0],
- &out_off[1], &dim[0], &dim[1]);
+ &out_off[1], &dim[0], &dim[1]);
if ((dim[0] == 0) || (dim[1] == 0))
return;
}
- for (y=0; y < dim[1]; y++) {
- for (x=0; x < dim[0]; x++) {
+ for (y = 0; y < dim[1]; y++) {
+ for (x = 0; x < dim[0]; x++) {
/* get input pixel */
xi = in_off[0] + x;
yi = in_off[1] + y;
@@ -4271,16 +4271,16 @@ static void imapaint_lift_soften(ImBuf *ibuf, ImBuf *ibufb, int *pos, short toru
count = 1;
imapaint_ibuf_get_set_rgb(ibuf, xi, yi, torus, 0, outrgb);
- count += imapaint_ibuf_add_if(ibuf, xi-1, yi-1, outrgb, torus);
- count += imapaint_ibuf_add_if(ibuf, xi-1, yi , outrgb, torus);
- count += imapaint_ibuf_add_if(ibuf, xi-1, yi+1, outrgb, torus);
+ count += imapaint_ibuf_add_if(ibuf, xi - 1, yi - 1, outrgb, torus);
+ count += imapaint_ibuf_add_if(ibuf, xi - 1, yi, outrgb, torus);
+ count += imapaint_ibuf_add_if(ibuf, xi - 1, yi + 1, outrgb, torus);
- count += imapaint_ibuf_add_if(ibuf, xi , yi-1, outrgb, torus);
- count += imapaint_ibuf_add_if(ibuf, xi , yi+1, outrgb, torus);
+ count += imapaint_ibuf_add_if(ibuf, xi, yi - 1, outrgb, torus);
+ count += imapaint_ibuf_add_if(ibuf, xi, yi + 1, outrgb, torus);
- count += imapaint_ibuf_add_if(ibuf, xi+1, yi-1, outrgb, torus);
- count += imapaint_ibuf_add_if(ibuf, xi+1, yi , outrgb, torus);
- count += imapaint_ibuf_add_if(ibuf, xi+1, yi+1, outrgb, torus);
+ count += imapaint_ibuf_add_if(ibuf, xi + 1, yi - 1, outrgb, torus);
+ count += imapaint_ibuf_add_if(ibuf, xi + 1, yi, outrgb, torus);
+ count += imapaint_ibuf_add_if(ibuf, xi + 1, yi + 1, outrgb, torus);
outrgb[0] /= count;
outrgb[1] /= count;
@@ -4296,23 +4296,23 @@ static void imapaint_lift_soften(ImBuf *ibuf, ImBuf *ibufb, int *pos, short toru
static void imapaint_set_region(ImagePaintRegion *region, int destx, int desty, int srcx, int srcy, int width, int height)
{
- region->destx= destx;
- region->desty= desty;
- region->srcx= srcx;
- region->srcy= srcy;
- region->width= width;
- region->height= height;
+ region->destx = destx;
+ region->desty = desty;
+ region->srcx = srcx;
+ region->srcy = srcy;
+ region->width = width;
+ region->height = height;
}
static int imapaint_torus_split_region(ImagePaintRegion region[4], ImBuf *dbuf, ImBuf *sbuf)
{
- int destx= region->destx;
- int desty= region->desty;
- int srcx= region->srcx;
- int srcy= region->srcy;
- int width= region->width;
- int height= region->height;
- int origw, origh, w, h, tot= 0;
+ int destx = region->destx;
+ int desty = region->desty;
+ int srcx = region->srcx;
+ int srcy = region->srcy;
+ int width = region->width;
+ int height = region->height;
+ int origw, origh, w, h, tot = 0;
/* convert destination and source coordinates to be within image */
destx = destx % dbuf->x;
@@ -4326,8 +4326,8 @@ static int imapaint_torus_split_region(ImagePaintRegion region[4], ImBuf *dbuf,
/* clip width of blending area to destination imbuf, to avoid writing the
* same pixel twice */
- origw = w = (width > dbuf->x)? dbuf->x: width;
- origh = h = (height > dbuf->y)? dbuf->y: height;
+ origw = w = (width > dbuf->x) ? dbuf->x : width;
+ origh = h = (height > dbuf->y) ? dbuf->y : height;
/* clip within image */
IMB_rectclip(dbuf, sbuf, &destx, &desty, &srcx, &srcy, &w, &h);
@@ -4335,11 +4335,11 @@ static int imapaint_torus_split_region(ImagePaintRegion region[4], ImBuf *dbuf,
/* do 3 other rects if needed */
if (w < origw)
- imapaint_set_region(&region[tot++], (destx+w)%dbuf->x, desty, (srcx+w)%sbuf->x, srcy, origw-w, h);
+ imapaint_set_region(&region[tot++], (destx + w) % dbuf->x, desty, (srcx + w) % sbuf->x, srcy, origw - w, h);
if (h < origh)
- imapaint_set_region(&region[tot++], destx, (desty+h)%dbuf->y, srcx, (srcy+h)%sbuf->y, w, origh-h);
+ imapaint_set_region(&region[tot++], destx, (desty + h) % dbuf->y, srcx, (srcy + h) % sbuf->y, w, origh - h);
if ((w < origw) && (h < origh))
- imapaint_set_region(&region[tot++], (destx+w)%dbuf->x, (desty+h)%dbuf->y, (srcx+w)%sbuf->x, (srcy+h)%sbuf->y, origw-w, origh-h);
+ imapaint_set_region(&region[tot++], (destx + w) % dbuf->x, (desty + h) % dbuf->y, (srcx + w) % sbuf->x, (srcy + h) % sbuf->y, origw - w, origh - h);
return tot;
}
@@ -4350,46 +4350,46 @@ static void imapaint_lift_smear(ImBuf *ibuf, ImBuf *ibufb, int *pos)
int a, tot;
imapaint_set_region(region, 0, 0, pos[0], pos[1], ibufb->x, ibufb->y);
- tot= imapaint_torus_split_region(region, ibufb, ibuf);
+ tot = imapaint_torus_split_region(region, ibufb, ibuf);
- for (a=0; a<tot; a++)
+ for (a = 0; a < tot; a++)
IMB_rectblend(ibufb, ibuf, region[a].destx, region[a].desty,
- region[a].srcx, region[a].srcy,
- region[a].width, region[a].height, IMB_BLEND_COPY_RGB);
+ region[a].srcx, region[a].srcy,
+ region[a].width, region[a].height, IMB_BLEND_COPY_RGB);
}
static ImBuf *imapaint_lift_clone(ImBuf *ibuf, ImBuf *ibufb, int *pos)
{
/* note: allocImbuf returns zero'd memory, so regions outside image will
* have zero alpha, and hence not be blended onto the image */
- int w=ibufb->x, h=ibufb->y, destx=0, desty=0, srcx=pos[0], srcy=pos[1];
- ImBuf *clonebuf= IMB_allocImBuf(w, h, ibufb->planes, ibufb->flags);
+ int w = ibufb->x, h = ibufb->y, destx = 0, desty = 0, srcx = pos[0], srcy = pos[1];
+ ImBuf *clonebuf = IMB_allocImBuf(w, h, ibufb->planes, ibufb->flags);
IMB_rectclip(clonebuf, ibuf, &destx, &desty, &srcx, &srcy, &w, &h);
IMB_rectblend(clonebuf, ibuf, destx, desty, srcx, srcy, w, h,
- IMB_BLEND_COPY_RGB);
+ IMB_BLEND_COPY_RGB);
IMB_rectblend(clonebuf, ibufb, destx, desty, destx, desty, w, h,
- IMB_BLEND_COPY_ALPHA);
+ IMB_BLEND_COPY_ALPHA);
return clonebuf;
}
static void imapaint_convert_brushco(ImBuf *ibufb, const float pos[2], int ipos[2])
{
- ipos[0]= (int)floorf((pos[0] - ibufb->x/2) + 1.0f);
- ipos[1]= (int)floorf((pos[1] - ibufb->y/2) + 1.0f);
+ ipos[0] = (int)floorf((pos[0] - ibufb->x / 2) + 1.0f);
+ ipos[1] = (int)floorf((pos[1] - ibufb->y / 2) + 1.0f);
}
/* dosnt run for projection painting
* only the old style painting in the 3d view */
static int imapaint_paint_op(void *state, ImBuf *ibufb, const float lastpos[2], const float pos[2])
{
- ImagePaintState *s= ((ImagePaintState*)state);
- ImBuf *clonebuf= NULL, *frombuf;
+ ImagePaintState *s = ((ImagePaintState *)state);
+ ImBuf *clonebuf = NULL, *frombuf;
ImagePaintRegion region[4];
- short torus= s->brush->flag & BRUSH_TORUS;
- short blend= s->blend;
- float *offset= s->brush->clone.offset;
+ short torus = s->brush->flag & BRUSH_TORUS;
+ short blend = s->blend;
+ float *offset = s->brush->clone.offset;
float liftpos[2];
int bpos[2], blastpos[2], bliftpos[2];
int a, tot;
@@ -4401,41 +4401,41 @@ static int imapaint_paint_op(void *state, ImBuf *ibufb, const float lastpos[2],
imapaint_lift_soften(s->canvas, ibufb, bpos, torus);
}
else if (s->tool == PAINT_TOOL_SMEAR) {
- if (lastpos[0]==pos[0] && lastpos[1]==pos[1])
+ if (lastpos[0] == pos[0] && lastpos[1] == pos[1])
return 0;
imapaint_convert_brushco(ibufb, lastpos, blastpos);
imapaint_lift_smear(s->canvas, ibufb, blastpos);
}
else if (s->tool == PAINT_TOOL_CLONE && s->clonecanvas) {
- liftpos[0]= pos[0] - offset[0]*s->canvas->x;
- liftpos[1]= pos[1] - offset[1]*s->canvas->y;
+ liftpos[0] = pos[0] - offset[0] * s->canvas->x;
+ liftpos[1] = pos[1] - offset[1] * s->canvas->y;
imapaint_convert_brushco(ibufb, liftpos, bliftpos);
- clonebuf= imapaint_lift_clone(s->clonecanvas, ibufb, bliftpos);
+ clonebuf = imapaint_lift_clone(s->clonecanvas, ibufb, bliftpos);
}
- frombuf= (clonebuf)? clonebuf: ibufb;
+ frombuf = (clonebuf) ? clonebuf : ibufb;
if (torus) {
imapaint_set_region(region, bpos[0], bpos[1], 0, 0, frombuf->x, frombuf->y);
- tot= imapaint_torus_split_region(region, s->canvas, frombuf);
+ tot = imapaint_torus_split_region(region, s->canvas, frombuf);
}
else {
imapaint_set_region(region, bpos[0], bpos[1], 0, 0, frombuf->x, frombuf->y);
- tot= 1;
+ tot = 1;
}
/* blend into canvas */
- for (a=0; a<tot; a++) {
+ for (a = 0; a < tot; a++) {
imapaint_dirty_region(s->image, s->canvas,
- region[a].destx, region[a].desty,
- region[a].width, region[a].height);
+ region[a].destx, region[a].desty,
+ region[a].width, region[a].height);
IMB_rectblend(s->canvas, frombuf,
- region[a].destx, region[a].desty,
- region[a].srcx, region[a].srcy,
- region[a].width, region[a].height, blend);
+ region[a].destx, region[a].desty,
+ region[a].srcx, region[a].srcy,
+ region[a].width, region[a].height, blend);
}
if (clonebuf) IMB_freeImBuf(clonebuf);
@@ -4455,42 +4455,42 @@ static int texpaint_break_stroke(float *prevuv, float *fwuv, float *bkuv, float
sub_v2_v2v2(d1, fwuv, prevuv);
sub_v2_v2v2(d2, uv, bkuv);
- return ((dot_v2v2(d1, d2) < 0.0f) || (mismatch > MAX2(len1, len2)*2));
+ return ((dot_v2v2(d1, d2) < 0.0f) || (mismatch > MAX2(len1, len2) * 2));
}
/* ImagePaint Common */
static int imapaint_canvas_set(ImagePaintState *s, Image *ima)
{
- ImBuf *ibuf= BKE_image_get_ibuf(ima, s->sima? &s->sima->iuser: NULL);
+ ImBuf *ibuf = BKE_image_get_ibuf(ima, s->sima ? &s->sima->iuser : NULL);
/* verify that we can paint and set canvas */
- if (ima==NULL) {
+ if (ima == NULL) {
return 0;
}
else if (ima->packedfile && ima->rr) {
s->warnpackedfile = ima->id.name + 2;
return 0;
}
- else if (ibuf && ibuf->channels!=4) {
+ else if (ibuf && ibuf->channels != 4) {
s->warnmultifile = ima->id.name + 2;
return 0;
}
else if (!ibuf || !(ibuf->rect || ibuf->rect_float))
return 0;
- s->image= ima;
- s->canvas= ibuf;
+ s->image = ima;
+ s->canvas = ibuf;
/* set clone canvas */
if (s->tool == PAINT_TOOL_CLONE) {
- ima= s->brush->clone.image;
- ibuf= BKE_image_get_ibuf(ima, s->sima? &s->sima->iuser: NULL);
+ ima = s->brush->clone.image;
+ ibuf = BKE_image_get_ibuf(ima, s->sima ? &s->sima->iuser : NULL);
if (!ima || !ibuf || !(ibuf->rect || ibuf->rect_float))
return 0;
- s->clonecanvas= ibuf;
+ s->clonecanvas = ibuf;
/* temporarily add float rect for cloning */
if (s->canvas->rect_float && !s->clonecanvas->rect_float) {
@@ -4500,7 +4500,7 @@ static int imapaint_canvas_set(ImagePaintState *s, Image *ima)
SWAP(int, s->clonecanvas->profile, profile);
IMB_float_from_rect(s->clonecanvas);
- s->clonefreefloat= 1;
+ s->clonefreefloat = 1;
SWAP(int, s->clonecanvas->profile, profile);
}
@@ -4519,16 +4519,16 @@ static void imapaint_canvas_free(ImagePaintState *s)
static int imapaint_paint_sub_stroke(ImagePaintState *s, BrushPainter *painter, Image *image, short texpaint, float *uv, double time, int update, float pressure)
{
- ImBuf *ibuf= BKE_image_get_ibuf(image, s->sima? &s->sima->iuser: NULL);
+ ImBuf *ibuf = BKE_image_get_ibuf(image, s->sima ? &s->sima->iuser : NULL);
float pos[2];
if (!ibuf)
return 0;
- pos[0] = uv[0]*ibuf->x;
- pos[1] = uv[1]*ibuf->y;
+ pos[0] = uv[0] * ibuf->x;
+ pos[1] = uv[1] * ibuf->y;
- brush_painter_require_imbuf(painter, ((ibuf->rect_float)? 1: 0), 0, 0);
+ brush_painter_require_imbuf(painter, ((ibuf->rect_float) ? 1 : 0), 0, 0);
if (brush_painter_paint(painter, imapaint_paint_op, pos, time, pressure, s, ibuf->profile == IB_PROFILE_LINEAR_RGB)) {
if (update)
@@ -4553,7 +4553,7 @@ static int imapaint_paint_stroke(ViewContext *vc, ImagePaintState *s, BrushPaint
ImBuf *ibuf;
newimage = imapaint_face_image(s, newfaceindex);
- ibuf= BKE_image_get_ibuf(newimage, s->sima? &s->sima->iuser: NULL);
+ ibuf = BKE_image_get_ibuf(newimage, s->sima ? &s->sima->iuser : NULL);
if (ibuf && ibuf->rect)
imapaint_pick_uv(s->scene, s->ob, newfaceindex, mval, newuv);
@@ -4571,17 +4571,17 @@ static int imapaint_paint_stroke(ViewContext *vc, ImagePaintState *s, BrushPaint
imapaint_pick_uv(s->scene, s->ob, newfaceindex, prevmval, bkuv);
if (newimage == s->image)
- breakstroke= texpaint_break_stroke(s->uv, fwuv, bkuv, newuv);
+ breakstroke = texpaint_break_stroke(s->uv, fwuv, bkuv, newuv);
else
- breakstroke= 1;
+ breakstroke = 1;
}
else
- fwuv[0]= fwuv[1]= 0.0f;
+ fwuv[0] = fwuv[1] = 0.0f;
if (breakstroke) {
imapaint_pick_uv(s->scene, s->ob, s->faceindex, mval, fwuv);
redraw |= imapaint_paint_sub_stroke(s, painter, s->image, texpaint,
- fwuv, time, 1, pressure);
+ fwuv, time, 1, pressure);
imapaint_clear_partial_redraw();
brush_painter_break_stroke(painter);
}
@@ -4594,10 +4594,10 @@ static int imapaint_paint_stroke(ViewContext *vc, ImagePaintState *s, BrushPaint
/* paint in new image */
if (newimage) {
if (breakstroke)
- redraw|= imapaint_paint_sub_stroke(s, painter, newimage,
- texpaint, bkuv, time, 0, pressure);
- redraw|= imapaint_paint_sub_stroke(s, painter, newimage, texpaint,
- newuv, time, 1, pressure);
+ redraw |= imapaint_paint_sub_stroke(s, painter, newimage,
+ texpaint, bkuv, time, 0, pressure);
+ redraw |= imapaint_paint_sub_stroke(s, painter, newimage, texpaint,
+ newuv, time, 1, pressure);
}
/* update state */
@@ -4609,7 +4609,7 @@ static int imapaint_paint_stroke(ViewContext *vc, ImagePaintState *s, BrushPaint
else {
UI_view2d_region_to_view(s->v2d, mval[0], mval[1], &newuv[0], &newuv[1]);
redraw |= imapaint_paint_sub_stroke(s, painter, s->image, texpaint, newuv,
- time, 1, pressure);
+ time, 1, pressure);
}
if (redraw)
@@ -4622,16 +4622,16 @@ static int imapaint_paint_stroke(ViewContext *vc, ImagePaintState *s, BrushPaint
static Brush *image_paint_brush(bContext *C)
{
- Scene *scene= CTX_data_scene(C);
- ToolSettings *settings= scene->toolsettings;
+ Scene *scene = CTX_data_scene(C);
+ ToolSettings *settings = scene->toolsettings;
return paint_brush(&settings->imapaint.paint);
}
static Brush *uv_sculpt_brush(bContext *C)
{
- Scene *scene= CTX_data_scene(C);
- ToolSettings *settings= scene->toolsettings;
+ Scene *scene = CTX_data_scene(C);
+ ToolSettings *settings = scene->toolsettings;
if (!settings->uvsculpt)
return NULL;
@@ -4649,12 +4649,12 @@ static int image_paint_poll(bContext *C)
return 1;
}
else {
- SpaceImage *sima= CTX_wm_space_image(C);
+ SpaceImage *sima = CTX_wm_space_image(C);
if (sima) {
- ARegion *ar= CTX_wm_region(C);
+ ARegion *ar = CTX_wm_region(C);
- if ((sima->flag & SI_DRAWTOOL) && ar->regiontype==RGN_TYPE_WINDOW)
+ if ((sima->flag & SI_DRAWTOOL) && ar->regiontype == RGN_TYPE_WINDOW)
return 1;
}
}
@@ -4667,7 +4667,7 @@ static int uv_sculpt_brush_poll(bContext *C)
BMEditMesh *em;
int ret;
Object *obedit = CTX_data_edit_object(C);
- SpaceImage *sima= CTX_wm_space_image(C);
+ SpaceImage *sima = CTX_wm_space_image(C);
Scene *scene = CTX_data_scene(C);
ToolSettings *toolsettings = scene->toolsettings;
@@ -4678,8 +4678,8 @@ static int uv_sculpt_brush_poll(bContext *C)
ret = EDBM_mtexpoly_check(em);
if (ret && sima) {
- ARegion *ar= CTX_wm_region(C);
- if ((toolsettings->use_uv_sculpt) && ar->regiontype==RGN_TYPE_WINDOW)
+ ARegion *ar = CTX_wm_region(C);
+ if ((toolsettings->use_uv_sculpt) && ar->regiontype == RGN_TYPE_WINDOW)
return 1;
}
@@ -4696,7 +4696,7 @@ static int image_paint_3d_poll(bContext *C)
static int image_paint_2d_clone_poll(bContext *C)
{
- Brush *brush= image_paint_brush(C);
+ Brush *brush = image_paint_brush(C);
if (!CTX_wm_region_view3d(C) && image_paint_poll(C))
if (brush && (brush->imagepaint_tool == PAINT_TOOL_CLONE))
@@ -4740,22 +4740,22 @@ static void paint_redraw(bContext *C, ImagePaintState *s, int texpaint, int fina
GPU_free_image(s->image);
/* compositor listener deals with updating */
- WM_event_add_notifier(C, NC_IMAGE|NA_EDITED, s->image);
+ WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, s->image);
}
else {
if (!s->sima || !s->sima->lock)
ED_region_tag_redraw(CTX_wm_region(C));
else
- WM_event_add_notifier(C, NC_IMAGE|NA_EDITED, s->image);
+ WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, s->image);
}
}
/* initialize project paint settings from context */
static void project_state_init(bContext *C, Object *ob, ProjPaintState *ps)
{
- Scene *scene= CTX_data_scene(C);
- ToolSettings *settings= scene->toolsettings;
- Brush *brush= paint_brush(&settings->imapaint.paint);
+ Scene *scene = CTX_data_scene(C);
+ ToolSettings *settings = scene->toolsettings;
+ Brush *brush = paint_brush(&settings->imapaint.paint);
/* brush */
ps->brush = brush;
@@ -4767,12 +4767,12 @@ static void project_state_init(bContext *C, Object *ob, ProjPaintState *ps)
/* these can be NULL */
- ps->v3d= CTX_wm_view3d(C);
- ps->rv3d= CTX_wm_region_view3d(C);
- ps->ar= CTX_wm_region(C);
+ ps->v3d = CTX_wm_view3d(C);
+ ps->rv3d = CTX_wm_region_view3d(C);
+ ps->ar = CTX_wm_region(C);
- ps->scene= scene;
- ps->ob= ob; /* allow override of active object */
+ ps->scene = scene;
+ ps->ob = ob; /* allow override of active object */
/* setup projection painting data */
ps->do_backfacecull = (settings->imapaint.flag & IMAGEPAINT_PROJECT_BACKFACE) ? 0 : 1;
@@ -4796,37 +4796,37 @@ static void project_state_init(bContext *C, Object *ob, ProjPaintState *ps)
ps->normal_angle = (ps->normal_angle_inner + 90.0f) * 0.5f;
}
else {
- ps->normal_angle_inner= ps->normal_angle= settings->imapaint.normal_angle;
+ ps->normal_angle_inner = ps->normal_angle = settings->imapaint.normal_angle;
}
- ps->normal_angle_inner *= (float)(M_PI_2 / 90);
- ps->normal_angle *= (float)(M_PI_2 / 90);
+ ps->normal_angle_inner *= (float)(M_PI_2 / 90);
+ ps->normal_angle *= (float)(M_PI_2 / 90);
ps->normal_angle_range = ps->normal_angle - ps->normal_angle_inner;
if (ps->normal_angle_range <= 0.0f)
- ps->do_mask_normal = 0; /* no need to do blending */
+ ps->do_mask_normal = 0; /* no need to do blending */
}
static void paint_brush_init_tex(Brush *brush)
{
/* init mtex nodes */
if (brush) {
- MTex *mtex= &brush->mtex;
+ MTex *mtex = &brush->mtex;
if (mtex->tex && mtex->tex->nodetree)
- ntreeTexBeginExecTree(mtex->tex->nodetree, 1); /* has internal flag to detect it only does it once */
+ ntreeTexBeginExecTree(mtex->tex->nodetree, 1); /* has internal flag to detect it only does it once */
}
}
static int texture_paint_init(bContext *C, wmOperator *op)
{
- Scene *scene= CTX_data_scene(C);
- ToolSettings *settings= scene->toolsettings;
- Brush *brush= paint_brush(&settings->imapaint.paint);
- PaintOperation *pop= MEM_callocN(sizeof(PaintOperation), "PaintOperation"); /* caller frees */
+ Scene *scene = CTX_data_scene(C);
+ ToolSettings *settings = scene->toolsettings;
+ Brush *brush = paint_brush(&settings->imapaint.paint);
+ PaintOperation *pop = MEM_callocN(sizeof(PaintOperation), "PaintOperation"); /* caller frees */
- pop->first= 1;
- op->customdata= pop;
+ pop->first = 1;
+ op->customdata = pop;
/* XXX: Soften tool does not support projection painting atm, so just disable
* projection for this brush */
@@ -4837,27 +4837,27 @@ static int texture_paint_init(bContext *C, wmOperator *op)
/* initialize from context */
if (CTX_wm_region_view3d(C)) {
- pop->mode= PAINT_MODE_3D;
+ pop->mode = PAINT_MODE_3D;
if (!(settings->imapaint.flag & IMAGEPAINT_PROJECT_DISABLE))
- pop->mode= PAINT_MODE_3D_PROJECT;
+ pop->mode = PAINT_MODE_3D_PROJECT;
else
view3d_set_viewcontext(C, &pop->vc);
}
else {
- pop->s.sima= CTX_wm_space_image(C);
- pop->s.v2d= &CTX_wm_region(C)->v2d;
+ pop->s.sima = CTX_wm_space_image(C);
+ pop->s.v2d = &CTX_wm_region(C)->v2d;
}
- pop->s.scene= scene;
- pop->s.screen= CTX_wm_screen(C);
+ pop->s.scene = scene;
+ pop->s.screen = CTX_wm_screen(C);
pop->s.brush = brush;
pop->s.tool = brush->imagepaint_tool;
if (pop->mode == PAINT_MODE_3D && (pop->s.tool == PAINT_TOOL_CLONE))
pop->s.tool = PAINT_TOOL_DRAW;
pop->s.blend = brush->blend;
- pop->orig_brush_size= brush_size(scene, brush);
+ pop->orig_brush_size = brush_size(scene, brush);
if (pop->mode != PAINT_MODE_2D) {
Object *ob = OBACT;
@@ -4872,7 +4872,7 @@ static int texture_paint_init(bContext *C, wmOperator *op)
/* for non prohect paint we need */
/* fill in derived mesh */
- if (ob->derivedFinal && CustomData_has_layer( &ob->derivedFinal->faceData, CD_MTFACE)) {
+ if (ob->derivedFinal && CustomData_has_layer(&ob->derivedFinal->faceData, CD_MTFACE)) {
pop->s.dm = ob->derivedFinal;
pop->s.dm_release = FALSE;
}
@@ -4891,7 +4891,7 @@ static int texture_paint_init(bContext *C, wmOperator *op)
}
pop->s.dm_mface = pop->s.dm->getTessFaceArray(pop->s.dm);
- pop->s.dm_mtface= pop->s.dm->getTessFaceDataArray(pop->s.dm, CD_MTFACE);
+ pop->s.dm_mtface = pop->s.dm->getTessFaceDataArray(pop->s.dm, CD_MTFACE);
pop->s.dm_totface = pop->s.dm->getNumTessFaces(pop->s.dm);
}
else {
@@ -4917,9 +4917,9 @@ static int texture_paint_init(bContext *C, wmOperator *op)
paint_brush_init_tex(pop->ps.brush);
- pop->ps.source= PROJ_SRC_VIEW;
+ pop->ps.source = PROJ_SRC_VIEW;
- if (pop->ps.ob==NULL || !(pop->ps.ob->lay & pop->ps.v3d->lay))
+ if (pop->ps.ob == NULL || !(pop->ps.ob->lay & pop->ps.v3d->lay))
return 0;
/* Don't allow brush size below 2 */
@@ -4929,23 +4929,23 @@ static int texture_paint_init(bContext *C, wmOperator *op)
/* allocate and initialize spacial data structures */
project_paint_begin(&pop->ps);
- if (pop->ps.dm==NULL)
+ if (pop->ps.dm == NULL)
return 0;
}
settings->imapaint.flag |= IMAGEPAINT_DRAWING;
undo_paint_push_begin(UNDO_PAINT_IMAGE, op->type->name,
- image_undo_restore, image_undo_free);
+ image_undo_restore, image_undo_free);
/* create painter */
- pop->painter= brush_painter_new(scene, pop->s.brush);
+ pop->painter = brush_painter_new(scene, pop->s.brush);
return 1;
}
static void paint_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
{
- PaintOperation *pop= op->customdata;
+ PaintOperation *pop = op->customdata;
float time, mousef[2];
float pressure;
int mouse[2], redraw;
@@ -4953,8 +4953,8 @@ static void paint_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
RNA_float_get_array(itemptr, "mouse", mousef);
mouse[0] = (int)(mousef[0]);
mouse[1] = (int)(mousef[1]);
- time= RNA_float_get(itemptr, "time");
- pressure= RNA_float_get(itemptr, "pressure");
+ time = RNA_float_get(itemptr, "time");
+ pressure = RNA_float_get(itemptr, "pressure");
if (pop->first)
project_paint_begin_clone(&pop->ps, mouse);
@@ -4963,27 +4963,27 @@ static void paint_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
view3d_operator_needs_opengl(C);
if (pop->mode == PAINT_MODE_3D_PROJECT) {
- redraw= project_paint_stroke(&pop->ps, pop->painter, pop->prevmouse, mouse, time, pressure);
- pop->prevmouse[0]= mouse[0];
- pop->prevmouse[1]= mouse[1];
+ redraw = project_paint_stroke(&pop->ps, pop->painter, pop->prevmouse, mouse, time, pressure);
+ pop->prevmouse[0] = mouse[0];
+ pop->prevmouse[1] = mouse[1];
}
else {
- redraw= imapaint_paint_stroke(&pop->vc, &pop->s, pop->painter, pop->mode == PAINT_MODE_3D, pop->prevmouse, mouse, time, pressure);
- pop->prevmouse[0]= mouse[0];
- pop->prevmouse[1]= mouse[1];
+ redraw = imapaint_paint_stroke(&pop->vc, &pop->s, pop->painter, pop->mode == PAINT_MODE_3D, pop->prevmouse, mouse, time, pressure);
+ pop->prevmouse[0] = mouse[0];
+ pop->prevmouse[1] = mouse[1];
}
if (redraw)
paint_redraw(C, &pop->s, pop->mode == PAINT_MODE_3D, 0);
- pop->first= 0;
+ pop->first = 0;
}
static void paint_brush_exit_tex(Brush *brush)
{
if (brush) {
- MTex *mtex= &brush->mtex;
+ MTex *mtex = &brush->mtex;
if (mtex->tex && mtex->tex->nodetree)
ntreeTexEndExecTree(mtex->tex->nodetree->execdata, 1);
}
@@ -4991,9 +4991,9 @@ static void paint_brush_exit_tex(Brush *brush)
static void paint_exit(bContext *C, wmOperator *op)
{
- Scene *scene= CTX_data_scene(C);
- ToolSettings *settings= scene->toolsettings;
- PaintOperation *pop= op->customdata;
+ Scene *scene = CTX_data_scene(C);
+ ToolSettings *settings = scene->toolsettings;
+ PaintOperation *pop = op->customdata;
if (pop->timer)
WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), pop->timer);
@@ -5050,34 +5050,34 @@ static int paint_exec(bContext *C, wmOperator *op)
static void paint_apply_event(bContext *C, wmOperator *op, wmEvent *event)
{
const Scene *scene = CTX_data_scene(C);
- PaintOperation *pop= op->customdata;
+ PaintOperation *pop = op->customdata;
wmTabletData *wmtab;
PointerRNA itemptr;
float pressure, mousef[2];
double time;
int tablet;
- time= PIL_check_seconds_timer();
+ time = PIL_check_seconds_timer();
- tablet= 0;
- pop->s.blend= pop->s.brush->blend;
+ tablet = 0;
+ pop->s.blend = pop->s.brush->blend;
if (event->custom == EVT_DATA_TABLET) {
- wmtab= event->customdata;
+ wmtab = event->customdata;
- tablet= (wmtab->Active != EVT_TABLET_NONE);
- pressure= wmtab->Pressure;
+ tablet = (wmtab->Active != EVT_TABLET_NONE);
+ pressure = wmtab->Pressure;
if (wmtab->Active == EVT_TABLET_ERASER)
- pop->s.blend= IMB_BLEND_ERASE_ALPHA;
+ pop->s.blend = IMB_BLEND_ERASE_ALPHA;
}
else { /* otherwise airbrush becomes 1.0 pressure instantly */
- pressure= pop->prev_pressure ? pop->prev_pressure : 1.0f;
+ pressure = pop->prev_pressure ? pop->prev_pressure : 1.0f;
}
if (pop->first) {
- pop->prevmouse[0]= event->mval[0];
- pop->prevmouse[1]= event->mval[1];
- pop->starttime= time;
+ pop->prevmouse[0] = event->mval[0];
+ pop->prevmouse[1] = event->mval[1];
+ pop->starttime = time;
/* special exception here for too high pressure values on first touch in
* windows for some tablets, then we just skip first touch .. */
@@ -5104,7 +5104,7 @@ static void paint_apply_event(bContext *C, wmOperator *op, wmEvent *event)
/* apply */
paint_apply(C, op, &itemptr);
- pop->prev_pressure= pressure;
+ pop->prev_pressure = pressure;
}
static int paint_invoke(bContext *C, wmOperator *op, wmEvent *event)
@@ -5118,20 +5118,20 @@ static int paint_invoke(bContext *C, wmOperator *op, wmEvent *event)
paint_apply_event(C, op, event);
- pop= op->customdata;
+ pop = op->customdata;
WM_event_add_modal_handler(C, op);
if (pop->s.brush->flag & BRUSH_AIRBRUSH)
- pop->timer= WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER, 0.01f);
+ pop->timer = WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER, 0.01f);
return OPERATOR_RUNNING_MODAL;
}
static int paint_modal(bContext *C, wmOperator *op, wmEvent *event)
{
- PaintOperation *pop= op->customdata;
+ PaintOperation *pop = op->customdata;
- switch(event->type) {
+ switch (event->type) {
case LEFTMOUSE:
case MIDDLEMOUSE:
case RIGHTMOUSE: // XXX hardcoded
@@ -5171,7 +5171,7 @@ void PAINT_OT_image_paint(wmOperatorType *ot)
ot->poll = image_paint_poll;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_BLOCKING;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_BLOCKING;
/* properties */
RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", "");
@@ -5179,11 +5179,11 @@ void PAINT_OT_image_paint(wmOperatorType *ot)
int get_imapaint_zoom(bContext *C, float *zoomx, float *zoomy)
{
- RegionView3D *rv3d= CTX_wm_region_view3d(C);
+ RegionView3D *rv3d = CTX_wm_region_view3d(C);
if (!rv3d) {
- SpaceImage *sima= CTX_wm_space_image(C);
- ARegion *ar= CTX_wm_region(C);
+ SpaceImage *sima = CTX_wm_space_image(C);
+ ARegion *ar = CTX_wm_region(C);
ED_space_image_zoom(sima, ar, zoomx, zoomy);
@@ -5202,22 +5202,22 @@ static void brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customdata)
#define PX_SIZE_FADE_MAX 12.0f
#define PX_SIZE_FADE_MIN 4.0f
- Scene *scene= CTX_data_scene(C);
+ Scene *scene = CTX_data_scene(C);
//Brush *brush= image_paint_brush(C);
- Paint *paint= paint_get_active(scene);
- Brush *brush= paint_brush(paint);
+ Paint *paint = paint_get_active(scene);
+ Brush *brush = paint_brush(paint);
if (paint && brush && paint->flags & PAINT_SHOW_BRUSH) {
ToolSettings *ts;
float zoomx, zoomy;
- const float size= (float)brush_size(scene, brush);
+ const float size = (float)brush_size(scene, brush);
short use_zoom;
float pixel_size;
- float alpha= 0.5f;
+ float alpha = 0.5f;
ts = scene->toolsettings;
- use_zoom= get_imapaint_zoom(C, &zoomx, &zoomy)
- && !(ts->use_uv_sculpt && (scene->basact->object->mode == OB_MODE_EDIT));
+ use_zoom = get_imapaint_zoom(C, &zoomx, &zoomy)
+ && !(ts->use_uv_sculpt && (scene->basact->object->mode == OB_MODE_EDIT));
if (use_zoom) {
pixel_size = MAX2(size * zoomx, size * zoomy);
@@ -5243,11 +5243,11 @@ static void brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customdata)
glScalef(zoomx, zoomy, 1.0f);
glColor4f(brush->add_col[0], brush->add_col[1], brush->add_col[2], alpha);
- glEnable( GL_LINE_SMOOTH );
+ glEnable(GL_LINE_SMOOTH);
glEnable(GL_BLEND);
- glutil_draw_lined_arc(0, (float)(M_PI*2.0), size, 40);
+ glutil_draw_lined_arc(0, (float)(M_PI * 2.0), size, 40);
glDisable(GL_BLEND);
- glDisable( GL_LINE_SMOOTH );
+ glDisable(GL_LINE_SMOOTH);
glPopMatrix();
}
@@ -5257,16 +5257,16 @@ static void brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customdata)
static void toggle_paint_cursor(bContext *C, int enable)
{
- wmWindowManager *wm= CTX_wm_manager(C);
+ wmWindowManager *wm = CTX_wm_manager(C);
Scene *scene = CTX_data_scene(C);
- ToolSettings *settings= scene->toolsettings;
+ ToolSettings *settings = scene->toolsettings;
if (settings->imapaint.paintcursor && !enable) {
WM_paint_cursor_end(wm, settings->imapaint.paintcursor);
settings->imapaint.paintcursor = NULL;
}
else if (enable)
- settings->imapaint.paintcursor= WM_paint_cursor_activate(wm, image_paint_poll, brush_drawcursor, NULL);
+ settings->imapaint.paintcursor = WM_paint_cursor_activate(wm, image_paint_poll, brush_drawcursor, NULL);
}
/* enable the paint cursor if it isn't already.
@@ -5280,8 +5280,8 @@ void ED_space_image_paint_update(wmWindowManager *wm, ToolSettings *settings)
if (!imapaint->paintcursor) {
imapaint->paintcursor =
- WM_paint_cursor_activate(wm, image_paint_poll,
- brush_drawcursor, NULL);
+ WM_paint_cursor_activate(wm, image_paint_poll,
+ brush_drawcursor, NULL);
}
}
@@ -5299,7 +5299,7 @@ void ED_space_image_uv_sculpt_update(wmWindowManager *wm, ToolSettings *settings
paint_init(&settings->uvsculpt->paint, PAINT_CURSOR_SCULPT);
WM_paint_cursor_activate(wm, uv_sculpt_brush_poll,
- brush_drawcursor, NULL);
+ brush_drawcursor, NULL);
}
else {
if (settings->uvsculpt)
@@ -5315,7 +5315,7 @@ typedef struct GrabClone {
static void grab_clone_apply(bContext *C, wmOperator *op)
{
- Brush *brush= image_paint_brush(C);
+ Brush *brush = image_paint_brush(C);
float delta[2];
RNA_float_get_array(op->ptr, "delta", delta);
@@ -5332,14 +5332,14 @@ static int grab_clone_exec(bContext *C, wmOperator *op)
static int grab_clone_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
- Brush *brush= image_paint_brush(C);
+ Brush *brush = image_paint_brush(C);
GrabClone *cmv;
- cmv= MEM_callocN(sizeof(GrabClone), "GrabClone");
+ cmv = MEM_callocN(sizeof(GrabClone), "GrabClone");
copy_v2_v2(cmv->startoffset, brush->clone.offset);
- cmv->startx= event->x;
- cmv->starty= event->y;
- op->customdata= cmv;
+ cmv->startx = event->x;
+ cmv->starty = event->y;
+ op->customdata = cmv;
WM_event_add_modal_handler(C, op);
@@ -5348,13 +5348,13 @@ static int grab_clone_invoke(bContext *C, wmOperator *op, wmEvent *event)
static int grab_clone_modal(bContext *C, wmOperator *op, wmEvent *event)
{
- Brush *brush= image_paint_brush(C);
- ARegion *ar= CTX_wm_region(C);
- GrabClone *cmv= op->customdata;
+ Brush *brush = image_paint_brush(C);
+ ARegion *ar = CTX_wm_region(C);
+ GrabClone *cmv = op->customdata;
float startfx, startfy, fx, fy, delta[2];
- int xmin= ar->winrct.xmin, ymin= ar->winrct.ymin;
+ int xmin = ar->winrct.xmin, ymin = ar->winrct.ymin;
- switch(event->type) {
+ switch (event->type) {
case LEFTMOUSE:
case MIDDLEMOUSE:
case RIGHTMOUSE: // XXX hardcoded
@@ -5365,8 +5365,8 @@ static int grab_clone_modal(bContext *C, wmOperator *op, wmEvent *event)
UI_view2d_region_to_view(&ar->v2d, cmv->startx - xmin, cmv->starty - ymin, &startfx, &startfy);
UI_view2d_region_to_view(&ar->v2d, event->x - xmin, event->y - ymin, &fx, &fy);
- delta[0]= fx - startfx;
- delta[1]= fy - startfy;
+ delta[0] = fx - startfx;
+ delta[1] = fy - startfy;
RNA_float_set_array(op->ptr, "delta", delta);
copy_v2_v2(brush->clone.offset, cmv->startoffset);
@@ -5398,7 +5398,7 @@ void PAINT_OT_grab_clone(wmOperatorType *ot)
ot->poll = image_paint_2d_clone_poll;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* properties */
RNA_def_float_vector(ot->srna, "delta", 2, NULL, -FLT_MAX, FLT_MAX, "Delta", "Delta offset of clone image in 0.0..1.0 coordinates", -1.0f, 1.0f);
@@ -5408,15 +5408,15 @@ void PAINT_OT_grab_clone(wmOperatorType *ot)
static int sample_color_exec(bContext *C, wmOperator *op)
{
- Scene *scene= CTX_data_scene(C);
- Brush *brush= image_paint_brush(C);
- ARegion *ar= CTX_wm_region(C);
+ Scene *scene = CTX_data_scene(C);
+ Brush *brush = image_paint_brush(C);
+ ARegion *ar = CTX_wm_region(C);
int location[2];
RNA_int_get_array(op->ptr, "location", location);
paint_sample_color(scene, ar, location[0], location[1]);
- WM_event_add_notifier(C, NC_BRUSH|NA_EDITED, brush);
+ WM_event_add_notifier(C, NC_BRUSH | NA_EDITED, brush);
return OPERATOR_FINISHED;
}
@@ -5433,7 +5433,7 @@ static int sample_color_invoke(bContext *C, wmOperator *op, wmEvent *event)
static int sample_color_modal(bContext *C, wmOperator *op, wmEvent *event)
{
- switch(event->type) {
+ switch (event->type) {
case LEFTMOUSE:
case RIGHTMOUSE: // XXX hardcoded
return OPERATOR_FINISHED;
@@ -5453,7 +5453,7 @@ static int image_paint_sample_color_poll(bContext *C)
if (CTX_wm_view3d(C)) {
Object *obact = CTX_data_active_object(C);
if (obact && obact->mode & OB_MODE_TEXTURE_PAINT) {
- Mesh *me= get_mesh(obact);
+ Mesh *me = get_mesh(obact);
if (me) {
return !(me->editflag & ME_EDIT_PAINT_MASK);
}
@@ -5479,7 +5479,7 @@ void PAINT_OT_sample_color(wmOperatorType *ot)
ot->poll = image_paint_sample_color_poll;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
RNA_def_int_vector(ot->srna, "location", 2, NULL, 0, INT_MAX, "Location", "Cursor location in region coordinates", 0, 16384);
@@ -5489,9 +5489,9 @@ void PAINT_OT_sample_color(wmOperatorType *ot)
static int set_clone_cursor_exec(bContext *C, wmOperator *op)
{
- Scene *scene= CTX_data_scene(C);
- View3D *v3d= CTX_wm_view3d(C);
- float *cursor= give_cursor(scene, v3d);
+ Scene *scene = CTX_data_scene(C);
+ View3D *v3d = CTX_wm_view3d(C);
+ float *cursor = give_cursor(scene, v3d);
RNA_float_get_array(op->ptr, "location", cursor);
@@ -5502,9 +5502,9 @@ static int set_clone_cursor_exec(bContext *C, wmOperator *op)
static int set_clone_cursor_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
- Scene *scene= CTX_data_scene(C);
- View3D *v3d= CTX_wm_view3d(C);
- ARegion *ar= CTX_wm_region(C);
+ Scene *scene = CTX_data_scene(C);
+ View3D *v3d = CTX_wm_view3d(C);
+ ARegion *ar = CTX_wm_region(C);
float location[3];
view3d_operator_needs_opengl(C);
@@ -5529,7 +5529,7 @@ void PAINT_OT_clone_cursor_set(wmOperatorType *ot)
ot->poll = image_paint_3d_poll;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
RNA_def_float_vector(ot->srna, "location", 3, NULL, -FLT_MAX, FLT_MAX, "Location", "Cursor location in world space coordinates", -10000.0f, 10000.0f);
@@ -5541,7 +5541,7 @@ static int texture_paint_toggle_poll(bContext *C)
{
if (CTX_data_edit_object(C))
return 0;
- if (CTX_data_active_object(C)==NULL)
+ if (CTX_data_active_object(C) == NULL)
return 0;
return 1;
@@ -5549,11 +5549,11 @@ static int texture_paint_toggle_poll(bContext *C)
static int texture_paint_toggle_exec(bContext *C, wmOperator *op)
{
- Scene *scene= CTX_data_scene(C);
- Object *ob= CTX_data_active_object(C);
- Mesh *me= NULL;
+ Scene *scene = CTX_data_scene(C);
+ Object *ob = CTX_data_active_object(C);
+ Mesh *me = NULL;
- if (ob==NULL)
+ if (ob == NULL)
return OPERATOR_CANCELLED;
if (object_data_is_libdata(ob)) {
@@ -5561,7 +5561,7 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- me= get_mesh(ob);
+ me = get_mesh(ob);
if (!(ob->mode & OB_MODE_TEXTURE_PAINT) && !me) {
BKE_report(op->reports, RPT_ERROR, "Can only enter texture paint mode for mesh objects");
@@ -5580,9 +5580,9 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op)
else {
ob->mode |= OB_MODE_TEXTURE_PAINT;
- if (me->mtface==NULL)
- me->mtface= CustomData_add_layer(&me->fdata, CD_MTFACE, CD_DEFAULT,
- NULL, me->totface);
+ if (me->mtface == NULL)
+ me->mtface = CustomData_add_layer(&me->fdata, CD_MTFACE, CD_DEFAULT,
+ NULL, me->totface);
paint_init(&scene->toolsettings->imapaint.paint, PAINT_CURSOR_TEXTURE_PAINT);
@@ -5594,7 +5594,7 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op)
}
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
- WM_event_add_notifier(C, NC_SCENE|ND_MODE, scene);
+ WM_event_add_notifier(C, NC_SCENE | ND_MODE, scene);
return OPERATOR_FINISHED;
}
@@ -5610,7 +5610,7 @@ void PAINT_OT_texture_paint_toggle(wmOperatorType *ot)
ot->poll = texture_paint_toggle_poll;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int texture_paint_poll(bContext *C)
@@ -5649,37 +5649,37 @@ int mask_paint_poll(bContext *C)
/* use project paint to re-apply an image */
static int texture_paint_camera_project_exec(bContext *C, wmOperator *op)
{
- Image *image= BLI_findlink(&CTX_data_main(C)->image, RNA_enum_get(op->ptr, "image"));
- Scene *scene= CTX_data_scene(C);
- ProjPaintState ps= {NULL};
+ Image *image = BLI_findlink(&CTX_data_main(C)->image, RNA_enum_get(op->ptr, "image"));
+ Scene *scene = CTX_data_scene(C);
+ ProjPaintState ps = {NULL};
int orig_brush_size;
IDProperty *idgroup;
- IDProperty *view_data= NULL;
+ IDProperty *view_data = NULL;
project_state_init(C, OBACT, &ps);
- if (ps.ob==NULL || ps.ob->type != OB_MESH) {
+ if (ps.ob == NULL || ps.ob->type != OB_MESH) {
BKE_report(op->reports, RPT_ERROR, "No active mesh object");
return OPERATOR_CANCELLED;
}
- if (image==NULL) {
+ if (image == NULL) {
BKE_report(op->reports, RPT_ERROR, "Image could not be found");
return OPERATOR_CANCELLED;
}
- ps.reproject_image= image;
- ps.reproject_ibuf= BKE_image_get_ibuf(image, NULL);
+ ps.reproject_image = image;
+ ps.reproject_ibuf = BKE_image_get_ibuf(image, NULL);
- if (ps.reproject_ibuf==NULL || ps.reproject_ibuf->rect==NULL) {
+ if (ps.reproject_ibuf == NULL || ps.reproject_ibuf->rect == NULL) {
BKE_report(op->reports, RPT_ERROR, "Image data could not be found");
return OPERATOR_CANCELLED;
}
- idgroup= IDP_GetProperties(&image->id, 0);
+ idgroup = IDP_GetProperties(&image->id, 0);
if (idgroup) {
- view_data= IDP_GetPropertyTypeFromGroup(idgroup, PROJ_VIEW_DATA_ID, IDP_ARRAY);
+ view_data = IDP_GetPropertyTypeFromGroup(idgroup, PROJ_VIEW_DATA_ID, IDP_ARRAY);
/* type check to make sure its ok */
if (view_data->len != PROJ_VIEW_DATA_SIZE || view_data->subtype != IDP_FLOAT) {
@@ -5690,52 +5690,52 @@ static int texture_paint_camera_project_exec(bContext *C, wmOperator *op)
if (view_data) {
/* image has stored view projection info */
- ps.source= PROJ_SRC_IMAGE_VIEW;
+ ps.source = PROJ_SRC_IMAGE_VIEW;
}
else {
- ps.source= PROJ_SRC_IMAGE_CAM;
+ ps.source = PROJ_SRC_IMAGE_CAM;
- if (scene->camera==NULL) {
+ if (scene->camera == NULL) {
BKE_report(op->reports, RPT_ERROR, "No active camera set");
return OPERATOR_CANCELLED;
}
}
/* override */
- ps.is_texbrush= 0;
- ps.is_airbrush= 1;
- orig_brush_size= brush_size(scene, ps.brush);
+ ps.is_texbrush = 0;
+ ps.is_airbrush = 1;
+ orig_brush_size = brush_size(scene, ps.brush);
brush_set_size(scene, ps.brush, 32); /* cover the whole image */
- ps.tool= PAINT_TOOL_DRAW; /* so pixels are initialized with minimal info */
+ ps.tool = PAINT_TOOL_DRAW; /* so pixels are initialized with minimal info */
scene->toolsettings->imapaint.flag |= IMAGEPAINT_DRAWING;
undo_paint_push_begin(UNDO_PAINT_IMAGE, op->type->name,
- image_undo_restore, image_undo_free);
+ image_undo_restore, image_undo_free);
/* allocate and initialize spacial data structures */
project_paint_begin(&ps);
- if (ps.dm==NULL) {
+ if (ps.dm == NULL) {
brush_set_size(scene, ps.brush, orig_brush_size);
return OPERATOR_CANCELLED;
}
else {
- float pos[2]= {0.0, 0.0};
- float lastpos[2]= {0.0, 0.0};
+ float pos[2] = {0.0, 0.0};
+ float lastpos[2] = {0.0, 0.0};
int a;
- for (a=0; a < ps.image_tot; a++)
+ for (a = 0; a < ps.image_tot; a++)
partial_redraw_array_init(ps.projImages[a].partRedrawRect);
project_paint_op(&ps, NULL, lastpos, pos);
project_image_refresh_tagged(&ps);
- for (a=0; a < ps.image_tot; a++) {
+ for (a = 0; a < ps.image_tot; a++) {
GPU_free_image(ps.projImages[a].ima);
- WM_event_add_notifier(C, NC_IMAGE|NA_EDITED, ps.projImages[a].ima);
+ WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, ps.projImages[a].ima);
}
}
@@ -5761,9 +5761,9 @@ void PAINT_OT_project_image(wmOperatorType *ot)
ot->exec = texture_paint_camera_project_exec;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- prop= RNA_def_enum(ot->srna, "image", DummyRNA_NULL_items, 0, "Image", "");
+ prop = RNA_def_enum(ot->srna, "image", DummyRNA_NULL_items, 0, "Image", "");
RNA_def_enum_funcs(prop, RNA_image_itemf);
ot->prop = prop;
}
@@ -5774,21 +5774,21 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op)
ImBuf *ibuf;
char filename[FILE_MAX];
- Scene *scene= CTX_data_scene(C);
- ToolSettings *settings= scene->toolsettings;
- int w= settings->imapaint.screen_grab_size[0];
- int h= settings->imapaint.screen_grab_size[1];
+ Scene *scene = CTX_data_scene(C);
+ ToolSettings *settings = scene->toolsettings;
+ int w = settings->imapaint.screen_grab_size[0];
+ int h = settings->imapaint.screen_grab_size[1];
int maxsize;
- char err_out[256]= "unknown";
+ char err_out[256] = "unknown";
RNA_string_get(op->ptr, "filepath", filename);
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxsize);
- if (w > maxsize) w= maxsize;
- if (h > maxsize) h= maxsize;
+ if (w > maxsize) w = maxsize;
+ if (h > maxsize) h = maxsize;
- ibuf= ED_view3d_draw_offscreen_imbuf(CTX_data_scene(C), CTX_wm_view3d(C), CTX_wm_region(C), w, h, IB_rect, FALSE, err_out);
+ ibuf = ED_view3d_draw_offscreen_imbuf(CTX_data_scene(C), CTX_wm_view3d(C), CTX_wm_region(C), w, h, IB_rect, FALSE, err_out);
if (!ibuf) {
/* Mostly happens when OpenGL offscreen buffer was failed to create, */
/* but could be other reasons. Should be handled in the future. nazgul */
@@ -5796,16 +5796,16 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- image= BKE_add_image_imbuf(ibuf);
+ image = BKE_add_image_imbuf(ibuf);
if (image) {
/* now for the trickyness. store the view projection here!
* re-projection will reuse this */
- View3D *v3d= CTX_wm_view3d(C);
- RegionView3D *rv3d= CTX_wm_region_view3d(C);
+ View3D *v3d = CTX_wm_view3d(C);
+ RegionView3D *rv3d = CTX_wm_region_view3d(C);
IDPropertyTemplate val;
- IDProperty *idgroup= IDP_GetProperties(&image->id, 1);
+ IDProperty *idgroup = IDP_GetProperties(&image->id, 1);
IDProperty *view_data;
int orth;
float *array;
@@ -5814,11 +5814,11 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op)
val.array.type = IDP_FLOAT;
view_data = IDP_New(IDP_ARRAY, &val, PROJ_VIEW_DATA_ID);
- array= (float *)IDP_Array(view_data);
- memcpy(array, rv3d->winmat, sizeof(rv3d->winmat)); array += sizeof(rv3d->winmat)/sizeof(float);
- memcpy(array, rv3d->viewmat, sizeof(rv3d->viewmat)); array += sizeof(rv3d->viewmat)/sizeof(float);
- orth= project_paint_view_clip(v3d, rv3d, &array[0], &array[1]);
- array[2]= orth ? 1.0f : 0.0f; /* using float for a bool is dodgy but since its an extra member in the array... easier then adding a single bool prop */
+ array = (float *)IDP_Array(view_data);
+ memcpy(array, rv3d->winmat, sizeof(rv3d->winmat)); array += sizeof(rv3d->winmat) / sizeof(float);
+ memcpy(array, rv3d->viewmat, sizeof(rv3d->viewmat)); array += sizeof(rv3d->viewmat) / sizeof(float);
+ orth = project_paint_view_clip(v3d, rv3d, &array[0], &array[1]);
+ array[2] = orth ? 1.0f : 0.0f; /* using float for a bool is dodgy but since its an extra member in the array... easier then adding a single bool prop */
IDP_AddToGroup(idgroup, view_data);
diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c
index 046a3b374ba..3bc3c7a9224 100644
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@ -83,23 +83,23 @@ static void BRUSH_OT_add(wmOperatorType *ot)
ot->exec = brush_add_exec;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int brush_scale_size_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
- Paint *paint= paint_get_active(scene);
- struct Brush *brush= paint_brush(paint);
+ Paint *paint = paint_get_active(scene);
+ struct Brush *brush = paint_brush(paint);
// Object *ob= CTX_data_active_object(C);
- float scalar= RNA_float_get(op->ptr, "scalar");
+ float scalar = RNA_float_get(op->ptr, "scalar");
if (brush) {
// pixel radius
{
- const int old_size= brush_size(scene, brush);
- int size= (int)(scalar*old_size);
+ const int old_size = brush_size(scene, brush);
+ int size = (int)(scalar * old_size);
if (old_size == size) {
if (scalar > 1) {
@@ -116,10 +116,10 @@ static int brush_scale_size_exec(bContext *C, wmOperator *op)
// unprojected radius
{
- float unprojected_radius= scalar*brush_unprojected_radius(scene, brush);
+ float unprojected_radius = scalar * brush_unprojected_radius(scene, brush);
if (unprojected_radius < 0.001f) // XXX magic number
- unprojected_radius= 0.001f;
+ unprojected_radius = 0.001f;
brush_set_unprojected_radius(scene, brush, unprojected_radius);
}
@@ -139,7 +139,7 @@ static void BRUSH_OT_scale_size(wmOperatorType *ot)
ot->exec = brush_scale_size_exec;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_float(ot->srna, "scalar", 1, 0, 2, "Scalar", "Factor to scale brush size by", 0, 2);
}
@@ -166,7 +166,7 @@ static void PAINT_OT_vertex_color_set(wmOperatorType *ot)
ot->poll = vertex_paint_mode_poll;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int brush_reset_exec(bContext *C, wmOperator *UNUSED(op))
@@ -195,7 +195,7 @@ static void BRUSH_OT_reset(wmOperatorType *ot)
ot->exec = brush_reset_exec;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int brush_tool(const Brush *brush, size_t tool_offset)
@@ -208,16 +208,17 @@ static Brush *brush_tool_cycle(Main *bmain, Brush *brush_orig, const int tool, c
{
struct Brush *brush;
- if (!brush_orig && !(brush_orig= bmain->brush.first)) {
+ if (!brush_orig && !(brush_orig = bmain->brush.first)) {
return NULL;
}
/* get the next brush with the active tool */
- for (brush= brush_orig->id.next ? brush_orig->id.next : bmain->brush.first;
- brush != brush_orig;
- brush= brush->id.next ? brush->id.next : bmain->brush.first) {
+ for (brush = brush_orig->id.next ? brush_orig->id.next : bmain->brush.first;
+ brush != brush_orig;
+ brush = brush->id.next ? brush->id.next : bmain->brush.first)
+ {
if ((brush->ob_mode & ob_mode) &&
- (brush_tool(brush, tool_offset) == tool)) {
+ (brush_tool(brush, tool_offset) == tool)) {
return brush;
}
}
@@ -227,13 +228,13 @@ static Brush *brush_tool_cycle(Main *bmain, Brush *brush_orig, const int tool, c
static int brush_generic_tool_set(Main *bmain, Paint *paint, const int tool, const size_t tool_offset, const int ob_mode)
{
- struct Brush *brush, *brush_orig= paint_brush(paint);
+ struct Brush *brush, *brush_orig = paint_brush(paint);
- brush= brush_tool_cycle(bmain, brush_orig, tool, tool_offset, ob_mode);
+ brush = brush_tool_cycle(bmain, brush_orig, tool, tool_offset, ob_mode);
if (brush) {
paint_brush_set(paint, brush);
- WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush);
+ WM_main_add_notifier(NC_BRUSH | NA_EDITED, brush);
return OPERATOR_FINISHED;
}
else {
@@ -246,46 +247,46 @@ static int brush_generic_tool_set(Main *bmain, Paint *paint, const int tool, con
static int brush_select_exec(bContext *C, wmOperator *op)
{
- Main *bmain= CTX_data_main(C);
- ToolSettings *toolsettings= CTX_data_tool_settings(C);
- Paint *paint= NULL;
- int tool, paint_mode= RNA_enum_get(op->ptr, "paint_mode");
+ Main *bmain = CTX_data_main(C);
+ ToolSettings *toolsettings = CTX_data_tool_settings(C);
+ Paint *paint = NULL;
+ int tool, paint_mode = RNA_enum_get(op->ptr, "paint_mode");
size_t tool_offset;
if (paint_mode == OB_MODE_ACTIVE) {
/* select current paint mode */
paint_mode = CTX_data_active_object(C)->mode &
- (OB_MODE_SCULPT|
- OB_MODE_VERTEX_PAINT|
- OB_MODE_WEIGHT_PAINT|
- OB_MODE_TEXTURE_PAINT);
+ (OB_MODE_SCULPT |
+ OB_MODE_VERTEX_PAINT |
+ OB_MODE_WEIGHT_PAINT |
+ OB_MODE_TEXTURE_PAINT);
}
- switch(paint_mode) {
- case OB_MODE_SCULPT:
- paint= &toolsettings->sculpt->paint;
- tool_offset= offsetof(Brush, sculpt_tool);
- tool= RNA_enum_get(op->ptr, "sculpt_tool");
- break;
- case OB_MODE_VERTEX_PAINT:
- paint= &toolsettings->vpaint->paint;
- tool_offset= offsetof(Brush, vertexpaint_tool);
- tool= RNA_enum_get(op->ptr, "vertex_paint_tool");
- break;
- case OB_MODE_WEIGHT_PAINT:
- paint= &toolsettings->wpaint->paint;
- /* vertexpaint_tool is used for weight paint mode */
- tool_offset= offsetof(Brush, vertexpaint_tool);
- tool= RNA_enum_get(op->ptr, "weight_paint_tool");
- break;
- case OB_MODE_TEXTURE_PAINT:
- paint= &toolsettings->imapaint.paint;
- tool_offset= offsetof(Brush, imagepaint_tool);
- tool= RNA_enum_get(op->ptr, "texture_paint_tool");
- break;
- default:
- /* invalid paint mode */
- return OPERATOR_CANCELLED;
+ switch (paint_mode) {
+ case OB_MODE_SCULPT:
+ paint = &toolsettings->sculpt->paint;
+ tool_offset = offsetof(Brush, sculpt_tool);
+ tool = RNA_enum_get(op->ptr, "sculpt_tool");
+ break;
+ case OB_MODE_VERTEX_PAINT:
+ paint = &toolsettings->vpaint->paint;
+ tool_offset = offsetof(Brush, vertexpaint_tool);
+ tool = RNA_enum_get(op->ptr, "vertex_paint_tool");
+ break;
+ case OB_MODE_WEIGHT_PAINT:
+ paint = &toolsettings->wpaint->paint;
+ /* vertexpaint_tool is used for weight paint mode */
+ tool_offset = offsetof(Brush, vertexpaint_tool);
+ tool = RNA_enum_get(op->ptr, "weight_paint_tool");
+ break;
+ case OB_MODE_TEXTURE_PAINT:
+ paint = &toolsettings->imapaint.paint;
+ tool_offset = offsetof(Brush, imagepaint_tool);
+ tool = RNA_enum_get(op->ptr, "texture_paint_tool");
+ break;
+ default:
+ /* invalid paint mode */
+ return OPERATOR_CANCELLED;
}
return brush_generic_tool_set(bmain, paint, tool, tool_offset, paint_mode);
@@ -299,7 +300,8 @@ static void PAINT_OT_brush_select(wmOperatorType *ot)
{OB_MODE_VERTEX_PAINT, "VERTEX_PAINT", ICON_VPAINT_HLT, "Vertex Paint", ""},
{OB_MODE_WEIGHT_PAINT, "WEIGHT_PAINT", ICON_WPAINT_HLT, "Weight Paint", ""},
{OB_MODE_TEXTURE_PAINT, "TEXTURE_PAINT", ICON_TPAINT_HLT, "Texture Paint", ""},
- {0, NULL, 0, NULL, NULL}};
+ {0, NULL, 0, NULL, NULL}
+ };
/* identifiers */
ot->name = "Brush Select";
@@ -310,7 +312,7 @@ static void PAINT_OT_brush_select(wmOperatorType *ot)
ot->exec = brush_select_exec;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* props */
RNA_def_enum(ot->srna, "paint_mode", paint_mode_items, OB_MODE_ACTIVE, "Paint Mode", "");
@@ -321,28 +323,28 @@ static void PAINT_OT_brush_select(wmOperatorType *ot)
}
static wmKeyMapItem *keymap_brush_select(wmKeyMap *keymap, int paint_mode,
- int tool, int keymap_type,
- int keymap_modifier)
+ int tool, int keymap_type,
+ int keymap_modifier)
{
wmKeyMapItem *kmi;
kmi = WM_keymap_add_item(keymap, "PAINT_OT_brush_select",
- keymap_type, KM_PRESS, keymap_modifier, 0);
+ keymap_type, KM_PRESS, keymap_modifier, 0);
RNA_enum_set(kmi->ptr, "paint_mode", paint_mode);
- switch(paint_mode) {
- case OB_MODE_SCULPT:
- RNA_enum_set(kmi->ptr, "sculpt_tool", tool);
- break;
- case OB_MODE_VERTEX_PAINT:
- RNA_enum_set(kmi->ptr, "vertex_paint_tool", tool);
- break;
- case OB_MODE_WEIGHT_PAINT:
- RNA_enum_set(kmi->ptr, "weight_paint_tool", tool);
- break;
- case OB_MODE_TEXTURE_PAINT:
- RNA_enum_set(kmi->ptr, "texture_paint_tool", tool);
- break;
+ switch (paint_mode) {
+ case OB_MODE_SCULPT:
+ RNA_enum_set(kmi->ptr, "sculpt_tool", tool);
+ break;
+ case OB_MODE_VERTEX_PAINT:
+ RNA_enum_set(kmi->ptr, "vertex_paint_tool", tool);
+ break;
+ case OB_MODE_WEIGHT_PAINT:
+ RNA_enum_set(kmi->ptr, "weight_paint_tool", tool);
+ break;
+ case OB_MODE_TEXTURE_PAINT:
+ RNA_enum_set(kmi->ptr, "texture_paint_tool", tool);
+ break;
}
return kmi;
@@ -351,12 +353,12 @@ static wmKeyMapItem *keymap_brush_select(wmKeyMap *keymap, int paint_mode,
static int brush_uv_sculpt_tool_set_exec(bContext *C, wmOperator *op)
{
Brush *brush;
- Scene *scene= CTX_data_scene(C);
+ Scene *scene = CTX_data_scene(C);
ToolSettings *ts = scene->toolsettings;
ts->uv_sculpt_tool = RNA_enum_get(op->ptr, "tool");
brush = ts->uvsculpt->paint.brush;
/* To update toolshelf */
- WM_event_add_notifier(C, NC_BRUSH|NA_EDITED, brush);
+ WM_event_add_notifier(C, NC_BRUSH | NA_EDITED, brush);
return OPERATOR_FINISHED;
}
@@ -444,7 +446,7 @@ static void ed_keymap_paint_brush_switch(wmKeyMap *keymap, const char *mode)
/* index 0-9 (zero key is tenth), shift key for index 10-19 */
for (i = 0; i < 20; i++) {
kmi = WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set",
- ZEROKEY + ((i + 1) % 10), KM_PRESS, i < 10 ? 0 : KM_SHIFT, 0);
+ ZEROKEY + ((i + 1) % 10), KM_PRESS, i < 10 ? 0 : KM_SHIFT, 0);
RNA_string_set(kmi->ptr, "mode", mode);
RNA_int_set(kmi->ptr, "index", i);
}
@@ -458,7 +460,7 @@ static void ed_keymap_paint_brush_size(wmKeyMap *keymap, const char *UNUSED(path
RNA_float_set(kmi->ptr, "scalar", 0.9);
kmi = WM_keymap_add_item(keymap, "BRUSH_OT_scale_size", RIGHTBRACKETKEY, KM_PRESS, 0, 0);
- RNA_float_set(kmi->ptr, "scalar", 10.0/9.0); // 1.1111....
+ RNA_float_set(kmi->ptr, "scalar", 10.0 / 9.0); // 1.1111....
}
typedef enum {
@@ -468,7 +470,7 @@ typedef enum {
} RCFlags;
static void set_brush_rc_path(PointerRNA *ptr, const char *brush_path,
- const char *output_name, const char *input_name)
+ const char *output_name, const char *input_name)
{
char *path;
@@ -478,8 +480,8 @@ static void set_brush_rc_path(PointerRNA *ptr, const char *brush_path,
}
static void set_brush_rc_props(PointerRNA *ptr, const char *paint,
- const char *prop, const char *secondary_prop,
- RCFlags flags)
+ const char *prop, const char *secondary_prop,
+ RCFlags flags)
{
const char *ups_path = "tool_settings.unified_paint_settings";
char *brush_path;
@@ -512,7 +514,7 @@ static void set_brush_rc_props(PointerRNA *ptr, const char *paint,
}
static void ed_keymap_paint_brush_radial_control(wmKeyMap *keymap, const char *paint,
- RCFlags flags)
+ RCFlags flags)
{
wmKeyMapItem *kmi;
@@ -561,8 +563,8 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
/* Partial visibility, sculpt-only for now */
paint_partial_visibility_keys(keymap);
- for (i=0; i<=5; i++)
- RNA_int_set(WM_keymap_add_item(keymap, "OBJECT_OT_subdivision_set", ZEROKEY+i, KM_PRESS, KM_CTRL, 0)->ptr, "level", i);
+ for (i = 0; i <= 5; i++)
+ RNA_int_set(WM_keymap_add_item(keymap, "OBJECT_OT_subdivision_set", ZEROKEY + i, KM_PRESS, KM_CTRL, 0)->ptr, "level", i);
/* multires switch */
kmi = WM_keymap_add_item(keymap, "OBJECT_OT_subdivision_set", PAGEUPKEY, KM_PRESS, 0, 0);
@@ -605,7 +607,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "PAINT_OT_sample_color", RIGHTMOUSE, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap,
- "PAINT_OT_vertex_color_set",KKEY, KM_PRESS, KM_SHIFT, 0);
+ "PAINT_OT_vertex_color_set", KKEY, KM_PRESS, KM_SHIFT, 0);
ed_keymap_paint_brush_switch(keymap, "vertex_paint");
ed_keymap_paint_brush_size(keymap, "tool_settings.vertex_paint.brush.size");
@@ -625,7 +627,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
WM_keymap_verify_item(keymap, "PAINT_OT_weight_sample_group", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_item(keymap,
- "PAINT_OT_weight_set", KKEY, KM_PRESS, KM_SHIFT, 0);
+ "PAINT_OT_weight_set", KKEY, KM_PRESS, KM_SHIFT, 0);
ed_keymap_paint_brush_switch(keymap, "weight_paint");
ed_keymap_paint_brush_size(keymap, "tool_settings.weight_paint.brush.size");
@@ -649,7 +651,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "VIEW3D_OT_select_border", BKEY, KM_PRESS, 0, 0);
kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_CTRL, 0);
RNA_boolean_set(kmi->ptr, "deselect", FALSE);
- kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_SHIFT|KM_CTRL, 0);
+ kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_SHIFT | KM_CTRL, 0);
RNA_boolean_set(kmi->ptr, "deselect", TRUE);
WM_keymap_add_item(keymap, "VIEW3D_OT_select_circle", CKEY, KM_PRESS, 0, 0);
@@ -664,7 +666,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
ed_keymap_paint_brush_switch(keymap, "image_paint");
ed_keymap_paint_brush_size(keymap, "tool_settings.image_paint.brush.size");
- ed_keymap_paint_brush_radial_control(keymap, "image_paint", RC_COLOR|RC_ZOOM);
+ ed_keymap_paint_brush_radial_control(keymap, "image_paint", RC_COLOR | RC_ZOOM);
kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", MKEY, KM_PRESS, 0, 0); /* mask toggle */
RNA_string_set(kmi->ptr, "data_path", "image_paint_object.data.use_paint_mask");
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c
index 28fee887cd8..fb640346a99 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -98,7 +98,7 @@ static void paint_draw_smooth_stroke(bContext *C, int x, int y, void *customdata
if (stroke && brush && (brush->flag & BRUSH_SMOOTH_STROKE)) {
ARegion *ar = CTX_wm_region(C);
sdrawline(x, y, (int)stroke->last_mouse_position[0] - ar->winrct.xmin,
- (int)stroke->last_mouse_position[1] - ar->winrct.ymin);
+ (int)stroke->last_mouse_position[1] - ar->winrct.ymin);
}
glDisable(GL_BLEND);
@@ -113,7 +113,7 @@ static float event_tablet_data(wmEvent *event, int *pen_flip)
float pressure = 1;
if (event->custom == EVT_DATA_TABLET) {
- wmTabletData *wmtab= event->customdata;
+ wmTabletData *wmtab = event->customdata;
erasor = (wmtab->Active == EVT_TABLET_ERASER);
pressure = (wmtab->Active != EVT_TABLET_NONE) ? wmtab->Pressure : 1;
@@ -197,7 +197,7 @@ static int paint_smooth_stroke(PaintStroke *stroke, float output[2], wmEvent *ev
/* If the mouse is moving within the radius of the last move,
* don't update the mouse position. This allows sharp turns. */
- if (dx*dx + dy*dy < stroke->brush->smooth_stroke_radius * stroke->brush->smooth_stroke_radius)
+ if (dx * dx + dy * dy < stroke->brush->smooth_stroke_radius * stroke->brush->smooth_stroke_radius)
return 0;
output[0] = event->x * v + stroke->last_mouse_position[0] * u;
@@ -228,14 +228,14 @@ static int paint_space_stroke(bContext *C, wmOperator *op, wmEvent *event, const
const Scene *scene = CTX_data_scene(C);
int steps;
int i;
- float pressure= 1.0f;
+ float pressure = 1.0f;
/* XXX mysterious :) what has 'use size' do with this here... if you don't check for it, pressure fails */
if (brush_use_size_pressure(scene, stroke->brush))
pressure = event_tablet_data(event, NULL);
if (pressure > FLT_EPSILON) {
- scale = (brush_size(scene, stroke->brush)*pressure*stroke->brush->spacing/50.0f) / length;
+ scale = (brush_size(scene, stroke->brush) * pressure * stroke->brush->spacing / 50.0f) / length;
if (scale > FLT_EPSILON) {
mul_v2_fl(vec, scale);
@@ -256,10 +256,10 @@ static int paint_space_stroke(bContext *C, wmOperator *op, wmEvent *event, const
/**** Public API ****/
PaintStroke *paint_stroke_new(bContext *C,
- StrokeGetLocation get_location,
- StrokeTestStart test_start,
- StrokeUpdateStep update_step,
- StrokeDone done, int event_type)
+ StrokeGetLocation get_location,
+ StrokeTestStart test_start,
+ StrokeUpdateStep update_step,
+ StrokeDone done, int event_type)
{
PaintStroke *stroke = MEM_callocN(sizeof(PaintStroke), "PaintStroke");
@@ -271,7 +271,7 @@ PaintStroke *paint_stroke_new(bContext *C,
stroke->test_start = test_start;
stroke->update_step = update_step;
stroke->done = done;
- stroke->event_type= event_type; /* for modal, return event */
+ stroke->event_type = event_type; /* for modal, return event */
return stroke;
}
@@ -293,7 +293,7 @@ int paint_stroke_modal(bContext *C, wmOperator *op, wmEvent *event)
{
PaintStroke *stroke = op->customdata;
float mouse[2];
- int first= 0;
+ int first = 0;
// let NDOF motion pass through to the 3D view so we can paint and rotate simultaneously!
// this isn't perfect... even when an extra MOUSEMOVE is spoofed, the stroke discards it
@@ -309,13 +309,13 @@ int paint_stroke_modal(bContext *C, wmOperator *op, wmEvent *event)
if (stroke->stroke_started) {
stroke->smooth_stroke_cursor =
- WM_paint_cursor_activate(CTX_wm_manager(C), paint_poll, paint_draw_smooth_stroke, stroke);
+ WM_paint_cursor_activate(CTX_wm_manager(C), paint_poll, paint_draw_smooth_stroke, stroke);
if (stroke->brush->flag & BRUSH_AIRBRUSH)
stroke->timer = WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER, stroke->brush->rate);
}
- first= 1;
+ first = 1;
//ED_region_tag_redraw(ar);
}
@@ -331,7 +331,7 @@ int paint_stroke_modal(bContext *C, wmOperator *op, wmEvent *event)
MEM_freeN(stroke);
return OPERATOR_FINISHED;
}
- else if ( (first) ||
+ else if ((first) ||
(ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) ||
(event->type == TIMER && (event->customdata == stroke->timer)) )
{
@@ -347,7 +347,7 @@ int paint_stroke_modal(bContext *C, wmOperator *op, wmEvent *event)
}
}
else {
- ;//ED_region_tag_redraw(ar);
+ ; //ED_region_tag_redraw(ar);
}
}
}
@@ -355,10 +355,10 @@ int paint_stroke_modal(bContext *C, wmOperator *op, wmEvent *event)
/* we want the stroke to have the first daub at the start location
* instead of waiting till we have moved the space distance */
if (first &&
- stroke->stroke_started &&
- paint_space_stroke_enabled(stroke->brush) &&
- !(stroke->brush->flag & BRUSH_ANCHORED) &&
- !(stroke->brush->flag & BRUSH_SMOOTH_STROKE))
+ stroke->stroke_started &&
+ paint_space_stroke_enabled(stroke->brush) &&
+ !(stroke->brush->flag & BRUSH_ANCHORED) &&
+ !(stroke->brush->flag & BRUSH_SMOOTH_STROKE))
{
paint_brush_stroke_add_step(C, op, event, mouse);
}
@@ -374,7 +374,7 @@ int paint_stroke_exec(bContext *C, wmOperator *op)
if (stroke->stroke_started == 0) {
/* XXX stroke->last_mouse_position is unset, this may cause problems */
stroke->test_start(C, op, NULL);
- stroke->stroke_started= 1;
+ stroke->stroke_started = 1;
}
RNA_BEGIN(op->ptr, itemptr, "stroke") {
@@ -424,6 +424,6 @@ int paint_poll(bContext *C)
Object *ob = CTX_data_active_object(C);
return p && ob && paint_brush(p) &&
- CTX_wm_area(C)->spacetype == SPACE_VIEW3D &&
- CTX_wm_region(C)->regiontype == RGN_TYPE_WINDOW;
+ CTX_wm_area(C)->spacetype == SPACE_VIEW3D &&
+ CTX_wm_region(C)->regiontype == RGN_TYPE_WINDOW;
}
diff --git a/source/blender/editors/sculpt_paint/paint_undo.c b/source/blender/editors/sculpt_paint/paint_undo.c
index 8406c8b20af..fbf83dd8df5 100644
--- a/source/blender/editors/sculpt_paint/paint_undo.c
+++ b/source/blender/editors/sculpt_paint/paint_undo.c
@@ -45,7 +45,7 @@
#include "paint_intern.h"
-#define MAXUNDONAME 64
+#define MAXUNDONAME 64
typedef struct UndoElem {
struct UndoElem *next, *prev;
@@ -94,31 +94,31 @@ static void undo_stack_push_begin(UndoStack *stack, const char *name, UndoRestor
/* remove all undos after (also when stack->current==NULL) */
while (stack->elems.last != stack->current) {
- uel= stack->elems.last;
+ uel = stack->elems.last;
undo_elem_free(stack, uel);
BLI_freelinkN(&stack->elems, uel);
}
/* make new */
- stack->current= uel= MEM_callocN(sizeof(UndoElem), "undo file");
- uel->restore= restore;
- uel->free= free;
+ stack->current = uel = MEM_callocN(sizeof(UndoElem), "undo file");
+ uel->restore = restore;
+ uel->free = free;
BLI_addtail(&stack->elems, uel);
/* name can be a dynamic string */
BLI_strncpy(uel->name, name, sizeof(uel->name));
/* limit amount to the maximum amount*/
- nr= 0;
- uel= stack->elems.last;
+ nr = 0;
+ uel = stack->elems.last;
while (uel) {
nr++;
- if (nr==U.undosteps) break;
- uel= uel->prev;
+ if (nr == U.undosteps) break;
+ uel = uel->prev;
}
if (uel) {
- while (stack->elems.first!=uel) {
- UndoElem *first= stack->elems.first;
+ while (stack->elems.first != uel) {
+ UndoElem *first = stack->elems.first;
undo_elem_free(stack, first);
BLI_freelinkN(&stack->elems, first);
}
@@ -132,19 +132,19 @@ static void undo_stack_push_end(UndoStack *stack)
if (U.undomemory != 0) {
/* limit to maximum memory (afterwards, we can't know in advance) */
- totmem= 0;
- maxmem= ((uintptr_t)U.undomemory)*1024*1024;
+ totmem = 0;
+ maxmem = ((uintptr_t)U.undomemory) * 1024 * 1024;
- uel= stack->elems.last;
+ uel = stack->elems.last;
while (uel) {
- totmem+= uel->undosize;
- if (totmem>maxmem) break;
- uel= uel->prev;
+ totmem += uel->undosize;
+ if (totmem > maxmem) break;
+ uel = uel->prev;
}
if (uel) {
- while (stack->elems.first!=uel) {
- UndoElem *first= stack->elems.first;
+ while (stack->elems.first != uel) {
+ UndoElem *first = stack->elems.first;
undo_elem_free(stack, first);
BLI_freelinkN(&stack->elems, first);
}
@@ -156,24 +156,24 @@ static int undo_stack_step(bContext *C, UndoStack *stack, int step, const char *
{
UndoElem *undo;
- if (step==1) {
- if (stack->current==NULL);
+ if (step == 1) {
+ if (stack->current == NULL) ;
else {
if (!name || strcmp(stack->current->name, name) == 0) {
if (G.f & G_DEBUG) printf("undo %s\n", stack->current->name);
undo_restore(C, stack, stack->current);
- stack->current= stack->current->prev;
+ stack->current = stack->current->prev;
return 1;
}
}
}
- else if (step==-1) {
- if ((stack->current!=NULL && stack->current->next==NULL) || stack->elems.first==NULL);
+ else if (step == -1) {
+ if ((stack->current != NULL && stack->current->next == NULL) || stack->elems.first == NULL) ;
else {
if (!name || strcmp(stack->current->name, name) == 0) {
- undo= (stack->current && stack->current->next)? stack->current->next: stack->elems.first;
+ undo = (stack->current && stack->current->next) ? stack->current->next : stack->elems.first;
undo_restore(C, stack, undo);
- stack->current= undo;
+ stack->current = undo;
if (G.f & G_DEBUG) printf("redo %s\n", undo->name);
return 1;
}
@@ -187,11 +187,11 @@ static void undo_stack_free(UndoStack *stack)
{
UndoElem *uel;
- for (uel=stack->elems.first; uel; uel=uel->next)
+ for (uel = stack->elems.first; uel; uel = uel->next)
undo_elem_free(stack, uel);
BLI_freelistN(&stack->elems);
- stack->current= NULL;
+ stack->current = NULL;
}
/* Exported Functions */
@@ -249,13 +249,13 @@ int ED_undo_paint_valid(int type, const char *name)
UndoStack *stack;
if (type == UNDO_PAINT_IMAGE)
- stack= &ImageUndoStack;
+ stack = &ImageUndoStack;
else if (type == UNDO_PAINT_MESH)
- stack= &MeshUndoStack;
+ stack = &MeshUndoStack;
else
return 0;
- if (stack->current==NULL);
+ if (stack->current == NULL) ;
else {
if (name && strcmp(stack->current->name, name) == 0)
return 1;
diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c
index eac0434d255..6a31e96b51b 100644
--- a/source/blender/editors/sculpt_paint/paint_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_utils.c
@@ -71,11 +71,11 @@
* its minimum and maximum corners) into a screen-space rectangle,
* returns zero if the result is empty */
int paint_convert_bb_to_rect(rcti *rect,
- const float bb_min[3],
- const float bb_max[3],
- const ARegion *ar,
- RegionView3D *rv3d,
- Object *ob)
+ const float bb_min[3],
+ const float bb_max[3],
+ const ARegion *ar,
+ RegionView3D *rv3d,
+ Object *ob)
{
float projection_mat[4][4];
int i, j, k;
@@ -115,10 +115,10 @@ int paint_convert_bb_to_rect(rcti *rect,
* screen_rect from screen into object-space (essentially converting a
* 2D screens-space bounding box into four 3D planes) */
void paint_calc_redraw_planes(float planes[4][4],
- const ARegion *ar,
- RegionView3D *rv3d,
- Object *ob,
- const rcti *screen_rect)
+ const ARegion *ar,
+ RegionView3D *rv3d,
+ Object *ob,
+ const rcti *screen_rect)
{
BoundBox bb;
bglMats mats;
@@ -145,14 +145,14 @@ void projectf(bglMats *mats, const float v[3], float p[2])
{
double ux, uy, uz;
- gluProject(v[0],v[1],v[2], mats->modelview, mats->projection,
- (GLint *)mats->viewport, &ux, &uy, &uz);
- p[0]= ux;
- p[1]= uy;
+ gluProject(v[0], v[1], v[2], mats->modelview, mats->projection,
+ (GLint *)mats->viewport, &ux, &uy, &uz);
+ p[0] = ux;
+ p[1] = uy;
}
float paint_calc_object_space_radius(ViewContext *vc, const float center[3],
- float pixel_radius)
+ float pixel_radius)
{
Object *ob = vc->obact;
float delta[3], scale, loc[3];
@@ -162,17 +162,17 @@ float paint_calc_object_space_radius(ViewContext *vc, const float center[3],
initgrabz(vc->rv3d, loc[0], loc[1], loc[2]);
- mval_f[0]= pixel_radius;
- mval_f[1]= 0.0f;
+ mval_f[0] = pixel_radius;
+ mval_f[1] = 0.0f;
ED_view3d_win_to_delta(vc->ar, mval_f, delta);
- scale= fabsf(mat4_to_scale(ob->obmat));
- scale= (scale == 0.0f)? 1.0f: scale;
+ scale = fabsf(mat4_to_scale(ob->obmat));
+ scale = (scale == 0.0f) ? 1.0f : scale;
- return len_v3(delta)/scale;
+ return len_v3(delta) / scale;
}
-float paint_get_tex_pixel(Brush* br, float u, float v)
+float paint_get_tex_pixel(Brush *br, float u, float v)
{
TexResult texres;
float co[3];
@@ -186,7 +186,7 @@ float paint_get_tex_pixel(Brush* br, float u, float v)
hasrgb = multitex_ext(br->mtex.tex, co, NULL, NULL, 0, &texres);
if (hasrgb & TEX_RGB)
- texres.tin = (0.35f*texres.tr + 0.45f*texres.tg + 0.2f*texres.tb)*texres.ta;
+ texres.tin = (0.35f * texres.tr + 0.45f * texres.tg + 0.2f * texres.tb) * texres.ta;
return texres.tin;
}
@@ -196,7 +196,7 @@ float paint_get_tex_pixel(Brush* br, float u, float v)
static void imapaint_project(Object *ob, float model[][4], float proj[][4], const float co[3], float pco[4])
{
copy_v3_v3(pco, co);
- pco[3]= 1.0f;
+ pco[3] = 1.0f;
mul_m4_v3(ob->obmat, pco);
mul_m4_v3(model, pco);
@@ -225,16 +225,16 @@ static void imapaint_tri_weights(Object *ob,
imapaint_project(ob, model, proj, v3, pv3);
/* do inverse view mapping, see gluProject man page */
- h[0]= (co[0] - view[0])*2.0f/view[2] - 1;
- h[1]= (co[1] - view[1])*2.0f/view[3] - 1;
- h[2]= 1.0f;
+ h[0] = (co[0] - view[0]) * 2.0f / view[2] - 1;
+ h[1] = (co[1] - view[1]) * 2.0f / view[3] - 1;
+ h[2] = 1.0f;
/* solve for (w1,w2,w3)/perspdiv in:
* h * perspdiv = Project * Model * (w1 * v1 + w2 * v2 + w3 * v3) */
- wmat[0][0]= pv1[0]; wmat[1][0]= pv2[0]; wmat[2][0]= pv3[0];
- wmat[0][1]= pv1[1]; wmat[1][1]= pv2[1]; wmat[2][1]= pv3[1];
- wmat[0][2]= pv1[3]; wmat[1][2]= pv2[3]; wmat[2][2]= pv3[3];
+ wmat[0][0] = pv1[0]; wmat[1][0] = pv2[0]; wmat[2][0] = pv3[0];
+ wmat[0][1] = pv1[1]; wmat[1][1] = pv2[1]; wmat[2][1] = pv3[1];
+ wmat[0][2] = pv1[3]; wmat[1][2] = pv2[3]; wmat[2][2] = pv3[3];
invert_m3_m3(invwmat, wmat);
mul_m3_v3(invwmat, h);
@@ -242,9 +242,9 @@ static void imapaint_tri_weights(Object *ob,
copy_v3_v3(w, h);
/* w is still divided by perspdiv, make it sum to one */
- divw= w[0] + w[1] + w[2];
+ divw = w[0] + w[1] + w[2];
if (divw != 0.0f) {
- mul_v3_fl(w, 1.0f/divw);
+ mul_v3_fl(w, 1.0f / divw);
}
}
@@ -264,7 +264,7 @@ void imapaint_pick_uv(Scene *scene, Object *ob, unsigned int faceindex, const in
/* test all faces in the derivedmesh with the original index of the picked face */
for (a = 0; a < numfaces; a++) {
- findex= index ? index[a]: a;
+ findex = index ? index[a] : a;
if (findex == faceindex) {
dm->getTessFace(dm, a, &mf);
@@ -275,36 +275,36 @@ void imapaint_pick_uv(Scene *scene, Object *ob, unsigned int faceindex, const in
if (mf.v4)
dm->getVert(dm, mf.v4, &mv[3]);
- tf= &tface[a];
+ tf = &tface[a];
- p[0]= xy[0];
- p[1]= xy[1];
+ p[0] = xy[0];
+ p[1] = xy[1];
if (mf.v4) {
/* the triangle with the largest absolute values is the one
* with the most negative weights */
imapaint_tri_weights(ob, mv[0].co, mv[1].co, mv[3].co, p, w);
- absw= fabs(w[0]) + fabs(w[1]) + fabs(w[2]);
+ absw = fabs(w[0]) + fabs(w[1]) + fabs(w[2]);
if (absw < minabsw) {
- uv[0]= tf->uv[0][0]*w[0] + tf->uv[1][0]*w[1] + tf->uv[3][0]*w[2];
- uv[1]= tf->uv[0][1]*w[0] + tf->uv[1][1]*w[1] + tf->uv[3][1]*w[2];
+ uv[0] = tf->uv[0][0] * w[0] + tf->uv[1][0] * w[1] + tf->uv[3][0] * w[2];
+ uv[1] = tf->uv[0][1] * w[0] + tf->uv[1][1] * w[1] + tf->uv[3][1] * w[2];
minabsw = absw;
}
imapaint_tri_weights(ob, mv[1].co, mv[2].co, mv[3].co, p, w);
- absw= fabs(w[0]) + fabs(w[1]) + fabs(w[2]);
+ absw = fabs(w[0]) + fabs(w[1]) + fabs(w[2]);
if (absw < minabsw) {
- uv[0]= tf->uv[1][0]*w[0] + tf->uv[2][0]*w[1] + tf->uv[3][0]*w[2];
- uv[1]= tf->uv[1][1]*w[0] + tf->uv[2][1]*w[1] + tf->uv[3][1]*w[2];
+ uv[0] = tf->uv[1][0] * w[0] + tf->uv[2][0] * w[1] + tf->uv[3][0] * w[2];
+ uv[1] = tf->uv[1][1] * w[0] + tf->uv[2][1] * w[1] + tf->uv[3][1] * w[2];
minabsw = absw;
}
}
else {
imapaint_tri_weights(ob, mv[0].co, mv[1].co, mv[2].co, p, w);
- absw= fabs(w[0]) + fabs(w[1]) + fabs(w[2]);
+ absw = fabs(w[0]) + fabs(w[1]) + fabs(w[2]);
if (absw < minabsw) {
- uv[0]= tf->uv[0][0]*w[0] + tf->uv[1][0]*w[1] + tf->uv[2][0]*w[2];
- uv[1]= tf->uv[0][1]*w[0] + tf->uv[1][1]*w[1] + tf->uv[2][1]*w[2];
+ uv[0] = tf->uv[0][0] * w[0] + tf->uv[1][0] * w[1] + tf->uv[2][0] * w[2];
+ uv[1] = tf->uv[0][1] * w[0] + tf->uv[1][1] * w[1] + tf->uv[2][1] * w[2];
minabsw = absw;
}
}
@@ -333,7 +333,7 @@ int imapaint_pick_face(ViewContext *vc, const int mval[2], unsigned int *index,
}
/* used for both 3d view and image window */
-void paint_sample_color(Scene *scene, ARegion *ar, int x, int y) /* frontbuf */
+void paint_sample_color(Scene *scene, ARegion *ar, int x, int y) /* frontbuf */
{
Brush *br = paint_brush(paint_get_active(scene));
unsigned int col;
@@ -343,15 +343,15 @@ void paint_sample_color(Scene *scene, ARegion *ar, int x, int y) /* frontbuf */
CLAMP(y, 0, ar->winy);
glReadBuffer(GL_FRONT);
- glReadPixels(x+ar->winrct.xmin, y+ar->winrct.ymin, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &col);
+ glReadPixels(x + ar->winrct.xmin, y + ar->winrct.ymin, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &col);
glReadBuffer(GL_BACK);
cp = (char *)&col;
if (br) {
- br->rgb[0]= cp[0]/255.0f;
- br->rgb[1]= cp[1]/255.0f;
- br->rgb[2]= cp[2]/255.0f;
+ br->rgb[0] = cp[0] / 255.0f;
+ br->rgb[1] = cp[1] / 255.0f;
+ br->rgb[2] = cp[2] / 255.0f;
}
}
@@ -388,7 +388,7 @@ void BRUSH_OT_curve_preset(wmOperatorType *ot)
ot->exec = brush_curve_preset_exec;
ot->poll = brush_curve_preset_poll;
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_enum(ot->srna, "shape", prop_shape_items, CURVE_PRESET_SMOOTH, "Mode", "");
}
@@ -411,12 +411,12 @@ void PAINT_OT_face_select_linked(wmOperatorType *ot)
ot->exec = paint_select_linked_exec;
ot->poll = facemask_paint_poll;
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int paint_select_linked_pick_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
- int mode= RNA_boolean_get(op->ptr, "extend") ? 1:0;
+ int mode = RNA_boolean_get(op->ptr, "extend") ? 1 : 0;
paintface_select_linked(C, CTX_data_active_object(C), event->mval, mode);
ED_region_tag_redraw(CTX_wm_region(C));
return OPERATOR_FINISHED;
@@ -431,7 +431,7 @@ void PAINT_OT_face_select_linked_pick(wmOperatorType *ot)
ot->invoke = paint_select_linked_pick_invoke;
ot->poll = facemask_paint_poll;
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend the existing selection");
}
@@ -439,7 +439,7 @@ void PAINT_OT_face_select_linked_pick(wmOperatorType *ot)
static int face_select_all_exec(bContext *C, wmOperator *op)
{
- Object *ob= CTX_data_active_object(C);
+ Object *ob = CTX_data_active_object(C);
paintface_deselect_all_visible(ob, RNA_enum_get(op->ptr, "action"), TRUE);
ED_region_tag_redraw(CTX_wm_region(C));
return OPERATOR_FINISHED;
@@ -455,7 +455,7 @@ void PAINT_OT_face_select_all(wmOperatorType *ot)
ot->exec = face_select_all_exec;
ot->poll = facemask_paint_poll;
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
WM_operator_properties_select_all(ot);
}
@@ -463,7 +463,7 @@ void PAINT_OT_face_select_all(wmOperatorType *ot)
static int vert_select_all_exec(bContext *C, wmOperator *op)
{
- Object *ob= CTX_data_active_object(C);
+ Object *ob = CTX_data_active_object(C);
paintvert_deselect_all_visible(ob, RNA_enum_get(op->ptr, "action"), TRUE);
ED_region_tag_redraw(CTX_wm_region(C));
return OPERATOR_FINISHED;
@@ -479,14 +479,14 @@ void PAINT_OT_vert_select_all(wmOperatorType *ot)
ot->exec = vert_select_all_exec;
ot->poll = vert_paint_poll;
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
WM_operator_properties_select_all(ot);
}
static int vert_select_inverse_exec(bContext *C, wmOperator *UNUSED(op))
{
- Object *ob= CTX_data_active_object(C);
+ Object *ob = CTX_data_active_object(C);
paintvert_deselect_all_visible(ob, SEL_INVERT, TRUE);
ED_region_tag_redraw(CTX_wm_region(C));
return OPERATOR_FINISHED;
@@ -501,11 +501,11 @@ void PAINT_OT_vert_select_inverse(wmOperatorType *ot)
ot->exec = vert_select_inverse_exec;
ot->poll = vert_paint_poll;
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int face_select_inverse_exec(bContext *C, wmOperator *UNUSED(op))
{
- Object *ob= CTX_data_active_object(C);
+ Object *ob = CTX_data_active_object(C);
paintface_deselect_all_visible(ob, SEL_INVERT, TRUE);
ED_region_tag_redraw(CTX_wm_region(C));
return OPERATOR_FINISHED;
@@ -521,13 +521,13 @@ void PAINT_OT_face_select_inverse(wmOperatorType *ot)
ot->exec = face_select_inverse_exec;
ot->poll = facemask_paint_poll;
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int face_select_hide_exec(bContext *C, wmOperator *op)
{
- const int unselected= RNA_boolean_get(op->ptr, "unselected");
- Object *ob= CTX_data_active_object(C);
+ const int unselected = RNA_boolean_get(op->ptr, "unselected");
+ Object *ob = CTX_data_active_object(C);
paintface_hide(ob, unselected);
ED_region_tag_redraw(CTX_wm_region(C));
return OPERATOR_FINISHED;
@@ -542,14 +542,14 @@ void PAINT_OT_face_select_hide(wmOperatorType *ot)
ot->exec = face_select_hide_exec;
ot->poll = facemask_paint_poll;
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Hide unselected rather than selected objects");
}
static int face_select_reveal_exec(bContext *C, wmOperator *UNUSED(op))
{
- Object *ob= CTX_data_active_object(C);
+ Object *ob = CTX_data_active_object(C);
paintface_reveal(ob);
ED_region_tag_redraw(CTX_wm_region(C));
return OPERATOR_FINISHED;
@@ -564,7 +564,7 @@ void PAINT_OT_face_select_reveal(wmOperatorType *ot)
ot->exec = face_select_reveal_exec;
ot->poll = facemask_paint_poll;
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Hide unselected rather than selected objects");
}
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index 54f4d0c1a26..ae0c19d7245 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -130,14 +130,15 @@ int vertex_paint_mode_poll(bContext *C)
int vertex_paint_poll(bContext *C)
{
if (vertex_paint_mode_poll(C) &&
- paint_brush(&CTX_data_tool_settings(C)->vpaint->paint)) {
+ paint_brush(&CTX_data_tool_settings(C)->vpaint->paint))
+ {
ScrArea *sa = CTX_wm_area(C);
if (sa->spacetype == SPACE_VIEW3D) {
ARegion *ar = CTX_wm_region(C);
if (ar->regiontype == RGN_TYPE_WINDOW)
return 1;
- }
}
+ }
return 0;
}
@@ -321,7 +322,7 @@ void do_shared_vertexcol(Mesh *me, int do_tessface)
}
}
-static void make_vertexcol(Object *ob) /* single ob */
+static void make_vertexcol(Object *ob) /* single ob */
{
Mesh *me;
if (!ob || ob->id.lib) return;
@@ -387,7 +388,7 @@ static int wpaint_mirror_vgroup_ensure(Object *ob, const int vgroup_active)
}
if (curdef == NULL) {
- int olddef = ob->actdef; /* tsk, ED_vgroup_add sets the active defgroup */
+ int olddef = ob->actdef; /* tsk, ED_vgroup_add sets the active defgroup */
curdef = ED_vgroup_add_name(ob, name);
ob->actdef = olddef;
}
@@ -418,7 +419,7 @@ static void copy_vpaint_prev(VPaint *vp, unsigned int *lcol, int tot)
}
-static void copy_wpaint_prev (VPaint *wp, MDeformVert *dverts, int dcount)
+static void copy_wpaint_prev(VPaint *wp, MDeformVert *dverts, int dcount)
{
if (wp->wpaint_prev) {
free_dverts(wp->wpaint_prev, wp->tot);
@@ -427,9 +428,9 @@ static void copy_wpaint_prev (VPaint *wp, MDeformVert *dverts, int dcount)
if (dverts && dcount) {
- wp->wpaint_prev = MEM_mallocN (sizeof(MDeformVert) * dcount, "wpaint prev");
+ wp->wpaint_prev = MEM_mallocN(sizeof(MDeformVert) * dcount, "wpaint prev");
wp->tot = dcount;
- copy_dverts (wp->wpaint_prev, dverts, dcount);
+ copy_dverts(wp->wpaint_prev, dverts, dcount);
}
}
@@ -445,7 +446,7 @@ void vpaint_fill(Object *ob, unsigned int paintcol)
if (me == NULL || me->totpoly == 0) return;
if (!me->mloopcol) make_vertexcol(ob);
- if (!me->mloopcol) return; /* possible we can't make mcol's */
+ if (!me->mloopcol) return; /* possible we can't make mcol's */
selected = (me->editflag & ME_EDIT_PAINT_MASK);
@@ -512,7 +513,7 @@ void wpaint_fill(VPaint *wp, Object *ob, float paintweight)
dw_prev->weight = dw->weight; /* set the undo weight */
dw->weight = paintweight;
- if (me->editflag & ME_EDIT_MIRROR_X) { /* x mirror painting */
+ if (me->editflag & ME_EDIT_MIRROR_X) { /* x mirror painting */
int j = mesh_get_x_mirror_vert(ob, vidx);
if (j >= 0) {
/* copy, not paint again */
@@ -568,7 +569,7 @@ void vpaint_dogamma(Scene *scene)
for (a = 0; a < 256; a++) {
fac = ((float)a) / 255.0;
- fac = vp->mul * pow( fac, igam);
+ fac = vp->mul * pow(fac, igam);
temp = 255.9 * fac;
@@ -581,9 +582,9 @@ void vpaint_dogamma(Scene *scene)
cp = (unsigned char *)me->mcol;
while (a--) {
- cp[1] = gamtab[ cp[1] ];
- cp[2] = gamtab[ cp[2] ];
- cp[3] = gamtab[ cp[3] ];
+ cp[1] = gamtab[cp[1]];
+ cp[2] = gamtab[cp[2]];
+ cp[3] = gamtab[cp[3]];
cp += 4;
}
@@ -799,13 +800,13 @@ static unsigned int vpaint_blend(VPaint *vp, unsigned int col, unsigned int colo
co = (char *)&colorig;
for (a = 0; a < 4; a++) {
- if ( ct[a] < co[a] ) {
- if ( cp[a] < ct[a] ) cp[a] = ct[a];
- else if ( cp[a] > co[a] ) cp[a] = co[a];
+ if (ct[a] < co[a]) {
+ if (cp[a] < ct[a]) cp[a] = ct[a];
+ else if (cp[a] > co[a]) cp[a] = co[a];
}
else {
- if ( cp[a] < co[a] ) cp[a] = co[a];
- else if ( cp[a] > ct[a] ) cp[a] = ct[a];
+ if (cp[a] < co[a]) cp[a] = co[a];
+ else if (cp[a] > ct[a]) cp[a] = ct[a];
}
}
}
@@ -853,7 +854,7 @@ static int sample_backbuf_area(ViewContext *vc, int *indexar, int totface, int x
/* whats _dl mean? */
static float calc_vp_strength_dl(VPaint *vp, ViewContext *vc, const float *vert_nor,
- const float mval[2], const float brush_size_pressure)
+ const float mval[2], const float brush_size_pressure)
{
Brush *brush = paint_brush(&vp->paint);
float dist_squared;
@@ -918,7 +919,7 @@ BLI_INLINE float wval_sub(const float weight, const float paintval, const float
return weight - (paintval * alpha);
}
BLI_INLINE float wval_mul(const float weight, const float paintval, const float alpha)
-{ /* first mul, then blend the fac */
+{ /* first mul, then blend the fac */
return ((1.0f - alpha) + (alpha * paintval)) * weight;
}
BLI_INLINE float wval_lighten(const float weight, const float paintval, const float alpha)
@@ -962,7 +963,7 @@ static float wpaint_blend(VPaint *wp, float weight, float weight_prev,
int tool = brush->vertexpaint_tool;
if (do_flip) {
- switch(tool) {
+ switch (tool) {
case PAINT_BLEND_MIX:
paintval = 1.f - paintval; break;
case PAINT_BLEND_ADD:
@@ -1066,7 +1067,7 @@ static int weight_sample_invoke(bContext *C, wmOperator *op, wmEvent *event)
if (change) {
/* not really correct since the brush didnt change, but redraws the toolbar */
- WM_main_add_notifier(NC_BRUSH|NA_EDITED, NULL); /* ts->wpaint->paint.brush */
+ WM_main_add_notifier(NC_BRUSH | NA_EDITED, NULL); /* ts->wpaint->paint.brush */
return OPERATOR_FINISHED;
}
@@ -1169,7 +1170,7 @@ static int weight_sample_group_exec(bContext *C, wmOperator *op)
vc.obact->actdef = type + 1;
DAG_id_tag_update(&vc.obact->id, OB_RECALC_DATA);
- WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, vc.obact);
+ WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, vc.obact);
return OPERATOR_FINISHED;
}
@@ -1218,7 +1219,7 @@ static void do_weight_paint_normalize_all(MDeformVert *dvert, const int defbase_
for (i = dvert->totweight, dw = dvert->dw; i != 0; i--, dw++) {
if (dw->def_nr < defbase_tot && vgroup_validmap[dw->def_nr]) {
- dw->weight *= fac;
+ dw->weight *= fac;
}
}
}
@@ -1315,7 +1316,7 @@ static char has_locked_group(MDeformVert *dvert, const int defbase_tot,
}
/*
* gen_lck_flags gets the status of "flag" for each bDeformGroup
- *in ob->defbase and returns an array containing them
+ * in ob->defbase and returns an array containing them
*/
static char *gen_lock_flags(Object *ob, int defbase_tot)
{
@@ -1443,7 +1444,7 @@ static float redistribute_change(MDeformVert *ndv, const int defbase_tot,
change_status[ndw->def_nr] = changeto;
total_valid--;
}
- else {/* a perfectly valid change occurred to ndw->weight */
+ else { /* a perfectly valid change occurred to ndw->weight */
totchange -= change;
ndw->weight += change;
}
@@ -1731,11 +1732,12 @@ static int get_first_selected_nonzero_weight(MDeformVert *dvert, const int defba
static char *wpaint_make_validmap(Object *ob);
-static void do_weight_paint_vertex(/* vars which remain the same for every vert */
- VPaint *wp, Object *ob, const WeightPaintInfo *wpi,
- /* vars which change on each stroke */
- const unsigned int index, float alpha, float paintweight
- )
+static void do_weight_paint_vertex(
+ /* vars which remain the same for every vert */
+ VPaint *wp, Object *ob, const WeightPaintInfo *wpi,
+ /* vars which change on each stroke */
+ const unsigned int index, float alpha, float paintweight
+ )
{
Mesh *me = ob->data;
MDeformVert *dv = &me->dvert[index];
@@ -1915,7 +1917,7 @@ static void do_weight_paint_vertex(/* vars which remain the same for every vert
if (tdw->weight != tdw_prev->weight) {
oldChange = tdw->weight / tdw_prev->weight;
testw = tdw_prev->weight * change;
- if ( testw > tdw_prev->weight ) {
+ if (testw > tdw_prev->weight) {
if (change > oldChange) {
/* reset the weights and use the new change */
defvert_reset_to_prev(wp->wpaint_prev + index, dv);
@@ -1955,7 +1957,7 @@ static void do_weight_paint_vertex(/* vars which remain the same for every vert
dw = defvert_find_index(dv, vgroup);
#else
dw = NULL; /* UNUSED after assignment, set to NULL to ensuyre we don't
- * use again, we thats needed un-ifdef the line above */
+ * use again, we thats needed un-ifdef the line above */
(void)dw; /* quiet warnigns */
#endif
@@ -1972,7 +1974,7 @@ static void do_weight_paint_vertex(/* vars which remain the same for every vert
/* *************** set wpaint operator ****************** */
-static int set_wpaint(bContext *C, wmOperator *UNUSED(op)) /* toggle */
+static int set_wpaint(bContext *C, wmOperator *UNUSED(op)) /* toggle */
{
Object *ob = CTX_data_active_object(C);
Scene *scene = CTX_data_scene(C);
@@ -2018,7 +2020,7 @@ static int set_wpaint(bContext *C, wmOperator *UNUSED(op)) /* toggle */
mesh_mirrtopo_table(NULL, 'e');
}
- WM_event_add_notifier(C, NC_SCENE|ND_MODE, scene);
+ WM_event_add_notifier(C, NC_SCENE | ND_MODE, scene);
return OPERATOR_FINISHED;
}
@@ -2048,7 +2050,7 @@ void PAINT_OT_weight_paint_toggle(wmOperatorType *ot)
ot->poll = paint_poll_test;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -2089,7 +2091,7 @@ static char *wpaint_make_validmap(Object *ob)
/* now loop through the armature modifiers and identify deform bones */
for (md = ob->modifiers.first; md; md = !md->next && step1 ? (step1 = 0), modifiers_getVirtualModifierList(ob) : md->next) {
- if (!(md->mode & (eModifierMode_Realtime|eModifierMode_Virtual)))
+ if (!(md->mode & (eModifierMode_Realtime | eModifierMode_Virtual)))
continue;
if (md->type == eModifierType_Armature) {
@@ -2149,7 +2151,7 @@ static int wpaint_stroke_test_start(bContext *C, wmOperator *op, wmEvent *UNUSED
/* if nothing was added yet, we make dverts and a vertex deform group */
if (!me->dvert) {
ED_vgroup_data_create(&me->id);
- WM_event_add_notifier(C, NC_GEOM|ND_DATA, me);
+ WM_event_add_notifier(C, NC_GEOM | ND_DATA, me);
}
/* this happens on a Bone select, when no vgroup existed yet */
@@ -2163,7 +2165,7 @@ static int wpaint_stroke_test_start(bContext *C, wmOperator *op, wmEvent *UNUSED
if (pchan) {
bDeformGroup *dg = defgroup_find_name(ob, pchan->name);
if (dg == NULL) {
- dg = ED_vgroup_add_name(ob, pchan->name); /* sets actdef */
+ dg = ED_vgroup_add_name(ob, pchan->name); /* sets actdef */
}
else {
int actdef = 1 + BLI_findindex(&ob->defbase, dg);
@@ -2403,7 +2405,7 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
if (me->dvert[vidx].flag) {
alpha = calc_vp_alpha_dl(wp, vc, wpd->wpimat, wpd->vertexcosnos + 6 * vidx,
- mval, brush_size_pressure, brush_alpha_pressure);
+ mval, brush_size_pressure, brush_alpha_pressure);
if (alpha) {
do_weight_paint_vertex(wp, ob, &wpi, vidx, alpha, paintweight);
}
@@ -2503,7 +2505,7 @@ void PAINT_OT_weight_paint(wmOperatorType *ot)
ot->cancel = wpaint_cancel;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", "");
}
@@ -2529,13 +2531,13 @@ void PAINT_OT_weight_set(wmOperatorType *ot)
ot->poll = mask_paint_poll; /* it was facemask_paint_poll */
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/* ************ set / clear vertex paint mode ********** */
-static int set_vpaint(bContext *C, wmOperator *op) /* toggle */
+static int set_vpaint(bContext *C, wmOperator *op) /* toggle */
{
Object *ob = CTX_data_active_object(C);
Scene *scene = CTX_data_scene(C);
@@ -2576,7 +2578,7 @@ static int set_vpaint(bContext *C, wmOperator *op) /* toggle */
/* update modifier stack for mapping requirements */
DAG_id_tag_update(&me->id, 0);
- WM_event_add_notifier(C, NC_SCENE|ND_MODE, scene);
+ WM_event_add_notifier(C, NC_SCENE | ND_MODE, scene);
return OPERATOR_FINISHED;
}
@@ -2593,7 +2595,7 @@ void PAINT_OT_vertex_paint_toggle(wmOperatorType *ot)
ot->poll = paint_poll_test;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -2737,17 +2739,17 @@ static void vpaint_paint_face(VPaint *vp, VPaintData *vpd, Object *ob,
int brush_alpha_pressure_i;
if ((vp->flag & VP_COLINDEX && mface->mat_nr != ob->actcol - 1) ||
- ((me->editflag & ME_EDIT_PAINT_MASK) && !(mface->flag & ME_FACE_SEL)))
+ ((me->editflag & ME_EDIT_PAINT_MASK) && !(mface->flag & ME_FACE_SEL)))
return;
if (brush->vertexpaint_tool == PAINT_BLEND_BLUR) {
- unsigned int fcol1 = mcol_blend( mcol[0], mcol[1], 128);
+ unsigned int fcol1 = mcol_blend(mcol[0], mcol[1], 128);
if (mface->v4) {
- unsigned int fcol2 = mcol_blend( mcol[2], mcol[3], 128);
- vpd->paintcol = mcol_blend( fcol1, fcol2, 128);
+ unsigned int fcol2 = mcol_blend(mcol[2], mcol[3], 128);
+ vpd->paintcol = mcol_blend(fcol1, fcol2, 128);
}
else {
- vpd->paintcol = mcol_blend( mcol[2], fcol1, 170);
+ vpd->paintcol = mcol_blend(mcol[2], fcol1, 170);
}
}
@@ -2974,8 +2976,8 @@ static int vpaint_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
op->customdata = paint_stroke_new(C, NULL, vpaint_stroke_test_start,
- vpaint_stroke_update_step,
- vpaint_stroke_done, event->type);
+ vpaint_stroke_update_step,
+ vpaint_stroke_done, event->type);
/* add modal handler */
WM_event_add_modal_handler(C, op);
@@ -3006,7 +3008,7 @@ void PAINT_OT_vertex_paint(wmOperatorType *ot)
ot->cancel = vpaint_cancel;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", "");
}
@@ -3031,7 +3033,7 @@ static int weight_from_bones_exec(bContext *C, wmOperator *op)
create_vgroups_from_armature(op->reports, scene, ob, armob, type, (me->editflag & ME_EDIT_MIRROR_X));
DAG_id_tag_update(&me->id, 0);
- WM_event_add_notifier(C, NC_GEOM|ND_DATA, me);
+ WM_event_add_notifier(C, NC_GEOM | ND_DATA, me);
return OPERATOR_FINISHED;
}
@@ -3053,7 +3055,7 @@ void PAINT_OT_weight_from_bones(wmOperatorType *ot)
ot->poll = weight_from_bones_poll;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
ot->prop = RNA_def_enum(ot->srna, "type", type_items, 0, "Type", "Method to use for assigning weights");
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index e91f26fc9ba..506716543ea 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -95,7 +95,7 @@
void ED_sculpt_force_update(bContext *C)
{
- Object *ob= CTX_data_active_object(C);
+ Object *ob = CTX_data_active_object(C);
if (ob && (ob->mode & OB_MODE_SCULPT))
multires_force_update(ob);
@@ -103,9 +103,8 @@ void ED_sculpt_force_update(bContext *C)
/* Sculpt mode handles multires differently from regular meshes, but only if
* it's the last modifier on the stack and it is not on the first level */
-struct MultiresModifierData *sculpt_multires_active(Scene *scene, Object *ob)
-{
- Mesh *me= (Mesh*)ob->data;
+struct MultiresModifierData *sculpt_multires_active(Scene *scene, Object *ob){
+ Mesh *me = (Mesh *)ob->data;
ModifierData *md;
if (!CustomData_get_layer(&me->ldata, CD_MDISPS)) {
@@ -113,9 +112,9 @@ struct MultiresModifierData *sculpt_multires_active(Scene *scene, Object *ob)
return NULL;
}
- for (md= modifiers_getVirtualModifierList(ob); md; md= md->next) {
+ for (md = modifiers_getVirtualModifierList(ob); md; md = md->next) {
if (md->type == eModifierType_Multires) {
- MultiresModifierData *mmd= (MultiresModifierData*)md;
+ MultiresModifierData *mmd = (MultiresModifierData *)md;
if (!modifier_isEnabled(scene, md, eModifierMode_Realtime))
continue;
@@ -133,10 +132,10 @@ static int sculpt_has_active_modifiers(Scene *scene, Object *ob)
{
ModifierData *md;
- md= modifiers_getVirtualModifierList(ob);
+ md = modifiers_getVirtualModifierList(ob);
/* exception for shape keys because we can edit those */
- for (; md; md= md->next) {
+ for (; md; md = md->next) {
if (modifier_isEnabled(scene, md, eModifierMode_Realtime))
return 1;
}
@@ -148,25 +147,25 @@ static int sculpt_has_active_modifiers(Scene *scene, Object *ob)
static int sculpt_modifiers_active(Scene *scene, Sculpt *sd, Object *ob)
{
ModifierData *md;
- Mesh *me= (Mesh*)ob->data;
- MultiresModifierData *mmd= sculpt_multires_active(scene, ob);
+ Mesh *me = (Mesh *)ob->data;
+ MultiresModifierData *mmd = sculpt_multires_active(scene, ob);
if (mmd) return 0;
/* non-locked shape keys could be handled in the same way as deformed mesh */
- if ((ob->shapeflag&OB_SHAPE_LOCK)==0 && me->key && ob->shapenr)
+ if ((ob->shapeflag & OB_SHAPE_LOCK) == 0 && me->key && ob->shapenr)
return 1;
- md= modifiers_getVirtualModifierList(ob);
+ md = modifiers_getVirtualModifierList(ob);
/* exception for shape keys because we can edit those */
- for (; md; md= md->next) {
+ for (; md; md = md->next) {
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
if (!modifier_isEnabled(scene, md, eModifierMode_Realtime)) continue;
- if (md->type==eModifierType_ShapeKey) continue;
+ if (md->type == eModifierType_ShapeKey) continue;
- if (mti->type==eModifierTypeType_OnlyDeform) return 1;
- else if ((sd->flags & SCULPT_ONLY_DEFORM)==0) return 1;
+ if (mti->type == eModifierTypeType_OnlyDeform) return 1;
+ else if ((sd->flags & SCULPT_ONLY_DEFORM) == 0) return 1;
}
return 0;
@@ -248,10 +247,10 @@ typedef struct StrokeCache {
/* Get a screen-space rectangle of the modified area */
static int sculpt_get_redraw_rect(ARegion *ar, RegionView3D *rv3d,
- Object *ob, rcti *rect)
+ Object *ob, rcti *rect)
{
SculptSession *ss;
- PBVH *pbvh= ob->sculpt->pbvh;
+ PBVH *pbvh = ob->sculpt->pbvh;
float bb_min[3], bb_max[3];
if (!pbvh)
@@ -261,11 +260,11 @@ static int sculpt_get_redraw_rect(ARegion *ar, RegionView3D *rv3d,
/* convert 3D bounding box to screen space */
if (!paint_convert_bb_to_rect(rect,
- bb_min,
- bb_max,
- ar,
- rv3d,
- ob)) {
+ bb_min,
+ bb_max,
+ ar,
+ rv3d,
+ ob)) {
return 0;
}
@@ -285,9 +284,9 @@ static int sculpt_get_redraw_rect(ARegion *ar, RegionView3D *rv3d,
}
void sculpt_get_redraw_planes(float planes[4][4], ARegion *ar,
- RegionView3D *rv3d, Object *ob)
+ RegionView3D *rv3d, Object *ob)
{
- PBVH *pbvh= ob->sculpt->pbvh;
+ PBVH *pbvh = ob->sculpt->pbvh;
rcti rect;
sculpt_get_redraw_rect(ar, rv3d, ob, &rect);
@@ -309,9 +308,9 @@ typedef struct SculptBrushTest {
static void sculpt_brush_test_init(SculptSession *ss, SculptBrushTest *test)
{
- test->radius_squared= ss->cache->radius_squared;
+ test->radius_squared = ss->cache->radius_squared;
copy_v3_v3(test->location, ss->cache->location);
- test->dist= 0.0f; /* just for initialize */
+ test->dist = 0.0f; /* just for initialize */
}
static int sculpt_brush_test(SculptBrushTest *test, float co[3])
@@ -360,8 +359,8 @@ static int sculpt_brush_test_cube(SculptBrushTest *test, float co[3], float loca
float p = 4;
test->dist = ((powf(local_co[0], p) +
- powf(local_co[1], p) +
- powf(local_co[2], p)) / pow(side, p));
+ powf(local_co[1], p) +
+ powf(local_co[2], p)) / pow(side, p));
return 1;
}
@@ -371,7 +370,7 @@ static int sculpt_brush_test_cube(SculptBrushTest *test, float co[3], float loca
}
static float frontface(Brush *brush, const float sculpt_normal[3],
- const short no[3], const float fno[3])
+ const short no[3], const float fno[3])
{
if (brush->flag & BRUSH_FRONTFACE) {
float dot;
@@ -380,10 +379,10 @@ static float frontface(Brush *brush, const float sculpt_normal[3],
float tmp[3];
normal_short_to_float_v3(tmp, no);
- dot= dot_v3v3(tmp, sculpt_normal);
+ dot = dot_v3v3(tmp, sculpt_normal);
}
else {
- dot= dot_v3v3(fno, sculpt_normal);
+ dot = dot_v3v3(fno, sculpt_normal);
}
return dot > 0 ? dot : 0;
}
@@ -404,7 +403,7 @@ static int sculpt_brush_test_cyl(SculptBrushTest *test, float co[3], float locat
cross_v3_v3v3(t3, an, t1);
- dist = len_v3(t3)/len_v3(t2);
+ dist = len_v3(t3) / len_v3(t2);
test->dist = dist;
@@ -421,20 +420,20 @@ static int sculpt_brush_test_cyl(SculptBrushTest *test, float co[3], float locat
*/
-static float overlapped_curve(Brush* br, float x)
+static float overlapped_curve(Brush *br, float x)
{
int i;
const int n = 100 / br->spacing;
const float h = br->spacing / 50.0f;
- const float x0 = x-1;
+ const float x0 = x - 1;
float sum;
sum = 0;
- for (i= 0; i < n; i++) {
+ for (i = 0; i < n; i++) {
float xx;
- xx = fabs(x0 + i*h);
+ xx = fabs(x0 + i * h);
if (xx < 1.0f)
sum += brush_curve_strength(br, xx, 1);
@@ -443,16 +442,16 @@ static float overlapped_curve(Brush* br, float x)
return sum;
}
-static float integrate_overlap(Brush* br)
+static float integrate_overlap(Brush *br)
{
int i;
- int m= 10;
- float g = 1.0f/m;
+ int m = 10;
+ float g = 1.0f / m;
float max;
- max= 0;
- for (i= 0; i < m; i++) {
- float overlap= overlapped_curve(br, i*g);
+ max = 0;
+ for (i = 0; i < m; i++) {
+ float overlap = overlapped_curve(br, i * g);
if (overlap > max)
max = overlap;
@@ -465,17 +464,17 @@ static float integrate_overlap(Brush* br)
static void flip_coord(float out[3], float in[3], const char symm)
{
if (symm & SCULPT_SYMM_X)
- out[0]= -in[0];
+ out[0] = -in[0];
else
- out[0]= in[0];
+ out[0] = in[0];
if (symm & SCULPT_SYMM_Y)
- out[1]= -in[1];
+ out[1] = -in[1];
else
- out[1]= in[1];
+ out[1] = in[1];
if (symm & SCULPT_SYMM_Z)
- out[2]= -in[2];
+ out[2] = -in[2];
else
- out[2]= in[2];
+ out[2] = in[2];
}
static float calc_overlap(StrokeCache *cache, const char symm, const char axis, const float angle)
@@ -487,7 +486,7 @@ static float calc_overlap(StrokeCache *cache, const char symm, const char axis,
flip_coord(mirror, cache->true_location, symm);
if (axis != 0) {
- float mat[4][4]= MAT4_UNITY;
+ float mat[4][4] = MAT4_UNITY;
rotate_m4(mat, axis, angle);
mul_m4_v3(mat, mirror);
}
@@ -495,8 +494,8 @@ static float calc_overlap(StrokeCache *cache, const char symm, const char axis,
/* distsq = len_squared_v3v3(mirror, cache->traced_location); */
distsq = len_squared_v3v3(mirror, cache->true_location);
- if (distsq <= 4.0f*(cache->radius_squared))
- return (2.0f*(cache->radius) - sqrtf(distsq)) / (2.0f*(cache->radius));
+ if (distsq <= 4.0f * (cache->radius_squared))
+ return (2.0f * (cache->radius) - sqrtf(distsq)) / (2.0f * (cache->radius));
else
return 0;
}
@@ -507,15 +506,15 @@ static float calc_radial_symmetry_feather(Sculpt *sd, StrokeCache *cache, const
float overlap;
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 (i = 1; i < sd->radial_symm[axis - 'X']; ++i) {
+ const float angle = 2 * M_PI * i / sd->radial_symm[axis - 'X'];
overlap += calc_overlap(cache, symm, axis, angle);
}
return overlap;
}
-static float calc_symmetry_feather(Sculpt *sd, StrokeCache* cache)
+static float calc_symmetry_feather(Sculpt *sd, StrokeCache *cache)
{
if (sd->flags & SCULPT_SYMMETRY_FEATHER) {
float overlap;
@@ -534,7 +533,7 @@ static float calc_symmetry_feather(Sculpt *sd, StrokeCache* cache)
}
}
- return 1/overlap;
+ return 1 / overlap;
}
else {
return 1;
@@ -551,7 +550,7 @@ static float brush_strength(Sculpt *sd, StrokeCache *cache, float feather)
/* Primary strength input; square it to make lower values more sensitive */
const float root_alpha = brush_alpha(scene, brush);
- float alpha = root_alpha*root_alpha;
+ float alpha = root_alpha * root_alpha;
float dir = brush->flag & BRUSH_DIR_IN ? -1 : 1;
float pressure = brush_use_alpha_pressure(scene, brush) ? cache->pressure : 1;
float pen_flip = cache->pen_flip ? -1 : 1;
@@ -560,12 +559,12 @@ static float brush_strength(Sculpt *sd, StrokeCache *cache, float feather)
/* spacing is integer percentage of radius, divide by 50 to get
* normalized diameter */
float overlap = (brush->flag & BRUSH_SPACE_ATTEN &&
- brush->flag & BRUSH_SPACE &&
- !(brush->flag & BRUSH_ANCHORED) &&
- (brush->spacing < 100)) ? 1.0f/accum : 1;
+ brush->flag & BRUSH_SPACE &&
+ !(brush->flag & BRUSH_ANCHORED) &&
+ (brush->spacing < 100)) ? 1.0f / accum : 1;
float flip = dir * invert * pen_flip;
- switch(brush->sculpt_tool) {
+ switch (brush->sculpt_tool) {
case SCULPT_TOOL_CLAY:
case SCULPT_TOOL_CLAY_STRIPS:
case SCULPT_TOOL_DRAW:
@@ -588,7 +587,7 @@ static float brush_strength(Sculpt *sd, StrokeCache *cache, float feather)
case SCULPT_TOOL_SCRAPE:
case SCULPT_TOOL_FLATTEN:
if (flip > 0) {
- overlap = (1+overlap) / 2;
+ overlap = (1 + overlap) / 2;
return alpha * flip * pressure * overlap * feather;
}
else {
@@ -608,11 +607,11 @@ static float brush_strength(Sculpt *sd, StrokeCache *cache, float feather)
}
case SCULPT_TOOL_NUDGE:
- overlap = (1+overlap) / 2;
+ overlap = (1 + overlap) / 2;
return alpha * pressure * overlap * feather;
case SCULPT_TOOL_THUMB:
- return alpha*pressure*feather;
+ return alpha * pressure * feather;
case SCULPT_TOOL_SNAKE_HOOK:
return feather;
@@ -621,7 +620,7 @@ static float brush_strength(Sculpt *sd, StrokeCache *cache, float feather)
return feather;
case SCULPT_TOOL_ROTATE:
- return alpha*pressure*feather;
+ return alpha * pressure * feather;
default:
return 0;
@@ -630,24 +629,24 @@ static float brush_strength(Sculpt *sd, StrokeCache *cache, float feather)
/* Return a multiplier for brush strength on a particular vertex. */
static float tex_strength(SculptSession *ss, Brush *br, float point[3],
- const float len,
- const float sculpt_normal[3],
- const short vno[3],
- const float fno[3])
+ const float len,
+ const float sculpt_normal[3],
+ const short vno[3],
+ const float fno[3])
{
MTex *mtex = &br->mtex;
- float avg= 1;
+ float avg = 1;
if (!mtex->tex) {
- avg= 1;
+ avg = 1;
}
else if (mtex->brush_map_mode == MTEX_MAP_MODE_3D) {
float jnk;
/* Get strength by feeding the vertex
- * location directly into a texture */
+ * location directly into a texture */
externtex(mtex, point, &avg,
- &jnk, &jnk, &jnk, &jnk, 0);
+ &jnk, &jnk, &jnk, &jnk, 0);
}
else if (ss->texcache) {
float rotation = -mtex->rot;
@@ -680,9 +679,9 @@ static float tex_strength(SculptSession *ss, Brush *br, float point[3],
x = point_2d[0] + ss->cache->vc->ar->winrct.xmin;
y = point_2d[1] + ss->cache->vc->ar->winrct.ymin;
}
- else /* else (mtex->brush_map_mode == MTEX_MAP_MODE_TILED) */
- /* leave the coordinates relative to the screen */
- {
+ else { /* else (mtex->brush_map_mode == MTEX_MAP_MODE_TILED) */
+ /* leave the coordinates relative to the screen */
+
/* use unadjusted size for tiled mode */
radius = brush_size(ss->cache->vc->scene, br);
@@ -706,7 +705,7 @@ static float tex_strength(SculptSession *ss, Brush *br, float point[3],
* atan2, sqrtf, sin, and cos. */
if (rotation > 0.001f || rotation < -0.001f) {
const float angle = atan2f(y, x) + rotation;
- const float flen = sqrtf(x*x + y*y);
+ const float flen = sqrtf(x * x + y * y);
x = flen * cosf(angle);
y = flen * sinf(angle);
@@ -770,14 +769,14 @@ static void sculpt_clip(Sculpt *sd, SculptSession *ss, float *co, const float va
{
int i;
- for (i=0; i<3; ++i) {
+ for (i = 0; i < 3; ++i) {
if (sd->flags & (SCULPT_LOCK_X << i))
continue;
if ((ss->cache->flag & (CLIP_X << i)) && (fabsf(co[i]) <= ss->cache->clip_tolerance[i]))
- co[i]= 0.0f;
+ co[i] = 0.0f;
else
- co[i]= val[i];
+ co[i] = val[i];
}
}
@@ -803,7 +802,7 @@ static void calc_area_normal(Sculpt *sd, Object *ob, float an[3], PBVHNode **nod
zero_v3(an);
#pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP)
- for (n=0; n<totnode; n++) {
+ for (n = 0; n < totnode; n++) {
PBVHVertexIter vd;
SculptBrushTest test;
SculptUndoNode *unode;
@@ -863,7 +862,7 @@ static void calc_sculpt_normal(Sculpt *sd, Object *ob, float an[3], PBVHNode **n
if (ss->cache->mirror_symmetry_pass == 0 &&
ss->cache->radial_symmetry_pass == 0 &&
- (ss->cache->first_time || !(brush->flag & BRUSH_ORIGINAL_NORMAL)))
+ (ss->cache->first_time || !(brush->flag & BRUSH_ORIGINAL_NORMAL)))
{
switch (brush->sculpt_plane) {
case SCULPT_DISP_DIR_VIEW:
@@ -920,7 +919,7 @@ static void neighbor_average(SculptSession *ss, float avg[3], unsigned vert)
int i, total = 0;
for (i = 0; i < vert_map->count; i++) {
- const MPoly *p= &ss->mpoly[vert_map->indices[i]];
+ const MPoly *p = &ss->mpoly[vert_map->indices[i]];
unsigned f_adj_v[3];
if (poly_get_adj_loops_from_vert(f_adj_v, p, ss->mloop, vert) != -1) {
@@ -929,7 +928,7 @@ static void neighbor_average(SculptSession *ss, float avg[3], unsigned vert)
for (j = 0; j < 3; j++) {
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);
+ mvert[f_adj_v[j]].co);
total++;
}
@@ -958,8 +957,8 @@ static void do_mesh_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *node,
BLI_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE) {
if (sculpt_brush_test(&test, vd.co)) {
- const float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist,
- ss->cache->view_normal, vd.no, vd.fno);
+ const float fade = bstrength * tex_strength(ss, brush, vd.co, test.dist,
+ ss->cache->view_normal, vd.no, vd.fno);
float avg[3], val[3];
neighbor_average(ss, avg, vd.vert_indices[vd.i]);
@@ -971,7 +970,7 @@ static void do_mesh_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *node,
sculpt_clip(sd, ss, vd.co, val);
if (vd.mvert)
- vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
}
}
BLI_pbvh_vertex_iter_end;
@@ -992,34 +991,34 @@ static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *no
CLAMP(bstrength, 0.0f, 1.0f);
BLI_pbvh_node_get_grids(ss->pbvh, node, &grid_indices, &totgrid,
- NULL, &gridsize, &griddata, &gridadj);
+ NULL, &gridsize, &griddata, &gridadj);
#pragma omp critical
{
- tmpgrid= MEM_mallocN(sizeof(float)*3*gridsize*gridsize, "tmpgrid");
- tmprow= MEM_mallocN(sizeof(float)*3*gridsize, "tmprow");
+ tmpgrid = MEM_mallocN(sizeof(float) * 3 * gridsize * gridsize, "tmpgrid");
+ tmprow = MEM_mallocN(sizeof(float) * 3 * gridsize, "tmprow");
}
for (i = 0; i < totgrid; ++i) {
data = griddata[grid_indices[i]];
adj = &gridadj[grid_indices[i]];
- memset(tmpgrid, 0, sizeof(float)*3*gridsize*gridsize);
+ memset(tmpgrid, 0, sizeof(float) * 3 * gridsize * gridsize);
- for (y= 0; y < gridsize-1; y++) {
+ for (y = 0; y < gridsize - 1; y++) {
float tmp[3];
- v1 = y*gridsize;
- add_v3_v3v3(tmprow[0], data[v1].co, data[v1+gridsize].co);
+ v1 = y * gridsize;
+ add_v3_v3v3(tmprow[0], data[v1].co, data[v1 + gridsize].co);
- for (x= 0; x < gridsize-1; x++) {
- v1 = x + y*gridsize;
+ for (x = 0; x < gridsize - 1; x++) {
+ v1 = x + y * gridsize;
v2 = v1 + 1;
v3 = v1 + gridsize;
v4 = v3 + 1;
- add_v3_v3v3(tmprow[x+1], data[v2].co, data[v4].co);
- add_v3_v3v3(tmp, tmprow[x+1], tmprow[x]);
+ add_v3_v3v3(tmprow[x + 1], data[v2].co, data[v4].co);
+ add_v3_v3v3(tmp, tmprow[x + 1], tmprow[x]);
add_v3_v3(tmpgrid[v1], tmp);
add_v3_v3(tmpgrid[v2], tmp);
@@ -1047,19 +1046,19 @@ static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *no
if (y == gridsize - 1 && adj->index[1] == -1)
continue;
- index = x + y*gridsize;
- co= data[index].co;
- fno= data[index].no;
+ index = x + y * gridsize;
+ co = data[index].co;
+ fno = data[index].no;
if (sculpt_brush_test(&test, co)) {
- const float fade = bstrength*tex_strength(ss, brush, co, test.dist,
- ss->cache->view_normal, NULL, fno);
+ const float fade = bstrength * tex_strength(ss, brush, co, test.dist,
+ ss->cache->view_normal, NULL, fno);
float *avg, val[3];
float n;
- avg = tmpgrid[x + y*gridsize];
+ avg = tmpgrid[x + y * gridsize];
- n = 1/16.0f;
+ n = 1 / 16.0f;
if (x == 0 || x == gridsize - 1)
n *= 2;
@@ -1091,18 +1090,18 @@ static void smooth(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode, float
{
SculptSession *ss = ob->sculpt;
const int max_iterations = 4;
- const float fract = 1.0f/max_iterations;
+ const float fract = 1.0f / max_iterations;
int iteration, n, count;
float last;
CLAMP(bstrength, 0, 1);
- count = (int)(bstrength*max_iterations);
- last = max_iterations*(bstrength - count*fract);
+ count = (int)(bstrength * max_iterations);
+ last = max_iterations * (bstrength - count * fract);
for (iteration = 0; iteration <= count; ++iteration) {
#pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP)
- for (n=0; n<totnode; n++) {
+ for (n = 0; n < totnode; n++) {
if (ss->multires) {
do_multires_smooth_brush(sd, ss, nodes[n], iteration != count ? 1.0f : last);
}
@@ -1126,7 +1125,7 @@ static void do_draw_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
SculptSession *ss = ob->sculpt;
Brush *brush = paint_brush(&sd->paint);
float offset[3], area_normal[3];
- float bstrength= ss->cache->bstrength;
+ float bstrength = ss->cache->bstrength;
int n;
calc_sculpt_normal(sd, ob, area_normal, nodes, totnode);
@@ -1138,12 +1137,12 @@ static void do_draw_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
/* threaded loop over nodes */
#pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP)
- for (n=0; n<totnode; n++) {
+ for (n = 0; n < totnode; n++) {
PBVHVertexIter vd;
SculptBrushTest test;
float (*proxy)[3];
- proxy= BLI_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co;
+ proxy = BLI_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co;
sculpt_brush_test_init(ss, &test);
@@ -1151,7 +1150,7 @@ static void do_draw_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
if (sculpt_brush_test(&test, vd.co)) {
/* offset vertex */
float fade = tex_strength(ss, brush, vd.co, test.dist,
- area_normal, vd.no, vd.fno);
+ area_normal, vd.no, vd.fno);
mul_v3_v3fl(proxy[vd.i], offset, fade);
@@ -1169,7 +1168,7 @@ static void do_crease_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod
const Scene *scene = ss->cache->vc->scene;
Brush *brush = paint_brush(&sd->paint);
float offset[3], area_normal[3];
- float bstrength= ss->cache->bstrength;
+ float bstrength = ss->cache->bstrength;
float flippedbstrength, crease_correction;
int n;
@@ -1183,23 +1182,23 @@ static void do_crease_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod
/* we divide out the squared alpha and multiply by the squared crease to give us the pinch strength */
if (brush_alpha(scene, brush) > 0.0f)
- crease_correction = brush->crease_pinch_factor*brush->crease_pinch_factor/(brush_alpha(scene, brush)*brush_alpha(scene, brush));
+ crease_correction = brush->crease_pinch_factor * brush->crease_pinch_factor / (brush_alpha(scene, brush) * brush_alpha(scene, brush));
else
- crease_correction = brush->crease_pinch_factor*brush->crease_pinch_factor;
+ crease_correction = brush->crease_pinch_factor * brush->crease_pinch_factor;
/* 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) ? -crease_correction * bstrength : crease_correction * bstrength;
if (brush->sculpt_tool == SCULPT_TOOL_BLOB) flippedbstrength *= -1.0f;
/* threaded loop over nodes */
#pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP)
- for (n=0; n<totnode; n++) {
+ for (n = 0; n < totnode; n++) {
PBVHVertexIter vd;
SculptBrushTest test;
float (*proxy)[3];
- proxy= BLI_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co;
+ proxy = BLI_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co;
sculpt_brush_test_init(ss, &test);
@@ -1213,7 +1212,7 @@ static void do_crease_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod
/* first we pinch */
sub_v3_v3v3(val1, test.location, vd.co);
- mul_v3_fl(val1, fade*flippedbstrength);
+ mul_v3_fl(val1, fade * flippedbstrength);
/* then we draw */
mul_v3_v3fl(val2, offset, fade);
@@ -1232,23 +1231,23 @@ static void do_pinch_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode
{
SculptSession *ss = ob->sculpt;
Brush *brush = paint_brush(&sd->paint);
- float bstrength= ss->cache->bstrength;
+ float bstrength = ss->cache->bstrength;
int n;
#pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP)
- for (n=0; n<totnode; n++) {
+ for (n = 0; n < totnode; n++) {
PBVHVertexIter vd;
SculptBrushTest test;
float (*proxy)[3];
- proxy= BLI_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co;
+ proxy = BLI_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co;
sculpt_brush_test_init(ss, &test);
BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) {
if (sculpt_brush_test(&test, vd.co)) {
- float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist,
- ss->cache->view_normal, vd.no, vd.fno);
+ float fade = bstrength * tex_strength(ss, brush, vd.co, test.dist,
+ ss->cache->view_normal, vd.no, vd.fno);
float val[3];
sub_v3_v3v3(val, test.location, vd.co);
@@ -1265,14 +1264,14 @@ static void do_pinch_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode
static void do_grab_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
{
SculptSession *ss = ob->sculpt;
- Brush *brush= paint_brush(&sd->paint);
- float bstrength= ss->cache->bstrength;
+ Brush *brush = paint_brush(&sd->paint);
+ float bstrength = ss->cache->bstrength;
float grab_delta[3], an[3];
int n;
float len;
if (brush->normal_weight > 0 || brush->flag & BRUSH_FRONTFACE) {
- int cache= 1;
+ int cache = 1;
/* grab brush requires to test on original data */
SWAP(int, ss->cache->original, cache);
calc_sculpt_normal(sd, ob, an, nodes, totnode);
@@ -1284,32 +1283,33 @@ static void do_grab_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
len = len_v3(grab_delta);
if (brush->normal_weight > 0) {
- mul_v3_fl(an, len*brush->normal_weight);
+ mul_v3_fl(an, len * brush->normal_weight);
mul_v3_fl(grab_delta, 1.0f - brush->normal_weight);
add_v3_v3(grab_delta, an);
}
#pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP)
- for (n=0; n<totnode; n++) {
+ for (n = 0; n < totnode; n++) {
PBVHVertexIter vd;
- SculptUndoNode* unode;
+ SculptUndoNode *unode;
SculptBrushTest test;
float (*origco)[3];
short (*origno)[3];
float (*proxy)[3];
- unode= sculpt_undo_push_node(ob, nodes[n], SCULPT_UNDO_COORDS);
- origco= unode->co;
- origno= unode->no;
+ unode = sculpt_undo_push_node(ob, nodes[n], SCULPT_UNDO_COORDS);
+ origco = unode->co;
+ origno = unode->no;
- proxy= BLI_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co;
+ proxy = BLI_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co;
sculpt_brush_test_init(ss, &test);
- BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) {
+ BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE)
+ {
if (sculpt_brush_test(&test, origco[vd.i])) {
- const float fade = bstrength*tex_strength(ss, brush, origco[vd.i], test.dist,
- an, origno[vd.i], NULL);
+ const float fade = bstrength * tex_strength(ss, brush, origco[vd.i], test.dist,
+ an, origno[vd.i], NULL);
mul_v3_v3fl(proxy[vd.i], grab_delta, fade);
@@ -1344,14 +1344,14 @@ static void do_nudge_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode
SculptBrushTest test;
float (*proxy)[3];
- proxy= BLI_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co;
+ proxy = BLI_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co;
sculpt_brush_test_init(ss, &test);
BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) {
if (sculpt_brush_test(&test, vd.co)) {
- const float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist,
- an, vd.no, vd.fno);
+ const float fade = bstrength * tex_strength(ss, brush, vd.co, test.dist,
+ an, vd.no, vd.fno);
mul_v3_v3fl(proxy[vd.i], cono, fade);
@@ -1383,7 +1383,7 @@ static void do_snake_hook_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int to
negate_v3(grab_delta);
if (brush->normal_weight > 0) {
- mul_v3_fl(an, len*brush->normal_weight);
+ mul_v3_fl(an, len * brush->normal_weight);
mul_v3_fl(grab_delta, 1.0f - brush->normal_weight);
add_v3_v3(grab_delta, an);
}
@@ -1394,14 +1394,14 @@ static void do_snake_hook_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int to
SculptBrushTest test;
float (*proxy)[3];
- proxy= BLI_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co;
+ proxy = BLI_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co;
sculpt_brush_test_init(ss, &test);
BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) {
if (sculpt_brush_test(&test, vd.co)) {
- const float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist,
- an, vd.no, vd.fno);
+ const float fade = bstrength * tex_strength(ss, brush, vd.co, test.dist,
+ an, vd.no, vd.fno);
mul_v3_v3fl(proxy[vd.i], grab_delta, fade);
@@ -1433,24 +1433,24 @@ static void do_thumb_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode
#pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP)
for (n = 0; n < totnode; n++) {
PBVHVertexIter vd;
- SculptUndoNode* unode;
+ SculptUndoNode *unode;
SculptBrushTest test;
float (*origco)[3];
short (*origno)[3];
float (*proxy)[3];
- unode= sculpt_undo_push_node(ob, nodes[n], SCULPT_UNDO_COORDS);
- origco= unode->co;
- origno= unode->no;
+ unode = sculpt_undo_push_node(ob, nodes[n], SCULPT_UNDO_COORDS);
+ origco = unode->co;
+ origno = unode->no;
- proxy= BLI_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co;
+ proxy = BLI_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co;
sculpt_brush_test_init(ss, &test);
BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) {
if (sculpt_brush_test(&test, origco[vd.i])) {
- const float fade = bstrength*tex_strength(ss, brush, origco[vd.i], test.dist,
- an, origno[vd.i], NULL);
+ const float fade = bstrength * tex_strength(ss, brush, origco[vd.i], test.dist,
+ an, origno[vd.i], NULL);
mul_v3_v3fl(proxy[vd.i], cono, fade);
@@ -1465,8 +1465,8 @@ static void do_thumb_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode
static void do_rotate_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
{
SculptSession *ss = ob->sculpt;
- Brush *brush= paint_brush(&sd->paint);
- float bstrength= ss->cache->bstrength;
+ Brush *brush = paint_brush(&sd->paint);
+ float bstrength = ss->cache->bstrength;
float an[3];
int n;
float m[4][4], rot[4][4], lmat[4][4], ilmat[4][4];
@@ -1485,26 +1485,26 @@ static void do_rotate_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod
mul_serie_m4(m, lmat, rot, ilmat, NULL, NULL, NULL, NULL, NULL);
#pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP)
- for (n=0; n<totnode; n++) {
+ for (n = 0; n < totnode; n++) {
PBVHVertexIter vd;
- SculptUndoNode* unode;
+ SculptUndoNode *unode;
SculptBrushTest test;
float (*origco)[3];
short (*origno)[3];
float (*proxy)[3];
- unode= sculpt_undo_push_node(ob, nodes[n], SCULPT_UNDO_COORDS);
- origco= unode->co;
- origno= unode->no;
+ unode = sculpt_undo_push_node(ob, nodes[n], SCULPT_UNDO_COORDS);
+ origco = unode->co;
+ origno = unode->no;
- proxy= BLI_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co;
+ proxy = BLI_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co;
sculpt_brush_test_init(ss, &test);
BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) {
if (sculpt_brush_test(&test, origco[vd.i])) {
- const float fade = bstrength*tex_strength(ss, brush, origco[vd.i], test.dist,
- an, origno[vd.i], NULL);
+ const float fade = bstrength * tex_strength(ss, brush, origco[vd.i], test.dist,
+ an, origno[vd.i], NULL);
mul_v3_m4v3(proxy[vd.i], m, origco[vd.i]);
sub_v3_v3(proxy[vd.i], origco[vd.i]);
@@ -1522,9 +1522,9 @@ static void do_layer_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode
{
SculptSession *ss = ob->sculpt;
Brush *brush = paint_brush(&sd->paint);
- float bstrength= ss->cache->bstrength;
+ float bstrength = ss->cache->bstrength;
float area_normal[3], offset[3];
- float lim= brush->height;
+ float lim = brush->height;
int n;
if (bstrength < 0)
@@ -1535,7 +1535,7 @@ static void do_layer_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode
mul_v3_v3v3(offset, ss->cache->scale, area_normal);
#pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP)
- for (n=0; n<totnode; n++) {
+ for (n = 0; n < totnode; n++) {
PBVHVertexIter vd;
SculptBrushTest test;
SculptUndoNode *unode;
@@ -1543,25 +1543,25 @@ static void do_layer_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode
/* XXX: layer brush needs conversion to proxy but its more complicated */
/* proxy= BLI_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co; */
- unode= sculpt_undo_push_node(ob, nodes[n], SCULPT_UNDO_COORDS);
- origco=unode->co;
+ unode = sculpt_undo_push_node(ob, nodes[n], SCULPT_UNDO_COORDS);
+ origco = unode->co;
if (!unode->layer_disp) {
#pragma omp critical
- unode->layer_disp= MEM_callocN(sizeof(float)*unode->totvert, "layer disp");
+ unode->layer_disp = MEM_callocN(sizeof(float) * unode->totvert, "layer disp");
}
- layer_disp= unode->layer_disp;
+ layer_disp = unode->layer_disp;
sculpt_brush_test_init(ss, &test);
BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) {
if (sculpt_brush_test(&test, origco[vd.i])) {
- const float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist,
- area_normal, vd.no, vd.fno);
- float *disp= &layer_disp[vd.i];
+ const float fade = bstrength * tex_strength(ss, brush, vd.co, test.dist,
+ area_normal, vd.no, vd.fno);
+ float *disp = &layer_disp[vd.i];
float val[3];
- *disp+= fade;
+ *disp += fade;
/* Don't let the displacement go past the limit */
if ((lim < 0 && *disp < lim) || (lim >= 0 && *disp > lim))
@@ -1570,7 +1570,7 @@ static void do_layer_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode
mul_v3_v3fl(val, offset, *disp);
if (ss->layer_co && (brush->flag & BRUSH_PERSISTENT)) {
- int index= vd.vert_indices[vd.i];
+ int index = vd.vert_indices[vd.i];
/* persistent base */
add_v3_v3(val, ss->layer_co[index]);
@@ -1593,23 +1593,23 @@ static void do_inflate_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totno
{
SculptSession *ss = ob->sculpt;
Brush *brush = paint_brush(&sd->paint);
- float bstrength= ss->cache->bstrength;
+ float bstrength = ss->cache->bstrength;
int n;
#pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP)
- for (n=0; n<totnode; n++) {
+ for (n = 0; n < totnode; n++) {
PBVHVertexIter vd;
SculptBrushTest test;
float (*proxy)[3];
- proxy= BLI_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co;
+ proxy = BLI_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co;
sculpt_brush_test_init(ss, &test);
BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) {
if (sculpt_brush_test(&test, vd.co)) {
- const float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist,
- ss->cache->view_normal, vd.no, vd.fno);
+ const float fade = bstrength * tex_strength(ss, brush, vd.co, test.dist,
+ ss->cache->view_normal, vd.no, vd.fno);
float val[3];
if (vd.fno) copy_v3_v3(val, vd.fno);
@@ -1638,7 +1638,7 @@ static void calc_flatten_center(Sculpt *sd, Object *ob, PBVHNode **nodes, int to
zero_v3(fc);
#pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP)
- for (n=0; n<totnode; n++) {
+ for (n = 0; n < totnode; n++) {
PBVHVertexIter vd;
SculptBrushTest test;
SculptUndoNode *unode;
@@ -1680,8 +1680,8 @@ static void calc_flatten_center(Sculpt *sd, Object *ob, PBVHNode **nodes, int to
/* this calculates flatten center and area normal together,
* amortizing the memory bandwidth and loop overhead to calculate both at the same time */
static void calc_area_normal_and_flatten_center(Sculpt *sd, Object *ob,
- PBVHNode **nodes, int totnode,
- float an[3], float fc[3])
+ PBVHNode **nodes, int totnode,
+ float an[3], float fc[3])
{
SculptSession *ss = ob->sculpt;
int n;
@@ -1701,7 +1701,7 @@ static void calc_area_normal_and_flatten_center(Sculpt *sd, Object *ob,
zero_v3(fc);
#pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP)
- for (n=0; n<totnode; n++) {
+ for (n = 0; n < totnode; n++) {
PBVHVertexIter vd;
SculptBrushTest test;
SculptUndoNode *unode;
@@ -1785,7 +1785,7 @@ static void calc_sculpt_plane(Sculpt *sd, Object *ob, PBVHNode **nodes, int totn
if (ss->cache->mirror_symmetry_pass == 0 &&
ss->cache->radial_symmetry_pass == 0 &&
- (ss->cache->first_time || !(brush->flag & BRUSH_ORIGINAL_NORMAL)))
+ (ss->cache->first_time || !(brush->flag & BRUSH_ORIGINAL_NORMAL)))
{
switch (brush->sculpt_plane) {
case SCULPT_DISP_DIR_VIEW:
@@ -1859,7 +1859,7 @@ static void point_plane_project(float intr[3], float co[3], float plane_normal[3
static int plane_trim(StrokeCache *cache, Brush *brush, float val[3])
{
- return !(brush->flag & BRUSH_PLANE_TRIM) || (dot_v3v3(val, val) <= cache->radius_squared*cache->plane_trim_squared);
+ return !(brush->flag & BRUSH_PLANE_TRIM) || (dot_v3v3(val, val) <= cache->radius_squared * cache->plane_trim_squared);
}
static int plane_point_side_flip(float co[3], float plane_normal[3], float plane_center[3], int flip)
@@ -1880,12 +1880,12 @@ static int plane_point_side(float co[3], float plane_normal[3], float plane_cent
float delta[3];
sub_v3_v3v3(delta, co, plane_center);
- return dot_v3v3(plane_normal, delta) <= 0.0f;
+ return dot_v3v3(plane_normal, delta) <= 0.0f;
}
static float get_offset(Sculpt *sd, SculptSession *ss)
{
- Brush* brush = paint_brush(&sd->paint);
+ Brush *brush = paint_brush(&sd->paint);
float rv = brush->plane_offset;
@@ -1917,7 +1917,7 @@ static void do_flatten_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totno
calc_sculpt_plane(sd, ob, nodes, totnode, an, fc);
- displace = radius*offset;
+ displace = radius * offset;
mul_v3_v3v3(temp, an, ss->cache->scale);
mul_v3_fl(temp, displace);
@@ -1925,11 +1925,11 @@ static void do_flatten_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totno
#pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP)
for (n = 0; n < totnode; n++) {
- PBVHVertexIter vd;
+ PBVHVertexIter vd;
SculptBrushTest test;
float (*proxy)[3];
- proxy= BLI_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co;
+ proxy = BLI_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co;
sculpt_brush_test_init(ss, &test);
@@ -1943,8 +1943,8 @@ static void do_flatten_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totno
sub_v3_v3v3(val, intr, vd.co);
if (plane_trim(ss->cache, brush, val)) {
- const float fade = bstrength*tex_strength(ss, brush, vd.co, sqrt(test.dist),
- an, vd.no, vd.fno);
+ const float fade = bstrength * tex_strength(ss, brush, vd.co, sqrt(test.dist),
+ an, vd.no, vd.fno);
mul_v3_v3fl(proxy[vd.i], val, fade);
@@ -1986,7 +1986,7 @@ static void do_clay_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
radius = -radius;
}
- displace = radius * (0.25f+offset);
+ displace = radius * (0.25f + offset);
mul_v3_v3v3(temp, an, ss->cache->scale);
mul_v3_fl(temp, displace);
@@ -2000,7 +2000,7 @@ static void do_clay_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
SculptBrushTest test;
float (*proxy)[3];
- proxy= BLI_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co;
+ proxy = BLI_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co;
sculpt_brush_test_init(ss, &test);
@@ -2015,9 +2015,9 @@ static void do_clay_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
sub_v3_v3v3(val, intr, vd.co);
if (plane_trim(ss->cache, brush, val)) {
- const float fade = bstrength*tex_strength(ss, brush, vd.co,
- sqrt(test.dist),
- an, vd.no, vd.fno);
+ const float fade = bstrength * tex_strength(ss, brush, vd.co,
+ sqrt(test.dist),
+ an, vd.no, vd.fno);
mul_v3_v3fl(proxy[vd.i], val, fade);
@@ -2073,7 +2073,7 @@ static void do_clay_strips_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int t
radius = -radius;
}
- displace = radius * (0.25f+offset);
+ displace = radius * (0.25f + offset);
mul_v3_v3v3(temp, sn, ss->cache->scale);
mul_v3_fl(temp, displace);
@@ -2101,7 +2101,7 @@ static void do_clay_strips_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int t
SculptBrushTest test;
float (*proxy)[3];
- proxy= BLI_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co;
+ proxy = BLI_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co;
sculpt_brush_test_init(ss, &test);
@@ -2116,9 +2116,9 @@ static void do_clay_strips_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int t
sub_v3_v3v3(val, intr, vd.co);
if (plane_trim(ss->cache, brush, val)) {
- const float fade = bstrength*tex_strength(ss, brush, vd.co,
- ss->cache->radius*test.dist,
- an, vd.no, vd.fno);
+ const float fade = bstrength * tex_strength(ss, brush, vd.co,
+ ss->cache->radius * test.dist,
+ an, vd.no, vd.fno);
mul_v3_v3fl(proxy[vd.i], val, fade);
@@ -2152,7 +2152,7 @@ static void do_fill_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
calc_sculpt_plane(sd, ob, nodes, totnode, an, fc);
- displace = radius*offset;
+ displace = radius * offset;
mul_v3_v3v3(temp, an, ss->cache->scale);
mul_v3_fl(temp, displace);
@@ -2164,7 +2164,7 @@ static void do_fill_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
SculptBrushTest test;
float (*proxy)[3];
- proxy= BLI_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co;
+ proxy = BLI_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co;
sculpt_brush_test_init(ss, &test);
@@ -2179,9 +2179,9 @@ static void do_fill_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
sub_v3_v3v3(val, intr, vd.co);
if (plane_trim(ss->cache, brush, val)) {
- const float fade = bstrength*tex_strength(ss, brush, vd.co,
- sqrt(test.dist),
- an, vd.no, vd.fno);
+ const float fade = bstrength * tex_strength(ss, brush, vd.co,
+ sqrt(test.dist),
+ an, vd.no, vd.fno);
mul_v3_v3fl(proxy[vd.i], val, fade);
@@ -2215,7 +2215,7 @@ static void do_scrape_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod
calc_sculpt_plane(sd, ob, nodes, totnode, an, fc);
- displace = -radius*offset;
+ displace = -radius * offset;
mul_v3_v3v3(temp, an, ss->cache->scale);
mul_v3_fl(temp, displace);
@@ -2227,7 +2227,7 @@ static void do_scrape_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod
SculptBrushTest test;
float (*proxy)[3];
- proxy= BLI_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co;
+ proxy = BLI_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co;
sculpt_brush_test_init(ss, &test);
@@ -2242,9 +2242,9 @@ static void do_scrape_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod
sub_v3_v3v3(val, intr, vd.co);
if (plane_trim(ss->cache, brush, val)) {
- const float fade = bstrength*tex_strength(ss, brush, vd.co,
- sqrt(test.dist),
- an, vd.no, vd.fno);
+ const float fade = bstrength * tex_strength(ss, brush, vd.co,
+ sqrt(test.dist),
+ an, vd.no, vd.fno);
mul_v3_v3fl(proxy[vd.i], val, fade);
@@ -2260,36 +2260,36 @@ static void do_scrape_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod
void sculpt_vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3])
{
- Mesh *me= (Mesh*)ob->data;
- float (*ofs)[3]= NULL;
- int a, is_basis= 0;
+ Mesh *me = (Mesh *)ob->data;
+ float (*ofs)[3] = NULL;
+ int a, is_basis = 0;
KeyBlock *currkey;
/* for relative keys editing of base should update other keys */
if (me->key->type == KEY_RELATIVE)
- for (currkey = me->key->block.first; currkey; currkey= currkey->next)
- if (ob->shapenr-1 == currkey->relative) {
- is_basis= 1;
+ for (currkey = me->key->block.first; currkey; currkey = currkey->next)
+ if (ob->shapenr - 1 == currkey->relative) {
+ is_basis = 1;
break;
}
if (is_basis) {
- ofs= key_to_vertcos(ob, kb);
+ ofs = key_to_vertcos(ob, kb);
/* calculate key coord offsets (from previous location) */
- for (a= 0; a < me->totvert; a++) {
+ for (a = 0; a < me->totvert; a++) {
sub_v3_v3v3(ofs[a], vertCos[a], ofs[a]);
}
/* apply offsets on other keys */
currkey = me->key->block.first;
while (currkey) {
- int apply_offset = ((currkey != kb) && (ob->shapenr-1 == currkey->relative));
+ int apply_offset = ((currkey != kb) && (ob->shapenr - 1 == currkey->relative));
if (apply_offset)
offset_to_key(ob, currkey, ofs);
- currkey= currkey->next;
+ currkey = currkey->next;
}
MEM_freeN(ofs);
@@ -2297,9 +2297,9 @@ void sculpt_vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3])
/* modifying of basis key should update mesh */
if (kb == me->key->refkey) {
- MVert *mvert= me->mvert;
+ MVert *mvert = me->mvert;
- for (a= 0; a < me->totvert; a++, mvert++)
+ for (a = 0; a < me->totvert; a++, mvert++)
copy_v3_v3(mvert->co, vertCos[a]);
mesh_calc_normals_mapping(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL, NULL, 0, NULL, NULL);
@@ -2326,69 +2326,69 @@ static void do_brush_action(Sculpt *sd, Object *ob, Brush *brush)
/* Only act if some verts are inside the brush area */
if (totnode) {
#pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP)
- for (n= 0; n < totnode; n++) {
+ for (n = 0; n < totnode; n++) {
sculpt_undo_push_node(ob, nodes[n], SCULPT_UNDO_COORDS);
BLI_pbvh_node_mark_update(nodes[n]);
}
/* Apply one type of brush action */
- switch(brush->sculpt_tool) {
- case SCULPT_TOOL_DRAW:
- do_draw_brush(sd, ob, nodes, totnode);
- break;
- case SCULPT_TOOL_SMOOTH:
- do_smooth_brush(sd, ob, nodes, totnode);
- break;
- case SCULPT_TOOL_CREASE:
- do_crease_brush(sd, ob, nodes, totnode);
- break;
- case SCULPT_TOOL_BLOB:
- do_crease_brush(sd, ob, nodes, totnode);
- break;
- case SCULPT_TOOL_PINCH:
- do_pinch_brush(sd, ob, nodes, totnode);
- break;
- case SCULPT_TOOL_INFLATE:
- do_inflate_brush(sd, ob, nodes, totnode);
- break;
- case SCULPT_TOOL_GRAB:
- do_grab_brush(sd, ob, nodes, totnode);
- break;
- case SCULPT_TOOL_ROTATE:
- do_rotate_brush(sd, ob, nodes, totnode);
- break;
- case SCULPT_TOOL_SNAKE_HOOK:
- do_snake_hook_brush(sd, ob, nodes, totnode);
- break;
- case SCULPT_TOOL_NUDGE:
- do_nudge_brush(sd, ob, nodes, totnode);
- break;
- case SCULPT_TOOL_THUMB:
- do_thumb_brush(sd, ob, nodes, totnode);
- break;
- case SCULPT_TOOL_LAYER:
- do_layer_brush(sd, ob, nodes, totnode);
- break;
- case SCULPT_TOOL_FLATTEN:
- do_flatten_brush(sd, ob, nodes, totnode);
- break;
- case SCULPT_TOOL_CLAY:
- do_clay_brush(sd, ob, nodes, totnode);
- break;
- case SCULPT_TOOL_CLAY_STRIPS:
- do_clay_strips_brush(sd, ob, nodes, totnode);
- break;
- case SCULPT_TOOL_FILL:
- do_fill_brush(sd, ob, nodes, totnode);
- break;
- case SCULPT_TOOL_SCRAPE:
- do_scrape_brush(sd, ob, nodes, totnode);
- break;
+ switch (brush->sculpt_tool) {
+ case SCULPT_TOOL_DRAW:
+ do_draw_brush(sd, ob, nodes, totnode);
+ break;
+ case SCULPT_TOOL_SMOOTH:
+ do_smooth_brush(sd, ob, nodes, totnode);
+ break;
+ case SCULPT_TOOL_CREASE:
+ do_crease_brush(sd, ob, nodes, totnode);
+ break;
+ case SCULPT_TOOL_BLOB:
+ do_crease_brush(sd, ob, nodes, totnode);
+ break;
+ case SCULPT_TOOL_PINCH:
+ do_pinch_brush(sd, ob, nodes, totnode);
+ break;
+ case SCULPT_TOOL_INFLATE:
+ do_inflate_brush(sd, ob, nodes, totnode);
+ break;
+ case SCULPT_TOOL_GRAB:
+ do_grab_brush(sd, ob, nodes, totnode);
+ break;
+ case SCULPT_TOOL_ROTATE:
+ do_rotate_brush(sd, ob, nodes, totnode);
+ break;
+ case SCULPT_TOOL_SNAKE_HOOK:
+ do_snake_hook_brush(sd, ob, nodes, totnode);
+ break;
+ case SCULPT_TOOL_NUDGE:
+ do_nudge_brush(sd, ob, nodes, totnode);
+ break;
+ case SCULPT_TOOL_THUMB:
+ do_thumb_brush(sd, ob, nodes, totnode);
+ break;
+ case SCULPT_TOOL_LAYER:
+ do_layer_brush(sd, ob, nodes, totnode);
+ break;
+ case SCULPT_TOOL_FLATTEN:
+ do_flatten_brush(sd, ob, nodes, totnode);
+ break;
+ case SCULPT_TOOL_CLAY:
+ do_clay_brush(sd, ob, nodes, totnode);
+ break;
+ case SCULPT_TOOL_CLAY_STRIPS:
+ do_clay_strips_brush(sd, ob, nodes, totnode);
+ break;
+ case SCULPT_TOOL_FILL:
+ do_fill_brush(sd, ob, nodes, totnode);
+ break;
+ case SCULPT_TOOL_SCRAPE:
+ do_scrape_brush(sd, ob, nodes, totnode);
+ break;
}
if (brush->sculpt_tool != SCULPT_TOOL_SMOOTH && brush->autosmooth_factor > 0) {
if (brush->flag & BRUSH_INVERSE_SMOOTH_PRESSURE) {
- smooth(sd, ob, nodes, totnode, brush->autosmooth_factor*(1-ss->cache->pressure));
+ smooth(sd, ob, nodes, totnode, brush->autosmooth_factor * (1 - ss->cache->pressure));
}
else {
smooth(sd, ob, nodes, totnode, brush->autosmooth_factor);
@@ -2403,9 +2403,9 @@ static void do_brush_action(Sculpt *sd, Object *ob, Brush *brush)
static void sculpt_flush_pbvhvert_deform(Object *ob, PBVHVertexIter *vd)
{
SculptSession *ss = ob->sculpt;
- Mesh *me= ob->data;
+ Mesh *me = ob->data;
float disp[3], newco[3];
- int index= vd->vert_indices[vd->i];
+ int index = vd->vert_indices[vd->i];
sub_v3_v3v3(disp, vd->co, ss->deform_cos[index]);
mul_m3_v3(ss->deform_imats[index], disp);
@@ -2421,8 +2421,8 @@ static void sculpt_flush_pbvhvert_deform(Object *ob, PBVHVertexIter *vd)
static void sculpt_combine_proxies(Sculpt *sd, Object *ob)
{
SculptSession *ss = ob->sculpt;
- Brush *brush= paint_brush(&sd->paint);
- PBVHNode** nodes;
+ Brush *brush = paint_brush(&sd->paint);
+ PBVHNode **nodes;
int totnode, n;
BLI_pbvh_gather_proxies(ss->pbvh, &nodes, &totnode);
@@ -2433,14 +2433,14 @@ static void sculpt_combine_proxies(Sculpt *sd, Object *ob)
SCULPT_TOOL_ROTATE, SCULPT_TOOL_THUMB));
#pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP)
- for (n= 0; n < totnode; n++) {
+ for (n = 0; n < totnode; n++) {
PBVHVertexIter vd;
- PBVHProxyNode* proxies;
+ PBVHProxyNode *proxies;
int proxy_count;
float (*orco)[3];
if (use_orco)
- orco= sculpt_undo_push_node(ob, nodes[n], SCULPT_UNDO_COORDS)->co;
+ orco = sculpt_undo_push_node(ob, nodes[n], SCULPT_UNDO_COORDS)->co;
BLI_pbvh_node_get_proxies(nodes[n], &proxies, &proxy_count);
@@ -2453,7 +2453,7 @@ static void sculpt_combine_proxies(Sculpt *sd, Object *ob)
else
copy_v3_v3(val, vd.co);
- for (p= 0; p < proxy_count; p++)
+ for (p = 0; p < proxy_count; p++)
add_v3_v3(val, proxies[p].co[vd.i]);
sculpt_clip(sd, ss, vd.co, val);
@@ -2494,31 +2494,31 @@ static void sculpt_update_keyblock(Object *ob)
static void sculpt_flush_stroke_deform(Sculpt *sd, Object *ob)
{
SculptSession *ss = ob->sculpt;
- Brush *brush= paint_brush(&sd->paint);
+ Brush *brush = paint_brush(&sd->paint);
if (ELEM(brush->sculpt_tool, SCULPT_TOOL_SMOOTH, SCULPT_TOOL_LAYER)) {
/* this brushes aren't using proxies, so sculpt_combine_proxies() wouldn't
* propagate needed deformation to original base */
int n, totnode;
- Mesh *me= (Mesh*)ob->data;
- PBVHNode** nodes;
- float (*vertCos)[3]= NULL;
+ Mesh *me = (Mesh *)ob->data;
+ PBVHNode **nodes;
+ float (*vertCos)[3] = NULL;
if (ss->kb)
- vertCos= MEM_callocN(sizeof(*vertCos)*me->totvert, "flushStrokeDeofrm keyVerts");
+ vertCos = MEM_callocN(sizeof(*vertCos) * me->totvert, "flushStrokeDeofrm keyVerts");
BLI_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &totnode);
#pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP)
- for (n= 0; n < totnode; n++) {
+ for (n = 0; n < totnode; n++) {
PBVHVertexIter vd;
BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) {
sculpt_flush_pbvhvert_deform(ob, &vd);
if (vertCos) {
- int index= vd.vert_indices[vd.i];
+ int index = vd.vert_indices[vd.i];
copy_v3_v3(vertCos[index], ss->orig_cos[index]);
}
}
@@ -2545,8 +2545,8 @@ static void sculpt_flush_stroke_deform(Sculpt *sd, Object *ob)
/* Flip all the editdata across the axis/axes specified by symm. Used to
* calculate multiple modifications to the mesh when symmetry is enabled. */
static void calc_brushdata_symm(Sculpt *sd, StrokeCache *cache, const char symm,
- const char axis, const float angle,
- const float UNUSED(feather))
+ const char axis, const float angle,
+ const float UNUSED(feather))
{
(void)sd; /* unused */
@@ -2557,14 +2557,14 @@ static void calc_brushdata_symm(Sculpt *sd, StrokeCache *cache, const char symm,
/* XXX This reduces the length of the grab delta if it approaches the line of symmetry
XXX However, a different approach appears to be needed
if (sd->flags & SCULPT_SYMMETRY_FEATHER) {
- float frac = 1.0f/max_overlap_count(sd);
- float reduce = (feather-frac)/(1-frac);
+ float frac = 1.0f/max_overlap_count(sd);
+ float reduce = (feather-frac)/(1-frac);
- printf("feather: %f frac: %f reduce: %f\n", feather, frac, reduce);
+ printf("feather: %f frac: %f reduce: %f\n", feather, frac, reduce);
- if (frac < 1)
- mul_v3_fl(cache->grab_delta_symmetry, reduce);
- } */
+ if (frac < 1)
+ mul_v3_fl(cache->grab_delta_symmetry, reduce);
+ } */
unit_m4(cache->symm_rot_mat);
unit_m4(cache->symm_rot_mat_inv);
@@ -2579,15 +2579,15 @@ static void calc_brushdata_symm(Sculpt *sd, StrokeCache *cache, const char symm,
}
static void do_radial_symmetry(Sculpt *sd, Object *ob, Brush *brush,
- const char symm, const int axis,
- const float feather)
+ const char symm, const int axis,
+ const float 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'];
- ss->cache->radial_symmetry_pass= i;
+ for (i = 1; i < sd->radial_symm[axis - 'X']; ++i) {
+ const float angle = 2 * M_PI * i / sd->radial_symm[axis - 'X'];
+ ss->cache->radial_symmetry_pass = i;
calc_brushdata_symm(sd, ss->cache, symm, axis, angle, feather);
do_brush_action(sd, ob, brush);
}
@@ -2616,15 +2616,15 @@ static void do_symmetrical_brush_actions(Sculpt *sd, Object *ob)
float feather = calc_symmetry_feather(sd, ss->cache);
- cache->bstrength= brush_strength(sd, cache, feather);
+ cache->bstrength = brush_strength(sd, cache, feather);
- cache->symmetry= symm;
+ cache->symmetry = symm;
/* 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) {
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;
+ cache->mirror_symmetry_pass = i;
+ cache->radial_symmetry_pass = 0;
calc_brushdata_symm(sd, cache, i, 0, 0, feather);
do_brush_action(sd, ob, brush);
@@ -2643,21 +2643,21 @@ static void do_symmetrical_brush_actions(Sculpt *sd, Object *ob)
if (ss->modifiers_active)
sculpt_flush_stroke_deform(sd, ob);
- cache->first_time= 0;
+ cache->first_time = 0;
}
static void sculpt_update_tex(const Scene *scene, Sculpt *sd, SculptSession *ss)
{
Brush *brush = paint_brush(&sd->paint);
- const int radius= brush_size(scene, brush);
+ const int radius = brush_size(scene, brush);
if (ss->texcache) {
MEM_freeN(ss->texcache);
- ss->texcache= NULL;
+ ss->texcache = NULL;
}
/* Need to allocate a bigger buffer for bigger brush size */
- ss->texcache_side = 2*radius;
+ ss->texcache_side = 2 * radius;
if (!ss->texcache || ss->texcache_side > ss->texcache_actual) {
ss->texcache = brush_gen_texture_cache(brush, radius);
ss->texcache_actual = ss->texcache_side;
@@ -2668,21 +2668,21 @@ void sculpt_update_mesh_elements(Scene *scene, Sculpt *sd, Object *ob, int need_
{
DerivedMesh *dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);
SculptSession *ss = ob->sculpt;
- MultiresModifierData *mmd= sculpt_multires_active(scene, ob);
+ MultiresModifierData *mmd = sculpt_multires_active(scene, ob);
- ss->modifiers_active= sculpt_modifiers_active(scene, sd, ob);
+ ss->modifiers_active = sculpt_modifiers_active(scene, sd, ob);
- if (!mmd) ss->kb= ob_get_keyblock(ob);
- else ss->kb= NULL;
+ if (!mmd) ss->kb = ob_get_keyblock(ob);
+ else ss->kb = NULL;
if (mmd) {
ss->multires = mmd;
ss->totvert = dm->getNumVerts(dm);
ss->totpoly = dm->getNumPolys(dm);
- ss->mvert= NULL;
- ss->mpoly= NULL;
- ss->mloop= NULL;
- ss->face_normals= NULL;
+ ss->mvert = NULL;
+ ss->mpoly = NULL;
+ ss->mloop = NULL;
+ ss->face_normals = NULL;
}
else {
Mesh *me = get_mesh(ob);
@@ -2699,7 +2699,7 @@ void sculpt_update_mesh_elements(Scene *scene, Sculpt *sd, Object *ob, int need_
BKE_mesh_tessface_ensure(ob->data);
ss->pbvh = dm->getPBVH(ob, dm);
- ss->pmap = (need_pmap && dm->getPolyMap)? dm->getPolyMap(ob, dm): NULL;
+ ss->pmap = (need_pmap && dm->getPolyMap) ? dm->getPolyMap(ob, dm) : NULL;
if (ss->modifiers_active) {
if (!ss->orig_cos) {
@@ -2713,7 +2713,7 @@ void sculpt_update_mesh_elements(Scene *scene, Sculpt *sd, Object *ob, int need_
crazyspace_build_sculpt(scene, ob, &ss->deform_imats, &ss->deform_cos);
BLI_pbvh_apply_vertCos(ss->pbvh, ss->deform_cos);
- for (a = 0; a < ((Mesh*)ob->data)->totvert; ++a)
+ for (a = 0; a < ((Mesh *)ob->data)->totvert; ++a)
invert_m3(ss->deform_imats[a]);
}
}
@@ -2721,7 +2721,7 @@ void sculpt_update_mesh_elements(Scene *scene, Sculpt *sd, Object *ob, int need_
/* if pbvh is deformed, key block is already applied to it */
if (ss->kb && !BLI_pbvh_isDeformed(ss->pbvh)) {
- float (*vertCos)[3]= key_to_vertcos(ob, ss->kb);
+ float (*vertCos)[3] = key_to_vertcos(ob, ss->kb);
if (vertCos) {
/* apply shape keys coordinates to PBVH */
@@ -2746,39 +2746,39 @@ static const char *sculpt_tool_name(Sculpt *sd)
{
Brush *brush = paint_brush(&sd->paint);
- switch(brush->sculpt_tool) {
- case SCULPT_TOOL_DRAW:
- return "Draw Brush"; break;
- case SCULPT_TOOL_SMOOTH:
- return "Smooth Brush"; break;
- case SCULPT_TOOL_CREASE:
- return "Crease Brush"; break;
- case SCULPT_TOOL_BLOB:
- return "Blob Brush"; break;
- case SCULPT_TOOL_PINCH:
- return "Pinch Brush"; break;
- case SCULPT_TOOL_INFLATE:
- return "Inflate Brush"; break;
- case SCULPT_TOOL_GRAB:
- return "Grab Brush"; break;
- case SCULPT_TOOL_NUDGE:
- return "Nudge Brush"; break;
- case SCULPT_TOOL_THUMB:
- return "Thumb Brush"; break;
- case SCULPT_TOOL_LAYER:
- return "Layer Brush"; break;
- case SCULPT_TOOL_FLATTEN:
- return "Flatten Brush"; break;
- case SCULPT_TOOL_CLAY:
- return "Clay Brush"; break;
- case SCULPT_TOOL_CLAY_STRIPS:
- return "Clay Strips Brush"; break;
- case SCULPT_TOOL_FILL:
- return "Fill Brush"; break;
- case SCULPT_TOOL_SCRAPE:
- return "Scrape Brush"; break;
- default:
- return "Sculpting"; break;
+ switch (brush->sculpt_tool) {
+ case SCULPT_TOOL_DRAW:
+ return "Draw Brush"; break;
+ case SCULPT_TOOL_SMOOTH:
+ return "Smooth Brush"; break;
+ case SCULPT_TOOL_CREASE:
+ return "Crease Brush"; break;
+ case SCULPT_TOOL_BLOB:
+ return "Blob Brush"; break;
+ case SCULPT_TOOL_PINCH:
+ return "Pinch Brush"; break;
+ case SCULPT_TOOL_INFLATE:
+ return "Inflate Brush"; break;
+ case SCULPT_TOOL_GRAB:
+ return "Grab Brush"; break;
+ case SCULPT_TOOL_NUDGE:
+ return "Nudge Brush"; break;
+ case SCULPT_TOOL_THUMB:
+ return "Thumb Brush"; break;
+ case SCULPT_TOOL_LAYER:
+ return "Layer Brush"; break;
+ case SCULPT_TOOL_FLATTEN:
+ return "Flatten Brush"; break;
+ case SCULPT_TOOL_CLAY:
+ return "Clay Brush"; break;
+ case SCULPT_TOOL_CLAY_STRIPS:
+ return "Clay Strips Brush"; break;
+ case SCULPT_TOOL_FILL:
+ return "Fill Brush"; break;
+ case SCULPT_TOOL_SCRAPE:
+ return "Scrape Brush"; break;
+ default:
+ return "Sculpting"; break;
}
}
@@ -2799,10 +2799,10 @@ 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)) {
- MirrorModifierData *mmd = (MirrorModifierData*)md;
+ for (md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Mirror &&
+ (md->mode & eModifierMode_Realtime)) {
+ MirrorModifierData *mmd = (MirrorModifierData *)md;
if (mmd->flag & MOD_MIR_CLIPPING) {
/* check each axis for mirroring */
@@ -2813,9 +2813,9 @@ static void sculpt_init_mirror_clipping(Object *ob, SculptSession *ss)
/* update the clip tolerance */
if (mmd->tolerance >
- ss->cache->clip_tolerance[i])
+ ss->cache->clip_tolerance[i])
ss->cache->clip_tolerance[i] =
- mmd->tolerance;
+ mmd->tolerance;
}
}
}
@@ -2824,12 +2824,12 @@ static void sculpt_init_mirror_clipping(Object *ob, SculptSession *ss)
}
/* Initialize the stroke cache invariants from operator properties */
-static void sculpt_update_cache_invariants(bContext* C, Sculpt *sd, SculptSession *ss, wmOperator *op, wmEvent *event)
+static void sculpt_update_cache_invariants(bContext *C, Sculpt *sd, SculptSession *ss, wmOperator *op, wmEvent *event)
{
StrokeCache *cache = MEM_callocN(sizeof(StrokeCache), "stroke cache");
Brush *brush = paint_brush(&sd->paint);
ViewContext *vc = paint_stroke_view_context(op->customdata);
- Object *ob= CTX_data_active_object(C);
+ Object *ob = CTX_data_active_object(C);
int i;
int mode;
@@ -2867,12 +2867,12 @@ static void sculpt_update_cache_invariants(bContext* C, Sculpt *sd, SculptSessio
/* Alt-Smooth */
if (ss->cache->alt_smooth) {
- Paint *p= &sd->paint;
+ Paint *p = &sd->paint;
Brush *br;
- BLI_strncpy(cache->saved_active_brush_name, brush->id.name+2, sizeof(cache->saved_active_brush_name));
+ BLI_strncpy(cache->saved_active_brush_name, brush->id.name + 2, sizeof(cache->saved_active_brush_name));
- br= (Brush *)find_id("BR", "Smooth");
+ br = (Brush *)find_id("BR", "Smooth");
if (br) {
paint_brush_set(p, br);
brush = br;
@@ -2897,8 +2897,8 @@ static void sculpt_update_cache_invariants(bContext* C, Sculpt *sd, SculptSessio
/* not supported yet for multires */
if (!ss->multires && !ss->layer_co && (brush->flag & BRUSH_PERSISTENT)) {
if (!ss->layer_co)
- ss->layer_co= MEM_mallocN(sizeof(float) * 3 * ss->totvert,
- "sculpt mesh vertices copy");
+ ss->layer_co = MEM_mallocN(sizeof(float) * 3 * ss->totvert,
+ "sculpt mesh vertices copy");
if (ss->deform_cos) memcpy(ss->layer_co, ss->deform_cos, ss->totvert);
else {
@@ -2913,7 +2913,7 @@ static void sculpt_update_cache_invariants(bContext* C, Sculpt *sd, SculptSessio
if (brush->flag & BRUSH_ANCHORED) {
if (ss->face_normals) {
float *fn = ss->face_normals;
- cache->face_norms= MEM_mallocN(sizeof(float) * 3 * ss->totpoly, "Sculpt face norms");
+ cache->face_norms = MEM_mallocN(sizeof(float) * 3 * ss->totpoly, "Sculpt face norms");
for (i = 0; i < ss->totpoly; ++i, fn += 3)
copy_v3_v3(cache->face_norms[i], fn);
}
@@ -2922,17 +2922,17 @@ static void sculpt_update_cache_invariants(bContext* C, Sculpt *sd, SculptSessio
}
if (ELEM8(brush->sculpt_tool,
- SCULPT_TOOL_DRAW, SCULPT_TOOL_CREASE, SCULPT_TOOL_BLOB,
- SCULPT_TOOL_LAYER, SCULPT_TOOL_INFLATE, SCULPT_TOOL_CLAY,
- SCULPT_TOOL_CLAY_STRIPS, SCULPT_TOOL_ROTATE))
+ SCULPT_TOOL_DRAW, SCULPT_TOOL_CREASE, SCULPT_TOOL_BLOB,
+ SCULPT_TOOL_LAYER, SCULPT_TOOL_INFLATE, SCULPT_TOOL_CLAY,
+ SCULPT_TOOL_CLAY_STRIPS, SCULPT_TOOL_ROTATE))
if (!(brush->flag & BRUSH_ACCUMULATE))
cache->original = 1;
cache->special_rotation = (brush->flag & BRUSH_RAKE) ? sd->last_angle : 0;
- cache->first_time= 1;
+ cache->first_time = 1;
- cache->vertex_rotation= 0;
+ cache->vertex_rotation = 0;
}
static void sculpt_update_brush_delta(Sculpt *sd, Object *ob, Brush *brush)
@@ -2946,9 +2946,9 @@ static void sculpt_update_brush_delta(Sculpt *sd, Object *ob, Brush *brush)
int tool = brush->sculpt_tool;
if (ELEM5(tool,
- SCULPT_TOOL_GRAB, SCULPT_TOOL_NUDGE,
- SCULPT_TOOL_CLAY_STRIPS, SCULPT_TOOL_SNAKE_HOOK,
- SCULPT_TOOL_THUMB)) {
+ SCULPT_TOOL_GRAB, SCULPT_TOOL_NUDGE,
+ SCULPT_TOOL_CLAY_STRIPS, SCULPT_TOOL_SNAKE_HOOK,
+ SCULPT_TOOL_THUMB)) {
float grab_location[3], imat[4][4], delta[3], loc[3];
if (cache->first_time) {
@@ -2966,30 +2966,30 @@ static void sculpt_update_brush_delta(Sculpt *sd, Object *ob, Brush *brush)
/* compute delta to move verts by */
if (!cache->first_time) {
- switch(tool) {
- case SCULPT_TOOL_GRAB:
- case SCULPT_TOOL_THUMB:
- sub_v3_v3v3(delta, grab_location, cache->old_grab_location);
- invert_m4_m4(imat, ob->obmat);
- mul_mat3_m4_v3(imat, delta);
- add_v3_v3(cache->grab_delta, delta);
- break;
- case SCULPT_TOOL_CLAY_STRIPS:
- case SCULPT_TOOL_NUDGE:
- case SCULPT_TOOL_SNAKE_HOOK:
- if (brush->flag & BRUSH_ANCHORED) {
- float orig[3];
- mul_v3_m4v3(orig, ob->obmat, cache->orig_grab_location);
- sub_v3_v3v3(cache->grab_delta, grab_location, orig);
- }
- else {
- sub_v3_v3v3(cache->grab_delta, grab_location,
- cache->old_grab_location);
- }
+ switch (tool) {
+ case SCULPT_TOOL_GRAB:
+ case SCULPT_TOOL_THUMB:
+ sub_v3_v3v3(delta, grab_location, cache->old_grab_location);
+ invert_m4_m4(imat, ob->obmat);
+ mul_mat3_m4_v3(imat, delta);
+ add_v3_v3(cache->grab_delta, delta);
+ break;
+ case SCULPT_TOOL_CLAY_STRIPS:
+ case SCULPT_TOOL_NUDGE:
+ case SCULPT_TOOL_SNAKE_HOOK:
+ if (brush->flag & BRUSH_ANCHORED) {
+ float orig[3];
+ mul_v3_m4v3(orig, ob->obmat, cache->orig_grab_location);
+ sub_v3_v3v3(cache->grab_delta, grab_location, orig);
+ }
+ else {
+ sub_v3_v3v3(cache->grab_delta, grab_location,
+ cache->old_grab_location);
+ }
- invert_m4_m4(imat, ob->obmat);
- mul_mat3_m4_v3(imat, cache->grab_delta);
- break;
+ invert_m4_m4(imat, ob->obmat);
+ mul_mat3_m4_v3(imat, cache->grab_delta);
+ break;
}
}
else {
@@ -3016,8 +3016,8 @@ static void sculpt_update_brush_delta(Sculpt *sd, Object *ob, Brush *brush)
/* Initialize the stroke cache variants from operator properties */
static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob,
- struct PaintStroke *stroke,
- PointerRNA *ptr)
+ struct PaintStroke *stroke,
+ PointerRNA *ptr)
{
Scene *scene = CTX_data_scene(C);
SculptSession *ss = ob->sculpt;
@@ -3029,10 +3029,10 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob,
/* RNA_float_get_array(ptr, "location", cache->traced_location); */
if (cache->first_time ||
- !((brush->flag & BRUSH_ANCHORED)||
- (brush->sculpt_tool == SCULPT_TOOL_SNAKE_HOOK)||
+ !((brush->flag & BRUSH_ANCHORED) ||
+ (brush->sculpt_tool == SCULPT_TOOL_SNAKE_HOOK) ||
(brush->sculpt_tool == SCULPT_TOOL_ROTATE))
- )
+ )
{
RNA_float_get_array(ptr, "location", cache->true_location);
}
@@ -3050,41 +3050,42 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob,
/* Truly temporary data that isn't stored in properties */
- sd->draw_pressure= 1;
- sd->pressure_value= cache->pressure;
+ sd->draw_pressure = 1;
+ sd->pressure_value = cache->pressure;
cache->previous_pixel_radius = cache->pixel_radius;
cache->pixel_radius = brush_size(scene, brush);
if (cache->first_time) {
if (!brush_use_locked_size(scene, brush)) {
- cache->initial_radius= paint_calc_object_space_radius(cache->vc, cache->true_location, brush_size(scene, brush));
+ cache->initial_radius = paint_calc_object_space_radius(cache->vc, cache->true_location, brush_size(scene, brush));
brush_set_unprojected_radius(scene, brush, cache->initial_radius);
}
else {
- cache->initial_radius= brush_unprojected_radius(scene, brush);
+ cache->initial_radius = brush_unprojected_radius(scene, brush);
}
}
if (brush_use_size_pressure(scene, brush)) {
cache->pixel_radius *= cache->pressure;
- cache->radius= cache->initial_radius * cache->pressure;
+ cache->radius = cache->initial_radius * cache->pressure;
}
else
- cache->radius= cache->initial_radius;
+ cache->radius = cache->initial_radius;
- cache->radius_squared = cache->radius*cache->radius;
+ cache->radius_squared = cache->radius * cache->radius;
if (!(brush->flag & BRUSH_ANCHORED ||
- ELEM4(brush->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK,
- SCULPT_TOOL_THUMB, SCULPT_TOOL_ROTATE))) {
+ ELEM4(brush->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK,
+ SCULPT_TOOL_THUMB, SCULPT_TOOL_ROTATE)))
+ {
copy_v2_v2(cache->tex_mouse, cache->mouse);
if ( (brush->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED) &&
- (brush->flag & BRUSH_RANDOM_ROTATION) &&
- !(brush->flag & BRUSH_RAKE))
+ (brush->flag & BRUSH_RANDOM_ROTATION) &&
+ !(brush->flag & BRUSH_RAKE))
{
- cache->special_rotation = 2.0f*(float)M_PI*BLI_frand();
+ cache->special_rotation = 2.0f * (float)M_PI * BLI_frand();
}
}
@@ -3094,7 +3095,7 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob,
dx = cache->mouse[0] - cache->initial_mouse[0];
dy = cache->mouse[1] - cache->initial_mouse[1];
- sd->anchored_size = cache->pixel_radius = sqrt(dx*dx + dy*dy);
+ sd->anchored_size = cache->pixel_radius = sqrt(dx * dx + dy * dy);
cache->special_rotation = atan2(dx, dy) + M_PI;
@@ -3119,10 +3120,10 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob,
if (!hit)
copy_v2_v2(sd->anchored_initial_mouse, cache->initial_mouse);
- cache->radius= paint_calc_object_space_radius(paint_stroke_view_context(stroke),
- cache->true_location,
- cache->pixel_radius);
- cache->radius_squared = cache->radius*cache->radius;
+ cache->radius = paint_calc_object_space_radius(paint_stroke_view_context(stroke),
+ cache->true_location,
+ cache->pixel_radius);
+ cache->radius_squared = cache->radius * cache->radius;
copy_v3_v3(sd->anchored_location, cache->true_location);
@@ -3139,11 +3140,11 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob,
if (cache->first_time) {
copy_v2_v2(cache->last_rake, cache->mouse);
}
- else if (dx*dx + dy*dy >= r*r) {
+ else if (dx * dx + dy * dy >= r * r) {
cache->special_rotation = atan2(dx, dy);
- cache->last_rake[0] = u*cache->last_rake[0] + v*cache->mouse[0];
- cache->last_rake[1] = u*cache->last_rake[1] + v*cache->mouse[1];
+ cache->last_rake[0] = u * cache->last_rake[0] + v * cache->mouse[0];
+ cache->last_rake[1] = u * cache->last_rake[1] + v * cache->mouse[1];
}
}
@@ -3184,16 +3185,16 @@ typedef struct {
int original;
} SculptRaycastData;
-static void sculpt_raycast_cb(PBVHNode *node, void *data_v, float* tmin)
+static void sculpt_raycast_cb(PBVHNode *node, void *data_v, float *tmin)
{
if (BLI_pbvh_node_get_tmin(node) < *tmin) {
SculptRaycastData *srd = data_v;
- float (*origco)[3]= NULL;
+ float (*origco)[3] = NULL;
if (srd->original && srd->ss->cache) {
/* intersect with coordinates from before we started stroke */
- SculptUndoNode *unode= sculpt_undo_get_node(node);
- origco= (unode)? unode->co: NULL;
+ SculptUndoNode *unode = sculpt_undo_get_node(node);
+ origco = (unode) ? unode->co : NULL;
}
if (BLI_pbvh_node_raycast(srd->ss->pbvh, node, origco, srd->ray_start, srd->ray_normal, &srd->dist)) {
@@ -3236,14 +3237,14 @@ int sculpt_stroke_get_location(bContext *C, float out[3], float mouse[2])
mul_m4_v3(obimat, ray_end);
sub_v3_v3v3(ray_normal, ray_end, ray_start);
- dist= normalize_v3(ray_normal);
+ dist = normalize_v3(ray_normal);
srd.ss = vc.obact->sculpt;
srd.ray_start = ray_start;
srd.ray_normal = ray_normal;
srd.dist = dist;
srd.hit = 0;
- srd.original = (cache)? cache->original: 0;
+ srd.original = (cache) ? cache->original : 0;
BLI_pbvh_raycast(ss->pbvh, sculpt_raycast_cb, &srd,
ray_start, ray_normal, srd.original);
@@ -3257,11 +3258,11 @@ int sculpt_stroke_get_location(bContext *C, float out[3], float mouse[2])
static void sculpt_brush_init_tex(const Scene *scene, Sculpt *sd, SculptSession *ss)
{
Brush *brush = paint_brush(&sd->paint);
- MTex *mtex= &brush->mtex;
+ MTex *mtex = &brush->mtex;
/* init mtex nodes */
if (mtex->tex && mtex->tex->nodetree)
- ntreeTexBeginExecTree(mtex->tex->nodetree, 1); /* has internal flag to detect it only does it once */
+ ntreeTexBeginExecTree(mtex->tex->nodetree, 1); /* has internal flag to detect it only does it once */
/* TODO: Shouldn't really have to do this at the start of every
* stroke, but sculpt would need some sort of notification when
@@ -3271,19 +3272,19 @@ static void sculpt_brush_init_tex(const Scene *scene, Sculpt *sd, SculptSession
static int sculpt_brush_stroke_init(bContext *C, wmOperator *op)
{
- Scene *scene= CTX_data_scene(C);
- Object *ob= CTX_data_active_object(C);
+ Scene *scene = CTX_data_scene(C);
+ Object *ob = CTX_data_active_object(C);
Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
SculptSession *ss = CTX_data_active_object(C)->sculpt;
Brush *brush = paint_brush(&sd->paint);
- int mode= RNA_enum_get(op->ptr, "mode");
- int is_smooth= 0;
+ int mode = RNA_enum_get(op->ptr, "mode");
+ int is_smooth = 0;
view3d_operator_needs_opengl(C);
sculpt_brush_init_tex(scene, sd, ss);
- is_smooth|= mode == BRUSH_STROKE_SMOOTH;
- is_smooth|= brush->sculpt_tool == SCULPT_TOOL_SMOOTH;
+ is_smooth |= mode == BRUSH_STROKE_SMOOTH;
+ is_smooth |= brush->sculpt_tool == SCULPT_TOOL_SMOOTH;
sculpt_update_mesh_elements(scene, sd, ob, is_smooth);
@@ -3296,9 +3297,9 @@ static void sculpt_restore_mesh(Sculpt *sd, SculptSession *ss)
/* Restore the mesh before continuing with anchored stroke */
if ((brush->flag & BRUSH_ANCHORED) ||
- (brush->sculpt_tool == SCULPT_TOOL_GRAB &&
- brush_use_size_pressure(ss->cache->vc->scene, brush)) ||
- (brush->flag & BRUSH_RESTORE_MESH))
+ (brush->sculpt_tool == SCULPT_TOOL_GRAB &&
+ brush_use_size_pressure(ss->cache->vc->scene, brush)) ||
+ (brush->flag & BRUSH_RESTORE_MESH))
{
StrokeCache *cache = ss->cache;
int i;
@@ -3309,10 +3310,10 @@ static void sculpt_restore_mesh(Sculpt *sd, SculptSession *ss)
BLI_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &totnode);
#pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP)
- for (n=0; n<totnode; n++) {
+ for (n = 0; n < totnode; n++) {
SculptUndoNode *unode;
- unode= sculpt_undo_get_node(nodes[n]);
+ unode = sculpt_undo_get_node(nodes[n]);
if (unode) {
PBVHVertexIter vd;
@@ -3362,7 +3363,7 @@ static void sculpt_flush_update(bContext *C)
BLI_pbvh_update(ss->pbvh, PBVH_UpdateBB, NULL);
if (sculpt_get_redraw_rect(ar, CTX_wm_region_view3d(C), ob, &r)) {
if (ss->cache)
- ss->cache->previous_r= r;
+ ss->cache->previous_r = r;
r.xmin += ar->winrct.xmin + 1;
r.xmax += ar->winrct.xmin - 1;
@@ -3388,11 +3389,11 @@ static int over_mesh(bContext *C, struct wmOperator *UNUSED(op), float x, float
}
static int sculpt_stroke_test_start(bContext *C, struct wmOperator *op,
- wmEvent *event)
+ wmEvent *event)
{
/* Don't start the stroke until mouse goes over the mesh.
* note: event will only be null when re-executing the saved stroke. */
- if (event==NULL || over_mesh(C, op, event->x, event->y)) {
+ if (event == NULL || over_mesh(C, op, event->x, event->y)) {
Object *ob = CTX_data_active_object(C);
SculptSession *ss = ob->sculpt;
Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
@@ -3412,7 +3413,7 @@ static int sculpt_stroke_test_start(bContext *C, struct wmOperator *op,
int num_procs;
num_procs = omp_get_num_procs();
- omp_set_num_threads(2*num_procs);
+ omp_set_num_threads(2 * num_procs);
}
#endif
@@ -3439,8 +3440,8 @@ static void sculpt_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
static void sculpt_brush_exit_tex(Sculpt *sd)
{
- Brush *brush= paint_brush(&sd->paint);
- MTex *mtex= &brush->mtex;
+ Brush *brush = paint_brush(&sd->paint);
+ MTex *mtex = &brush->mtex;
if (mtex->tex && mtex->tex->nodetree)
ntreeTexEndExecTree(mtex->tex->nodetree->execdata, 1);
@@ -3448,26 +3449,26 @@ static void sculpt_brush_exit_tex(Sculpt *sd)
static void sculpt_stroke_done(bContext *C, struct PaintStroke *UNUSED(stroke))
{
- Object *ob= CTX_data_active_object(C);
+ Object *ob = CTX_data_active_object(C);
SculptSession *ss = ob->sculpt;
Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
/* reset values used to draw brush after completing the stroke */
- sd->draw_anchored= 0;
- sd->draw_pressure= 0;
- sd->special_rotation= 0;
+ sd->draw_anchored = 0;
+ sd->draw_pressure = 0;
+ sd->special_rotation = 0;
/* Finished */
if (ss->cache) {
- Brush *brush= paint_brush(&sd->paint);
+ Brush *brush = paint_brush(&sd->paint);
brush->flag &= ~BRUSH_INVERTED;
sculpt_stroke_modifiers_check(C, ob);
/* Alt-Smooth */
if (ss->cache->alt_smooth) {
- Paint *p= &sd->paint;
- brush= (Brush *)find_id("BR", ss->cache->saved_active_brush_name);
+ Paint *p = &sd->paint;
+ brush = (Brush *)find_id("BR", ss->cache->saved_active_brush_name);
if (brush) {
paint_brush_set(p, brush);
}
@@ -3488,10 +3489,10 @@ static void sculpt_stroke_done(bContext *C, struct PaintStroke *UNUSED(stroke))
ss->partial_redraw = 0;
/* try to avoid calling this, only for e.g. linked duplicates now */
- if (((Mesh*)ob->data)->id.us > 1)
+ if (((Mesh *)ob->data)->id.us > 1)
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
- WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
+ WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
}
sculpt_brush_exit_tex(sd);
@@ -3514,7 +3515,7 @@ static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, wmEvent *even
/* For tablet rotation */
ignore_background_click = RNA_boolean_get(op->ptr,
- "ignore_background_click");
+ "ignore_background_click");
if (ignore_background_click && !over_mesh(C, op, event->x, event->y)) {
paint_stroke_free(stroke);
@@ -3535,7 +3536,7 @@ static int sculpt_brush_stroke_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
op->customdata = paint_stroke_new(C, sculpt_stroke_get_location, sculpt_stroke_test_start,
- sculpt_stroke_update_step, sculpt_stroke_done, 0);
+ sculpt_stroke_update_step, sculpt_stroke_done, 0);
/* frees op->customdata */
paint_stroke_exec(C, op);
@@ -3545,7 +3546,7 @@ static int sculpt_brush_stroke_exec(bContext *C, wmOperator *op)
static int sculpt_brush_stroke_cancel(bContext *C, wmOperator *op)
{
- Object *ob= CTX_data_active_object(C);
+ Object *ob = CTX_data_active_object(C);
SculptSession *ss = ob->sculpt;
Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
@@ -3587,15 +3588,15 @@ static void SCULPT_OT_brush_stroke(wmOperatorType *ot)
/* properties */
RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement,
- "Stroke", "");
+ "Stroke", "");
RNA_def_enum(ot->srna, "mode", stroke_mode_items, BRUSH_STROKE_NORMAL,
- "Sculpt Stroke Mode",
- "Action taken when a sculpt stroke is made");
+ "Sculpt Stroke Mode",
+ "Action taken when a sculpt stroke is made");
RNA_def_boolean(ot->srna, "ignore_background_click", 0,
- "Ignore Background Click",
- "Clicks on the background do not start the stroke");
+ "Ignore Background Click",
+ "Clicks on the background do not start the stroke");
}
/**** Reset the copy of the mesh that is being sculpted on (currently just for the layer brush) ****/
@@ -3623,7 +3624,7 @@ static void SCULPT_OT_set_persistent_base(wmOperatorType *ot)
ot->exec = sculpt_set_persistent_base;
ot->poll = sculpt_mode_poll;
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/**** Toggle operator for turning sculpt mode on or off ****/
@@ -3640,8 +3641,8 @@ static int sculpt_toggle_mode(bContext *C, wmOperator *UNUSED(op))
Scene *scene = CTX_data_scene(C);
ToolSettings *ts = CTX_data_tool_settings(C);
Object *ob = CTX_data_active_object(C);
- MultiresModifierData *mmd= sculpt_multires_active(scene, ob);
- int flush_recalc= 0;
+ MultiresModifierData *mmd = sculpt_multires_active(scene, ob);
+ int flush_recalc = 0;
/* multires in sculpt mode could have different from object mode subdivision level */
flush_recalc |= mmd && mmd->sculptlvl != mmd->lvl;
@@ -3686,7 +3687,7 @@ static int sculpt_toggle_mode(bContext *C, wmOperator *UNUSED(op))
paint_cursor_start(C, sculpt_poll);
}
- WM_event_add_notifier(C, NC_SCENE|ND_MODE, CTX_data_scene(C));
+ WM_event_add_notifier(C, NC_SCENE | ND_MODE, CTX_data_scene(C));
return OPERATOR_FINISHED;
}
@@ -3701,7 +3702,7 @@ static void SCULPT_OT_sculptmode_toggle(wmOperatorType *ot)
ot->exec = sculpt_toggle_mode;
ot->poll = ED_operator_object_active_editable_mesh;
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
void ED_operatortypes_sculpt(void)
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c
index 73fa546b357..5378ce7872a 100644
--- a/source/blender/editors/sculpt_paint/sculpt_undo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_undo.c
@@ -71,7 +71,7 @@
static void update_cb(PBVHNode *node, void *rebuild)
{
BLI_pbvh_node_mark_update(node);
- if (*((int*)rebuild))
+ if (*((int *)rebuild))
BLI_pbvh_node_mark_rebuild_draw(node);
BLI_pbvh_node_fully_hidden_set(node, 0);
}
@@ -89,10 +89,10 @@ static void sculpt_undo_restore_deformed(SculptSession *ss, SculptUndoNode *unod
static int sculpt_undo_restore_coords(bContext *C, DerivedMesh *dm, SculptUndoNode *unode)
{
- Scene *scene= CTX_data_scene(C);
- Sculpt *sd= CTX_data_tool_settings(C)->sculpt;
- Object *ob= CTX_data_active_object(C);
- SculptSession *ss= ob->sculpt;
+ Scene *scene = CTX_data_scene(C);
+ Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
+ Object *ob = CTX_data_active_object(C);
+ SculptSession *ss = ob->sculpt;
MVert *mvert;
int *index, i, j;
@@ -102,14 +102,14 @@ static int sculpt_undo_restore_coords(bContext *C, DerivedMesh *dm, SculptUndoNo
if (ss->kb && strcmp(ss->kb->name, unode->shapeName)) {
/* shape key has been changed before calling undo operator */
- Key *key= ob_get_key(ob);
- KeyBlock *kb= key_get_named_keyblock(key, unode->shapeName);
+ Key *key = ob_get_key(ob);
+ KeyBlock *kb = key_get_named_keyblock(key, unode->shapeName);
if (kb) {
- ob->shapenr= BLI_findindex(&key->block, kb) + 1;
+ ob->shapenr = BLI_findindex(&key->block, kb) + 1;
sculpt_update_mesh_elements(scene, sd, ob, 0);
- WM_event_add_notifier(C, NC_OBJECT|ND_DATA, ob);
+ WM_event_add_notifier(C, NC_OBJECT | ND_DATA, ob);
}
else {
/* key has been removed -- skip this undo node */
@@ -117,14 +117,14 @@ static int sculpt_undo_restore_coords(bContext *C, DerivedMesh *dm, SculptUndoNo
}
}
- index= unode->index;
- mvert= ss->mvert;
+ index = unode->index;
+ mvert = ss->mvert;
if (ss->kb) {
float (*vertCos)[3];
- vertCos= key_to_vertcos(ob, ss->kb);
+ vertCos = key_to_vertcos(ob, ss->kb);
- for (i=0; i<unode->totvert; i++) {
+ for (i = 0; i < unode->totvert; i++) {
if (ss->modifiers_active) sculpt_undo_restore_deformed(ss, unode, i, index[i], vertCos[index[i]]);
else {
if (unode->orig_co) swap_v3_v3(vertCos[index[i]], unode->orig_co[i]);
@@ -142,7 +142,7 @@ static int sculpt_undo_restore_coords(bContext *C, DerivedMesh *dm, SculptUndoNo
MEM_freeN(vertCos);
}
else {
- for (i=0; i<unode->totvert; i++) {
+ for (i = 0; i < unode->totvert; i++) {
if (ss->modifiers_active) sculpt_undo_restore_deformed(ss, unode, i, index[i], mvert[index[i]].co);
else {
if (unode->orig_co) swap_v3_v3(mvert[index[i]].co, unode->orig_co[i]);
@@ -158,14 +158,14 @@ static int sculpt_undo_restore_coords(bContext *C, DerivedMesh *dm, SculptUndoNo
float (*co)[3];
int gridsize;
- grids= dm->getGridData(dm);
- gridsize= dm->getGridSize(dm);
+ grids = dm->getGridData(dm);
+ gridsize = dm->getGridSize(dm);
co = unode->co;
- for (j=0; j<unode->totgrid; j++) {
- grid= grids[unode->grids[j]];
+ for (j = 0; j < unode->totgrid; j++) {
+ grid = grids[unode->grids[j]];
- for (i=0; i<gridsize*gridsize; i++, co++)
+ for (i = 0; i < gridsize * gridsize; i++, co++)
swap_v3_v3(grid[i].co, co[0]);
}
}
@@ -174,21 +174,21 @@ static int sculpt_undo_restore_coords(bContext *C, DerivedMesh *dm, SculptUndoNo
}
static int sculpt_undo_restore_hidden(bContext *C, DerivedMesh *dm,
- SculptUndoNode *unode)
+ SculptUndoNode *unode)
{
Object *ob = CTX_data_active_object(C);
SculptSession *ss = ob->sculpt;
int i;
if (unode->maxvert) {
- MVert *mvert= ss->mvert;
+ MVert *mvert = ss->mvert;
- for (i=0; i<unode->totvert; i++) {
+ for (i = 0; i < unode->totvert; i++) {
MVert *v = &mvert[unode->index[i]];
- int uval= BLI_BITMAP_GET(unode->vert_hidden, i);
+ int uval = BLI_BITMAP_GET(unode->vert_hidden, i);
BLI_BITMAP_MODIFY(unode->vert_hidden, i,
- v->flag & ME_HIDE);
+ v->flag & ME_HIDE);
if (uval)
v->flag |= ME_HIDE;
else
@@ -200,10 +200,10 @@ static int sculpt_undo_restore_hidden(bContext *C, DerivedMesh *dm,
else if (unode->maxgrid && dm->getGridData) {
BLI_bitmap *grid_hidden = dm->getGridHidden(dm);
- for (i=0; i<unode->totgrid; i++) {
+ for (i = 0; i < unode->totgrid; i++) {
SWAP(BLI_bitmap,
- unode->grid_hidden[i],
- grid_hidden[unode->grids[i]]);
+ unode->grid_hidden[i],
+ grid_hidden[unode->grids[i]]);
}
}
@@ -220,12 +220,12 @@ static void sculpt_undo_restore(bContext *C, ListBase *lb)
SculptSession *ss = ob->sculpt;
SculptUndoNode *unode;
MultiresModifierData *mmd;
- int update= 0, rebuild= 1;
+ int update = 0, rebuild = 1;
sculpt_update_mesh_elements(scene, sd, ob, 0);
- for (unode=lb->first; unode; unode=unode->next) {
- if (!(strcmp(unode->idname, ob->id.name)==0))
+ for (unode = lb->first; unode; unode = unode->next) {
+ if (!(strcmp(unode->idname, ob->id.name) == 0))
continue;
/* check if undo data matches current data well enough to
@@ -236,48 +236,48 @@ static void sculpt_undo_restore(bContext *C, ListBase *lb)
}
else if (unode->maxgrid && dm->getGridData) {
if ((dm->getNumGrids(dm) != unode->maxgrid) ||
- (dm->getGridSize(dm) != unode->gridsize))
+ (dm->getGridSize(dm) != unode->gridsize))
continue;
}
else {
continue;
}
- switch(unode->type) {
- case SCULPT_UNDO_COORDS:
- if (sculpt_undo_restore_coords(C, dm, unode))
- update= 1;
- break;
- case SCULPT_UNDO_HIDDEN:
- if (sculpt_undo_restore_hidden(C, dm, unode))
- rebuild= 1;
- break;
+ switch (unode->type) {
+ case SCULPT_UNDO_COORDS:
+ if (sculpt_undo_restore_coords(C, dm, unode))
+ update = 1;
+ break;
+ case SCULPT_UNDO_HIDDEN:
+ if (sculpt_undo_restore_hidden(C, dm, unode))
+ rebuild = 1;
+ break;
}
}
if (update || rebuild) {
- int tag_update= 0;
+ int tag_update = 0;
/* we update all nodes still, should be more clever, but also
* needs to work correct when exiting/entering sculpt mode and
* the nodes get recreated, though in that case it could do all */
BLI_pbvh_search_callback(ss->pbvh, NULL, NULL, update_cb, &rebuild);
- BLI_pbvh_update(ss->pbvh, PBVH_UpdateBB|PBVH_UpdateOriginalBB|PBVH_UpdateRedraw, NULL);
+ BLI_pbvh_update(ss->pbvh, PBVH_UpdateBB | PBVH_UpdateOriginalBB | PBVH_UpdateRedraw, NULL);
- if ((mmd=sculpt_multires_active(scene, ob))) {
+ if ((mmd = sculpt_multires_active(scene, ob))) {
if (rebuild)
multires_mark_as_modified(ob, MULTIRES_HIDDEN_MODIFIED);
else
multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED);
}
- tag_update= ((Mesh*)ob->data)->id.us > 1;
+ tag_update = ((Mesh *)ob->data)->id.us > 1;
if (ss->modifiers_active) {
- Mesh *mesh= ob->data;
+ Mesh *mesh = ob->data;
mesh_calc_normals_mapping(mesh->mvert, mesh->totvert, mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly, NULL, NULL, 0, NULL, NULL);
free_sculptsession_deformMats(ss);
- tag_update|= 1;
+ tag_update |= 1;
}
if (tag_update)
@@ -293,7 +293,7 @@ static void sculpt_undo_free(ListBase *lb)
SculptUndoNode *unode;
int i;
- for (unode=lb->first; unode; unode=unode->next) {
+ for (unode = lb->first; unode; unode = unode->next) {
if (unode->co)
MEM_freeN(unode->co);
if (unode->no)
@@ -309,7 +309,7 @@ static void sculpt_undo_free(ListBase *lb)
if (unode->vert_hidden)
MEM_freeN(unode->vert_hidden);
if (unode->grid_hidden) {
- for (i=0; i<unode->totgrid; i++) {
+ for (i = 0; i < unode->totgrid; i++) {
if (unode->grid_hidden[i])
MEM_freeN(unode->grid_hidden[i]);
}
@@ -320,13 +320,13 @@ static void sculpt_undo_free(ListBase *lb)
SculptUndoNode *sculpt_undo_get_node(PBVHNode *node)
{
- ListBase *lb= undo_paint_push_get_list(UNDO_PAINT_MESH);
+ ListBase *lb = undo_paint_push_get_list(UNDO_PAINT_MESH);
SculptUndoNode *unode;
if (!lb)
return NULL;
- for (unode=lb->first; unode; unode=unode->next)
+ for (unode = lb->first; unode; unode = unode->next)
if (unode->node == node)
return unode;
@@ -334,19 +334,19 @@ SculptUndoNode *sculpt_undo_get_node(PBVHNode *node)
}
static void sculpt_undo_alloc_and_store_hidden(PBVH *pbvh,
- SculptUndoNode *unode)
+ SculptUndoNode *unode)
{
- PBVHNode *node= unode->node;
+ PBVHNode *node = unode->node;
BLI_bitmap *grid_hidden;
int i, *grid_indices, totgrid;
- grid_hidden= BLI_pbvh_grid_hidden(pbvh);
+ grid_hidden = BLI_pbvh_grid_hidden(pbvh);
BLI_pbvh_node_get_grids(pbvh, node, &grid_indices, &totgrid,
- NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL);
- unode->grid_hidden= MEM_mapallocN(sizeof(BLI_bitmap) * totgrid,
- "unode->grid_hidden");
+ unode->grid_hidden = MEM_mapallocN(sizeof(BLI_bitmap) * totgrid,
+ "unode->grid_hidden");
for (i = 0; i < totgrid; i++) {
if (grid_hidden[grid_indices[i]])
@@ -357,59 +357,59 @@ static void sculpt_undo_alloc_and_store_hidden(PBVH *pbvh,
}
static SculptUndoNode *sculpt_undo_alloc_node(Object *ob, PBVHNode *node,
- SculptUndoType type)
+ SculptUndoType type)
{
- ListBase *lb= undo_paint_push_get_list(UNDO_PAINT_MESH);
+ ListBase *lb = undo_paint_push_get_list(UNDO_PAINT_MESH);
SculptUndoNode *unode;
- SculptSession *ss= ob->sculpt;
+ SculptSession *ss = ob->sculpt;
int totvert, allvert, totgrid, maxgrid, gridsize, *grids;
- unode= MEM_callocN(sizeof(SculptUndoNode), "SculptUndoNode");
+ unode = MEM_callocN(sizeof(SculptUndoNode), "SculptUndoNode");
BLI_strncpy(unode->idname, ob->id.name, sizeof(unode->idname));
- unode->type= type;
- unode->node= node;
+ unode->type = type;
+ unode->node = node;
BLI_pbvh_node_num_verts(ss->pbvh, node, &totvert, &allvert);
BLI_pbvh_node_get_grids(ss->pbvh, node, &grids, &totgrid,
- &maxgrid, &gridsize, NULL, NULL);
+ &maxgrid, &gridsize, NULL, NULL);
- unode->totvert= totvert;
+ unode->totvert = totvert;
/* we will use this while sculpting, is mapalloc slow to access then? */
/* general TODO, fix count_alloc */
- switch(type) {
- case SCULPT_UNDO_COORDS:
- unode->co= MEM_mapallocN(sizeof(float)*3*allvert, "SculptUndoNode.co");
- unode->no= MEM_mapallocN(sizeof(short)*3*allvert, "SculptUndoNode.no");
- undo_paint_push_count_alloc(UNDO_PAINT_MESH, (sizeof(float)*3 + sizeof(short)*3 + sizeof(int))*allvert);
- break;
- case SCULPT_UNDO_HIDDEN:
- if (maxgrid)
- sculpt_undo_alloc_and_store_hidden(ss->pbvh, unode);
- else
- unode->vert_hidden= BLI_BITMAP_NEW(allvert, "SculptUndoNode.vert_hidden");
+ switch (type) {
+ case SCULPT_UNDO_COORDS:
+ unode->co = MEM_mapallocN(sizeof(float) * 3 * allvert, "SculptUndoNode.co");
+ unode->no = MEM_mapallocN(sizeof(short) * 3 * allvert, "SculptUndoNode.no");
+ undo_paint_push_count_alloc(UNDO_PAINT_MESH, (sizeof(float) * 3 + sizeof(short) * 3 + sizeof(int)) * allvert);
+ break;
+ case SCULPT_UNDO_HIDDEN:
+ if (maxgrid)
+ sculpt_undo_alloc_and_store_hidden(ss->pbvh, unode);
+ else
+ unode->vert_hidden = BLI_BITMAP_NEW(allvert, "SculptUndoNode.vert_hidden");
- break;
+ break;
}
BLI_addtail(lb, unode);
if (maxgrid) {
/* multires */
- unode->maxgrid= maxgrid;
- unode->totgrid= totgrid;
- unode->gridsize= gridsize;
- unode->grids= MEM_mapallocN(sizeof(int)*totgrid, "SculptUndoNode.grids");
+ unode->maxgrid = maxgrid;
+ unode->totgrid = totgrid;
+ unode->gridsize = gridsize;
+ unode->grids = MEM_mapallocN(sizeof(int) * totgrid, "SculptUndoNode.grids");
}
else {
/* regular mesh */
- unode->maxvert= ss->totvert;
- unode->index= MEM_mapallocN(sizeof(int)*allvert, "SculptUndoNode.index");
+ unode->maxvert = ss->totvert;
+ unode->index = MEM_mapallocN(sizeof(int) * allvert, "SculptUndoNode.index");
}
if (ss->modifiers_active)
- unode->orig_co= MEM_callocN(allvert*sizeof(*unode->orig_co), "undoSculpt orig_cos");
+ unode->orig_co = MEM_callocN(allvert * sizeof(*unode->orig_co), "undoSculpt orig_cos");
return unode;
}
@@ -432,12 +432,12 @@ static void sculpt_undo_store_coords(Object *ob, SculptUndoNode *unode)
static void sculpt_undo_store_hidden(Object *ob, SculptUndoNode *unode)
{
- PBVH *pbvh= ob->sculpt->pbvh;
- PBVHNode *node= unode->node;
+ PBVH *pbvh = ob->sculpt->pbvh;
+ PBVHNode *node = unode->node;
if (unode->grids) {
/* already stored during allocation */
- }
+ }
else {
MVert *mvert;
int *vert_indices, allvert;
@@ -447,13 +447,13 @@ static void sculpt_undo_store_hidden(Object *ob, SculptUndoNode *unode)
BLI_pbvh_node_get_verts(pbvh, node, &vert_indices, &mvert);
for (i = 0; i < allvert; i++) {
BLI_BITMAP_MODIFY(unode->vert_hidden, i,
- mvert[vert_indices[i]].flag & ME_HIDE);
+ mvert[vert_indices[i]].flag & ME_HIDE);
}
}
}
SculptUndoNode *sculpt_undo_push_node(Object *ob, PBVHNode *node,
- SculptUndoType type)
+ SculptUndoType type)
{
SculptSession *ss = ob->sculpt;
SculptUndoNode *unode;
@@ -461,41 +461,41 @@ SculptUndoNode *sculpt_undo_push_node(Object *ob, PBVHNode *node,
/* list is manipulated by multiple threads, so we lock */
BLI_lock_thread(LOCK_CUSTOM1);
- if ((unode= sculpt_undo_get_node(node))) {
+ if ((unode = sculpt_undo_get_node(node))) {
BLI_unlock_thread(LOCK_CUSTOM1);
return unode;
}
- unode= sculpt_undo_alloc_node(ob, node, type);
+ unode = sculpt_undo_alloc_node(ob, node, type);
BLI_unlock_thread(LOCK_CUSTOM1);
/* copy threaded, hopefully this is the performance critical part */
- switch(type) {
- case SCULPT_UNDO_COORDS:
- sculpt_undo_store_coords(ob, unode);
- break;
- case SCULPT_UNDO_HIDDEN:
- sculpt_undo_store_hidden(ob, unode);
- break;
+ switch (type) {
+ case SCULPT_UNDO_COORDS:
+ sculpt_undo_store_coords(ob, unode);
+ break;
+ case SCULPT_UNDO_HIDDEN:
+ sculpt_undo_store_hidden(ob, unode);
+ break;
}
if (unode->grids) {
int totgrid, *grids;
BLI_pbvh_node_get_grids(ss->pbvh, node, &grids, &totgrid,
- NULL, NULL, NULL, NULL);
- memcpy(unode->grids, grids, sizeof(int)*totgrid);
+ NULL, NULL, NULL, NULL);
+ memcpy(unode->grids, grids, sizeof(int) * totgrid);
}
else {
int *vert_indices, allvert;
BLI_pbvh_node_num_verts(ss->pbvh, node, NULL, &allvert);
BLI_pbvh_node_get_verts(ss->pbvh, node, &vert_indices, NULL);
- memcpy(unode->index, vert_indices, sizeof(int)*unode->totvert);
+ memcpy(unode->index, vert_indices, sizeof(int) * unode->totvert);
}
/* store active shape key */
if (ss->kb) BLI_strncpy(unode->shapeName, ss->kb->name, sizeof(ss->kb->name));
- else unode->shapeName[0]= '\0';
+ else unode->shapeName[0] = '\0';
return unode;
}
@@ -503,24 +503,24 @@ SculptUndoNode *sculpt_undo_push_node(Object *ob, PBVHNode *node,
void sculpt_undo_push_begin(const char *name)
{
undo_paint_push_begin(UNDO_PAINT_MESH, name,
- sculpt_undo_restore, sculpt_undo_free);
+ sculpt_undo_restore, sculpt_undo_free);
}
void sculpt_undo_push_end(void)
{
- ListBase *lb= undo_paint_push_get_list(UNDO_PAINT_MESH);
+ ListBase *lb = undo_paint_push_get_list(UNDO_PAINT_MESH);
SculptUndoNode *unode;
/* we don't need normals in the undo stack */
- for (unode=lb->first; unode; unode=unode->next) {
+ for (unode = lb->first; unode; unode = unode->next) {
if (unode->no) {
MEM_freeN(unode->no);
- unode->no= NULL;
+ unode->no = NULL;
}
if (unode->layer_disp) {
MEM_freeN(unode->layer_disp);
- unode->layer_disp= NULL;
+ unode->layer_disp = NULL;
}
}
diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c
index 4aa56266a21..2a0118f9c24 100644
--- a/source/blender/editors/sculpt_paint/sculpt_uv.c
+++ b/source/blender/editors/sculpt_paint/sculpt_uv.c
@@ -68,7 +68,7 @@
#include "UI_view2d.h"
-#define MARK_BOUNDARY 1
+#define MARK_BOUNDARY 1
typedef struct UvAdjacencyElement {
/* pointer to original uvelement */
@@ -86,7 +86,7 @@ typedef struct UvEdge {
char flag;
}UvEdge;
-typedef struct UVInitialStrokeElement{
+typedef struct UVInitialStrokeElement {
/* index to unique uv */
int uv;
@@ -97,7 +97,7 @@ typedef struct UVInitialStrokeElement{
float initial_uv[2];
}UVInitialStrokeElement;
-typedef struct UVInitialStroke{
+typedef struct UVInitialStroke {
/* Initial Selection,for grab brushes for instance */
UVInitialStrokeElement *initialSelection;
@@ -110,7 +110,7 @@ typedef struct UVInitialStroke{
/* custom data for uv smoothing brush */
-typedef struct UvSculptData{
+typedef struct UvSculptData {
/* Contains the first of each set of coincident uvs.
* These will be used to perform smoothing on and propagate the changes
* to their coincident uvs */
@@ -146,10 +146,10 @@ typedef struct UvSculptData{
/*********** Improved Laplacian Relaxation Operator ************************/
/* original code by Raul Fernandez Hernandez "farsthary" *
- * adapted to uv smoothing by Antony Riakiatakis *
- ***************************************************************************/
+* adapted to uv smoothing by Antony Riakiatakis *
+***************************************************************************/
-typedef struct Temp_UvData{
+typedef struct Temp_UvData {
float sum_co[2], p[2], b[2], sum_b[2];
int ncounter;
}Temp_UVData;
@@ -169,7 +169,7 @@ void HC_relaxation_iteration_uv(BMEditMesh *em, UvSculptData *sculptdata, float
/* counting neighbors */
for (i = 0; i < sculptdata->totalUvEdges; i++) {
- UvEdge *tmpedge = sculptdata->uvedges+i;
+ UvEdge *tmpedge = sculptdata->uvedges + i;
tmp_uvdata[tmpedge->uv1].ncounter++;
tmp_uvdata[tmpedge->uv2].ncounter++;
@@ -178,16 +178,16 @@ void HC_relaxation_iteration_uv(BMEditMesh *em, UvSculptData *sculptdata, float
}
for (i = 0; i < sculptdata->totalUniqueUvs; i++) {
- copy_v2_v2(diff,tmp_uvdata[i].sum_co);
- mul_v2_fl(diff,1.f/tmp_uvdata[i].ncounter);
- copy_v2_v2(tmp_uvdata[i].p,diff);
+ copy_v2_v2(diff, tmp_uvdata[i].sum_co);
+ mul_v2_fl(diff, 1.f / tmp_uvdata[i].ncounter);
+ copy_v2_v2(tmp_uvdata[i].p, diff);
tmp_uvdata[i].b[0] = diff[0] - sculptdata->uv[i].uv[0];
tmp_uvdata[i].b[1] = diff[1] - sculptdata->uv[i].uv[1];
}
for (i = 0; i < sculptdata->totalUvEdges; i++) {
- UvEdge *tmpedge = sculptdata->uvedges+i;
+ UvEdge *tmpedge = sculptdata->uvedges + i;
add_v2_v2(tmp_uvdata[tmpedge->uv1].sum_b, tmp_uvdata[tmpedge->uv2].b);
add_v2_v2(tmp_uvdata[tmpedge->uv2].sum_b, tmp_uvdata[tmpedge->uv1].b);
}
@@ -205,10 +205,10 @@ void HC_relaxation_iteration_uv(BMEditMesh *em, UvSculptData *sculptdata, float
if ((dist = dot_v2v2(diff, diff)) <= radius) {
UvElement *element;
float strength;
- strength = alpha*brush_curve_strength(brush, sqrt(dist), radius_root);
+ strength = alpha * brush_curve_strength(brush, sqrt(dist), radius_root);
- sculptdata->uv[i].uv[0] = (1.0-strength)*sculptdata->uv[i].uv[0] + strength*(tmp_uvdata[i].p[0] - 0.5f*(tmp_uvdata[i].b[0] + tmp_uvdata[i].sum_b[0]/tmp_uvdata[i].ncounter));
- sculptdata->uv[i].uv[1] = (1.0-strength)*sculptdata->uv[i].uv[1] + strength*(tmp_uvdata[i].p[1] - 0.5f*(tmp_uvdata[i].b[1] + tmp_uvdata[i].sum_b[1]/tmp_uvdata[i].ncounter));
+ sculptdata->uv[i].uv[0] = (1.0 - strength) * sculptdata->uv[i].uv[0] + strength * (tmp_uvdata[i].p[0] - 0.5f * (tmp_uvdata[i].b[0] + tmp_uvdata[i].sum_b[0] / tmp_uvdata[i].ncounter));
+ sculptdata->uv[i].uv[1] = (1.0 - strength) * sculptdata->uv[i].uv[1] + strength * (tmp_uvdata[i].p[1] - 0.5f * (tmp_uvdata[i].b[1] + tmp_uvdata[i].sum_b[1] / tmp_uvdata[i].ncounter));
for (element = sculptdata->uv[i].element; element; element = element->next) {
MLoopUV *luv;
@@ -241,7 +241,7 @@ static void laplacian_relaxation_iteration_uv(BMEditMesh *em, UvSculptData *scul
/* counting neighbors */
for (i = 0; i < sculptdata->totalUvEdges; i++) {
- UvEdge *tmpedge = sculptdata->uvedges+i;
+ UvEdge *tmpedge = sculptdata->uvedges + i;
tmp_uvdata[tmpedge->uv1].ncounter++;
tmp_uvdata[tmpedge->uv2].ncounter++;
@@ -253,7 +253,7 @@ static void laplacian_relaxation_iteration_uv(BMEditMesh *em, UvSculptData *scul
* needed since we translate along the UV plane always.*/
for (i = 0; i < sculptdata->totalUniqueUvs; i++) {
copy_v2_v2(tmp_uvdata[i].p, tmp_uvdata[i].sum_co);
- mul_v2_fl(tmp_uvdata[i].p, 1.f/tmp_uvdata[i].ncounter);
+ mul_v2_fl(tmp_uvdata[i].p, 1.f / tmp_uvdata[i].ncounter);
}
for (i = 0; i < sculptdata->totalUniqueUvs; i++) {
@@ -269,10 +269,10 @@ static void laplacian_relaxation_iteration_uv(BMEditMesh *em, UvSculptData *scul
if ((dist = dot_v2v2(diff, diff)) <= radius) {
UvElement *element;
float strength;
- strength = alpha*brush_curve_strength(brush, sqrt(dist), radius_root);
+ strength = alpha * brush_curve_strength(brush, sqrt(dist), radius_root);
- sculptdata->uv[i].uv[0] = (1.0-strength)*sculptdata->uv[i].uv[0] + strength*tmp_uvdata[i].p[0];
- sculptdata->uv[i].uv[1] = (1.0-strength)*sculptdata->uv[i].uv[1] + strength*tmp_uvdata[i].p[1];
+ sculptdata->uv[i].uv[0] = (1.0 - strength) * sculptdata->uv[i].uv[0] + strength * tmp_uvdata[i].p[0];
+ sculptdata->uv[i].uv[1] = (1.0 - strength) * sculptdata->uv[i].uv[1] + strength * tmp_uvdata[i].p[1];
for (element = sculptdata->uv[i].element; element; element = element->next) {
MLoopUV *luv;
@@ -310,7 +310,7 @@ static void uv_sculpt_stroke_apply(bContext *C, wmOperator *op, wmEvent *event,
Brush *brush = paint_brush(sculptdata->uvsculpt);
ToolSettings *toolsettings = CTX_data_tool_settings(C);
tool = sculptdata->tool;
- invert = sculptdata->invert? -1 : 1;
+ invert = sculptdata->invert ? -1 : 1;
alpha = brush_alpha(scene, brush);
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &co[0], &co[1]);
@@ -318,11 +318,11 @@ static void uv_sculpt_stroke_apply(bContext *C, wmOperator *op, wmEvent *event,
ED_space_image_size(sima, &width, &height);
ED_space_image_zoom(sima, ar, &zoomx, &zoomy);
- radius = brush_size(scene, brush)/(width*zoomx);
- aspectRatio = width/(float)height;
+ radius = brush_size(scene, brush) / (width * zoomx);
+ aspectRatio = width / (float)height;
/* We will compare squares to save some computation */
- radius = radius*radius;
+ radius = radius * radius;
radius_root = sqrt(radius);
/*
@@ -344,11 +344,11 @@ static void uv_sculpt_stroke_apply(bContext *C, wmOperator *op, wmEvent *event,
if ((dist = dot_v2v2(diff, diff)) <= radius) {
UvElement *element;
float strength;
- strength = alpha*brush_curve_strength(brush, sqrt(dist), radius_root);
+ strength = alpha * brush_curve_strength(brush, sqrt(dist), radius_root);
normalize_v2(diff);
- sculptdata->uv[i].uv[0] -= strength*diff[0]*0.001;
- sculptdata->uv[i].uv[1] -= strength*diff[1]*0.001;
+ sculptdata->uv[i].uv[0] -= strength * diff[0] * 0.001;
+ sculptdata->uv[i].uv[1] -= strength * diff[1] * 0.001;
for (element = sculptdata->uv[i].element; element; element = element->next) {
MLoopUV *luv;
@@ -386,12 +386,12 @@ static void uv_sculpt_stroke_apply(bContext *C, wmOperator *op, wmEvent *event,
float diff[2];
sub_v2_v2v2(diff, co, sculptdata->initial_stroke->init_coord);
- for (i = 0; i < sculptdata->initial_stroke->totalInitialSelected; i++ ) {
+ for (i = 0; i < sculptdata->initial_stroke->totalInitialSelected; i++) {
UvElement *element;
int uvindex = sculptdata->initial_stroke->initialSelection[i].uv;
float strength = sculptdata->initial_stroke->initialSelection[i].strength;
- sculptdata->uv[uvindex].uv[0] = sculptdata->initial_stroke->initialSelection[i].initial_uv[0] + strength*diff[0];
- sculptdata->uv[uvindex].uv[1] = sculptdata->initial_stroke->initialSelection[i].initial_uv[1] + strength*diff[1];
+ sculptdata->uv[uvindex].uv[0] = sculptdata->initial_stroke->initialSelection[i].initial_uv[0] + strength * diff[0];
+ sculptdata->uv[uvindex].uv[1] = sculptdata->initial_stroke->initialSelection[i].initial_uv[1] + strength * diff[1];
for (element = sculptdata->uv[uvindex].element; element; element = element->next) {
MLoopUV *luv;
@@ -445,12 +445,11 @@ static int uv_element_offset_from_face_get(UvElementMap *map, BMFace *efa, BMLoo
}
-static unsigned int uv_edge_hash(const void *key)
+static unsigned int uv_edge_hash(const void *key)
{
UvEdge *edge = (UvEdge *)key;
- return
- BLI_ghashutil_inthash(SET_INT_IN_POINTER(edge->uv2)) +
- BLI_ghashutil_inthash(SET_INT_IN_POINTER(edge->uv1));
+ return (BLI_ghashutil_inthash(SET_INT_IN_POINTER(edge->uv2)) +
+ BLI_ghashutil_inthash(SET_INT_IN_POINTER(edge->uv1)));
}
static int uv_edge_compare(const void *a, const void *b)
@@ -478,7 +477,7 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, wmEvent
if (data) {
int counter = 0, i;
- ARegion *ar= CTX_wm_region(C);
+ ARegion *ar = CTX_wm_region(C);
float co[2];
BMFace *efa;
MLoopUV *luv;
@@ -487,14 +486,14 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, wmEvent
UvEdge *edges;
GHash *edgeHash;
- GHashIterator* ghi;
+ GHashIterator *ghi;
int do_island_optimization = !(ts->uv_sculpt_settings & UV_SCULPT_ALL_ISLANDS);
int island_index = 0;
/* Holds, for each UvElement in elementMap, a pointer to its unique uv.*/
int *uniqueUv;
- data->tool = (RNA_enum_get(op->ptr, "mode") == BRUSH_STROKE_SMOOTH)? UV_SCULPT_TOOL_RELAX : ts->uv_sculpt_tool;
- data->invert = (RNA_enum_get(op->ptr, "mode") == BRUSH_STROKE_INVERT)? 1 : 0;
+ data->tool = (RNA_enum_get(op->ptr, "mode") == BRUSH_STROKE_SMOOTH) ? UV_SCULPT_TOOL_RELAX : ts->uv_sculpt_tool;
+ data->invert = (RNA_enum_get(op->ptr, "mode") == BRUSH_STROKE_INVERT) ? 1 : 0;
data->uvsculpt = &ts->uvsculpt->paint;
@@ -528,7 +527,7 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, wmEvent
if (do_island_optimization) {
UvElement *element;
NearestHit hit;
- Image *ima= CTX_data_edit_image(C);
+ Image *ima = CTX_data_edit_image(C);
uv_find_nearest_vert(scene, ima, em, co, NULL, &hit);
element = ED_uv_element_get(data->elementMap, hit.efa, hit.l);
@@ -539,17 +538,17 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, wmEvent
/* Count 'unique' uvs */
for (i = 0; i < data->elementMap->totalUVs; i++) {
if (data->elementMap->buf[i].separate
- && (!do_island_optimization || data->elementMap->buf[i].island == island_index)) {
+ && (!do_island_optimization || data->elementMap->buf[i].island == island_index)) {
counter++;
}
}
/* Allocate the unique uv buffers */
- data->uv = MEM_mallocN(sizeof(*data->uv)*counter, "uv_brush_unique_uvs");
- uniqueUv = MEM_mallocN(sizeof(*uniqueUv)*data->elementMap->totalUVs, "uv_brush_unique_uv_map");
+ data->uv = MEM_mallocN(sizeof(*data->uv) * counter, "uv_brush_unique_uvs");
+ uniqueUv = MEM_mallocN(sizeof(*uniqueUv) * data->elementMap->totalUVs, "uv_brush_unique_uv_map");
edgeHash = BLI_ghash_new(uv_edge_hash, uv_edge_compare, "uv_brush_edge_hash");
/* we have at most totalUVs edges */
- edges = MEM_mallocN(sizeof(*edges)*data->elementMap->totalUVs, "uv_brush_all_edges");
+ edges = MEM_mallocN(sizeof(*edges) * data->elementMap->totalUVs, "uv_brush_all_edges");
if (!data->uv || !uniqueUv || !edgeHash || !edges) {
if (edges) {
MEM_freeN(edges);
@@ -634,7 +633,7 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, wmEvent
MEM_freeN(uniqueUv);
/* Allocate connectivity data, we allocate edges once */
- data->uvedges = MEM_mallocN(sizeof(*data->uvedges)*BLI_ghash_size(edgeHash), "uv_brush_edge_connectivity_data");
+ data->uvedges = MEM_mallocN(sizeof(*data->uvedges) * BLI_ghash_size(edgeHash), "uv_brush_edge_connectivity_data");
if (!data->uvedges) {
BLI_ghash_free(edgeHash, NULL, NULL);
MEM_freeN(edges);
@@ -686,9 +685,9 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, wmEvent
ED_space_image_size(sima, &width, &height);
ED_space_image_zoom(sima, ar, &zoomx, &zoomy);
- aspectRatio = width/(float)height;
- radius /= (width*zoomx);
- radius = radius*radius;
+ aspectRatio = width / (float)height;
+ radius /= (width * zoomx);
+ radius = radius * radius;
radius_root = sqrt(radius);
/* Allocate selection stack */
@@ -696,7 +695,7 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, wmEvent
if (!data->initial_stroke) {
uv_sculpt_stroke_exit(C, op);
}
- data->initial_stroke->initialSelection = MEM_mallocN(sizeof(*data->initial_stroke->initialSelection)*data->totalUniqueUvs, "uv_sculpt_initial_selection");
+ data->initial_stroke->initialSelection = MEM_mallocN(sizeof(*data->initial_stroke->initialSelection) * data->totalUniqueUvs, "uv_sculpt_initial_selection");
if (!data->initial_stroke->initialSelection) {
uv_sculpt_stroke_exit(C, op);
}
@@ -715,7 +714,7 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, wmEvent
diff[1] /= aspectRatio;
if ((dist = dot_v2v2(diff, diff)) <= radius) {
float strength;
- strength = alpha*brush_curve_strength(brush, sqrt(dist), radius_root);
+ strength = alpha * brush_curve_strength(brush, sqrt(dist), radius_root);
data->initial_stroke->initialSelection[counter].uv = i;
data->initial_stroke->initialSelection[counter].strength = strength;
@@ -742,7 +741,7 @@ static int uv_sculpt_stroke_invoke(bContext *C, wmOperator *op, wmEvent *event)
uv_sculpt_stroke_apply(C, op, event, obedit);
- data->timer= WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER, 0.001f);
+ data->timer = WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER, 0.001f);
if (!data->timer) {
uv_sculpt_stroke_exit(C, op);
@@ -759,7 +758,7 @@ static int uv_sculpt_stroke_modal(bContext *C, wmOperator *op, wmEvent *event)
UvSculptData *data = (UvSculptData *)op->customdata;
Object *obedit = CTX_data_edit_object(C);
- switch(event->type) {
+ switch (event->type) {
case LEFTMOUSE:
case MIDDLEMOUSE:
case RIGHTMOUSE:
@@ -779,7 +778,7 @@ static int uv_sculpt_stroke_modal(bContext *C, wmOperator *op, wmEvent *event)
}
ED_region_tag_redraw(CTX_wm_region(C));
- WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
+ WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
DAG_id_tag_update(obedit->data, 0);
return OPERATOR_RUNNING_MODAL;
}
@@ -804,7 +803,7 @@ void SCULPT_OT_uv_sculpt_stroke(wmOperatorType *ot)
ot->poll = uv_sculpt_poll;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* props */
RNA_def_enum(ot->srna, "mode", stroke_mode_items, BRUSH_STROKE_NORMAL, "Mode", "Stroke Mode");