style cleanup: mainly whitespace around operators and indentation - paint/sculpt tools

This commit is contained in:
Campbell Barton 2012-03-28 03:47:33 +00:00
parent 274e243a67
commit c9f677d24d
11 changed files with 1982 additions and 1978 deletions

@ -76,9 +76,9 @@ typedef struct Snapshot {
int curve_changed_timestamp; int curve_changed_timestamp;
} Snapshot; } 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) && return (((mtex->tex) &&
equals_v3v3(mtex->ofs, snap->ofs) && equals_v3v3(mtex->ofs, snap->ofs) &&
@ -95,7 +95,7 @@ static int same_snap(Snapshot* snap, Brush* brush, ViewContext* vc)
(vc->ar->winy == snap->winy)); (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) { if (brush->mtex.tex) {
snap->brush_map_mode = brush->mtex.brush_map_mode; snap->brush_map_mode = brush->mtex.brush_map_mode;
@ -105,8 +105,8 @@ static void make_snap(Snapshot* snap, Brush* brush, ViewContext* vc)
} }
else { else {
snap->brush_map_mode = -1; snap->brush_map_mode = -1;
snap->ofs[0]= snap->ofs[1]= snap->ofs[2]= -1; snap->ofs[0] = snap->ofs[1] = snap->ofs[2] = -1;
snap->size[0]= snap->size[1]= snap->size[2]= -1; snap->size[0] = snap->size[1] = snap->size[2] = -1;
snap->rot = -1; snap->rot = -1;
} }
@ -115,7 +115,7 @@ static void make_snap(Snapshot* snap, Brush* brush, ViewContext* vc)
snap->winy = vc->ar->winy; 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 GLuint overlay_texture = 0;
static int init = 0; static int init = 0;
@ -124,7 +124,7 @@ static int load_tex(Sculpt *sd, Brush* br, ViewContext* vc)
static Snapshot snap; static Snapshot snap;
static int old_size = -1; static int old_size = -1;
GLubyte* buffer = NULL; GLubyte *buffer = NULL;
int size; int size;
int j; int j;
@ -161,7 +161,7 @@ static int load_tex(Sculpt *sd, Brush* br, ViewContext* vc)
for (s >>= 1; s > 0; s >>= 1) for (s >>= 1; s > 0; s >>= 1)
r++; r++;
size = (1<<r); size = (1 << r);
if (size < 256) if (size < 256)
size = 256; size = 256;
@ -183,26 +183,26 @@ static int load_tex(Sculpt *sd, Brush* br, ViewContext* vc)
old_size = size; 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) #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; int i;
float y; float y;
float len; float len;
for (i= 0; i < size; i++) { for (i = 0; i < size; i++) {
// largely duplicated from tex_strength // largely duplicated from tex_strength
const float rotation = -br->mtex.rot; const float rotation = -br->mtex.rot;
float radius = brush_size(vc->scene, br); float radius = brush_size(vc->scene, br);
int index = j*size + i; int index = j * size + i;
float x; float x;
float avg; float avg;
x = (float)i/size; x = (float)i / size;
y = (float)j/size; y = (float)j / size;
x -= 0.5f; x -= 0.5f;
y -= 0.5f; y -= 0.5f;
@ -216,7 +216,7 @@ static int load_tex(Sculpt *sd, Brush* br, ViewContext* vc)
y *= 2; 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) { if ((br->mtex.brush_map_mode == MTEX_MAP_MODE_TILED) || len <= 1) {
/* it is probably worth optimizing for those cases where /* it is probably worth optimizing for those cases where
@ -242,7 +242,7 @@ static int load_tex(Sculpt *sd, Brush* br, ViewContext* vc)
if (br->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED) 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 { else {
buffer[index] = 0; buffer[index] = 0;
@ -254,7 +254,7 @@ static int load_tex(Sculpt *sd, Brush* br, ViewContext* vc)
glGenTextures(1, &overlay_texture); glGenTextures(1, &overlay_texture);
} }
else { else {
size= old_size; size = old_size;
} }
glBindTexture(GL_TEXTURE_2D, overlay_texture); glBindTexture(GL_TEXTURE_2D, overlay_texture);
@ -328,8 +328,8 @@ static int project_brush_radius(ViewContext *vc,
return len_v2v2(p1, p2); return len_v2v2(p1, p2);
} }
static int sculpt_get_brush_geometry(bContext* C, ViewContext *vc, static int sculpt_get_brush_geometry(bContext *C, ViewContext *vc,
int x, int y, int* pixel_radius, int x, int y, int *pixel_radius,
float location[3]) float location[3])
{ {
Scene *scene = CTX_data_scene(C); Scene *scene = CTX_data_scene(C);
@ -356,8 +356,8 @@ static int sculpt_get_brush_geometry(bContext* C, ViewContext *vc,
hit = 1; hit = 1;
} }
else { else {
Sculpt* sd = CTX_data_tool_settings(C)->sculpt; Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
Brush* brush = paint_brush(&sd->paint); Brush *brush = paint_brush(&sd->paint);
*pixel_radius = brush_size(scene, brush); *pixel_radius = brush_size(scene, brush);
hit = 0; hit = 0;
@ -381,15 +381,15 @@ static void paint_draw_alpha_overlay(Sculpt *sd, Brush *brush,
/* save lots of GL state /* save lots of GL state
* TODO: check on whether all of these are needed? */ * TODO: check on whether all of these are needed? */
glPushAttrib(GL_COLOR_BUFFER_BIT| glPushAttrib(GL_COLOR_BUFFER_BIT |
GL_CURRENT_BIT| GL_CURRENT_BIT |
GL_DEPTH_BUFFER_BIT| GL_DEPTH_BUFFER_BIT |
GL_ENABLE_BIT| GL_ENABLE_BIT |
GL_LINE_BIT| GL_LINE_BIT |
GL_POLYGON_BIT| GL_POLYGON_BIT |
GL_STENCIL_BUFFER_BIT| GL_STENCIL_BUFFER_BIT |
GL_TRANSFORM_BIT| GL_TRANSFORM_BIT |
GL_VIEWPORT_BIT| GL_VIEWPORT_BIT |
GL_TEXTURE_BIT); GL_TEXTURE_BIT);
if (load_tex(sd, brush, vc)) { if (load_tex(sd, brush, vc)) {
@ -414,20 +414,20 @@ static void paint_draw_alpha_overlay(Sculpt *sd, Brush *brush,
/* scale based on tablet pressure */ /* scale based on tablet pressure */
if (sd->draw_pressure && brush_use_size_pressure(vc->scene, brush)) { if (sd->draw_pressure && brush_use_size_pressure(vc->scene, brush)) {
glTranslatef(0.5f, 0.5f, 0); 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); glTranslatef(-0.5f, -0.5f, 0);
} }
if (sd->draw_anchored) { if (sd->draw_anchored) {
const float *aim = sd->anchored_initial_mouse; const float *aim = sd->anchored_initial_mouse;
const rcti *win = &vc->ar->winrct; const rcti *win = &vc->ar->winrct;
quad.xmin = aim[0]-sd->anchored_size - win->xmin; quad.xmin = aim[0] - sd->anchored_size - win->xmin;
quad.ymin = aim[1]-sd->anchored_size - win->ymin; quad.ymin = aim[1] - sd->anchored_size - win->ymin;
quad.xmax = aim[0]+sd->anchored_size - win->xmin; quad.xmax = aim[0] + sd->anchored_size - win->xmin;
quad.ymax = aim[1]+sd->anchored_size - win->ymin; quad.ymax = aim[1] + sd->anchored_size - win->ymin;
} }
else { else {
const int radius= brush_size(vc->scene, brush); const int radius = brush_size(vc->scene, brush);
quad.xmin = x - radius; quad.xmin = x - radius;
quad.ymin = y - radius; quad.ymin = y - radius;
quad.xmax = x + radius; quad.xmax = x + radius;
@ -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 dx = sd->last_x - x;
const float dy = sd->last_y - y; 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_angle = atan2(dx, dy);
sd->last_x = u*sd->last_x + v*x; sd->last_x = u * sd->last_x + v * x;
sd->last_y = u*sd->last_y + v*y; sd->last_y = u * sd->last_y + v * y;
} }
} }
@ -588,7 +588,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
/* draw brush outline */ /* draw brush outline */
glTranslatef(translation[0], translation[1], 0); 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); glTranslatef(-translation[0], -translation[1], 0);
/* restore GL state */ /* restore GL state */

@ -163,7 +163,7 @@ static void partialvis_update_grids(Object *ob,
BLI_bitmap gh = grid_hidden[g]; BLI_bitmap gh = grid_hidden[g];
if (!gh) { if (!gh) {
switch(action) { switch (action) {
case PARTIALVIS_HIDE: case PARTIALVIS_HIDE:
/* create grid flags data */ /* create grid flags data */
gh = grid_hidden[g] = BLI_BITMAP_NEW(gridsize * gridsize, gh = grid_hidden[g] = BLI_BITMAP_NEW(gridsize * gridsize,
@ -235,7 +235,7 @@ static void clip_planes_from_rect(bContext *C,
{ {
ViewContext vc; ViewContext vc;
BoundBox bb; BoundBox bb;
bglMats mats= {{0}}; bglMats mats = {{0}};
view3d_operator_needs_opengl(C); view3d_operator_needs_opengl(C);
view3d_set_viewcontext(C, &vc); view3d_set_viewcontext(C, &vc);
@ -257,7 +257,7 @@ static void get_pbvh_nodes(PBVH *pbvh,
BLI_pbvh_SearchCallback cb; BLI_pbvh_SearchCallback cb;
/* select search callback */ /* select search callback */
switch(mode) { switch (mode) {
case PARTIALVIS_INSIDE: case PARTIALVIS_INSIDE:
cb = BLI_pbvh_node_planes_contain_AABB; cb = BLI_pbvh_node_planes_contain_AABB;
break; break;
@ -301,7 +301,7 @@ static int hide_show_exec(bContext *C, wmOperator *op)
pbvh_type = BLI_pbvh_type(pbvh); pbvh_type = BLI_pbvh_type(pbvh);
/* start undo */ /* start undo */
switch(action) { switch (action) {
case PARTIALVIS_HIDE: case PARTIALVIS_HIDE:
sculpt_undo_push_begin("Hide area"); sculpt_undo_push_begin("Hide area");
break; break;
@ -311,7 +311,7 @@ static int hide_show_exec(bContext *C, wmOperator *op)
} }
for (i = 0; i < totnode; i++) { for (i = 0; i < totnode; i++) {
switch(pbvh_type) { switch (pbvh_type) {
case PBVH_FACES: case PBVH_FACES:
partialvis_update_mesh(ob, pbvh, nodes[i], action, area, clip_planes); partialvis_update_mesh(ob, pbvh, nodes[i], action, area, clip_planes);
break; break;

File diff suppressed because it is too large Load Diff

@ -83,23 +83,23 @@ static void BRUSH_OT_add(wmOperatorType *ot)
ot->exec = brush_add_exec; ot->exec = brush_add_exec;
/* flags */ /* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
} }
static int brush_scale_size_exec(bContext *C, wmOperator *op) static int brush_scale_size_exec(bContext *C, wmOperator *op)
{ {
Scene *scene = CTX_data_scene(C); Scene *scene = CTX_data_scene(C);
Paint *paint= paint_get_active(scene); Paint *paint = paint_get_active(scene);
struct Brush *brush= paint_brush(paint); struct Brush *brush = paint_brush(paint);
// Object *ob= CTX_data_active_object(C); // 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) { if (brush) {
// pixel radius // pixel radius
{ {
const int old_size= brush_size(scene, brush); const int old_size = brush_size(scene, brush);
int size= (int)(scalar*old_size); int size = (int)(scalar * old_size);
if (old_size == size) { if (old_size == size) {
if (scalar > 1) { if (scalar > 1) {
@ -116,10 +116,10 @@ static int brush_scale_size_exec(bContext *C, wmOperator *op)
// unprojected radius // 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 if (unprojected_radius < 0.001f) // XXX magic number
unprojected_radius= 0.001f; unprojected_radius = 0.001f;
brush_set_unprojected_radius(scene, brush, unprojected_radius); 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; ot->exec = brush_scale_size_exec;
/* flags */ /* 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); 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; ot->poll = vertex_paint_mode_poll;
/* flags */ /* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
} }
static int brush_reset_exec(bContext *C, wmOperator *UNUSED(op)) 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; ot->exec = brush_reset_exec;
/* flags */ /* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
} }
static int brush_tool(const Brush *brush, size_t tool_offset) static int brush_tool(const Brush *brush, size_t tool_offset)
@ -208,14 +208,15 @@ static Brush *brush_tool_cycle(Main *bmain, Brush *brush_orig, const int tool, c
{ {
struct Brush *brush; struct Brush *brush;
if (!brush_orig && !(brush_orig= bmain->brush.first)) { if (!brush_orig && !(brush_orig = bmain->brush.first)) {
return NULL; return NULL;
} }
/* get the next brush with the active tool */ /* get the next brush with the active tool */
for (brush= brush_orig->id.next ? brush_orig->id.next : bmain->brush.first; for (brush = brush_orig->id.next ? brush_orig->id.next : bmain->brush.first;
brush != brush_orig; brush != brush_orig;
brush= brush->id.next ? brush->id.next : bmain->brush.first) { brush = brush->id.next ? brush->id.next : bmain->brush.first)
{
if ((brush->ob_mode & ob_mode) && if ((brush->ob_mode & ob_mode) &&
(brush_tool(brush, tool_offset) == tool)) { (brush_tool(brush, tool_offset) == tool)) {
return brush; 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) 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) { if (brush) {
paint_brush_set(paint, 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; return OPERATOR_FINISHED;
} }
else { else {
@ -246,42 +247,42 @@ static int brush_generic_tool_set(Main *bmain, Paint *paint, const int tool, con
static int brush_select_exec(bContext *C, wmOperator *op) static int brush_select_exec(bContext *C, wmOperator *op)
{ {
Main *bmain= CTX_data_main(C); Main *bmain = CTX_data_main(C);
ToolSettings *toolsettings= CTX_data_tool_settings(C); ToolSettings *toolsettings = CTX_data_tool_settings(C);
Paint *paint= NULL; Paint *paint = NULL;
int tool, paint_mode= RNA_enum_get(op->ptr, "paint_mode"); int tool, paint_mode = RNA_enum_get(op->ptr, "paint_mode");
size_t tool_offset; size_t tool_offset;
if (paint_mode == OB_MODE_ACTIVE) { if (paint_mode == OB_MODE_ACTIVE) {
/* select current paint mode */ /* select current paint mode */
paint_mode = CTX_data_active_object(C)->mode & paint_mode = CTX_data_active_object(C)->mode &
(OB_MODE_SCULPT| (OB_MODE_SCULPT |
OB_MODE_VERTEX_PAINT| OB_MODE_VERTEX_PAINT |
OB_MODE_WEIGHT_PAINT| OB_MODE_WEIGHT_PAINT |
OB_MODE_TEXTURE_PAINT); OB_MODE_TEXTURE_PAINT);
} }
switch(paint_mode) { switch (paint_mode) {
case OB_MODE_SCULPT: case OB_MODE_SCULPT:
paint= &toolsettings->sculpt->paint; paint = &toolsettings->sculpt->paint;
tool_offset= offsetof(Brush, sculpt_tool); tool_offset = offsetof(Brush, sculpt_tool);
tool= RNA_enum_get(op->ptr, "sculpt_tool"); tool = RNA_enum_get(op->ptr, "sculpt_tool");
break; break;
case OB_MODE_VERTEX_PAINT: case OB_MODE_VERTEX_PAINT:
paint= &toolsettings->vpaint->paint; paint = &toolsettings->vpaint->paint;
tool_offset= offsetof(Brush, vertexpaint_tool); tool_offset = offsetof(Brush, vertexpaint_tool);
tool= RNA_enum_get(op->ptr, "vertex_paint_tool"); tool = RNA_enum_get(op->ptr, "vertex_paint_tool");
break; break;
case OB_MODE_WEIGHT_PAINT: case OB_MODE_WEIGHT_PAINT:
paint= &toolsettings->wpaint->paint; paint = &toolsettings->wpaint->paint;
/* vertexpaint_tool is used for weight paint mode */ /* vertexpaint_tool is used for weight paint mode */
tool_offset= offsetof(Brush, vertexpaint_tool); tool_offset = offsetof(Brush, vertexpaint_tool);
tool= RNA_enum_get(op->ptr, "weight_paint_tool"); tool = RNA_enum_get(op->ptr, "weight_paint_tool");
break; break;
case OB_MODE_TEXTURE_PAINT: case OB_MODE_TEXTURE_PAINT:
paint= &toolsettings->imapaint.paint; paint = &toolsettings->imapaint.paint;
tool_offset= offsetof(Brush, imagepaint_tool); tool_offset = offsetof(Brush, imagepaint_tool);
tool= RNA_enum_get(op->ptr, "texture_paint_tool"); tool = RNA_enum_get(op->ptr, "texture_paint_tool");
break; break;
default: default:
/* invalid paint mode */ /* invalid 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_VERTEX_PAINT, "VERTEX_PAINT", ICON_VPAINT_HLT, "Vertex Paint", ""},
{OB_MODE_WEIGHT_PAINT, "WEIGHT_PAINT", ICON_WPAINT_HLT, "Weight Paint", ""}, {OB_MODE_WEIGHT_PAINT, "WEIGHT_PAINT", ICON_WPAINT_HLT, "Weight Paint", ""},
{OB_MODE_TEXTURE_PAINT, "TEXTURE_PAINT", ICON_TPAINT_HLT, "Texture Paint", ""}, {OB_MODE_TEXTURE_PAINT, "TEXTURE_PAINT", ICON_TPAINT_HLT, "Texture Paint", ""},
{0, NULL, 0, NULL, NULL}}; {0, NULL, 0, NULL, NULL}
};
/* identifiers */ /* identifiers */
ot->name = "Brush Select"; ot->name = "Brush Select";
@ -310,7 +312,7 @@ static void PAINT_OT_brush_select(wmOperatorType *ot)
ot->exec = brush_select_exec; ot->exec = brush_select_exec;
/* flags */ /* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* props */ /* props */
RNA_def_enum(ot->srna, "paint_mode", paint_mode_items, OB_MODE_ACTIVE, "Paint Mode", ""); RNA_def_enum(ot->srna, "paint_mode", paint_mode_items, OB_MODE_ACTIVE, "Paint Mode", "");
@ -330,7 +332,7 @@ static wmKeyMapItem *keymap_brush_select(wmKeyMap *keymap, int paint_mode,
RNA_enum_set(kmi->ptr, "paint_mode", paint_mode); RNA_enum_set(kmi->ptr, "paint_mode", paint_mode);
switch(paint_mode) { switch (paint_mode) {
case OB_MODE_SCULPT: case OB_MODE_SCULPT:
RNA_enum_set(kmi->ptr, "sculpt_tool", tool); RNA_enum_set(kmi->ptr, "sculpt_tool", tool);
break; break;
@ -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) static int brush_uv_sculpt_tool_set_exec(bContext *C, wmOperator *op)
{ {
Brush *brush; Brush *brush;
Scene *scene= CTX_data_scene(C); Scene *scene = CTX_data_scene(C);
ToolSettings *ts = scene->toolsettings; ToolSettings *ts = scene->toolsettings;
ts->uv_sculpt_tool = RNA_enum_get(op->ptr, "tool"); ts->uv_sculpt_tool = RNA_enum_get(op->ptr, "tool");
brush = ts->uvsculpt->paint.brush; brush = ts->uvsculpt->paint.brush;
/* To update toolshelf */ /* 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; return OPERATOR_FINISHED;
} }
@ -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); RNA_float_set(kmi->ptr, "scalar", 0.9);
kmi = WM_keymap_add_item(keymap, "BRUSH_OT_scale_size", RIGHTBRACKETKEY, KM_PRESS, 0, 0); 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 { typedef enum {
@ -561,8 +563,8 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
/* Partial visibility, sculpt-only for now */ /* Partial visibility, sculpt-only for now */
paint_partial_visibility_keys(keymap); paint_partial_visibility_keys(keymap);
for (i=0; i<=5; 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); RNA_int_set(WM_keymap_add_item(keymap, "OBJECT_OT_subdivision_set", ZEROKEY + i, KM_PRESS, KM_CTRL, 0)->ptr, "level", i);
/* multires switch */ /* multires switch */
kmi = WM_keymap_add_item(keymap, "OBJECT_OT_subdivision_set", PAGEUPKEY, KM_PRESS, 0, 0); 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_sample_color", RIGHTMOUSE, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, 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_switch(keymap, "vertex_paint");
ed_keymap_paint_brush_size(keymap, "tool_settings.vertex_paint.brush.size"); ed_keymap_paint_brush_size(keymap, "tool_settings.vertex_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); 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); 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); 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); RNA_boolean_set(kmi->ptr, "deselect", TRUE);
WM_keymap_add_item(keymap, "VIEW3D_OT_select_circle", CKEY, KM_PRESS, 0, 0); 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_switch(keymap, "image_paint");
ed_keymap_paint_brush_size(keymap, "tool_settings.image_paint.brush.size"); 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 */ 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"); RNA_string_set(kmi->ptr, "data_path", "image_paint_object.data.use_paint_mask");

@ -113,7 +113,7 @@ static float event_tablet_data(wmEvent *event, int *pen_flip)
float pressure = 1; float pressure = 1;
if (event->custom == EVT_DATA_TABLET) { if (event->custom == EVT_DATA_TABLET) {
wmTabletData *wmtab= event->customdata; wmTabletData *wmtab = event->customdata;
erasor = (wmtab->Active == EVT_TABLET_ERASER); erasor = (wmtab->Active == EVT_TABLET_ERASER);
pressure = (wmtab->Active != EVT_TABLET_NONE) ? wmtab->Pressure : 1; 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, /* If the mouse is moving within the radius of the last move,
* don't update the mouse position. This allows sharp turns. */ * 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; return 0;
output[0] = event->x * v + stroke->last_mouse_position[0] * u; 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); const Scene *scene = CTX_data_scene(C);
int steps; int steps;
int i; 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 */ /* 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)) if (brush_use_size_pressure(scene, stroke->brush))
pressure = event_tablet_data(event, NULL); pressure = event_tablet_data(event, NULL);
if (pressure > FLT_EPSILON) { 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) { if (scale > FLT_EPSILON) {
mul_v2_fl(vec, scale); mul_v2_fl(vec, scale);
@ -271,7 +271,7 @@ PaintStroke *paint_stroke_new(bContext *C,
stroke->test_start = test_start; stroke->test_start = test_start;
stroke->update_step = update_step; stroke->update_step = update_step;
stroke->done = done; stroke->done = done;
stroke->event_type= event_type; /* for modal, return event */ stroke->event_type = event_type; /* for modal, return event */
return stroke; return stroke;
} }
@ -293,7 +293,7 @@ int paint_stroke_modal(bContext *C, wmOperator *op, wmEvent *event)
{ {
PaintStroke *stroke = op->customdata; PaintStroke *stroke = op->customdata;
float mouse[2]; 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! // 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 // this isn't perfect... even when an extra MOUSEMOVE is spoofed, the stroke discards it
@ -315,7 +315,7 @@ int paint_stroke_modal(bContext *C, wmOperator *op, wmEvent *event)
stroke->timer = WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER, stroke->brush->rate); 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); //ED_region_tag_redraw(ar);
} }
@ -331,7 +331,7 @@ int paint_stroke_modal(bContext *C, wmOperator *op, wmEvent *event)
MEM_freeN(stroke); MEM_freeN(stroke);
return OPERATOR_FINISHED; return OPERATOR_FINISHED;
} }
else if ( (first) || else if ((first) ||
(ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) || (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) ||
(event->type == TIMER && (event->customdata == stroke->timer)) ) (event->type == TIMER && (event->customdata == stroke->timer)) )
{ {
@ -347,7 +347,7 @@ int paint_stroke_modal(bContext *C, wmOperator *op, wmEvent *event)
} }
} }
else { else {
;//ED_region_tag_redraw(ar); ; //ED_region_tag_redraw(ar);
} }
} }
} }
@ -374,7 +374,7 @@ int paint_stroke_exec(bContext *C, wmOperator *op)
if (stroke->stroke_started == 0) { if (stroke->stroke_started == 0) {
/* XXX stroke->last_mouse_position is unset, this may cause problems */ /* XXX stroke->last_mouse_position is unset, this may cause problems */
stroke->test_start(C, op, NULL); stroke->test_start(C, op, NULL);
stroke->stroke_started= 1; stroke->stroke_started = 1;
} }
RNA_BEGIN(op->ptr, itemptr, "stroke") { RNA_BEGIN(op->ptr, itemptr, "stroke") {

@ -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) */ /* remove all undos after (also when stack->current==NULL) */
while (stack->elems.last != stack->current) { while (stack->elems.last != stack->current) {
uel= stack->elems.last; uel = stack->elems.last;
undo_elem_free(stack, uel); undo_elem_free(stack, uel);
BLI_freelinkN(&stack->elems, uel); BLI_freelinkN(&stack->elems, uel);
} }
/* make new */ /* make new */
stack->current= uel= MEM_callocN(sizeof(UndoElem), "undo file"); stack->current = uel = MEM_callocN(sizeof(UndoElem), "undo file");
uel->restore= restore; uel->restore = restore;
uel->free= free; uel->free = free;
BLI_addtail(&stack->elems, uel); BLI_addtail(&stack->elems, uel);
/* name can be a dynamic string */ /* name can be a dynamic string */
BLI_strncpy(uel->name, name, sizeof(uel->name)); BLI_strncpy(uel->name, name, sizeof(uel->name));
/* limit amount to the maximum amount*/ /* limit amount to the maximum amount*/
nr= 0; nr = 0;
uel= stack->elems.last; uel = stack->elems.last;
while (uel) { while (uel) {
nr++; nr++;
if (nr==U.undosteps) break; if (nr == U.undosteps) break;
uel= uel->prev; uel = uel->prev;
} }
if (uel) { if (uel) {
while (stack->elems.first!=uel) { while (stack->elems.first != uel) {
UndoElem *first= stack->elems.first; UndoElem *first = stack->elems.first;
undo_elem_free(stack, first); undo_elem_free(stack, first);
BLI_freelinkN(&stack->elems, first); BLI_freelinkN(&stack->elems, first);
} }
@ -132,19 +132,19 @@ static void undo_stack_push_end(UndoStack *stack)
if (U.undomemory != 0) { if (U.undomemory != 0) {
/* limit to maximum memory (afterwards, we can't know in advance) */ /* limit to maximum memory (afterwards, we can't know in advance) */
totmem= 0; totmem = 0;
maxmem= ((uintptr_t)U.undomemory)*1024*1024; maxmem = ((uintptr_t)U.undomemory) * 1024 * 1024;
uel= stack->elems.last; uel = stack->elems.last;
while (uel) { while (uel) {
totmem+= uel->undosize; totmem += uel->undosize;
if (totmem>maxmem) break; if (totmem > maxmem) break;
uel= uel->prev; uel = uel->prev;
} }
if (uel) { if (uel) {
while (stack->elems.first!=uel) { while (stack->elems.first != uel) {
UndoElem *first= stack->elems.first; UndoElem *first = stack->elems.first;
undo_elem_free(stack, first); undo_elem_free(stack, first);
BLI_freelinkN(&stack->elems, 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; UndoElem *undo;
if (step==1) { if (step == 1) {
if (stack->current==NULL); if (stack->current == NULL) ;
else { else {
if (!name || strcmp(stack->current->name, name) == 0) { if (!name || strcmp(stack->current->name, name) == 0) {
if (G.f & G_DEBUG) printf("undo %s\n", stack->current->name); if (G.f & G_DEBUG) printf("undo %s\n", stack->current->name);
undo_restore(C, stack, stack->current); undo_restore(C, stack, stack->current);
stack->current= stack->current->prev; stack->current = stack->current->prev;
return 1; return 1;
} }
} }
} }
else if (step==-1) { else if (step == -1) {
if ((stack->current!=NULL && stack->current->next==NULL) || stack->elems.first==NULL); if ((stack->current != NULL && stack->current->next == NULL) || stack->elems.first == NULL) ;
else { else {
if (!name || strcmp(stack->current->name, name) == 0) { 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); undo_restore(C, stack, undo);
stack->current= undo; stack->current = undo;
if (G.f & G_DEBUG) printf("redo %s\n", undo->name); if (G.f & G_DEBUG) printf("redo %s\n", undo->name);
return 1; return 1;
} }
@ -187,11 +187,11 @@ static void undo_stack_free(UndoStack *stack)
{ {
UndoElem *uel; 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); undo_elem_free(stack, uel);
BLI_freelistN(&stack->elems); BLI_freelistN(&stack->elems);
stack->current= NULL; stack->current = NULL;
} }
/* Exported Functions */ /* Exported Functions */
@ -249,13 +249,13 @@ int ED_undo_paint_valid(int type, const char *name)
UndoStack *stack; UndoStack *stack;
if (type == UNDO_PAINT_IMAGE) if (type == UNDO_PAINT_IMAGE)
stack= &ImageUndoStack; stack = &ImageUndoStack;
else if (type == UNDO_PAINT_MESH) else if (type == UNDO_PAINT_MESH)
stack= &MeshUndoStack; stack = &MeshUndoStack;
else else
return 0; return 0;
if (stack->current==NULL); if (stack->current == NULL) ;
else { else {
if (name && strcmp(stack->current->name, name) == 0) if (name && strcmp(stack->current->name, name) == 0)
return 1; return 1;

@ -145,10 +145,10 @@ void projectf(bglMats *mats, const float v[3], float p[2])
{ {
double ux, uy, uz; double ux, uy, uz;
gluProject(v[0],v[1],v[2], mats->modelview, mats->projection, gluProject(v[0], v[1], v[2], mats->modelview, mats->projection,
(GLint *)mats->viewport, &ux, &uy, &uz); (GLint *)mats->viewport, &ux, &uy, &uz);
p[0]= ux; p[0] = ux;
p[1]= uy; p[1] = uy;
} }
float paint_calc_object_space_radius(ViewContext *vc, const float center[3], float paint_calc_object_space_radius(ViewContext *vc, const float center[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]); initgrabz(vc->rv3d, loc[0], loc[1], loc[2]);
mval_f[0]= pixel_radius; mval_f[0] = pixel_radius;
mval_f[1]= 0.0f; mval_f[1] = 0.0f;
ED_view3d_win_to_delta(vc->ar, mval_f, delta); ED_view3d_win_to_delta(vc->ar, mval_f, delta);
scale= fabsf(mat4_to_scale(ob->obmat)); scale = fabsf(mat4_to_scale(ob->obmat));
scale= (scale == 0.0f)? 1.0f: scale; 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; TexResult texres;
float co[3]; 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); hasrgb = multitex_ext(br->mtex.tex, co, NULL, NULL, 0, &texres);
if (hasrgb & TEX_RGB) 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; 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]) static void imapaint_project(Object *ob, float model[][4], float proj[][4], const float co[3], float pco[4])
{ {
copy_v3_v3(pco, co); copy_v3_v3(pco, co);
pco[3]= 1.0f; pco[3] = 1.0f;
mul_m4_v3(ob->obmat, pco); mul_m4_v3(ob->obmat, pco);
mul_m4_v3(model, pco); mul_m4_v3(model, pco);
@ -225,16 +225,16 @@ static void imapaint_tri_weights(Object *ob,
imapaint_project(ob, model, proj, v3, pv3); imapaint_project(ob, model, proj, v3, pv3);
/* do inverse view mapping, see gluProject man page */ /* do inverse view mapping, see gluProject man page */
h[0]= (co[0] - view[0])*2.0f/view[2] - 1; h[0] = (co[0] - view[0]) * 2.0f / view[2] - 1;
h[1]= (co[1] - view[1])*2.0f/view[3] - 1; h[1] = (co[1] - view[1]) * 2.0f / view[3] - 1;
h[2]= 1.0f; h[2] = 1.0f;
/* solve for (w1,w2,w3)/perspdiv in: /* solve for (w1,w2,w3)/perspdiv in:
* h * perspdiv = Project * Model * (w1 * v1 + w2 * v2 + w3 * v3) */ * 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][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][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][2] = pv1[3]; wmat[1][2] = pv2[3]; wmat[2][2] = pv3[3];
invert_m3_m3(invwmat, wmat); invert_m3_m3(invwmat, wmat);
mul_m3_v3(invwmat, h); mul_m3_v3(invwmat, h);
@ -242,9 +242,9 @@ static void imapaint_tri_weights(Object *ob,
copy_v3_v3(w, h); copy_v3_v3(w, h);
/* w is still divided by perspdiv, make it sum to one */ /* 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) { 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 */ /* test all faces in the derivedmesh with the original index of the picked face */
for (a = 0; a < numfaces; a++) { for (a = 0; a < numfaces; a++) {
findex= index ? index[a]: a; findex = index ? index[a] : a;
if (findex == faceindex) { if (findex == faceindex) {
dm->getTessFace(dm, a, &mf); 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) if (mf.v4)
dm->getVert(dm, mf.v4, &mv[3]); dm->getVert(dm, mf.v4, &mv[3]);
tf= &tface[a]; tf = &tface[a];
p[0]= xy[0]; p[0] = xy[0];
p[1]= xy[1]; p[1] = xy[1];
if (mf.v4) { if (mf.v4) {
/* the triangle with the largest absolute values is the one /* the triangle with the largest absolute values is the one
* with the most negative weights */ * with the most negative weights */
imapaint_tri_weights(ob, mv[0].co, mv[1].co, mv[3].co, p, w); 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) { if (absw < minabsw) {
uv[0]= tf->uv[0][0]*w[0] + tf->uv[1][0]*w[1] + tf->uv[3][0]*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]; uv[1] = tf->uv[0][1] * w[0] + tf->uv[1][1] * w[1] + tf->uv[3][1] * w[2];
minabsw = absw; minabsw = absw;
} }
imapaint_tri_weights(ob, mv[1].co, mv[2].co, mv[3].co, p, w); 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) { if (absw < minabsw) {
uv[0]= tf->uv[1][0]*w[0] + tf->uv[2][0]*w[1] + tf->uv[3][0]*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]; uv[1] = tf->uv[1][1] * w[0] + tf->uv[2][1] * w[1] + tf->uv[3][1] * w[2];
minabsw = absw; minabsw = absw;
} }
} }
else { else {
imapaint_tri_weights(ob, mv[0].co, mv[1].co, mv[2].co, p, w); 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) { if (absw < minabsw) {
uv[0]= tf->uv[0][0]*w[0] + tf->uv[1][0]*w[1] + tf->uv[2][0]*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]; uv[1] = tf->uv[0][1] * w[0] + tf->uv[1][1] * w[1] + tf->uv[2][1] * w[2];
minabsw = absw; minabsw = absw;
} }
} }
@ -343,15 +343,15 @@ void paint_sample_color(Scene *scene, ARegion *ar, int x, int y) /* frontbuf */
CLAMP(y, 0, ar->winy); CLAMP(y, 0, ar->winy);
glReadBuffer(GL_FRONT); 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); glReadBuffer(GL_BACK);
cp = (char *)&col; cp = (char *)&col;
if (br) { if (br) {
br->rgb[0]= cp[0]/255.0f; br->rgb[0] = cp[0] / 255.0f;
br->rgb[1]= cp[1]/255.0f; br->rgb[1] = cp[1] / 255.0f;
br->rgb[2]= cp[2]/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->exec = brush_curve_preset_exec;
ot->poll = brush_curve_preset_poll; 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", ""); 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->exec = paint_select_linked_exec;
ot->poll = facemask_paint_poll; 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) 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); paintface_select_linked(C, CTX_data_active_object(C), event->mval, mode);
ED_region_tag_redraw(CTX_wm_region(C)); ED_region_tag_redraw(CTX_wm_region(C));
return OPERATOR_FINISHED; return OPERATOR_FINISHED;
@ -431,7 +431,7 @@ void PAINT_OT_face_select_linked_pick(wmOperatorType *ot)
ot->invoke = paint_select_linked_pick_invoke; ot->invoke = paint_select_linked_pick_invoke;
ot->poll = facemask_paint_poll; 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"); 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) 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); paintface_deselect_all_visible(ob, RNA_enum_get(op->ptr, "action"), TRUE);
ED_region_tag_redraw(CTX_wm_region(C)); ED_region_tag_redraw(CTX_wm_region(C));
return OPERATOR_FINISHED; return OPERATOR_FINISHED;
@ -455,7 +455,7 @@ void PAINT_OT_face_select_all(wmOperatorType *ot)
ot->exec = face_select_all_exec; ot->exec = face_select_all_exec;
ot->poll = facemask_paint_poll; ot->poll = facemask_paint_poll;
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
WM_operator_properties_select_all(ot); 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) 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); paintvert_deselect_all_visible(ob, RNA_enum_get(op->ptr, "action"), TRUE);
ED_region_tag_redraw(CTX_wm_region(C)); ED_region_tag_redraw(CTX_wm_region(C));
return OPERATOR_FINISHED; return OPERATOR_FINISHED;
@ -479,14 +479,14 @@ void PAINT_OT_vert_select_all(wmOperatorType *ot)
ot->exec = vert_select_all_exec; ot->exec = vert_select_all_exec;
ot->poll = vert_paint_poll; ot->poll = vert_paint_poll;
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
WM_operator_properties_select_all(ot); WM_operator_properties_select_all(ot);
} }
static int vert_select_inverse_exec(bContext *C, wmOperator *UNUSED(op)) 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); paintvert_deselect_all_visible(ob, SEL_INVERT, TRUE);
ED_region_tag_redraw(CTX_wm_region(C)); ED_region_tag_redraw(CTX_wm_region(C));
return OPERATOR_FINISHED; return OPERATOR_FINISHED;
@ -501,11 +501,11 @@ void PAINT_OT_vert_select_inverse(wmOperatorType *ot)
ot->exec = vert_select_inverse_exec; ot->exec = vert_select_inverse_exec;
ot->poll = vert_paint_poll; 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)) 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); paintface_deselect_all_visible(ob, SEL_INVERT, TRUE);
ED_region_tag_redraw(CTX_wm_region(C)); ED_region_tag_redraw(CTX_wm_region(C));
return OPERATOR_FINISHED; return OPERATOR_FINISHED;
@ -521,13 +521,13 @@ void PAINT_OT_face_select_inverse(wmOperatorType *ot)
ot->exec = face_select_inverse_exec; ot->exec = face_select_inverse_exec;
ot->poll = facemask_paint_poll; 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) static int face_select_hide_exec(bContext *C, wmOperator *op)
{ {
const int unselected= RNA_boolean_get(op->ptr, "unselected"); const int unselected = RNA_boolean_get(op->ptr, "unselected");
Object *ob= CTX_data_active_object(C); Object *ob = CTX_data_active_object(C);
paintface_hide(ob, unselected); paintface_hide(ob, unselected);
ED_region_tag_redraw(CTX_wm_region(C)); ED_region_tag_redraw(CTX_wm_region(C));
return OPERATOR_FINISHED; return OPERATOR_FINISHED;
@ -542,14 +542,14 @@ void PAINT_OT_face_select_hide(wmOperatorType *ot)
ot->exec = face_select_hide_exec; ot->exec = face_select_hide_exec;
ot->poll = facemask_paint_poll; 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"); 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)) 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); paintface_reveal(ob);
ED_region_tag_redraw(CTX_wm_region(C)); ED_region_tag_redraw(CTX_wm_region(C));
return OPERATOR_FINISHED; return OPERATOR_FINISHED;
@ -564,7 +564,7 @@ void PAINT_OT_face_select_reveal(wmOperatorType *ot)
ot->exec = face_select_reveal_exec; ot->exec = face_select_reveal_exec;
ot->poll = facemask_paint_poll; 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"); RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Hide unselected rather than selected objects");
} }

@ -130,7 +130,8 @@ int vertex_paint_mode_poll(bContext *C)
int vertex_paint_poll(bContext *C) int vertex_paint_poll(bContext *C)
{ {
if (vertex_paint_mode_poll(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); ScrArea *sa = CTX_wm_area(C);
if (sa->spacetype == SPACE_VIEW3D) { if (sa->spacetype == SPACE_VIEW3D) {
ARegion *ar = CTX_wm_region(C); ARegion *ar = CTX_wm_region(C);
@ -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) { if (wp->wpaint_prev) {
free_dverts(wp->wpaint_prev, wp->tot); 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) { 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; wp->tot = dcount;
copy_dverts (wp->wpaint_prev, dverts, dcount); copy_dverts(wp->wpaint_prev, dverts, dcount);
} }
} }
@ -568,7 +569,7 @@ void vpaint_dogamma(Scene *scene)
for (a = 0; a < 256; a++) { for (a = 0; a < 256; a++) {
fac = ((float)a) / 255.0; fac = ((float)a) / 255.0;
fac = vp->mul * pow( fac, igam); fac = vp->mul * pow(fac, igam);
temp = 255.9 * fac; temp = 255.9 * fac;
@ -581,9 +582,9 @@ void vpaint_dogamma(Scene *scene)
cp = (unsigned char *)me->mcol; cp = (unsigned char *)me->mcol;
while (a--) { while (a--) {
cp[1] = gamtab[ cp[1] ]; cp[1] = gamtab[cp[1]];
cp[2] = gamtab[ cp[2] ]; cp[2] = gamtab[cp[2]];
cp[3] = gamtab[ cp[3] ]; cp[3] = gamtab[cp[3]];
cp += 4; cp += 4;
} }
@ -799,13 +800,13 @@ static unsigned int vpaint_blend(VPaint *vp, unsigned int col, unsigned int colo
co = (char *)&colorig; co = (char *)&colorig;
for (a = 0; a < 4; a++) { for (a = 0; a < 4; a++) {
if ( ct[a] < co[a] ) { if (ct[a] < co[a]) {
if ( cp[a] < ct[a] ) cp[a] = ct[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 { else {
if ( cp[a] < co[a] ) cp[a] = co[a]; if (cp[a] < co[a]) cp[a] = co[a];
else if ( cp[a] > ct[a] ) cp[a] = ct[a]; else if (cp[a] > ct[a]) cp[a] = ct[a];
} }
} }
} }
@ -962,7 +963,7 @@ static float wpaint_blend(VPaint *wp, float weight, float weight_prev,
int tool = brush->vertexpaint_tool; int tool = brush->vertexpaint_tool;
if (do_flip) { if (do_flip) {
switch(tool) { switch (tool) {
case PAINT_BLEND_MIX: case PAINT_BLEND_MIX:
paintval = 1.f - paintval; break; paintval = 1.f - paintval; break;
case PAINT_BLEND_ADD: case PAINT_BLEND_ADD:
@ -1066,7 +1067,7 @@ static int weight_sample_invoke(bContext *C, wmOperator *op, wmEvent *event)
if (change) { if (change) {
/* not really correct since the brush didnt change, but redraws the toolbar */ /* 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; return OPERATOR_FINISHED;
} }
@ -1169,7 +1170,7 @@ static int weight_sample_group_exec(bContext *C, wmOperator *op)
vc.obact->actdef = type + 1; vc.obact->actdef = type + 1;
DAG_id_tag_update(&vc.obact->id, OB_RECALC_DATA); 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; return OPERATOR_FINISHED;
} }
@ -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 * 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) 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; change_status[ndw->def_nr] = changeto;
total_valid--; total_valid--;
} }
else {/* a perfectly valid change occurred to ndw->weight */ else { /* a perfectly valid change occurred to ndw->weight */
totchange -= change; totchange -= change;
ndw->weight += change; ndw->weight += change;
} }
@ -1731,7 +1732,8 @@ static int get_first_selected_nonzero_weight(MDeformVert *dvert, const int defba
static char *wpaint_make_validmap(Object *ob); static char *wpaint_make_validmap(Object *ob);
static void do_weight_paint_vertex(/* vars which remain the same for every vert */ static void do_weight_paint_vertex(
/* vars which remain the same for every vert */
VPaint *wp, Object *ob, const WeightPaintInfo *wpi, VPaint *wp, Object *ob, const WeightPaintInfo *wpi,
/* vars which change on each stroke */ /* vars which change on each stroke */
const unsigned int index, float alpha, float paintweight const unsigned int index, float alpha, float paintweight
@ -1915,7 +1917,7 @@ static void do_weight_paint_vertex(/* vars which remain the same for every vert
if (tdw->weight != tdw_prev->weight) { if (tdw->weight != tdw_prev->weight) {
oldChange = tdw->weight / tdw_prev->weight; oldChange = tdw->weight / tdw_prev->weight;
testw = tdw_prev->weight * change; testw = tdw_prev->weight * change;
if ( testw > tdw_prev->weight ) { if (testw > tdw_prev->weight) {
if (change > oldChange) { if (change > oldChange) {
/* reset the weights and use the new change */ /* reset the weights and use the new change */
defvert_reset_to_prev(wp->wpaint_prev + index, dv); defvert_reset_to_prev(wp->wpaint_prev + index, dv);
@ -2018,7 +2020,7 @@ static int set_wpaint(bContext *C, wmOperator *UNUSED(op)) /* toggle */
mesh_mirrtopo_table(NULL, 'e'); 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; return OPERATOR_FINISHED;
} }
@ -2048,7 +2050,7 @@ void PAINT_OT_weight_paint_toggle(wmOperatorType *ot)
ot->poll = paint_poll_test; ot->poll = paint_poll_test;
/* flags */ /* 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 */ /* 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) { 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; continue;
if (md->type == eModifierType_Armature) { 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 nothing was added yet, we make dverts and a vertex deform group */
if (!me->dvert) { if (!me->dvert) {
ED_vgroup_data_create(&me->id); 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 */ /* this happens on a Bone select, when no vgroup existed yet */
@ -2503,7 +2505,7 @@ void PAINT_OT_weight_paint(wmOperatorType *ot)
ot->cancel = wpaint_cancel; ot->cancel = wpaint_cancel;
/* flags */ /* 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", ""); RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", "");
} }
@ -2529,7 +2531,7 @@ void PAINT_OT_weight_set(wmOperatorType *ot)
ot->poll = mask_paint_poll; /* it was facemask_paint_poll */ ot->poll = mask_paint_poll; /* it was facemask_paint_poll */
/* flags */ /* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
} }
/* ************ set / clear vertex paint mode ********** */ /* ************ set / clear vertex paint mode ********** */
@ -2576,7 +2578,7 @@ static int set_vpaint(bContext *C, wmOperator *op) /* toggle */
/* update modifier stack for mapping requirements */ /* update modifier stack for mapping requirements */
DAG_id_tag_update(&me->id, 0); 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; return OPERATOR_FINISHED;
} }
@ -2593,7 +2595,7 @@ void PAINT_OT_vertex_paint_toggle(wmOperatorType *ot)
ot->poll = paint_poll_test; ot->poll = paint_poll_test;
/* flags */ /* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
} }
@ -2741,13 +2743,13 @@ static void vpaint_paint_face(VPaint *vp, VPaintData *vpd, Object *ob,
return; return;
if (brush->vertexpaint_tool == PAINT_BLEND_BLUR) { 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) { if (mface->v4) {
unsigned int fcol2 = mcol_blend( mcol[2], mcol[3], 128); unsigned int fcol2 = mcol_blend(mcol[2], mcol[3], 128);
vpd->paintcol = mcol_blend( fcol1, fcol2, 128); vpd->paintcol = mcol_blend(fcol1, fcol2, 128);
} }
else { else {
vpd->paintcol = mcol_blend( mcol[2], fcol1, 170); vpd->paintcol = mcol_blend(mcol[2], fcol1, 170);
} }
} }
@ -3006,7 +3008,7 @@ void PAINT_OT_vertex_paint(wmOperatorType *ot)
ot->cancel = vpaint_cancel; ot->cancel = vpaint_cancel;
/* flags */ /* 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", ""); 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)); create_vgroups_from_armature(op->reports, scene, ob, armob, type, (me->editflag & ME_EDIT_MIRROR_X));
DAG_id_tag_update(&me->id, 0); 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; return OPERATOR_FINISHED;
} }
@ -3053,7 +3055,7 @@ void PAINT_OT_weight_from_bones(wmOperatorType *ot)
ot->poll = weight_from_bones_poll; ot->poll = weight_from_bones_poll;
/* flags */ /* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */ /* properties */
ot->prop = RNA_def_enum(ot->srna, "type", type_items, 0, "Type", "Method to use for assigning weights"); ot->prop = RNA_def_enum(ot->srna, "type", type_items, 0, "Type", "Method to use for assigning weights");

File diff suppressed because it is too large Load Diff

@ -71,7 +71,7 @@
static void update_cb(PBVHNode *node, void *rebuild) static void update_cb(PBVHNode *node, void *rebuild)
{ {
BLI_pbvh_node_mark_update(node); BLI_pbvh_node_mark_update(node);
if (*((int*)rebuild)) if (*((int *)rebuild))
BLI_pbvh_node_mark_rebuild_draw(node); BLI_pbvh_node_mark_rebuild_draw(node);
BLI_pbvh_node_fully_hidden_set(node, 0); 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) static int sculpt_undo_restore_coords(bContext *C, DerivedMesh *dm, SculptUndoNode *unode)
{ {
Scene *scene= CTX_data_scene(C); Scene *scene = CTX_data_scene(C);
Sculpt *sd= CTX_data_tool_settings(C)->sculpt; Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
Object *ob= CTX_data_active_object(C); Object *ob = CTX_data_active_object(C);
SculptSession *ss= ob->sculpt; SculptSession *ss = ob->sculpt;
MVert *mvert; MVert *mvert;
int *index, i, j; 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)) { if (ss->kb && strcmp(ss->kb->name, unode->shapeName)) {
/* shape key has been changed before calling undo operator */ /* shape key has been changed before calling undo operator */
Key *key= ob_get_key(ob); Key *key = ob_get_key(ob);
KeyBlock *kb= key_get_named_keyblock(key, unode->shapeName); KeyBlock *kb = key_get_named_keyblock(key, unode->shapeName);
if (kb) { 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); 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 { else {
/* key has been removed -- skip this undo node */ /* 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; index = unode->index;
mvert= ss->mvert; mvert = ss->mvert;
if (ss->kb) { if (ss->kb) {
float (*vertCos)[3]; 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]]); if (ss->modifiers_active) sculpt_undo_restore_deformed(ss, unode, i, index[i], vertCos[index[i]]);
else { else {
if (unode->orig_co) swap_v3_v3(vertCos[index[i]], unode->orig_co[i]); 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); MEM_freeN(vertCos);
} }
else { 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); if (ss->modifiers_active) sculpt_undo_restore_deformed(ss, unode, i, index[i], mvert[index[i]].co);
else { else {
if (unode->orig_co) swap_v3_v3(mvert[index[i]].co, unode->orig_co[i]); 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]; float (*co)[3];
int gridsize; int gridsize;
grids= dm->getGridData(dm); grids = dm->getGridData(dm);
gridsize= dm->getGridSize(dm); gridsize = dm->getGridSize(dm);
co = unode->co; co = unode->co;
for (j=0; j<unode->totgrid; j++) { for (j = 0; j < unode->totgrid; j++) {
grid= grids[unode->grids[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]); swap_v3_v3(grid[i].co, co[0]);
} }
} }
@ -181,11 +181,11 @@ static int sculpt_undo_restore_hidden(bContext *C, DerivedMesh *dm,
int i; int i;
if (unode->maxvert) { 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]]; 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, BLI_BITMAP_MODIFY(unode->vert_hidden, i,
v->flag & ME_HIDE); v->flag & ME_HIDE);
@ -200,7 +200,7 @@ static int sculpt_undo_restore_hidden(bContext *C, DerivedMesh *dm,
else if (unode->maxgrid && dm->getGridData) { else if (unode->maxgrid && dm->getGridData) {
BLI_bitmap *grid_hidden = dm->getGridHidden(dm); BLI_bitmap *grid_hidden = dm->getGridHidden(dm);
for (i=0; i<unode->totgrid; i++) { for (i = 0; i < unode->totgrid; i++) {
SWAP(BLI_bitmap, SWAP(BLI_bitmap,
unode->grid_hidden[i], unode->grid_hidden[i],
grid_hidden[unode->grids[i]]); grid_hidden[unode->grids[i]]);
@ -220,12 +220,12 @@ static void sculpt_undo_restore(bContext *C, ListBase *lb)
SculptSession *ss = ob->sculpt; SculptSession *ss = ob->sculpt;
SculptUndoNode *unode; SculptUndoNode *unode;
MultiresModifierData *mmd; MultiresModifierData *mmd;
int update= 0, rebuild= 1; int update = 0, rebuild = 1;
sculpt_update_mesh_elements(scene, sd, ob, 0); sculpt_update_mesh_elements(scene, sd, ob, 0);
for (unode=lb->first; unode; unode=unode->next) { for (unode = lb->first; unode; unode = unode->next) {
if (!(strcmp(unode->idname, ob->id.name)==0)) if (!(strcmp(unode->idname, ob->id.name) == 0))
continue; continue;
/* check if undo data matches current data well enough to /* check if undo data matches current data well enough to
@ -243,41 +243,41 @@ static void sculpt_undo_restore(bContext *C, ListBase *lb)
continue; continue;
} }
switch(unode->type) { switch (unode->type) {
case SCULPT_UNDO_COORDS: case SCULPT_UNDO_COORDS:
if (sculpt_undo_restore_coords(C, dm, unode)) if (sculpt_undo_restore_coords(C, dm, unode))
update= 1; update = 1;
break; break;
case SCULPT_UNDO_HIDDEN: case SCULPT_UNDO_HIDDEN:
if (sculpt_undo_restore_hidden(C, dm, unode)) if (sculpt_undo_restore_hidden(C, dm, unode))
rebuild= 1; rebuild = 1;
break; break;
} }
} }
if (update || rebuild) { if (update || rebuild) {
int tag_update= 0; int tag_update = 0;
/* we update all nodes still, should be more clever, but also /* we update all nodes still, should be more clever, but also
* needs to work correct when exiting/entering sculpt mode and * needs to work correct when exiting/entering sculpt mode and
* the nodes get recreated, though in that case it could do all */ * 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_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) if (rebuild)
multires_mark_as_modified(ob, MULTIRES_HIDDEN_MODIFIED); multires_mark_as_modified(ob, MULTIRES_HIDDEN_MODIFIED);
else else
multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED); 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) { 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); 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); free_sculptsession_deformMats(ss);
tag_update|= 1; tag_update |= 1;
} }
if (tag_update) if (tag_update)
@ -293,7 +293,7 @@ static void sculpt_undo_free(ListBase *lb)
SculptUndoNode *unode; SculptUndoNode *unode;
int i; int i;
for (unode=lb->first; unode; unode=unode->next) { for (unode = lb->first; unode; unode = unode->next) {
if (unode->co) if (unode->co)
MEM_freeN(unode->co); MEM_freeN(unode->co);
if (unode->no) if (unode->no)
@ -309,7 +309,7 @@ static void sculpt_undo_free(ListBase *lb)
if (unode->vert_hidden) if (unode->vert_hidden)
MEM_freeN(unode->vert_hidden); MEM_freeN(unode->vert_hidden);
if (unode->grid_hidden) { if (unode->grid_hidden) {
for (i=0; i<unode->totgrid; i++) { for (i = 0; i < unode->totgrid; i++) {
if (unode->grid_hidden[i]) if (unode->grid_hidden[i])
MEM_freeN(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) 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; SculptUndoNode *unode;
if (!lb) if (!lb)
return NULL; return NULL;
for (unode=lb->first; unode; unode=unode->next) for (unode = lb->first; unode; unode = unode->next)
if (unode->node == node) if (unode->node == node)
return unode; return unode;
@ -336,16 +336,16 @@ SculptUndoNode *sculpt_undo_get_node(PBVHNode *node)
static void sculpt_undo_alloc_and_store_hidden(PBVH *pbvh, 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; BLI_bitmap *grid_hidden;
int i, *grid_indices, totgrid; 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, 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 = MEM_mapallocN(sizeof(BLI_bitmap) * totgrid,
"unode->grid_hidden"); "unode->grid_hidden");
for (i = 0; i < totgrid; i++) { for (i = 0; i < totgrid; i++) {
@ -359,36 +359,36 @@ static void sculpt_undo_alloc_and_store_hidden(PBVH *pbvh,
static SculptUndoNode *sculpt_undo_alloc_node(Object *ob, PBVHNode *node, 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; SculptUndoNode *unode;
SculptSession *ss= ob->sculpt; SculptSession *ss = ob->sculpt;
int totvert, allvert, totgrid, maxgrid, gridsize, *grids; 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)); BLI_strncpy(unode->idname, ob->id.name, sizeof(unode->idname));
unode->type= type; unode->type = type;
unode->node= node; unode->node = node;
BLI_pbvh_node_num_verts(ss->pbvh, node, &totvert, &allvert); BLI_pbvh_node_num_verts(ss->pbvh, node, &totvert, &allvert);
BLI_pbvh_node_get_grids(ss->pbvh, node, &grids, &totgrid, 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? */ /* we will use this while sculpting, is mapalloc slow to access then? */
/* general TODO, fix count_alloc */ /* general TODO, fix count_alloc */
switch(type) { switch (type) {
case SCULPT_UNDO_COORDS: case SCULPT_UNDO_COORDS:
unode->co= MEM_mapallocN(sizeof(float)*3*allvert, "SculptUndoNode.co"); unode->co = MEM_mapallocN(sizeof(float) * 3 * allvert, "SculptUndoNode.co");
unode->no= MEM_mapallocN(sizeof(short)*3*allvert, "SculptUndoNode.no"); 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); undo_paint_push_count_alloc(UNDO_PAINT_MESH, (sizeof(float) * 3 + sizeof(short) * 3 + sizeof(int)) * allvert);
break; break;
case SCULPT_UNDO_HIDDEN: case SCULPT_UNDO_HIDDEN:
if (maxgrid) if (maxgrid)
sculpt_undo_alloc_and_store_hidden(ss->pbvh, unode); sculpt_undo_alloc_and_store_hidden(ss->pbvh, unode);
else else
unode->vert_hidden= BLI_BITMAP_NEW(allvert, "SculptUndoNode.vert_hidden"); unode->vert_hidden = BLI_BITMAP_NEW(allvert, "SculptUndoNode.vert_hidden");
break; break;
} }
@ -397,19 +397,19 @@ static SculptUndoNode *sculpt_undo_alloc_node(Object *ob, PBVHNode *node,
if (maxgrid) { if (maxgrid) {
/* multires */ /* multires */
unode->maxgrid= maxgrid; unode->maxgrid = maxgrid;
unode->totgrid= totgrid; unode->totgrid = totgrid;
unode->gridsize= gridsize; unode->gridsize = gridsize;
unode->grids= MEM_mapallocN(sizeof(int)*totgrid, "SculptUndoNode.grids"); unode->grids = MEM_mapallocN(sizeof(int) * totgrid, "SculptUndoNode.grids");
} }
else { else {
/* regular mesh */ /* regular mesh */
unode->maxvert= ss->totvert; unode->maxvert = ss->totvert;
unode->index= MEM_mapallocN(sizeof(int)*allvert, "SculptUndoNode.index"); unode->index = MEM_mapallocN(sizeof(int) * allvert, "SculptUndoNode.index");
} }
if (ss->modifiers_active) 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; return unode;
} }
@ -432,8 +432,8 @@ static void sculpt_undo_store_coords(Object *ob, SculptUndoNode *unode)
static void sculpt_undo_store_hidden(Object *ob, SculptUndoNode *unode) static void sculpt_undo_store_hidden(Object *ob, SculptUndoNode *unode)
{ {
PBVH *pbvh= ob->sculpt->pbvh; PBVH *pbvh = ob->sculpt->pbvh;
PBVHNode *node= unode->node; PBVHNode *node = unode->node;
if (unode->grids) { if (unode->grids) {
/* already stored during allocation */ /* already stored during allocation */
@ -461,17 +461,17 @@ SculptUndoNode *sculpt_undo_push_node(Object *ob, PBVHNode *node,
/* list is manipulated by multiple threads, so we lock */ /* list is manipulated by multiple threads, so we lock */
BLI_lock_thread(LOCK_CUSTOM1); BLI_lock_thread(LOCK_CUSTOM1);
if ((unode= sculpt_undo_get_node(node))) { if ((unode = sculpt_undo_get_node(node))) {
BLI_unlock_thread(LOCK_CUSTOM1); BLI_unlock_thread(LOCK_CUSTOM1);
return unode; return unode;
} }
unode= sculpt_undo_alloc_node(ob, node, type); unode = sculpt_undo_alloc_node(ob, node, type);
BLI_unlock_thread(LOCK_CUSTOM1); BLI_unlock_thread(LOCK_CUSTOM1);
/* copy threaded, hopefully this is the performance critical part */ /* copy threaded, hopefully this is the performance critical part */
switch(type) { switch (type) {
case SCULPT_UNDO_COORDS: case SCULPT_UNDO_COORDS:
sculpt_undo_store_coords(ob, unode); sculpt_undo_store_coords(ob, unode);
break; break;
@ -484,18 +484,18 @@ SculptUndoNode *sculpt_undo_push_node(Object *ob, PBVHNode *node,
int totgrid, *grids; int totgrid, *grids;
BLI_pbvh_node_get_grids(ss->pbvh, node, &grids, &totgrid, BLI_pbvh_node_get_grids(ss->pbvh, node, &grids, &totgrid,
NULL, NULL, NULL, NULL); NULL, NULL, NULL, NULL);
memcpy(unode->grids, grids, sizeof(int)*totgrid); memcpy(unode->grids, grids, sizeof(int) * totgrid);
} }
else { else {
int *vert_indices, allvert; int *vert_indices, allvert;
BLI_pbvh_node_num_verts(ss->pbvh, node, NULL, &allvert); BLI_pbvh_node_num_verts(ss->pbvh, node, NULL, &allvert);
BLI_pbvh_node_get_verts(ss->pbvh, node, &vert_indices, NULL); 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 */ /* store active shape key */
if (ss->kb) BLI_strncpy(unode->shapeName, ss->kb->name, sizeof(ss->kb->name)); 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; return unode;
} }
@ -508,19 +508,19 @@ void sculpt_undo_push_begin(const char *name)
void sculpt_undo_push_end(void) 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; SculptUndoNode *unode;
/* we don't need normals in the undo stack */ /* 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) { if (unode->no) {
MEM_freeN(unode->no); MEM_freeN(unode->no);
unode->no= NULL; unode->no = NULL;
} }
if (unode->layer_disp) { if (unode->layer_disp) {
MEM_freeN(unode->layer_disp); MEM_freeN(unode->layer_disp);
unode->layer_disp= NULL; unode->layer_disp = NULL;
} }
} }

@ -86,7 +86,7 @@ typedef struct UvEdge {
char flag; char flag;
}UvEdge; }UvEdge;
typedef struct UVInitialStrokeElement{ typedef struct UVInitialStrokeElement {
/* index to unique uv */ /* index to unique uv */
int uv; int uv;
@ -97,7 +97,7 @@ typedef struct UVInitialStrokeElement{
float initial_uv[2]; float initial_uv[2];
}UVInitialStrokeElement; }UVInitialStrokeElement;
typedef struct UVInitialStroke{ typedef struct UVInitialStroke {
/* Initial Selection,for grab brushes for instance */ /* Initial Selection,for grab brushes for instance */
UVInitialStrokeElement *initialSelection; UVInitialStrokeElement *initialSelection;
@ -110,7 +110,7 @@ typedef struct UVInitialStroke{
/* custom data for uv smoothing brush */ /* custom data for uv smoothing brush */
typedef struct UvSculptData{ typedef struct UvSculptData {
/* Contains the first of each set of coincident uvs. /* Contains the first of each set of coincident uvs.
* These will be used to perform smoothing on and propagate the changes * These will be used to perform smoothing on and propagate the changes
* to their coincident uvs */ * to their coincident uvs */
@ -146,10 +146,10 @@ typedef struct UvSculptData{
/*********** Improved Laplacian Relaxation Operator ************************/ /*********** Improved Laplacian Relaxation Operator ************************/
/* original code by Raul Fernandez Hernandez "farsthary" * /* 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]; float sum_co[2], p[2], b[2], sum_b[2];
int ncounter; int ncounter;
}Temp_UVData; }Temp_UVData;
@ -169,7 +169,7 @@ void HC_relaxation_iteration_uv(BMEditMesh *em, UvSculptData *sculptdata, float
/* counting neighbors */ /* counting neighbors */
for (i = 0; i < sculptdata->totalUvEdges; i++) { 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->uv1].ncounter++;
tmp_uvdata[tmpedge->uv2].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++) { for (i = 0; i < sculptdata->totalUniqueUvs; i++) {
copy_v2_v2(diff,tmp_uvdata[i].sum_co); copy_v2_v2(diff, tmp_uvdata[i].sum_co);
mul_v2_fl(diff,1.f/tmp_uvdata[i].ncounter); mul_v2_fl(diff, 1.f / tmp_uvdata[i].ncounter);
copy_v2_v2(tmp_uvdata[i].p,diff); copy_v2_v2(tmp_uvdata[i].p, diff);
tmp_uvdata[i].b[0] = diff[0] - sculptdata->uv[i].uv[0]; tmp_uvdata[i].b[0] = diff[0] - sculptdata->uv[i].uv[0];
tmp_uvdata[i].b[1] = diff[1] - sculptdata->uv[i].uv[1]; tmp_uvdata[i].b[1] = diff[1] - sculptdata->uv[i].uv[1];
} }
for (i = 0; i < sculptdata->totalUvEdges; i++) { 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->uv1].sum_b, tmp_uvdata[tmpedge->uv2].b);
add_v2_v2(tmp_uvdata[tmpedge->uv2].sum_b, tmp_uvdata[tmpedge->uv1].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) { if ((dist = dot_v2v2(diff, diff)) <= radius) {
UvElement *element; UvElement *element;
float strength; 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[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[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) { for (element = sculptdata->uv[i].element; element; element = element->next) {
MLoopUV *luv; MLoopUV *luv;
@ -241,7 +241,7 @@ static void laplacian_relaxation_iteration_uv(BMEditMesh *em, UvSculptData *scul
/* counting neighbors */ /* counting neighbors */
for (i = 0; i < sculptdata->totalUvEdges; i++) { 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->uv1].ncounter++;
tmp_uvdata[tmpedge->uv2].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.*/ * needed since we translate along the UV plane always.*/
for (i = 0; i < sculptdata->totalUniqueUvs; i++) { for (i = 0; i < sculptdata->totalUniqueUvs; i++) {
copy_v2_v2(tmp_uvdata[i].p, tmp_uvdata[i].sum_co); 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++) { 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) { if ((dist = dot_v2v2(diff, diff)) <= radius) {
UvElement *element; UvElement *element;
float strength; 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[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[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) { for (element = sculptdata->uv[i].element; element; element = element->next) {
MLoopUV *luv; MLoopUV *luv;
@ -310,7 +310,7 @@ static void uv_sculpt_stroke_apply(bContext *C, wmOperator *op, wmEvent *event,
Brush *brush = paint_brush(sculptdata->uvsculpt); Brush *brush = paint_brush(sculptdata->uvsculpt);
ToolSettings *toolsettings = CTX_data_tool_settings(C); ToolSettings *toolsettings = CTX_data_tool_settings(C);
tool = sculptdata->tool; tool = sculptdata->tool;
invert = sculptdata->invert? -1 : 1; invert = sculptdata->invert ? -1 : 1;
alpha = brush_alpha(scene, brush); alpha = brush_alpha(scene, brush);
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &co[0], &co[1]); 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_size(sima, &width, &height);
ED_space_image_zoom(sima, ar, &zoomx, &zoomy); ED_space_image_zoom(sima, ar, &zoomx, &zoomy);
radius = brush_size(scene, brush)/(width*zoomx); radius = brush_size(scene, brush) / (width * zoomx);
aspectRatio = width/(float)height; aspectRatio = width / (float)height;
/* We will compare squares to save some computation */ /* We will compare squares to save some computation */
radius = radius*radius; radius = radius * radius;
radius_root = sqrt(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) { if ((dist = dot_v2v2(diff, diff)) <= radius) {
UvElement *element; UvElement *element;
float strength; 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); normalize_v2(diff);
sculptdata->uv[i].uv[0] -= strength*diff[0]*0.001; sculptdata->uv[i].uv[0] -= strength * diff[0] * 0.001;
sculptdata->uv[i].uv[1] -= strength*diff[1]*0.001; sculptdata->uv[i].uv[1] -= strength * diff[1] * 0.001;
for (element = sculptdata->uv[i].element; element; element = element->next) { for (element = sculptdata->uv[i].element; element; element = element->next) {
MLoopUV *luv; MLoopUV *luv;
@ -386,12 +386,12 @@ static void uv_sculpt_stroke_apply(bContext *C, wmOperator *op, wmEvent *event,
float diff[2]; float diff[2];
sub_v2_v2v2(diff, co, sculptdata->initial_stroke->init_coord); 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; UvElement *element;
int uvindex = sculptdata->initial_stroke->initialSelection[i].uv; int uvindex = sculptdata->initial_stroke->initialSelection[i].uv;
float strength = sculptdata->initial_stroke->initialSelection[i].strength; 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[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[1] = sculptdata->initial_stroke->initialSelection[i].initial_uv[1] + strength * diff[1];
for (element = sculptdata->uv[uvindex].element; element; element = element->next) { for (element = sculptdata->uv[uvindex].element; element; element = element->next) {
MLoopUV *luv; MLoopUV *luv;
@ -448,9 +448,8 @@ 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; UvEdge *edge = (UvEdge *)key;
return return (BLI_ghashutil_inthash(SET_INT_IN_POINTER(edge->uv2)) +
BLI_ghashutil_inthash(SET_INT_IN_POINTER(edge->uv2)) + BLI_ghashutil_inthash(SET_INT_IN_POINTER(edge->uv1)));
BLI_ghashutil_inthash(SET_INT_IN_POINTER(edge->uv1));
} }
static int uv_edge_compare(const void *a, const void *b) 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) { if (data) {
int counter = 0, i; int counter = 0, i;
ARegion *ar= CTX_wm_region(C); ARegion *ar = CTX_wm_region(C);
float co[2]; float co[2];
BMFace *efa; BMFace *efa;
MLoopUV *luv; MLoopUV *luv;
@ -487,14 +486,14 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, wmEvent
UvEdge *edges; UvEdge *edges;
GHash *edgeHash; GHash *edgeHash;
GHashIterator* ghi; GHashIterator *ghi;
int do_island_optimization = !(ts->uv_sculpt_settings & UV_SCULPT_ALL_ISLANDS); int do_island_optimization = !(ts->uv_sculpt_settings & UV_SCULPT_ALL_ISLANDS);
int island_index = 0; int island_index = 0;
/* Holds, for each UvElement in elementMap, a pointer to its unique uv.*/ /* Holds, for each UvElement in elementMap, a pointer to its unique uv.*/
int *uniqueUv; int *uniqueUv;
data->tool = (RNA_enum_get(op->ptr, "mode") == BRUSH_STROKE_SMOOTH)? UV_SCULPT_TOOL_RELAX : ts->uv_sculpt_tool; 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->invert = (RNA_enum_get(op->ptr, "mode") == BRUSH_STROKE_INVERT) ? 1 : 0;
data->uvsculpt = &ts->uvsculpt->paint; data->uvsculpt = &ts->uvsculpt->paint;
@ -528,7 +527,7 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, wmEvent
if (do_island_optimization) { if (do_island_optimization) {
UvElement *element; UvElement *element;
NearestHit hit; 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); uv_find_nearest_vert(scene, ima, em, co, NULL, &hit);
element = ED_uv_element_get(data->elementMap, hit.efa, hit.l); element = ED_uv_element_get(data->elementMap, hit.efa, hit.l);
@ -545,11 +544,11 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, wmEvent
} }
/* Allocate the unique uv buffers */ /* Allocate the unique uv buffers */
data->uv = MEM_mallocN(sizeof(*data->uv)*counter, "uv_brush_unique_uvs"); 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"); 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"); edgeHash = BLI_ghash_new(uv_edge_hash, uv_edge_compare, "uv_brush_edge_hash");
/* we have at most totalUVs edges */ /* 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 (!data->uv || !uniqueUv || !edgeHash || !edges) {
if (edges) { if (edges) {
MEM_freeN(edges); MEM_freeN(edges);
@ -634,7 +633,7 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, wmEvent
MEM_freeN(uniqueUv); MEM_freeN(uniqueUv);
/* Allocate connectivity data, we allocate edges once */ /* 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) { if (!data->uvedges) {
BLI_ghash_free(edgeHash, NULL, NULL); BLI_ghash_free(edgeHash, NULL, NULL);
MEM_freeN(edges); 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_size(sima, &width, &height);
ED_space_image_zoom(sima, ar, &zoomx, &zoomy); ED_space_image_zoom(sima, ar, &zoomx, &zoomy);
aspectRatio = width/(float)height; aspectRatio = width / (float)height;
radius /= (width*zoomx); radius /= (width * zoomx);
radius = radius*radius; radius = radius * radius;
radius_root = sqrt(radius); radius_root = sqrt(radius);
/* Allocate selection stack */ /* Allocate selection stack */
@ -696,7 +695,7 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, wmEvent
if (!data->initial_stroke) { if (!data->initial_stroke) {
uv_sculpt_stroke_exit(C, op); 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) { if (!data->initial_stroke->initialSelection) {
uv_sculpt_stroke_exit(C, op); uv_sculpt_stroke_exit(C, op);
} }
@ -715,7 +714,7 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, wmEvent
diff[1] /= aspectRatio; diff[1] /= aspectRatio;
if ((dist = dot_v2v2(diff, diff)) <= radius) { if ((dist = dot_v2v2(diff, diff)) <= radius) {
float strength; 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].uv = i;
data->initial_stroke->initialSelection[counter].strength = strength; 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); 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) { if (!data->timer) {
uv_sculpt_stroke_exit(C, op); 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; UvSculptData *data = (UvSculptData *)op->customdata;
Object *obedit = CTX_data_edit_object(C); Object *obedit = CTX_data_edit_object(C);
switch(event->type) { switch (event->type) {
case LEFTMOUSE: case LEFTMOUSE:
case MIDDLEMOUSE: case MIDDLEMOUSE:
case RIGHTMOUSE: 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)); 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); DAG_id_tag_update(obedit->data, 0);
return OPERATOR_RUNNING_MODAL; return OPERATOR_RUNNING_MODAL;
} }
@ -804,7 +803,7 @@ void SCULPT_OT_uv_sculpt_stroke(wmOperatorType *ot)
ot->poll = uv_sculpt_poll; ot->poll = uv_sculpt_poll;
/* flags */ /* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* props */ /* props */
RNA_def_enum(ot->srna, "mode", stroke_mode_items, BRUSH_STROKE_NORMAL, "Mode", "Stroke Mode"); RNA_def_enum(ot->srna, "mode", stroke_mode_items, BRUSH_STROKE_NORMAL, "Mode", "Stroke Mode");