Cleanup: right shift

This commit is contained in:
Campbell Barton 2018-07-02 18:45:26 +02:00
parent 73c577d46a
commit dbe1b07e05
14 changed files with 437 additions and 328 deletions

View File

@ -257,9 +257,10 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col, bool prima
int size;
bool refresh;
eOverlayControlFlags invalid = (primary) ? (overlay_flags & PAINT_INVALID_OVERLAY_TEXTURE_PRIMARY) :
(overlay_flags & PAINT_INVALID_OVERLAY_TEXTURE_SECONDARY);
eOverlayControlFlags invalid = (
(primary) ?
(overlay_flags & PAINT_INVALID_OVERLAY_TEXTURE_PRIMARY) :
(overlay_flags & PAINT_INVALID_OVERLAY_TEXTURE_SECONDARY));
target = (primary) ? &primary_snap : &secondary_snap;
refresh =
@ -495,9 +496,10 @@ static int load_tex_cursor(Brush *br, ViewContext *vc, float zoom)
static int project_brush_radius(ViewContext *vc,
float radius,
const float location[3])
static int project_brush_radius(
ViewContext *vc,
float radius,
const float location[3])
{
float view[3], nonortho[3], ortho[3], offset[3], p1[2], p2[2];
@ -568,10 +570,8 @@ static bool sculpt_get_brush_geometry(
if (hit) {
Brush *brush = BKE_paint_brush(paint);
*pixel_radius =
project_brush_radius(vc,
BKE_brush_unprojected_radius_get(scene, brush),
location);
*pixel_radius = project_brush_radius(
vc, BKE_brush_unprojected_radius_get(scene, brush), location);
if (*pixel_radius == 0)
*pixel_radius = BKE_brush_size_get(scene, brush);
@ -590,15 +590,18 @@ static bool sculpt_get_brush_geometry(
/* Draw an overlay that shows what effect the brush's texture will
* have on brush strength */
static void paint_draw_tex_overlay(UnifiedPaintSettings *ups, Brush *brush,
ViewContext *vc, int x, int y, float zoom, bool col, bool primary)
static void paint_draw_tex_overlay(
UnifiedPaintSettings *ups, Brush *brush,
ViewContext *vc, int x, int y, float zoom, bool col, bool primary)
{
rctf quad;
/* check for overlay mode */
MTex *mtex = (primary) ? &brush->mtex : &brush->mask_mtex;
bool valid = (primary) ? (brush->overlay_flags & BRUSH_OVERLAY_PRIMARY) != 0 :
(brush->overlay_flags & BRUSH_OVERLAY_SECONDARY) != 0;
bool valid = (
(primary) ?
(brush->overlay_flags & BRUSH_OVERLAY_PRIMARY) != 0 :
(brush->overlay_flags & BRUSH_OVERLAY_SECONDARY) != 0);
int overlay_alpha = (primary) ? brush->texture_overlay_alpha : brush->mask_overlay_alpha;
if (!(mtex->tex) || !((mtex->brush_map_mode == MTEX_MAP_MODE_STENCIL) ||
@ -709,8 +712,9 @@ static void paint_draw_tex_overlay(UnifiedPaintSettings *ups, Brush *brush,
/* Draw an overlay that shows what effect the brush's texture will
* have on brush strength */
static void paint_draw_cursor_overlay(UnifiedPaintSettings *ups, Brush *brush,
ViewContext *vc, int x, int y, float zoom)
static void paint_draw_cursor_overlay(
UnifiedPaintSettings *ups, Brush *brush,
ViewContext *vc, int x, int y, float zoom)
{
rctf quad;
/* check for overlay mode */
@ -779,8 +783,9 @@ static void paint_draw_cursor_overlay(UnifiedPaintSettings *ups, Brush *brush,
}
}
static void paint_draw_alpha_overlay(UnifiedPaintSettings *ups, Brush *brush,
ViewContext *vc, int x, int y, float zoom, ePaintMode mode)
static void paint_draw_alpha_overlay(
UnifiedPaintSettings *ups, Brush *brush,
ViewContext *vc, int x, int y, float zoom, ePaintMode mode)
{
/* color means that primary brush texture is colured and secondary is used for alpha/mask control */
bool col = ELEM(mode, ePaintTextureProjective, ePaintTexture2D, ePaintVertex) ? true : false;
@ -951,8 +956,9 @@ static void paint_draw_curve_cursor(Brush *brush)
/* Special actions taken when paint cursor goes over mesh */
/* TODO: sculpt only for now */
static void paint_cursor_on_hit(UnifiedPaintSettings *ups, Brush *brush, ViewContext *vc,
const float location[3])
static void paint_cursor_on_hit(
UnifiedPaintSettings *ups, Brush *brush, ViewContext *vc,
const float location[3])
{
float unprojected_radius, projected_radius;
@ -969,8 +975,8 @@ static void paint_cursor_on_hit(UnifiedPaintSettings *ups, Brush *brush, ViewCon
}
/* convert brush radius from 2D to 3D */
unprojected_radius = paint_calc_object_space_radius(vc, location,
projected_radius);
unprojected_radius = paint_calc_object_space_radius(
vc, location, projected_radius);
/* scale 3D brush radius by pressure */
if (ups->stroke_active && BKE_brush_use_size_pressure(vc->scene, brush))

View File

@ -603,8 +603,9 @@ static int paintcurve_slide_modal(bContext *C, wmOperator *op, const wmEvent *ev
{
ARegion *ar = CTX_wm_region(C);
wmWindow *window = CTX_wm_window(C);
float diff[2] = {event->mval[0] - psd->initial_loc[0],
event->mval[1] - psd->initial_loc[1]};
float diff[2] = {
event->mval[0] - psd->initial_loc[0],
event->mval[1] - psd->initial_loc[1]};
if (psd->select == 1) {
int i;
for (i = 0; i < 3; i++)

View File

@ -71,10 +71,11 @@
#include <assert.h>
/* return true if the element should be hidden/shown */
static bool is_effected(PartialVisArea area,
float planes[4][4],
const float co[3],
const float mask)
static bool is_effected(
PartialVisArea area,
float planes[4][4],
const float co[3],
const float mask)
{
if (area == PARTIALVIS_ALL)
return 1;
@ -88,12 +89,13 @@ static bool is_effected(PartialVisArea area,
}
}
static void partialvis_update_mesh(Object *ob,
PBVH *pbvh,
PBVHNode *node,
PartialVisAction action,
PartialVisArea area,
float planes[4][4])
static void partialvis_update_mesh(
Object *ob,
PBVH *pbvh,
PBVHNode *node,
PartialVisAction action,
PartialVisArea area,
float planes[4][4])
{
Mesh *me = ob->data;
MVert *mvert;
@ -133,12 +135,13 @@ static void partialvis_update_mesh(Object *ob,
/* Hide or show elements in multires grids with a special GridFlags
* customdata layer. */
static void partialvis_update_grids(Object *ob,
PBVH *pbvh,
PBVHNode *node,
PartialVisAction action,
PartialVisArea area,
float planes[4][4])
static void partialvis_update_grids(
Object *ob,
PBVH *pbvh,
PBVHNode *node,
PartialVisAction action,
PartialVisArea area,
float planes[4][4])
{
CCGElem **grids;
CCGKey key;
@ -148,9 +151,10 @@ static void partialvis_update_grids(Object *ob,
/* get PBVH data */
BKE_pbvh_node_get_grids(pbvh, node,
&grid_indices, &totgrid, NULL, NULL,
&grids);
BKE_pbvh_node_get_grids(
pbvh, node,
&grid_indices, &totgrid, NULL, NULL,
&grids);
grid_hidden = BKE_pbvh_grid_hidden(pbvh);
BKE_pbvh_get_grid_key(pbvh, &key);
@ -165,8 +169,9 @@ static void partialvis_update_grids(Object *ob,
switch (action) {
case PARTIALVIS_HIDE:
/* create grid flags data */
gh = grid_hidden[g] = BLI_BITMAP_NEW(key.grid_area,
"partialvis_update_grids");
gh = grid_hidden[g] = BLI_BITMAP_NEW(
key.grid_area,
"partialvis_update_grids");
break;
case PARTIALVIS_SHOW:
/* entire grid is visible, nothing to show */
@ -192,8 +197,9 @@ static void partialvis_update_grids(Object *ob,
/* skip grid element if not in the effected area */
if (is_effected(area, planes, co, mask)) {
/* set or clear the hide flag */
BLI_BITMAP_SET(gh, y * key.grid_size + x,
action == PARTIALVIS_HIDE);
BLI_BITMAP_SET(
gh, y * key.grid_size + x,
action == PARTIALVIS_HIDE);
any_changed = true;
}
@ -222,21 +228,21 @@ static void partialvis_update_grids(Object *ob,
}
}
static void partialvis_update_bmesh_verts(BMesh *bm,
GSet *verts,
PartialVisAction action,
PartialVisArea area,
float planes[4][4],
bool *any_changed,
bool *any_visible)
static void partialvis_update_bmesh_verts(
BMesh *bm,
GSet *verts,
PartialVisAction action,
PartialVisArea area,
float planes[4][4],
bool *any_changed,
bool *any_visible)
{
GSetIterator gs_iter;
GSET_ITER (gs_iter, verts) {
BMVert *v = BLI_gsetIterator_getKey(&gs_iter);
float *vmask = CustomData_bmesh_get(&bm->vdata,
v->head.data,
CD_PAINT_MASK);
float *vmask = CustomData_bmesh_get(
&bm->vdata, v->head.data, CD_PAINT_MASK);
/* hide vertex if in the hide volume */
if (is_effected(area, planes, v->co, *vmask)) {
@ -266,12 +272,13 @@ static void partialvis_update_bmesh_faces(GSet *faces)
}
}
static void partialvis_update_bmesh(Object *ob,
PBVH *pbvh,
PBVHNode *node,
PartialVisAction action,
PartialVisArea area,
float planes[4][4])
static void partialvis_update_bmesh(
Object *ob,
PBVH *pbvh,
PBVHNode *node,
PartialVisAction action,
PartialVisArea area,
float planes[4][4])
{
BMesh *bm;
GSet *unique, *other, *faces;
@ -284,21 +291,23 @@ static void partialvis_update_bmesh(Object *ob,
sculpt_undo_push_node(ob, node, SCULPT_UNDO_HIDDEN);
partialvis_update_bmesh_verts(bm,
unique,
action,
area,
planes,
&any_changed,
&any_visible);
partialvis_update_bmesh_verts(
bm,
unique,
action,
area,
planes,
&any_changed,
&any_visible);
partialvis_update_bmesh_verts(bm,
other,
action,
area,
planes,
&any_changed,
&any_visible);
partialvis_update_bmesh_verts(
bm,
other,
action,
area,
planes,
&any_changed,
&any_visible);
/* finally loop over node faces and tag the ones that are fully hidden */
partialvis_update_bmesh_faces(faces);
@ -317,9 +326,10 @@ static void rect_from_props(rcti *rect, PointerRNA *ptr)
rect->ymax = RNA_int_get(ptr, "ymax");
}
static void clip_planes_from_rect(bContext *C,
float clip_planes[4][4],
const rcti *rect)
static void clip_planes_from_rect(
bContext *C,
float clip_planes[4][4],
const rcti *rect)
{
ViewContext vc;
BoundBox bb;
@ -336,11 +346,12 @@ static void clip_planes_from_rect(bContext *C,
* inside the clip_planes volume. If mode is outside, get all nodes
* that lie at least partially outside the volume. If showing all, get
* all nodes. */
static void get_pbvh_nodes(PBVH *pbvh,
PBVHNode ***nodes,
int *totnode,
float clip_planes[4][4],
PartialVisArea mode)
static void get_pbvh_nodes(
PBVH *pbvh,
PBVHNode ***nodes,
int *totnode,
float clip_planes[4][4],
PartialVisArea mode)
{
BKE_pbvh_SearchCallback cb = NULL;

View File

@ -164,8 +164,9 @@ void imapaint_image_update(SpaceImage *sima, Image *image, ImBuf *ibuf, short te
if (imapaintpartial.x1 != imapaintpartial.x2 &&
imapaintpartial.y1 != imapaintpartial.y2)
{
IMB_partial_display_buffer_update_delayed(ibuf, imapaintpartial.x1, imapaintpartial.y1,
imapaintpartial.x2, imapaintpartial.y2);
IMB_partial_display_buffer_update_delayed(
ibuf, imapaintpartial.x1, imapaintpartial.y1,
imapaintpartial.x2, imapaintpartial.y2);
}
if (ibuf->mipmap[0])
@ -323,15 +324,16 @@ typedef struct PaintOperation {
bool paint_use_opacity_masking(Brush *brush)
{
return (brush->flag & BRUSH_AIRBRUSH) ||
(brush->flag & BRUSH_DRAG_DOT) ||
(brush->flag & BRUSH_ANCHORED) ||
(brush->imagepaint_tool == PAINT_TOOL_SMEAR) ||
(brush->imagepaint_tool == PAINT_TOOL_SOFTEN) ||
(brush->imagepaint_tool == PAINT_TOOL_FILL) ||
(brush->flag & BRUSH_USE_GRADIENT) ||
(brush->mtex.tex && !ELEM(brush->mtex.brush_map_mode, MTEX_MAP_MODE_TILED, MTEX_MAP_MODE_STENCIL, MTEX_MAP_MODE_3D)) ?
false : true;
return ((brush->flag & BRUSH_AIRBRUSH) ||
(brush->flag & BRUSH_DRAG_DOT) ||
(brush->flag & BRUSH_ANCHORED) ||
(brush->imagepaint_tool == PAINT_TOOL_SMEAR) ||
(brush->imagepaint_tool == PAINT_TOOL_SOFTEN) ||
(brush->imagepaint_tool == PAINT_TOOL_FILL) ||
(brush->flag & BRUSH_USE_GRADIENT) ||
(brush->mtex.tex &&
!ELEM(brush->mtex.brush_map_mode, MTEX_MAP_MODE_TILED, MTEX_MAP_MODE_STENCIL, MTEX_MAP_MODE_3D)) ?
false : true);
}
void paint_brush_color_get(
@ -539,8 +541,9 @@ static void paint_stroke_done(const bContext *C, struct PaintStroke *stroke)
paint_2d_gradient_fill(C, brush, pop->startmouse, pop->prevmouse, pop->custom_paint);
}
else {
paint_proj_stroke(C, pop->custom_paint, pop->startmouse, pop->prevmouse, paint_stroke_flipped(stroke),
1.0, 0.0, BKE_brush_size_get(scene, brush));
paint_proj_stroke(
C, pop->custom_paint, pop->startmouse, pop->prevmouse, paint_stroke_flipped(stroke),
1.0, 0.0, BKE_brush_size_get(scene, brush));
/* two redraws, one for GPU update, one for notification */
paint_proj_redraw(C, pop->custom_paint, false);
paint_proj_redraw(C, pop->custom_paint, true);
@ -554,8 +557,9 @@ static void paint_stroke_done(const bContext *C, struct PaintStroke *stroke)
paint_2d_bucket_fill(C, color, brush, pop->prevmouse, pop->custom_paint);
}
else {
paint_proj_stroke(C, pop->custom_paint, pop->startmouse, pop->prevmouse, paint_stroke_flipped(stroke),
1.0, 0.0, BKE_brush_size_get(scene, brush));
paint_proj_stroke(
C, pop->custom_paint, pop->startmouse, pop->prevmouse, paint_stroke_flipped(stroke),
1.0, 0.0, BKE_brush_size_get(scene, brush));
/* two redraws, one for GPU update, one for notification */
paint_proj_redraw(C, pop->custom_paint, false);
paint_proj_redraw(C, pop->custom_paint, true);
@ -606,10 +610,11 @@ static int paint_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
int retval;
op->customdata = paint_stroke_new(C, op, NULL, paint_stroke_test_start,
paint_stroke_update_step,
paint_stroke_redraw,
paint_stroke_done, event->type);
op->customdata = paint_stroke_new(
C, op, NULL, paint_stroke_test_start,
paint_stroke_update_step,
paint_stroke_redraw,
paint_stroke_done, event->type);
if ((retval = op->type->modal(C, op, event)) == OPERATOR_FINISHED) {
paint_stroke_data_free(op);
@ -637,10 +642,11 @@ static int paint_exec(bContext *C, wmOperator *op)
RNA_float_get_array(&firstpoint, "mouse", mouse);
op->customdata = paint_stroke_new(C, op, NULL, paint_stroke_test_start,
paint_stroke_update_step,
paint_stroke_redraw,
paint_stroke_done, 0);
op->customdata = paint_stroke_new(
C, op, NULL, paint_stroke_test_start,
paint_stroke_update_step,
paint_stroke_redraw,
paint_stroke_done, 0);
/* frees op->customdata */
return paint_stroke_exec(C, op);
}
@ -845,11 +851,12 @@ static void sample_color_update_header(SampleColorData *data, bContext *C)
ScrArea *sa = CTX_wm_area(C);
if (sa) {
BLI_snprintf(msg, sizeof(msg),
IFACE_("Sample color for %s"),
!data->sample_palette ?
IFACE_("Brush. Use Left Click to sample for palette instead") :
IFACE_("Palette. Use Left Click to sample more colors"));
BLI_snprintf(
msg, sizeof(msg),
IFACE_("Sample color for %s"),
!data->sample_palette ?
IFACE_("Brush. Use Left Click to sample for palette instead") :
IFACE_("Palette. Use Left Click to sample more colors"));
ED_area_headerprint(sa, msg);
}
}

View File

@ -441,8 +441,9 @@ static ImBuf *brush_painter_imbuf_new(BrushPainter *painter, int size, float pre
}
/* update rectangular section of the brush image */
static void brush_painter_imbuf_update(BrushPainter *painter, ImBuf *oldtexibuf,
int origx, int origy, int w, int h, int xt, int yt)
static void brush_painter_imbuf_update(
BrushPainter *painter, ImBuf *oldtexibuf,
int origx, int origy, int w, int h, int xt, int yt)
{
Scene *scene = painter->scene;
Brush *brush = painter->brush;
@ -659,11 +660,12 @@ static void brush_painter_2d_refresh_cache(ImagePaintState *s, BrushPainter *pai
bool do_random = false;
bool do_partial_update = false;
bool update_color = (brush->flag & BRUSH_USE_GRADIENT) &&
((ELEM(brush->gradient_stroke_mode,
BRUSH_GRADIENT_SPACING_REPEAT,
BRUSH_GRADIENT_SPACING_CLAMP)) ||
(cache->last_pressure != pressure));
bool update_color = (
(brush->flag & BRUSH_USE_GRADIENT) &&
((ELEM(brush->gradient_stroke_mode,
BRUSH_GRADIENT_SPACING_REPEAT,
BRUSH_GRADIENT_SPACING_CLAMP)) ||
(cache->last_pressure != pressure)));
float tex_rotation = -brush->mtex.rot;
float mask_rotation = -brush->mask_mtex.rot;
@ -679,8 +681,9 @@ static void brush_painter_2d_refresh_cache(ImagePaintState *s, BrushPainter *pai
else if (!((brush->flag & BRUSH_ANCHORED) || update_color))
do_partial_update = true;
brush_painter_2d_tex_mapping(s, diameter, painter->startpaintpos, pos, mouse,
brush->mtex.brush_map_mode, &painter->tex_mapping);
brush_painter_2d_tex_mapping(
s, diameter, painter->startpaintpos, pos, mouse,
brush->mtex.brush_map_mode, &painter->tex_mapping);
}
if (painter->cache.is_maskbrush) {
@ -712,8 +715,9 @@ static void brush_painter_2d_refresh_cache(ImagePaintState *s, BrushPainter *pai
cache->tex_mask = NULL;
}
brush_painter_2d_tex_mapping(s, diameter, painter->startpaintpos, pos, mouse,
brush->mask_mtex.brush_map_mode, &painter->mask_mapping);
brush_painter_2d_tex_mapping(
s, diameter, painter->startpaintpos, pos, mouse,
brush->mask_mtex.brush_map_mode, &painter->mask_mapping);
if (do_partial_update_mask)
brush_painter_mask_imbuf_partial_update(painter, pos, diameter);
@ -893,9 +897,10 @@ static void paint_2d_lift_soften(ImagePaintState *s, ImBuf *ibuf, ImBuf *ibufb,
for (yk = 0; yk < kernel->side; yk++) {
for (xk = 0; xk < kernel->side; xk++) {
count += paint_2d_ibuf_add_if(ibuf, xi + xk - kernel->pixel_len,
yi + yk - kernel->pixel_len, outrgb, tile,
kernel->wdata[xk + yk * kernel->side]);
count += paint_2d_ibuf_add_if(
ibuf, xi + xk - kernel->pixel_len,
yi + yk - kernel->pixel_len, outrgb, tile,
kernel->wdata[xk + yk * kernel->side]);
}
}
@ -994,10 +999,11 @@ static void paint_2d_lift_smear(ImBuf *ibuf, ImBuf *ibufb, int *pos, short tile)
tot = paint_2d_torus_split_region(region, ibufb, ibuf, tile);
for (a = 0; a < tot; a++)
IMB_rectblend(ibufb, ibufb, ibuf, NULL, NULL, NULL, 0, region[a].destx, region[a].desty,
region[a].destx, region[a].desty,
region[a].srcx, region[a].srcy,
region[a].width, region[a].height, IMB_BLEND_COPY, false);
IMB_rectblend(
ibufb, ibufb, ibuf, NULL, NULL, NULL, 0, region[a].destx, region[a].desty,
region[a].destx, region[a].desty,
region[a].srcx, region[a].srcy,
region[a].width, region[a].height, IMB_BLEND_COPY, false);
}
static ImBuf *paint_2d_lift_clone(ImBuf *ibuf, ImBuf *ibufb, int *pos)
@ -1008,10 +1014,12 @@ static ImBuf *paint_2d_lift_clone(ImBuf *ibuf, ImBuf *ibufb, int *pos)
ImBuf *clonebuf = IMB_allocImBuf(w, h, ibufb->planes, ibufb->flags);
IMB_rectclip(clonebuf, ibuf, &destx, &desty, &srcx, &srcy, &w, &h);
IMB_rectblend(clonebuf, clonebuf, ibufb, NULL, NULL, NULL, 0, destx, desty, destx, desty, destx, desty, w, h,
IMB_BLEND_COPY_ALPHA, false);
IMB_rectblend(clonebuf, clonebuf, ibuf, NULL, NULL, NULL, 0, destx, desty, destx, desty, srcx, srcy, w, h,
IMB_BLEND_COPY_RGB, false);
IMB_rectblend(
clonebuf, clonebuf, ibufb, NULL, NULL, NULL, 0, destx, desty, destx, desty, destx, desty, w, h,
IMB_BLEND_COPY_ALPHA, false);
IMB_rectblend(
clonebuf, clonebuf, ibuf, NULL, NULL, NULL, 0, destx, desty, destx, desty, srcx, srcy, w, h,
IMB_BLEND_COPY_RGB, false);
return clonebuf;
}
@ -1022,15 +1030,16 @@ static void paint_2d_convert_brushco(ImBuf *ibufb, const float pos[2], int ipos[
ipos[1] = (int)floorf((pos[1] - ibufb->y / 2));
}
static void paint_2d_do_making_brush(ImagePaintState *s,
ImagePaintRegion *region,
unsigned short *curveb,
unsigned short *texmaskb,
ImBuf *frombuf,
float mask_max,
short blend,
int tilex, int tiley,
int tilew, int tileh)
static void paint_2d_do_making_brush(
ImagePaintState *s,
ImagePaintRegion *region,
unsigned short *curveb,
unsigned short *texmaskb,
ImBuf *frombuf,
float mask_max,
short blend,
int tilex, int tiley,
int tilew, int tileh)
{
ImBuf tmpbuf;
IMB_initImBuf(&tmpbuf, IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE, 32, 0);
@ -1049,13 +1058,14 @@ static void paint_2d_do_making_brush(ImagePaintState *s,
else
tmpbuf.rect = image_undo_find_tile(undo_tiles, s->image, s->canvas, tx, ty, &mask, false);
IMB_rectblend(s->canvas, &tmpbuf, frombuf, mask,
curveb, texmaskb, mask_max,
region->destx, region->desty,
origx, origy,
region->srcx, region->srcy,
region->width, region->height,
blend, ((s->brush->flag & BRUSH_ACCUMULATE) != 0));
IMB_rectblend(
s->canvas, &tmpbuf, frombuf, mask,
curveb, texmaskb, mask_max,
region->destx, region->desty,
origx, origy,
region->srcx, region->srcy,
region->width, region->height,
blend, ((s->brush->flag & BRUSH_ACCUMULATE) != 0));
}
}
}
@ -1078,11 +1088,12 @@ static void paint_2d_op_foreach_do(
const ParallelRangeTLS *__restrict UNUSED(tls))
{
Paint2DForeachData *data = (Paint2DForeachData *)data_v;
paint_2d_do_making_brush(data->s, data->region, data->curveb,
data->texmaskb, data->frombuf, data->mask_max,
data->blend,
data->tilex, iter,
data->tilew, iter);
paint_2d_do_making_brush(
data->s, data->region, data->curveb,
data->texmaskb, data->frombuf, data->mask_max,
data->blend,
data->tilex, iter,
data->tilew, iter);
}
static int paint_2d_op(void *state, ImBuf *ibufb, unsigned short *curveb, unsigned short *texmaskb, const float lastpos[2], const float pos[2])
@ -1134,21 +1145,24 @@ static int paint_2d_op(void *state, ImBuf *ibufb, unsigned short *curveb, unsign
/* blend into canvas */
for (a = 0; a < tot; a++) {
ED_imapaint_dirty_region(s->image, s->canvas,
region[a].destx, region[a].desty,
region[a].width, region[a].height, true);
ED_imapaint_dirty_region(
s->image, s->canvas,
region[a].destx, region[a].desty,
region[a].width, region[a].height, true);
if (s->do_masking) {
/* masking, find original pixels tiles from undo buffer to composite over */
int tilex, tiley, tilew, tileh;
imapaint_region_tiles(s->canvas, region[a].destx, region[a].desty,
region[a].width, region[a].height,
&tilex, &tiley, &tilew, &tileh);
imapaint_region_tiles(
s->canvas, region[a].destx, region[a].desty,
region[a].width, region[a].height,
&tilex, &tiley, &tilew, &tileh);
if (tiley == tileh) {
paint_2d_do_making_brush(s, &region[a], curveb, texmaskb, frombuf,
mask_max, blend, tilex, tiley, tilew, tileh);
paint_2d_do_making_brush(
s, &region[a], curveb, texmaskb, frombuf,
mask_max, blend, tilex, tiley, tilew, tileh);
}
else {
Paint2DForeachData data;
@ -1164,19 +1178,21 @@ static int paint_2d_op(void *state, ImBuf *ibufb, unsigned short *curveb, unsign
ParallelRangeSettings settings;
BLI_parallel_range_settings_defaults(&settings);
BLI_task_parallel_range(tiley, tileh + 1, &data,
paint_2d_op_foreach_do,
&settings);
BLI_task_parallel_range(
tiley, tileh + 1, &data,
paint_2d_op_foreach_do,
&settings);
}
}
else {
/* no masking, composite brush directly onto canvas */
IMB_rectblend_threaded(s->canvas, s->canvas, frombuf, NULL, curveb, texmaskb, mask_max,
region[a].destx, region[a].desty,
region[a].destx, region[a].desty,
region[a].srcx, region[a].srcy,
region[a].width, region[a].height, blend, false);
IMB_rectblend_threaded(
s->canvas, s->canvas, frombuf, NULL, curveb, texmaskb, mask_max,
region[a].destx, region[a].desty,
region[a].destx, region[a].desty,
region[a].srcx, region[a].srcy,
region[a].width, region[a].height, blend, false);
}
}
@ -1477,16 +1493,18 @@ void paint_2d_bucket_fill(
if (do_float) {
for (x_px = 0; x_px < ibuf->x; x_px++) {
for (y_px = 0; y_px < ibuf->y; y_px++) {
blend_color_mix_float(ibuf->rect_float + 4 * (((size_t)y_px) * ibuf->x + x_px),
ibuf->rect_float + 4 * (((size_t)y_px) * ibuf->x + x_px), color_f);
blend_color_mix_float(
ibuf->rect_float + 4 * (((size_t)y_px) * ibuf->x + x_px),
ibuf->rect_float + 4 * (((size_t)y_px) * ibuf->x + x_px), color_f);
}
}
}
else {
for (x_px = 0; x_px < ibuf->x; x_px++) {
for (y_px = 0; y_px < ibuf->y; y_px++) {
blend_color_mix_byte((unsigned char *)(ibuf->rect + ((size_t)y_px) * ibuf->x + x_px),
(unsigned char *)(ibuf->rect + ((size_t)y_px) * ibuf->x + x_px), (unsigned char *)&color_b);
blend_color_mix_byte(
(unsigned char *)(ibuf->rect + ((size_t)y_px) * ibuf->x + x_px),
(unsigned char *)(ibuf->rect + ((size_t)y_px) * ibuf->x + x_px), (unsigned char *)&color_b);
}
}
}
@ -1537,9 +1555,10 @@ void paint_2d_bucket_fill(
while (!BLI_stack_is_empty(stack)) {
BLI_stack_pop(stack, &coordinate);
IMB_blend_color_float(ibuf->rect_float + 4 * (coordinate),
ibuf->rect_float + 4 * (coordinate),
color_f, br->blend);
IMB_blend_color_float(
ibuf->rect_float + 4 * (coordinate),
ibuf->rect_float + 4 * (coordinate),
color_f, br->blend);
/* reconstruct the coordinates here */
x_px = coordinate % width;
@ -1568,9 +1587,10 @@ void paint_2d_bucket_fill(
while (!BLI_stack_is_empty(stack)) {
BLI_stack_pop(stack, &coordinate);
IMB_blend_color_byte((unsigned char *)(ibuf->rect + coordinate),
(unsigned char *)(ibuf->rect + coordinate),
(unsigned char *)&color_b, br->blend);
IMB_blend_color_byte(
(unsigned char *)(ibuf->rect + coordinate),
(unsigned char *)(ibuf->rect + coordinate),
(unsigned char *)&color_b, br->blend);
/* reconstruct the coordinates here */
x_px = coordinate % width;
@ -1678,9 +1698,10 @@ void paint_2d_gradient_fill(
/* convert to premultiplied */
mul_v3_fl(color_f, color_f[3]);
color_f[3] *= br->alpha;
IMB_blend_color_float(ibuf->rect_float + 4 * (((size_t)y_px) * ibuf->x + x_px),
ibuf->rect_float + 4 * (((size_t)y_px) * ibuf->x + x_px),
color_f, br->blend);
IMB_blend_color_float(
ibuf->rect_float + 4 * (((size_t)y_px) * ibuf->x + x_px),
ibuf->rect_float + 4 * (((size_t)y_px) * ibuf->x + x_px),
color_f, br->blend);
}
}
}
@ -1708,9 +1729,10 @@ void paint_2d_gradient_fill(
linearrgb_to_srgb_v3_v3(color_f, color_f);
rgba_float_to_uchar((unsigned char *)&color_b, color_f);
((unsigned char *)&color_b)[3] *= br->alpha;
IMB_blend_color_byte((unsigned char *)(ibuf->rect + ((size_t)y_px) * ibuf->x + x_px),
(unsigned char *)(ibuf->rect + ((size_t)y_px) * ibuf->x + x_px),
(unsigned char *)&color_b, br->blend);
IMB_blend_color_byte(
(unsigned char *)(ibuf->rect + ((size_t)y_px) * ibuf->x + x_px),
(unsigned char *)(ibuf->rect + ((size_t)y_px) * ibuf->x + x_px),
(unsigned char *)&color_b, br->blend);
}
}
}

View File

@ -2611,8 +2611,9 @@ static void project_paint_face_init(
}
#if 0
project_paint_undo_tiles_init(&bounds_px, ps->projImages + image_index, tmpibuf,
tile_width, threaded, ps->do_masking);
project_paint_undo_tiles_init(
&bounds_px, ps->projImages + image_index, tmpibuf,
tile_width, threaded, ps->do_masking);
#endif
/* clip face and */
@ -2661,10 +2662,10 @@ static void project_paint_face_init(
if (mask > 0.0f) {
BLI_linklist_prepend_arena(
bucketPixelNodes,
project_paint_uvpixel_init(ps, arena, &tinf, x, y, mask, tri_index,
pixelScreenCo, wco, w),
arena
);
project_paint_uvpixel_init(
ps, arena, &tinf, x, y, mask, tri_index,
pixelScreenCo, wco, w),
arena);
}
}
@ -4218,8 +4219,9 @@ static void do_projectpaint_clone_f(ProjPaintState *ps, ProjPixel *projPixel, fl
* accumulation of color greater than 'projPixel->mask' however in the case of smear its not
* really that important to be correct as it is with clone and painting
*/
static void do_projectpaint_smear(ProjPaintState *ps, ProjPixel *projPixel, float mask,
MemArena *smearArena, LinkNode **smearPixels, const float co[2])
static void do_projectpaint_smear(
ProjPaintState *ps, ProjPixel *projPixel, float mask,
MemArena *smearArena, LinkNode **smearPixels, const float co[2])
{
unsigned char rgba_ub[4];
@ -4230,8 +4232,9 @@ static void do_projectpaint_smear(ProjPaintState *ps, ProjPixel *projPixel, floa
BLI_linklist_prepend_arena(smearPixels, (void *)projPixel, smearArena);
}
static void do_projectpaint_smear_f(ProjPaintState *ps, ProjPixel *projPixel, float mask,
MemArena *smearArena, LinkNode **smearPixels_f, const float co[2])
static void do_projectpaint_smear_f(
ProjPaintState *ps, ProjPixel *projPixel, float mask,
MemArena *smearArena, LinkNode **smearPixels_f, const float co[2])
{
float rgba[4];
@ -4242,8 +4245,9 @@ static void do_projectpaint_smear_f(ProjPaintState *ps, ProjPixel *projPixel, fl
BLI_linklist_prepend_arena(smearPixels_f, (void *)projPixel, smearArena);
}
static void do_projectpaint_soften_f(ProjPaintState *ps, ProjPixel *projPixel, float mask,
MemArena *softenArena, LinkNode **softenPixels)
static void do_projectpaint_soften_f(
ProjPaintState *ps, ProjPixel *projPixel, float mask,
MemArena *softenArena, LinkNode **softenPixels)
{
float accum_tot = 0.0f;
int xk, yk;
@ -4298,8 +4302,9 @@ static void do_projectpaint_soften_f(ProjPaintState *ps, ProjPixel *projPixel, f
}
}
static void do_projectpaint_soften(ProjPaintState *ps, ProjPixel *projPixel, float mask,
MemArena *softenArena, LinkNode **softenPixels)
static void do_projectpaint_soften(
ProjPaintState *ps, ProjPixel *projPixel, float mask,
MemArena *softenArena, LinkNode **softenPixels)
{
float accum_tot = 0;
int xk, yk;
@ -4580,8 +4585,9 @@ static void *do_projectpaint_thread(void *ph_v)
if (is_floatbuf) {
/* convert to premultipied */
mul_v3_fl(color_f, color_f[3]);
IMB_blend_color_float(projPixel->pixel.f_pt, projPixel->origColor.f_pt,
color_f, ps->blend);
IMB_blend_color_float(
projPixel->pixel.f_pt, projPixel->origColor.f_pt,
color_f, ps->blend);
}
else {
linearrgb_to_srgb_v3_v3(color_f, color_f);
@ -4593,8 +4599,9 @@ static void *do_projectpaint_thread(void *ph_v)
unit_float_to_uchar_clamp_v3(projPixel->newColor.ch, color_f);
}
projPixel->newColor.ch[3] = unit_float_to_uchar_clamp(color_f[3]);
IMB_blend_color_byte(projPixel->pixel.ch_pt, projPixel->origColor.ch_pt,
projPixel->newColor.ch, ps->blend);
IMB_blend_color_byte(
projPixel->pixel.ch_pt, projPixel->origColor.ch_pt,
projPixel->newColor.ch, ps->blend);
}
}
else {
@ -4603,16 +4610,18 @@ static void *do_projectpaint_thread(void *ph_v)
newColor_f[3] = ((float)projPixel->mask) * (1.0f / 65535.0f) * brush->alpha;
copy_v3_v3(newColor_f, ps->paint_color_linear);
IMB_blend_color_float(projPixel->pixel.f_pt, projPixel->origColor.f_pt,
newColor_f, ps->blend);
IMB_blend_color_float(
projPixel->pixel.f_pt, projPixel->origColor.f_pt,
newColor_f, ps->blend);
}
else {
float mask = ((float)projPixel->mask) * (1.0f / 65535.0f);
projPixel->newColor.ch[3] = mask * 255 * brush->alpha;
rgb_float_to_uchar(projPixel->newColor.ch, ps->paint_color);
IMB_blend_color_byte(projPixel->pixel.ch_pt, projPixel->origColor.ch_pt,
projPixel->newColor.ch, ps->blend);
IMB_blend_color_byte(
projPixel->pixel.ch_pt, projPixel->origColor.ch_pt,
projPixel->newColor.ch, ps->blend);
}
}
@ -4640,15 +4649,17 @@ static void *do_projectpaint_thread(void *ph_v)
ps->reproject_ibuf_free_float = true;
}
bicubic_interpolation_color(ps->reproject_ibuf, NULL, projPixel->newColor.f,
projPixel->projCoSS[0], projPixel->projCoSS[1]);
bicubic_interpolation_color(
ps->reproject_ibuf, NULL, projPixel->newColor.f,
projPixel->projCoSS[0], projPixel->projCoSS[1]);
if (projPixel->newColor.f[3]) {
float mask = ((float)projPixel->mask) * (1.0f / 65535.0f);
mul_v4_v4fl(projPixel->newColor.f, projPixel->newColor.f, mask);
blend_color_mix_float(projPixel->pixel.f_pt, projPixel->origColor.f_pt,
projPixel->newColor.f);
blend_color_mix_float(
projPixel->pixel.f_pt, projPixel->origColor.f_pt,
projPixel->newColor.f);
}
}
else {
@ -4657,14 +4668,16 @@ static void *do_projectpaint_thread(void *ph_v)
ps->reproject_ibuf_free_uchar = true;
}
bicubic_interpolation_color(ps->reproject_ibuf, projPixel->newColor.ch, NULL,
projPixel->projCoSS[0], projPixel->projCoSS[1]);
bicubic_interpolation_color(
ps->reproject_ibuf, projPixel->newColor.ch, NULL,
projPixel->projCoSS[0], projPixel->projCoSS[1]);
if (projPixel->newColor.ch[3]) {
float mask = ((float)projPixel->mask) * (1.0f / 65535.0f);
projPixel->newColor.ch[3] *= mask;
blend_color_mix_byte(projPixel->pixel.ch_pt, projPixel->origColor.ch_pt,
projPixel->newColor.ch);
blend_color_mix_byte(
projPixel->pixel.ch_pt, projPixel->origColor.ch_pt,
projPixel->newColor.ch);
}
}
}
@ -5524,12 +5537,13 @@ void PAINT_OT_image_from_view(wmOperatorType *ot)
void BKE_paint_data_warning(struct ReportList *reports, bool uvs, bool mat, bool tex, bool stencil)
{
BKE_reportf(reports, RPT_WARNING, "Missing%s%s%s%s detected!",
!uvs ? " UVs," : "",
!mat ? " Materials," : "",
!tex ? " Textures," : "",
!stencil ? " Stencil," : ""
);
BKE_reportf(
reports, RPT_WARNING, "Missing%s%s%s%s detected!",
!uvs ? " UVs," : "",
!mat ? " Materials," : "",
!tex ? " Textures," : "",
!stencil ? " Stencil," : ""
);
}
/* Make sure that active object has a material, and assign UVs and image layers if they do not exist */
@ -5666,8 +5680,9 @@ static Image *proj_paint_image_create(wmOperator *op, Main *bmain)
alpha = RNA_boolean_get(op->ptr, "alpha");
RNA_string_get(op->ptr, "name", imagename);
}
ima = BKE_image_add_generated(bmain, width, height, imagename, alpha ? 32 : 24, use_float,
gen_type, color, false);
ima = BKE_image_add_generated(
bmain, width, height, imagename, alpha ? 32 : 24, use_float,
gen_type, color, false);
return ima;
}

View File

@ -103,8 +103,9 @@ static void undo_copy_tile(UndoImageTile *tile, ImBuf *tmpibuf, ImBuf *ibuf, Cop
{
if (mode == COPY) {
/* copy or swap contents of tile->rect and region in ibuf->rect */
IMB_rectcpy(tmpibuf, ibuf, 0, 0, tile->x * IMAPAINT_TILE_SIZE,
tile->y * IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE);
IMB_rectcpy(
tmpibuf, ibuf, 0, 0, tile->x * IMAPAINT_TILE_SIZE,
tile->y * IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE);
if (ibuf->rect_float) {
SWAP(float *, tmpibuf->rect_float, tile->rect.fp);
@ -115,8 +116,9 @@ static void undo_copy_tile(UndoImageTile *tile, ImBuf *tmpibuf, ImBuf *ibuf, Cop
}
else {
if (mode == RESTORE_COPY) {
IMB_rectcpy(tmpibuf, ibuf, 0, 0, tile->x * IMAPAINT_TILE_SIZE,
tile->y * IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE);
IMB_rectcpy(
tmpibuf, ibuf, 0, 0, tile->x * IMAPAINT_TILE_SIZE,
tile->y * IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE);
}
/* swap to the tmpbuf for easy copying */
if (ibuf->rect_float) {
@ -126,8 +128,9 @@ static void undo_copy_tile(UndoImageTile *tile, ImBuf *tmpibuf, ImBuf *ibuf, Cop
SWAP(unsigned int *, tmpibuf->rect, tile->rect.uint);
}
IMB_rectcpy(ibuf, tmpibuf, tile->x * IMAPAINT_TILE_SIZE,
tile->y * IMAPAINT_TILE_SIZE, 0, 0, IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE);
IMB_rectcpy(
ibuf, tmpibuf, tile->x * IMAPAINT_TILE_SIZE,
tile->y * IMAPAINT_TILE_SIZE, 0, 0, IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE);
if (mode == RESTORE) {
if (ibuf->rect_float) {
@ -154,8 +157,9 @@ void *image_undo_find_tile(
if (mask) {
/* allocate mask if requested */
if (!tile->mask) {
tile->mask = MEM_callocN(sizeof(unsigned short) * IMAPAINT_TILE_SIZE * IMAPAINT_TILE_SIZE,
"UndoImageTile.mask");
tile->mask = MEM_callocN(
sizeof(unsigned short) * IMAPAINT_TILE_SIZE * IMAPAINT_TILE_SIZE,
"UndoImageTile.mask");
}
*mask = tile->mask;
@ -202,8 +206,9 @@ void *image_undo_push_tile(
/* add mask explicitly here */
if (mask) {
*mask = tile->mask = MEM_callocN(sizeof(unsigned short) * IMAPAINT_TILE_SIZE * IMAPAINT_TILE_SIZE,
"UndoImageTile.mask");
*mask = tile->mask = MEM_callocN(
sizeof(unsigned short) * IMAPAINT_TILE_SIZE * IMAPAINT_TILE_SIZE,
"UndoImageTile.mask");
}
allocsize = IMAPAINT_TILE_SIZE * IMAPAINT_TILE_SIZE * 4;
allocsize *= (ibuf->rect_float) ? sizeof(float) : sizeof(char);
@ -251,8 +256,9 @@ static void image_undo_restore_runtime(ListBase *lb)
ImBuf *ibuf, *tmpibuf;
UndoImageTile *tile;
tmpibuf = IMB_allocImBuf(IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE, 32,
IB_rectfloat | IB_rect);
tmpibuf = IMB_allocImBuf(
IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE, 32,
IB_rectfloat | IB_rect);
for (tile = lb->first; tile; tile = tile->next) {
Image *ima = tile->ima;

View File

@ -265,7 +265,9 @@ void paint_calc_redraw_planes(float planes[4][4],
float paint_calc_object_space_radius(struct ViewContext *vc, const float center[3], float pixel_radius);
float paint_get_tex_pixel(const struct MTex *mtex, float u, float v, struct ImagePool *pool, int thread);
void paint_get_tex_pixel_col(const struct MTex *mtex, float u, float v, float rgba[4], struct ImagePool *pool, int thread, bool convert, struct ColorSpace *colorspace);
void paint_get_tex_pixel_col(
const struct MTex *mtex, float u, float v, float rgba[4],
struct ImagePool *pool, int thread, bool convert, struct ColorSpace *colorspace);
void paint_sample_color(struct bContext *C, struct ARegion *ar, int x, int y, bool texpaint_proj, bool palette);

View File

@ -76,9 +76,10 @@ static const EnumPropertyItem mode_items[] = {
{0}};
static void mask_flood_fill_set_elem(float *elem,
PaintMaskFloodMode mode,
float value)
static void mask_flood_fill_set_elem(
float *elem,
PaintMaskFloodMode mode,
float value)
{
switch (mode) {
case PAINT_MASK_FLOOD_VALUE:
@ -162,8 +163,9 @@ static int mask_flood_fill_exec(bContext *C, wmOperator *op)
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = ((sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_THREADED_LIMIT);
BLI_task_parallel_range(
0, totnode, &data, mask_flood_fill_task_cb,
&settings);
0, totnode, &data, mask_flood_fill_task_cb,
&settings);
if (multires)
multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED);

View File

@ -365,10 +365,11 @@ static Brush *brush_tool_toggle(Main *bmain, Brush *brush_orig, const int tool,
return NULL;
}
static int brush_generic_tool_set(Main *bmain, Paint *paint, const int tool,
const size_t tool_offset, const int ob_mode,
const char *tool_name, const bool create_missing,
const bool toggle)
static int brush_generic_tool_set(
Main *bmain, Paint *paint, const int tool,
const size_t tool_offset, const int ob_mode,
const char *tool_name, const bool create_missing,
const bool toggle)
{
Brush *brush, *brush_orig = BKE_paint_brush(paint);
@ -452,9 +453,10 @@ static int brush_select_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
return brush_generic_tool_set(bmain, paint, tool, tool_offset,
paint_mode, tool_name, create_missing,
toggle);
return brush_generic_tool_set(
bmain, paint, tool, tool_offset,
paint_mode, tool_name, create_missing,
toggle);
}
static void PAINT_OT_brush_select(wmOperatorType *ot)
@ -493,13 +495,15 @@ static void PAINT_OT_brush_select(wmOperatorType *ot)
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
static wmKeyMapItem *keymap_brush_select(wmKeyMap *keymap, int paint_mode,
int tool, int keymap_type,
int keymap_modifier)
static wmKeyMapItem *keymap_brush_select(
wmKeyMap *keymap, int paint_mode,
int tool, int keymap_type,
int keymap_modifier)
{
wmKeyMapItem *kmi;
kmi = WM_keymap_add_item(keymap, "PAINT_OT_brush_select",
keymap_type, KM_PRESS, keymap_modifier, 0);
kmi = WM_keymap_add_item(
keymap, "PAINT_OT_brush_select",
keymap_type, KM_PRESS, keymap_modifier, 0);
RNA_enum_set(kmi->ptr, "paint_mode", paint_mode);
@ -683,8 +687,7 @@ static void stencil_control_calculate(StencilControlData *scd, const int mval[2]
switch (scd->mode) {
case STENCIL_TRANSLATE:
sub_v2_v2v2(mdiff, mvalf, scd->init_mouse);
add_v2_v2v2(scd->pos_target, scd->init_spos,
mdiff);
add_v2_v2v2(scd->pos_target, scd->init_spos, mdiff);
CLAMP(scd->pos_target[0],
-scd->dim_target[0] + PIXEL_MARGIN,
scd->area_size[0] + scd->dim_target[0] - PIXEL_MARGIN);
@ -987,8 +990,9 @@ void ED_operatormacros_paint(void)
wmOperatorType *ot;
wmOperatorTypeMacro *otmacro;
ot = WM_operatortype_append_macro("PAINTCURVE_OT_add_point_slide", "Add Curve Point and Slide",
"Add new curve point and slide it", OPTYPE_UNDO);
ot = WM_operatortype_append_macro(
"PAINTCURVE_OT_add_point_slide", "Add Curve Point and Slide",
"Add new curve point and slide it", OPTYPE_UNDO);
ot->description = "Add new curve point and slide it";
WM_operatortype_macro_define(ot, "PAINTCURVE_OT_add_point");
otmacro = WM_operatortype_macro_define(ot, "PAINTCURVE_OT_slide");
@ -1088,8 +1092,9 @@ static void ed_keymap_paint_brush_switch(wmKeyMap *keymap, const char *mode)
int i;
/* index 0-9 (zero key is tenth), shift key for index 10-19 */
for (i = 0; i < 20; i++) {
kmi = WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set",
ZEROKEY + ((i + 1) % 10), KM_PRESS, i < 10 ? 0 : KM_SHIFT, 0);
kmi = WM_keymap_add_item(
keymap, "BRUSH_OT_active_index_set",
ZEROKEY + ((i + 1) % 10), KM_PRESS, i < 10 ? 0 : KM_SHIFT, 0);
RNA_string_set(kmi->ptr, "mode", mode);
RNA_int_set(kmi->ptr, "index", i);
}
@ -1106,8 +1111,9 @@ static void ed_keymap_paint_brush_size(wmKeyMap *keymap, const char *UNUSED(path
RNA_float_set(kmi->ptr, "scalar", 10.0 / 9.0); // 1.1111....
}
static void set_brush_rc_path(PointerRNA *ptr, const char *brush_path,
const char *output_name, const char *input_name)
static void set_brush_rc_path(
PointerRNA *ptr, const char *brush_path,
const char *output_name, const char *input_name)
{
char *path;
@ -1116,9 +1122,10 @@ static void set_brush_rc_path(PointerRNA *ptr, const char *brush_path,
MEM_freeN(path);
}
void set_brush_rc_props(PointerRNA *ptr, const char *paint,
const char *prop, const char *secondary_prop,
RCFlags flags)
void set_brush_rc_props(
PointerRNA *ptr, const char *paint,
const char *prop, const char *secondary_prop,
RCFlags flags)
{
const char *ups_path = "tool_settings.unified_paint_settings";
char *brush_path;
@ -1167,8 +1174,9 @@ void set_brush_rc_props(PointerRNA *ptr, const char *paint,
MEM_freeN(brush_path);
}
static void ed_keymap_paint_brush_radial_control(wmKeyMap *keymap, const char *paint,
RCFlags flags)
static void ed_keymap_paint_brush_radial_control(
wmKeyMap *keymap, const char *paint,
RCFlags flags)
{
wmKeyMapItem *kmi;
/* only size needs to follow zoom, strength shows fixed size circle */
@ -1336,8 +1344,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "PAINT_OT_brush_colors_flip", XKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "PAINT_OT_sample_color", SKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap,
"PAINT_OT_vertex_color_set", KKEY, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_item(keymap, "PAINT_OT_vertex_color_set", KKEY, KM_PRESS, KM_SHIFT, 0);
ed_keymap_paint_brush_switch(keymap, "vertex_paint");
ed_keymap_paint_brush_size(keymap, "tool_settings.vertex_paint.brush.size");
@ -1369,8 +1376,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_weight_gradient", LEFTMOUSE, KM_PRESS, KM_ALT, 0)->ptr, "type", WPAINT_GRADIENT_TYPE_LINEAR);
RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_weight_gradient", LEFTMOUSE, KM_PRESS, KM_ALT | KM_CTRL, 0)->ptr, "type", WPAINT_GRADIENT_TYPE_RADIAL);
WM_keymap_add_item(keymap,
"PAINT_OT_weight_set", KKEY, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_item(keymap, "PAINT_OT_weight_set", KKEY, KM_PRESS, KM_SHIFT, 0);
ed_keymap_paint_brush_switch(keymap, "weight_paint");
ed_keymap_paint_brush_size(keymap, "tool_settings.weight_paint.brush.size");

View File

@ -198,8 +198,9 @@ static bool paint_tool_require_location(Brush *brush, ePaintMode mode)
{
switch (mode) {
case ePaintSculpt:
if (ELEM(brush->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE,
SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB))
if (ELEM(brush->sculpt_tool,
SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE,
SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB))
{
return false;
}
@ -384,15 +385,17 @@ static bool paint_brush_update(
if (do_random) {
if (brush->mtex.brush_angle_mode & MTEX_ANGLE_RANDOM) {
ups->brush_rotation += -brush->mtex.random_angle / 2.0f +
brush->mtex.random_angle * BLI_frand();
ups->brush_rotation += (
-brush->mtex.random_angle / 2.0f +
brush->mtex.random_angle * BLI_frand());
}
}
if (do_random_mask) {
if (brush->mask_mtex.brush_angle_mode & MTEX_ANGLE_RANDOM) {
ups->brush_rotation_sec += -brush->mask_mtex.random_angle / 2.0f +
brush->mask_mtex.random_angle * BLI_frand();
ups->brush_rotation_sec += (
-brush->mask_mtex.random_angle / 2.0f +
brush->mask_mtex.random_angle * BLI_frand());
}
}
@ -449,14 +452,24 @@ static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, const float
#if 0
/* special exception here for too high pressure values on first touch in
* windows for some tablets, then we just skip first touch .. */
if (tablet && (pressure >= 0.99f) && ((pop->s.brush->flag & BRUSH_SPACING_PRESSURE) || BKE_brush_use_alpha_pressure(scene, pop->s.brush) || BKE_brush_use_size_pressure(scene, pop->s.brush)))
if (tablet && (pressure >= 0.99f) &&
((pop->s.brush->flag & BRUSH_SPACING_PRESSURE) ||
BKE_brush_use_alpha_pressure(scene, pop->s.brush) ||
BKE_brush_use_size_pressure(scene, pop->s.brush)))
{
return;
}
/* This can be removed once fixed properly in
* BKE_brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, double time, float pressure, void *user)
* at zero pressure we should do nothing 1/2^12 is 0.0002 which is the sensitivity of the most sensitive pen tablet available */
if (tablet && (pressure < 0.0002f) && ((pop->s.brush->flag & BRUSH_SPACING_PRESSURE) || BKE_brush_use_alpha_pressure(scene, pop->s.brush) || BKE_brush_use_size_pressure(scene, pop->s.brush)))
if (tablet && (pressure < 0.0002f) &&
((pop->s.brush->flag & BRUSH_SPACING_PRESSURE) ||
BKE_brush_use_alpha_pressure(scene, pop->s.brush) ||
BKE_brush_use_size_pressure(scene, pop->s.brush)))
{
return;
}
#endif
/* copy last position -before- jittering, or space fill code
@ -540,7 +553,8 @@ static bool paint_smooth_stroke(
return true;
}
static float paint_space_stroke_spacing(const Scene *scene, PaintStroke *stroke, float size_pressure, float spacing_pressure)
static float paint_space_stroke_spacing(
const Scene *scene, PaintStroke *stroke, float size_pressure, float spacing_pressure)
{
/* brushes can have a minimum size of 1.0 but with pressure it can be smaller then a pixel
* causing very high step sizes, hanging blender [#32381] */
@ -610,7 +624,8 @@ static float paint_stroke_integrate_overlap(Brush *br, float factor)
return 1.0f / max;
}
static float paint_space_stroke_spacing_variable(const Scene *scene, PaintStroke *stroke, float pressure, float dpressure, float length)
static float paint_space_stroke_spacing_variable(
const Scene *scene, PaintStroke *stroke, float pressure, float dpressure, float length)
{
if (BKE_brush_use_size_pressure(scene, stroke->brush)) {
/* use pressure to modify size. set spacing so that at 100%, the circles
@ -685,13 +700,14 @@ static int paint_space_stroke(bContext *C, wmOperator *op, const float final_mou
/**** Public API ****/
PaintStroke *paint_stroke_new(bContext *C,
wmOperator *op,
StrokeGetLocation get_location,
StrokeTestStart test_start,
StrokeUpdateStep update_step,
StrokeRedraw redraw,
StrokeDone done, int event_type)
PaintStroke *paint_stroke_new(
bContext *C,
wmOperator *op,
StrokeGetLocation get_location,
StrokeTestStart test_start,
StrokeUpdateStep update_step,
StrokeRedraw redraw,
StrokeDone done, int event_type)
{
PaintStroke *stroke = MEM_callocN(sizeof(PaintStroke), "PaintStroke");
ToolSettings *toolsettings = CTX_data_tool_settings(C);
@ -788,11 +804,12 @@ bool paint_space_stroke_enabled(Brush *br, ePaintMode mode)
static bool sculpt_is_grab_tool(Brush *br)
{
return ELEM(br->sculpt_tool,
SCULPT_TOOL_GRAB,
SCULPT_TOOL_THUMB,
SCULPT_TOOL_ROTATE,
SCULPT_TOOL_SNAKE_HOOK);
return ELEM(
br->sculpt_tool,
SCULPT_TOOL_GRAB,
SCULPT_TOOL_THUMB,
SCULPT_TOOL_ROTATE,
SCULPT_TOOL_SNAKE_HOOK);
}
/* return true if the brush size can change during paint (normally used for pressure) */
@ -893,9 +910,10 @@ struct wmKeyMap *paint_stroke_modal_keymap(struct wmKeyConfig *keyconf)
return keymap;
}
static void paint_stroke_add_sample(const Paint *paint,
PaintStroke *stroke,
float x, float y, float pressure)
static void paint_stroke_add_sample(
const Paint *paint,
PaintStroke *stroke,
float x, float y, float pressure)
{
PaintSample *sample = &stroke->samples[stroke->cur_sample];
int max_samples = CLAMPIS(paint->num_input_samples, 1, PAINT_MAX_INPUT_SAMPLES);
@ -911,8 +929,9 @@ static void paint_stroke_add_sample(const Paint *paint,
stroke->num_samples++;
}
static void paint_stroke_sample_average(const PaintStroke *stroke,
PaintSample *average)
static void paint_stroke_sample_average(
const PaintStroke *stroke,
PaintSample *average)
{
int i;
@ -1057,11 +1076,13 @@ static bool paint_stroke_curve_end(bContext *C, wmOperator *op, PaintStroke *str
if (stroke->stroke_started) {
paint_brush_stroke_add_step(C, op, data + 2 * j, 1.0);
paint_line_strokes_spacing(C, op, stroke, spacing, &length_residue, data + 2 * j, data + 2 * (j + 1));
paint_line_strokes_spacing(
C, op, stroke, spacing, &length_residue, data + 2 * j, data + 2 * (j + 1));
}
}
else {
paint_line_strokes_spacing(C, op, stroke, spacing, &length_residue, data + 2 * j, data + 2 * (j + 1));
paint_line_strokes_spacing(
C, op, stroke, spacing, &length_residue, data + 2 * j, data + 2 * (j + 1));
}
}
}
@ -1121,7 +1142,9 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event)
float pressure;
/* see if tablet affects event. Line, anchored and drag dot strokes do not support pressure */
pressure = (br->flag & (BRUSH_LINE | BRUSH_ANCHORED | BRUSH_DRAG_DOT)) ? 1.0f : WM_event_tablet_data(event, &stroke->pen_flip, NULL);
pressure = (
(br->flag & (BRUSH_LINE | BRUSH_ANCHORED | BRUSH_DRAG_DOT)) ?
1.0f : WM_event_tablet_data(event, &stroke->pen_flip, NULL));
paint_stroke_add_sample(p, stroke, event->mval[0], event->mval[1], pressure);
paint_stroke_sample_average(stroke, &sample_average);

View File

@ -82,12 +82,13 @@
/* Convert the object-space axis-aligned bounding box (expressed as
* its minimum and maximum corners) into a screen-space rectangle,
* returns zero if the result is empty */
bool paint_convert_bb_to_rect(rcti *rect,
const float bb_min[3],
const float bb_max[3],
const ARegion *ar,
RegionView3D *rv3d,
Object *ob)
bool paint_convert_bb_to_rect(
rcti *rect,
const float bb_min[3],
const float bb_max[3],
const ARegion *ar,
RegionView3D *rv3d,
Object *ob)
{
float projection_mat[4][4];
int i, j, k;
@ -128,11 +129,12 @@ bool paint_convert_bb_to_rect(rcti *rect,
/* Get four planes in object-space that describe the projection of
* screen_rect from screen into object-space (essentially converting a
* 2D screens-space bounding box into four 3D planes) */
void paint_calc_redraw_planes(float planes[4][4],
const ARegion *ar,
RegionView3D *rv3d,
Object *ob,
const rcti *screen_rect)
void paint_calc_redraw_planes(
float planes[4][4],
const ARegion *ar,
RegionView3D *rv3d,
Object *ob,
const rcti *screen_rect)
{
BoundBox bb;
bglMats mats;
@ -152,8 +154,9 @@ void paint_calc_redraw_planes(float planes[4][4],
negate_m4(planes);
}
float paint_calc_object_space_radius(ViewContext *vc, const float center[3],
float pixel_radius)
float paint_calc_object_space_radius(
ViewContext *vc, const float center[3],
float pixel_radius)
{
Object *ob = vc->obact;
float delta[3], scale, loc[3];
@ -182,7 +185,9 @@ float paint_get_tex_pixel(const MTex *mtex, float u, float v, struct ImagePool *
return intensity;
}
void paint_get_tex_pixel_col(const MTex *mtex, float u, float v, float rgba[4], struct ImagePool *pool, int thread, bool convert_to_linear, struct ColorSpace *colorspace)
void paint_get_tex_pixel_col(
const MTex *mtex, float u, float v, float rgba[4], struct ImagePool *pool,
int thread, bool convert_to_linear, struct ColorSpace *colorspace)
{
float co[3] = {u, v, 0.0f};
int hasrgb;
@ -238,9 +243,10 @@ static void imapaint_project(float matrix[4][4], const float co[3], float pco[4]
mul_m4_v4(matrix, pco);
}
static void imapaint_tri_weights(float matrix[4][4], GLint view[4],
const float v1[3], const float v2[3], const float v3[3],
const float co[2], float w[3])
static void imapaint_tri_weights(
float matrix[4][4], GLint view[4],
const float v1[3], const float v2[3], const float v3[3],
const float co[2], float w[3])
{
float pv1[4], pv2[4], pv3[4], h[3], divw;
float wmat[3][3], invwmat[3][3];

View File

@ -1459,8 +1459,9 @@ static bool wpaint_stroke_test_start(bContext *C, wmOperator *op, const float mo
wpd = MEM_callocN(sizeof(struct WPaintData), "WPaintData");
paint_stroke_set_mode_data(stroke, wpd);
ED_view3d_viewcontext_init(C, &wpd->vc);
view_angle_limits_init(&wpd->normal_angle_precalc, vp->paint.brush->falloff_angle,
(vp->paint.brush->flag & BRUSH_FRONTFACE_FALLOFF) != 0);
view_angle_limits_init(
&wpd->normal_angle_precalc, vp->paint.brush->falloff_angle,
(vp->paint.brush->flag & BRUSH_FRONTFACE_FALLOFF) != 0);
wpd->active.index = vgroup_index.active;
wpd->mirror.index = vgroup_index.mirror;
@ -2449,13 +2450,13 @@ static bool vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const f
vpd = MEM_callocN(sizeof(*vpd), "VPaintData");
paint_stroke_set_mode_data(stroke, vpd);
ED_view3d_viewcontext_init(C, &vpd->vc);
view_angle_limits_init(&vpd->normal_angle_precalc, vp->paint.brush->falloff_angle,
(vp->paint.brush->flag & BRUSH_FRONTFACE_FALLOFF) != 0);
view_angle_limits_init(
&vpd->normal_angle_precalc, vp->paint.brush->falloff_angle,
(vp->paint.brush->flag & BRUSH_FRONTFACE_FALLOFF) != 0);
vpd->paintcol = vpaint_get_current_col(scene, vp);
vpd->is_texbrush = !(brush->vertexpaint_tool == PAINT_BLEND_BLUR) &&
brush->mtex.tex;
vpd->is_texbrush = !(brush->vertexpaint_tool == PAINT_BLEND_BLUR) && brush->mtex.tex;
/* are we painting onto a modified mesh?,
* if not we can skip face map trickiness */

View File

@ -148,8 +148,9 @@ void PAINT_OT_weight_from_bones(wmOperatorType *ot)
/* identifiers */
ot->name = "Weight from Bones";
ot->idname = "PAINT_OT_weight_from_bones";
ot->description = "Set the weights of the groups matching the attached armature's selected bones, "
"using the distance between the vertices and the bones";
ot->description = (
"Set the weights of the groups matching the attached armature's selected bones, "
"using the distance between the vertices and the bones");
/* api callbacks */
ot->exec = weight_from_bones_exec;