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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--release/scripts/startup/bl_ui/properties_paint_common.py6
-rw-r--r--source/blender/blenkernel/BKE_paint.h24
-rw-r--r--source/blender/blenkernel/intern/brush.c6
-rw-r--r--source/blender/blenkernel/intern/colortools.c1
-rw-r--r--source/blender/blenkernel/intern/paint.c54
-rw-r--r--source/blender/editors/interface/interface_handlers.c3
-rw-r--r--source/blender/editors/render/render_update.c5
-rw-r--r--source/blender/editors/sculpt_paint/paint_cursor.c106
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c8
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_2d.c2
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_proj.c2
-rw-r--r--source/blender/editors/sculpt_paint/paint_ops.c30
-rw-r--r--source/blender/editors/sculpt_paint/paint_stroke.c22
-rw-r--r--source/blender/editors/sculpt_paint/paint_utils.c15
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.c26
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c92
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_uv.c10
-rw-r--r--source/blender/editors/space_buttons/buttons_context.c2
-rw-r--r--source/blender/editors/space_buttons/buttons_texture.c2
-rw-r--r--source/blender/editors/space_image/image_draw.c4
-rw-r--r--source/blender/editors/space_view3d/drawobject.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c2
-rw-r--r--source/blender/makesrna/intern/rna_brush.c64
-rw-r--r--source/blender/makesrna/intern/rna_internal.h1
-rw-r--r--source/blender/makesrna/intern/rna_texture.c22
-rw-r--r--source/blender/nodes/texture/node_texture_tree.c4
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c9
27 files changed, 325 insertions, 199 deletions
diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py b/release/scripts/startup/bl_ui/properties_paint_common.py
index f2566b2f2f5..3b9256c6ec9 100644
--- a/release/scripts/startup/bl_ui/properties_paint_common.py
+++ b/release/scripts/startup/bl_ui/properties_paint_common.py
@@ -120,6 +120,12 @@ def brush_texture_settings(layout, brush, sculpt):
def brush_mask_texture_settings(layout, brush):
mask_tex_slot = brush.mask_texture_slot
+ layout.label(text="Mask Mapping:")
+
+ # map_mode
+ layout.row().prop(mask_tex_slot, "mask_map_mode", text="")
+ layout.separator()
+
if brush.mask_texture:
layout.label(text="Mask Mapping:")
col = layout.column()
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index 35941d0a05a..810ff2faabc 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -36,6 +36,7 @@ struct bContext;
struct BMesh;
struct BMFace;
struct Brush;
+struct CurveMapping;
struct MDisps;
struct MeshElemMap;
struct GridPaintMask;
@@ -47,6 +48,7 @@ struct Paint;
struct PBVH;
struct Scene;
struct StrokeCache;
+struct Tex;
struct ImagePool;
struct UnifiedPaintSettings;
@@ -65,16 +67,26 @@ typedef enum PaintMode {
PAINT_INVALID = 6
} PaintMode;
+/* overlay invalidation */
+#define PAINT_INVALID_OVERLAY_TEXTURE_PRIMARY 1
+#define PAINT_INVALID_OVERLAY_TEXTURE_SECONDARY 2
+#define PAINT_INVALID_OVERLAY_CURVE 4
+
+void BKE_paint_invalidate_overlay_tex (struct Scene *scene,const struct Tex *tex);
+void BKE_paint_invalidate_cursor_overlay (struct Scene *scene, struct CurveMapping *curve);
+void BKE_paint_invalidate_overlay_all(void);
+int BKE_paint_get_overlay_flags (void);
+void BKE_paint_reset_overlay_invalid (void);
+
void BKE_paint_init(struct Paint *p, const char col[3]);
void BKE_paint_free(struct Paint *p);
void BKE_paint_copy(struct Paint *src, struct Paint *tar);
-/* TODO, give these BKE_ prefix too */
-struct Paint *paint_get_active(struct Scene *sce);
-struct Paint *paint_get_active_from_context(const struct bContext *C);
-PaintMode paintmode_get_active_from_context(const struct bContext *C);
-struct Brush *paint_brush(struct Paint *paint);
-void paint_brush_set(struct Paint *paint, struct Brush *br);
+struct Paint *BKE_paint_get_active(struct Scene *sce);
+struct Paint *BKE_paint_get_active_from_context(const struct bContext *C);
+PaintMode BKE_paintmode_get_active_from_context(const struct bContext *C);
+struct Brush *BKE_paint_brush(struct Paint *paint);
+void BKE_paint_brush_set(struct Paint *paint, struct Brush *br);
/* testing face select mode
* Texture paint could be removed since selected faces are not used
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index e140bd1a68a..053c5ca9eed 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -224,7 +224,7 @@ void BKE_brush_make_local(Brush *brush)
}
for (scene = bmain->scene.first; scene && ELEM(0, is_lib, is_local); scene = scene->id.next) {
- if (paint_brush(&scene->toolsettings->imapaint.paint) == brush) {
+ if (BKE_paint_brush(&scene->toolsettings->imapaint.paint) == brush) {
if (scene->id.lib) is_lib = TRUE;
else is_local = TRUE;
}
@@ -249,9 +249,9 @@ void BKE_brush_make_local(Brush *brush)
BKE_id_lib_local_paths(bmain, brush->id.lib, &brush_new->id);
for (scene = bmain->scene.first; scene; scene = scene->id.next) {
- if (paint_brush(&scene->toolsettings->imapaint.paint) == brush) {
+ if (BKE_paint_brush(&scene->toolsettings->imapaint.paint) == brush) {
if (scene->id.lib == NULL) {
- paint_brush_set(&scene->toolsettings->imapaint.paint, brush_new);
+ BKE_paint_brush_set(&scene->toolsettings->imapaint.paint, brush_new);
}
}
}
diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c
index 04cc3cc6a09..7f533cdb553 100644
--- a/source/blender/blenkernel/intern/colortools.c
+++ b/source/blender/blenkernel/intern/colortools.c
@@ -47,6 +47,7 @@
#include "BKE_colortools.h"
#include "BKE_curve.h"
#include "BKE_fcurve.h"
+#include "BKE_paint.h"
#include "IMB_colormanagement.h"
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index cc647a90c8f..e232e339603 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -59,7 +59,47 @@ const char PAINT_CURSOR_VERTEX_PAINT[3] = {255, 255, 255};
const char PAINT_CURSOR_WEIGHT_PAINT[3] = {200, 200, 255};
const char PAINT_CURSOR_TEXTURE_PAINT[3] = {255, 255, 255};
-Paint *paint_get_active(Scene *sce)
+static int overlay_flags = 0;
+
+void BKE_paint_invalidate_overlay_tex (Scene *scene, const Tex *tex)
+{
+ Paint *p = BKE_paint_get_active(scene);
+ Brush *br = p->brush;
+
+ if (br->mtex.tex == tex)
+ overlay_flags |= PAINT_INVALID_OVERLAY_TEXTURE_PRIMARY;
+ if (br->mask_mtex.tex == tex)
+ overlay_flags |= PAINT_INVALID_OVERLAY_TEXTURE_SECONDARY;
+}
+
+void BKE_paint_invalidate_cursor_overlay (Scene *scene, CurveMapping *curve)
+{
+ Paint *p = BKE_paint_get_active(scene);
+ Brush *br = p->brush;
+
+ if (br->curve == curve)
+ overlay_flags |= PAINT_INVALID_OVERLAY_CURVE;
+}
+
+void BKE_paint_invalidate_overlay_all()
+{
+ overlay_flags |= PAINT_INVALID_OVERLAY_TEXTURE_SECONDARY;
+ overlay_flags |= PAINT_INVALID_OVERLAY_TEXTURE_PRIMARY;
+ overlay_flags |= PAINT_INVALID_OVERLAY_CURVE;
+}
+
+int BKE_paint_get_overlay_flags () {
+ return overlay_flags;
+}
+
+void BKE_paint_reset_overlay_invalid (void) {
+ overlay_flags &= ~(PAINT_INVALID_OVERLAY_TEXTURE_PRIMARY |
+ PAINT_INVALID_OVERLAY_TEXTURE_SECONDARY |
+ PAINT_INVALID_OVERLAY_CURVE);
+}
+
+
+Paint *BKE_paint_get_active(Scene *sce)
{
if (sce) {
ToolSettings *ts = sce->toolsettings;
@@ -89,7 +129,7 @@ Paint *paint_get_active(Scene *sce)
return NULL;
}
-Paint *paint_get_active_from_context(const bContext *C)
+Paint *BKE_paint_get_active_from_context(const bContext *C)
{
Scene *sce = CTX_data_scene(C);
SpaceImage *sima;
@@ -138,7 +178,7 @@ Paint *paint_get_active_from_context(const bContext *C)
return NULL;
}
-PaintMode paintmode_get_active_from_context(const bContext *C)
+PaintMode BKE_paintmode_get_active_from_context(const bContext *C)
{
Scene *sce = CTX_data_scene(C);
SpaceImage *sima;
@@ -187,12 +227,12 @@ PaintMode paintmode_get_active_from_context(const bContext *C)
return PAINT_INVALID;
}
-Brush *paint_brush(Paint *p)
+Brush *BKE_paint_brush(Paint *p)
{
return p ? p->brush : NULL;
}
-void paint_brush_set(Paint *p, Brush *br)
+void BKE_paint_brush_set(Paint *p, Brush *br)
{
if (p) {
id_us_min((ID *)p->brush);
@@ -228,10 +268,10 @@ void BKE_paint_init(Paint *p, const char col[3])
Brush *brush;
/* If there's no brush, create one */
- brush = paint_brush(p);
+ brush = BKE_paint_brush(p);
if (brush == NULL)
brush = BKE_brush_add(G.main, "Brush");
- paint_brush_set(p, brush);
+ BKE_paint_brush_set(p, brush);
memcpy(p->paint_cursor_col, col, 3);
p->paint_cursor_col[3] = 128;
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index cce20cfd41a..1e46b767139 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -63,6 +63,7 @@
#include "BKE_texture.h"
#include "BKE_tracking.h"
#include "BKE_unit.h"
+#include "BKE_paint.h"
#include "ED_screen.h"
#include "ED_util.h"
@@ -4323,6 +4324,7 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt
{
int mx, my, a;
bool changed = false;
+ Scene *scene = CTX_data_scene(C);
mx = event->x;
my = event->y;
@@ -4451,6 +4453,7 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt
}
else {
curvemapping_changed(cumap, true); /* remove doubles */
+ BKE_paint_invalidate_cursor_overlay(scene, cumap);
}
}
diff --git a/source/blender/editors/render/render_update.c b/source/blender/editors/render/render_update.c
index d29c711cad0..f19ea08f381 100644
--- a/source/blender/editors/render/render_update.c
+++ b/source/blender/editors/render/render_update.c
@@ -53,6 +53,7 @@
#include "BKE_main.h"
#include "BKE_material.h"
#include "BKE_node.h"
+#include "BKE_paint.h"
#include "BKE_scene.h"
#include "BKE_texture.h"
#include "BKE_world.h"
@@ -333,6 +334,10 @@ static void texture_changed(Main *bmain, Tex *tex)
/* icons */
BKE_icon_changed(BKE_icon_getid(&tex->id));
+ /* paint overlays */
+ for (scene = bmain->scene.first; scene; scene = scene->id.next)
+ BKE_paint_invalidate_overlay_tex(scene, tex);
+
/* find materials */
for (ma = bmain->mat.first; ma; ma = ma->id.next) {
if (!material_uses_texture(ma, tex))
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c
index a27ef91df24..32cc6953c78 100644
--- a/source/blender/editors/sculpt_paint/paint_cursor.c
+++ b/source/blender/editors/sculpt_paint/paint_cursor.c
@@ -67,53 +67,34 @@
* There is also some ugliness with sculpt-specific code.
*/
-typedef struct Snapshot {
- float size[3];
- float ofs[3];
- float rot;
- int BKE_brush_size_get;
+typedef struct TexSnapshot {
int winx;
int winy;
- int brush_map_mode;
+ bool init;
+} TexSnapshot;
+
+typedef struct CurveSnapshot {
+ int BKE_brush_size_get;
int curve_changed_timestamp;
-} Snapshot;
+ bool init;
+} CurveSnapshot;
-static int same_snap(Snapshot *snap, Brush *brush, ViewContext *vc)
+static int same_tex_snap(TexSnapshot *snap, Brush *brush, ViewContext *vc)
{
MTex *mtex = &brush->mtex;
- return (((mtex->tex) &&
- equals_v3v3(mtex->ofs, snap->ofs) &&
- equals_v3v3(mtex->size, snap->size) &&
- (brush->mtex.brush_map_mode == MTEX_MAP_MODE_STENCIL ||
- mtex->rot == snap->rot)) &&
-
- /* make brush smaller shouldn't cause a resample */
- ((mtex->brush_map_mode == MTEX_MAP_MODE_VIEW &&
- (BKE_brush_size_get(vc->scene, brush) <= snap->BKE_brush_size_get)) ||
- (BKE_brush_size_get(vc->scene, brush) == snap->BKE_brush_size_get)) &&
+ return (/* make brush smaller shouldn't cause a resample */
+ //(mtex->brush_map_mode != MTEX_MAP_MODE_VIEW ||
+ //(BKE_brush_size_get(vc->scene, brush) <= snap->BKE_brush_size_get)) &&
- (mtex->brush_map_mode == snap->brush_map_mode) &&
- (vc->ar->winx == snap->winx) &&
- (vc->ar->winy == snap->winy));
+ (mtex->brush_map_mode != MTEX_MAP_MODE_TILED ||
+ (vc->ar->winx == snap->winx &&
+ vc->ar->winy == snap->winy))
+ );
}
-static void make_snap(Snapshot *snap, Brush *brush, ViewContext *vc)
+static void make_tex_snap(TexSnapshot *snap, ViewContext *vc)
{
- if (brush->mtex.tex) {
- snap->brush_map_mode = brush->mtex.brush_map_mode;
- copy_v3_v3(snap->ofs, brush->mtex.ofs);
- copy_v3_v3(snap->size, brush->mtex.size);
- snap->rot = brush->mtex.rot;
- }
- else {
- snap->brush_map_mode = -1;
- snap->ofs[0] = snap->ofs[1] = snap->ofs[2] = -1;
- snap->size[0] = snap->size[1] = snap->size[2] = -1;
- snap->rot = -1;
- }
-
- snap->BKE_brush_size_get = BKE_brush_size_get(vc->scene, brush);
snap->winx = vc->ar->winx;
snap->winy = vc->ar->winy;
}
@@ -122,13 +103,12 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col)
{
static GLuint overlay_texture = 0;
static int init = 0;
- static int tex_changed_timestamp = -1;
- static int curve_changed_timestamp = -1;
- static Snapshot snap;
+ static TexSnapshot snap;
static int old_size = -1;
static int old_zoom = -1;
static bool old_col = -1;
+ int invalid = BKE_paint_get_overlay_flags();
GLubyte *buffer = NULL;
int size;
@@ -136,18 +116,17 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col)
int refresh;
GLenum format = col ? GL_RGBA : GL_ALPHA;
- if (br->mtex.brush_map_mode == MTEX_MAP_MODE_TILED && !br->mtex.tex) return 0;
+ if (br->mtex.brush_map_mode != MTEX_MAP_MODE_VIEW && !br->mtex.tex) return 0;
refresh =
!overlay_texture ||
(br->mtex.tex &&
- (!br->mtex.tex->preview ||
- br->mtex.tex->preview->changed_timestamp[0] != tex_changed_timestamp)) ||
- !br->curve ||
- br->curve->changed_timestamp != curve_changed_timestamp ||
+ (invalid & PAINT_INVALID_OVERLAY_TEXTURE_PRIMARY)) ||
+ (br->curve &&
+ (invalid & PAINT_INVALID_OVERLAY_CURVE)) ||
old_zoom != zoom ||
old_col != col ||
- !same_snap(&snap, br, vc);
+ !same_tex_snap(&snap, br, vc);
if (refresh) {
struct ImagePool *pool = NULL;
@@ -157,14 +136,8 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col)
float radius = BKE_brush_size_get(vc->scene, br) * zoom;
- if (br->mtex.tex && br->mtex.tex->preview)
- tex_changed_timestamp = br->mtex.tex->preview->changed_timestamp[0];
-
- if (br->curve)
- curve_changed_timestamp = br->curve->changed_timestamp;
-
old_zoom = zoom;
- make_snap(&snap, br, vc);
+ make_tex_snap(&snap, vc);
if (br->mtex.brush_map_mode == MTEX_MAP_MODE_VIEW) {
int s = BKE_brush_size_get(vc->scene, br);
@@ -255,9 +228,11 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col)
if (br->mtex.tex)
paint_get_tex_pixel_col(&br->mtex, x, y, rgba, pool);
- if (br->mtex.brush_map_mode == MTEX_MAP_MODE_VIEW)
- mul_v4_fl(rgba, BKE_brush_curve_strength(br, len, 1)); /* Falloff curve */
-
+ if (br->mtex.brush_map_mode == MTEX_MAP_MODE_VIEW) {
+ float curve_str = BKE_brush_curve_strength(br, len, 1);
+ CLAMP(curve_str, 0.0, 1.0);
+ mul_v4_fl(rgba, curve_str); /* Falloff curve */
+ }
buffer[index * 4] = rgba[0] * 255;
buffer[index * 4 + 1] = rgba[1] * 255;
buffer[index * 4 + 2] = rgba[2] * 255;
@@ -271,6 +246,8 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col)
if (br->mtex.brush_map_mode == MTEX_MAP_MODE_VIEW)
avg *= BKE_brush_curve_strength(br, len, 1); /* Falloff curve */
+ /* clamp to avoid precision overflow */
+ CLAMP(avg, 0.0, 1.0);
buffer[index] = 255 - (GLubyte)(255 * avg);
}
}
@@ -326,6 +303,8 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
}
+ BKE_paint_reset_overlay_invalid();
+
return 1;
}
@@ -381,7 +360,7 @@ static int sculpt_get_brush_geometry(bContext *C, ViewContext *vc,
float location[3])
{
Scene *scene = CTX_data_scene(C);
- Paint *paint = paint_get_active_from_context(C);
+ Paint *paint = BKE_paint_get_active_from_context(C);
float mouse[2];
int hit;
@@ -391,7 +370,7 @@ static int sculpt_get_brush_geometry(bContext *C, ViewContext *vc,
if (vc->obact->sculpt && vc->obact->sculpt->pbvh &&
sculpt_stroke_get_location(C, location, mouse))
{
- Brush *brush = paint_brush(paint);
+ Brush *brush = BKE_paint_brush(paint);
*pixel_radius =
project_brush_radius(vc,
BKE_brush_unprojected_radius_get(scene, brush),
@@ -406,7 +385,7 @@ static int sculpt_get_brush_geometry(bContext *C, ViewContext *vc,
}
else {
Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
- Brush *brush = paint_brush(&sd->paint);
+ Brush *brush = BKE_paint_brush(&sd->paint);
*pixel_radius = BKE_brush_size_get(scene, brush);
hit = 0;
@@ -576,8 +555,8 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
{
Scene *scene = CTX_data_scene(C);
UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
- Paint *paint = paint_get_active_from_context(C);
- Brush *brush = paint_brush(paint);
+ Paint *paint = BKE_paint_get_active_from_context(C);
+ Brush *brush = BKE_paint_brush(paint);
ViewContext vc;
PaintMode mode;
float final_radius;
@@ -595,7 +574,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
get_imapaint_zoom(C, &zoomx, &zoomy);
zoomx = max_ff(zoomx, zoomy);
- mode = paintmode_get_active_from_context(C);
+ mode = BKE_paintmode_get_active_from_context(C);
/* set various defaults */
translation[0] = x;
@@ -677,10 +656,13 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
void paint_cursor_start(bContext *C, int (*poll)(bContext *C))
{
- Paint *p = paint_get_active_from_context(C);
+ Paint *p = BKE_paint_get_active_from_context(C);
if (p && !p->paint_cursor)
p->paint_cursor = WM_paint_cursor_activate(CTX_wm_manager(C), poll, paint_draw_cursor, NULL);
+
+ /* invalidate the paint cursors */
+ BKE_paint_invalidate_overlay_all();
}
void paint_cursor_start_explicit(Paint *p, wmWindowManager *wm, int (*poll)(bContext *C))
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index e1988215fc1..fbc71d90a93 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -343,7 +343,7 @@ static Brush *image_paint_brush(bContext *C)
Scene *scene = CTX_data_scene(C);
ToolSettings *settings = scene->toolsettings;
- return paint_brush(&settings->imapaint.paint);
+ return BKE_paint_brush(&settings->imapaint.paint);
}
static int image_paint_poll(bContext *C)
@@ -487,7 +487,7 @@ static void paint_stroke_update_step(bContext *C, struct PaintStroke *stroke, Po
{
PaintOperation *pop = paint_stroke_mode_data(stroke);
Scene *scene = CTX_data_scene(C);
- Brush *brush = paint_brush(&scene->toolsettings->imapaint.paint);
+ Brush *brush = BKE_paint_brush(&scene->toolsettings->imapaint.paint);
/* initial brush values. Maybe it should be considered moving these to stroke system */
float startsize = BKE_brush_size_get(scene, brush);
@@ -652,8 +652,8 @@ void brush_drawcursor_texpaint_uvsculpt(bContext *C, int x, int y, void *UNUSED(
Scene *scene = CTX_data_scene(C);
//Brush *brush = image_paint_brush(C);
- Paint *paint = paint_get_active_from_context(C);
- Brush *brush = paint_brush(paint);
+ Paint *paint = BKE_paint_get_active_from_context(C);
+ Brush *brush = BKE_paint_brush(paint);
if (paint && brush && paint->flags & PAINT_SHOW_BRUSH) {
float zoomx, zoomy;
diff --git a/source/blender/editors/sculpt_paint/paint_image_2d.c b/source/blender/editors/sculpt_paint/paint_image_2d.c
index 6032a7a4c22..5452d9fb7e8 100644
--- a/source/blender/editors/sculpt_paint/paint_image_2d.c
+++ b/source/blender/editors/sculpt_paint/paint_image_2d.c
@@ -754,7 +754,7 @@ void *paint_2d_new_stroke(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
ToolSettings *settings = scene->toolsettings;
- Brush *brush = paint_brush(&settings->imapaint.paint);
+ Brush *brush = BKE_paint_brush(&settings->imapaint.paint);
ImagePaintState *s = MEM_callocN(sizeof(ImagePaintState), "ImagePaintState");
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c
index bf897913b6c..8c1b590cdda 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -4151,7 +4151,7 @@ static void project_state_init(bContext *C, Object *ob, ProjPaintState *ps, int
/* brush */
ps->mode = mode;
- ps->brush = paint_brush(&settings->imapaint.paint);
+ ps->brush = BKE_paint_brush(&settings->imapaint.paint);
if (ps->brush) {
Brush *brush = ps->brush;
ps->tool = brush->imagepaint_tool;
diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c
index d5c5d9ee150..f1207aa5706 100644
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@ -63,8 +63,8 @@
static int brush_add_exec(bContext *C, wmOperator *UNUSED(op))
{
/*int type = RNA_enum_get(op->ptr, "type");*/
- Paint *paint = paint_get_active_from_context(C);
- Brush *br = paint_brush(paint);
+ Paint *paint = BKE_paint_get_active_from_context(C);
+ Brush *br = BKE_paint_brush(paint);
Main *bmain = CTX_data_main(C);
if (br)
@@ -72,7 +72,7 @@ static int brush_add_exec(bContext *C, wmOperator *UNUSED(op))
else
br = BKE_brush_add(bmain, "Brush");
- paint_brush_set(paint, br);
+ BKE_paint_brush_set(paint, br);
return OPERATOR_FINISHED;
}
@@ -95,8 +95,8 @@ static void BRUSH_OT_add(wmOperatorType *ot)
static int brush_scale_size_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
- Paint *paint = paint_get_active_from_context(C);
- Brush *brush = paint_brush(paint);
+ Paint *paint = BKE_paint_get_active_from_context(C);
+ Brush *brush = BKE_paint_brush(paint);
// Object *ob = CTX_data_active_object(C);
float scalar = RNA_float_get(op->ptr, "scalar");
@@ -177,8 +177,8 @@ static void PAINT_OT_vertex_color_set(wmOperatorType *ot)
static int brush_reset_exec(bContext *C, wmOperator *UNUSED(op))
{
- Paint *paint = paint_get_active_from_context(C);
- Brush *brush = paint_brush(paint);
+ Paint *paint = BKE_paint_get_active_from_context(C);
+ Brush *brush = BKE_paint_brush(paint);
Object *ob = CTX_data_active_object(C);
if (!ob || !brush) return OPERATOR_CANCELLED;
@@ -268,7 +268,7 @@ static int brush_generic_tool_set(Main *bmain, Paint *paint, const int tool,
const char *tool_name, int create_missing,
int toggle)
{
- Brush *brush, *brush_orig = paint_brush(paint);
+ Brush *brush, *brush_orig = BKE_paint_brush(paint);
if (toggle)
brush = brush_tool_toggle(bmain, brush_orig, tool, tool_offset, ob_mode);
@@ -283,7 +283,7 @@ static int brush_generic_tool_set(Main *bmain, Paint *paint, const int tool,
}
if (brush) {
- paint_brush_set(paint, brush);
+ BKE_paint_brush_set(paint, brush);
WM_main_add_notifier(NC_BRUSH | NA_EDITED, brush);
return OPERATOR_FINISHED;
}
@@ -475,8 +475,8 @@ typedef struct {
static int stencil_control_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- Paint *paint = paint_get_active_from_context(C);
- Brush *br = paint_brush(paint);
+ Paint *paint = BKE_paint_get_active_from_context(C);
+ Brush *br = BKE_paint_brush(paint);
float mdiff[2];
float mvalf[2] = {event->mval[0], event->mval[1]};
@@ -604,8 +604,8 @@ static int stencil_control_modal(bContext *C, wmOperator *op, const wmEvent *eve
static int stencil_control_poll(bContext *C)
{
- Paint *paint = paint_get_active_from_context(C);
- Brush *br = paint_brush(paint);
+ Paint *paint = BKE_paint_get_active_from_context(C);
+ Brush *br = BKE_paint_brush(paint);
return (br && br->mtex.brush_map_mode == MTEX_MAP_MODE_STENCIL);
}
@@ -638,8 +638,8 @@ static void BRUSH_OT_stencil_control(wmOperatorType *ot)
static int stencil_fit_image_aspect_exec(bContext *C, wmOperator *UNUSED(op))
{
- Paint *paint = paint_get_active_from_context(C);
- Brush *br = paint_brush(paint);
+ Paint *paint = BKE_paint_get_active_from_context(C);
+ Brush *br = BKE_paint_brush(paint);
Tex *tex = (br)? br->mtex.tex : NULL;
if (tex && tex->type == TEX_IMAGE && tex->ima) {
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c
index 1c0830a8158..2be5d62c105 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -107,8 +107,8 @@ typedef struct PaintStroke {
/*** Cursor ***/
static void paint_draw_smooth_stroke(bContext *C, int x, int y, void *customdata)
{
- Paint *paint = paint_get_active_from_context(C);
- Brush *brush = paint_brush(paint);
+ Paint *paint = BKE_paint_get_active_from_context(C);
+ Brush *brush = BKE_paint_brush(paint);
PaintStroke *stroke = customdata;
if (stroke && brush && (brush->flag & BRUSH_SMOOTH_STROKE)) {
@@ -243,9 +243,9 @@ static void paint_brush_update(bContext *C, Brush *brush, PaintMode mode,
static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, const wmEvent *event, const float mouse_in[2])
{
Scene *scene = CTX_data_scene(C);
- Paint *paint = paint_get_active_from_context(C);
- PaintMode mode = paintmode_get_active_from_context(C);
- Brush *brush = paint_brush(paint);
+ Paint *paint = BKE_paint_get_active_from_context(C);
+ PaintMode mode = BKE_paintmode_get_active_from_context(C);
+ Brush *brush = BKE_paint_brush(paint);
PaintStroke *stroke = op->customdata;
float mouse_out[2];
PointerRNA itemptr;
@@ -344,7 +344,7 @@ static int paint_smooth_stroke(PaintStroke *stroke, float output[2],
static int paint_space_stroke(bContext *C, wmOperator *op, const wmEvent *event, const float final_mouse[2])
{
PaintStroke *stroke = op->customdata;
- PaintMode mode = paintmode_get_active_from_context(C);
+ PaintMode mode = BKE_paintmode_get_active_from_context(C);
int cnt = 0;
@@ -411,7 +411,7 @@ PaintStroke *paint_stroke_new(bContext *C,
{
PaintStroke *stroke = MEM_callocN(sizeof(PaintStroke), "PaintStroke");
- stroke->brush = paint_brush(paint_get_active_from_context(C));
+ stroke->brush = BKE_paint_brush(BKE_paint_get_active_from_context(C));
view3d_set_viewcontext(C, &stroke->vc);
if (stroke->vc.v3d)
view3d_get_transformation(stroke->vc.ar, stroke->vc.rv3d, stroke->vc.obact, &stroke->mats);
@@ -586,8 +586,8 @@ static void paint_stroke_sample_average(const PaintStroke *stroke,
int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
- Paint *p = paint_get_active_from_context(C);
- PaintMode mode = paintmode_get_active_from_context(C);
+ Paint *p = BKE_paint_get_active_from_context(C);
+ PaintMode mode = BKE_paintmode_get_active_from_context(C);
PaintStroke *stroke = op->customdata;
PaintSample sample_average;
float mouse[2];
@@ -716,12 +716,12 @@ void paint_stroke_set_mode_data(PaintStroke *stroke, void *mode_data)
int paint_poll(bContext *C)
{
- Paint *p = paint_get_active_from_context(C);
+ Paint *p = BKE_paint_get_active_from_context(C);
Object *ob = CTX_data_active_object(C);
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
- return p && ob && paint_brush(p) &&
+ return p && ob && BKE_paint_brush(p) &&
(sa && sa->spacetype == SPACE_VIEW3D) &&
(ar && ar->regiontype == RGN_TYPE_WINDOW);
}
diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c
index 315fdd2fb32..0bf27267c89 100644
--- a/source/blender/editors/sculpt_paint/paint_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_utils.c
@@ -206,6 +206,10 @@ void paint_get_tex_pixel_col(MTex *mtex, float u, float v, float rgba[4], struct
rgba[2] = intensity;
rgba[3] = 1.0f;
}
+ CLAMP(rgba[0], 0.0, 1.0);
+ CLAMP(rgba[1], 0.0, 1.0);
+ CLAMP(rgba[2], 0.0, 1.0);
+ CLAMP(rgba[3], 0.0, 1.0);
}
/* 3D Paint */
@@ -358,7 +362,7 @@ int imapaint_pick_face(ViewContext *vc, const int mval[2], unsigned int *index,
/* used for both 3d view and image window */
void paint_sample_color(const bContext *C, ARegion *ar, int x, int y) /* frontbuf */
{
- Brush *br = paint_brush(paint_get_active_from_context(C));
+ Brush *br = BKE_paint_brush(BKE_paint_get_active_from_context(C));
unsigned int col;
char *cp;
@@ -380,17 +384,20 @@ void paint_sample_color(const bContext *C, ARegion *ar, int x, int y) /* fron
static int brush_curve_preset_exec(bContext *C, wmOperator *op)
{
- Brush *br = paint_brush(paint_get_active_from_context(C));
+ Brush *br = BKE_paint_brush(BKE_paint_get_active_from_context(C));
- if (br)
+ if (br) {
+ Scene *scene = CTX_data_scene(C);
BKE_brush_curve_preset(br, RNA_enum_get(op->ptr, "shape"));
+ BKE_paint_invalidate_cursor_overlay(scene, br->curve);
+ }
return OPERATOR_FINISHED;
}
static int brush_curve_preset_poll(bContext *C)
{
- Brush *br = paint_brush(paint_get_active_from_context(C));
+ Brush *br = BKE_paint_brush(BKE_paint_get_active_from_context(C));
return br && br->curve;
}
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index 2eca3f94e95..d0f1bb882a3 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -157,7 +157,7 @@ int vertex_paint_mode_poll(bContext *C)
int vertex_paint_poll(bContext *C)
{
if (vertex_paint_mode_poll(C) &&
- paint_brush(&CTX_data_tool_settings(C)->vpaint->paint))
+ BKE_paint_brush(&CTX_data_tool_settings(C)->vpaint->paint))
{
ScrArea *sa = CTX_wm_area(C);
if (sa && sa->spacetype == SPACE_VIEW3D) {
@@ -183,7 +183,7 @@ int weight_paint_poll(bContext *C)
if ((ob != NULL) &&
(ob->mode & OB_MODE_WEIGHT_PAINT) &&
- (paint_brush(&CTX_data_tool_settings(C)->wpaint->paint) != NULL) &&
+ (BKE_paint_brush(&CTX_data_tool_settings(C)->wpaint->paint) != NULL) &&
(sa = CTX_wm_area(C)) &&
(sa->spacetype == SPACE_VIEW3D))
{
@@ -214,7 +214,7 @@ static int *get_indexarray(Mesh *me)
unsigned int vpaint_get_current_col(VPaint *vp)
{
- Brush *brush = paint_brush(&vp->paint);
+ Brush *brush = BKE_paint_brush(&vp->paint);
unsigned char col[4];
rgb_float_to_uchar(col, brush->rgb);
col[3] = 255; /* alpha isn't used, could even be removed to speedup paint a little */
@@ -785,7 +785,7 @@ static unsigned int vpaint_blend(VPaint *vp, unsigned int col, unsigned int colo
/* pre scaled from [0-1] --> [0-255] */
const int brush_alpha_value_i)
{
- Brush *brush = paint_brush(&vp->paint);
+ Brush *brush = BKE_paint_brush(&vp->paint);
const int tool = brush->vertexpaint_tool;
col = vpaint_blend_tool(tool, col, paintcol, alpha_i);
@@ -871,7 +871,7 @@ static float calc_vp_strength_col_dl(VPaint *vp, ViewContext *vc, const float co
sub_v2_v2v2(delta, mval, co_ss);
dist_squared = dot_v2v2(delta, delta); /* len squared */
if (dist_squared <= brush_size_pressure * brush_size_pressure) {
- Brush *brush = paint_brush(&vp->paint);
+ Brush *brush = BKE_paint_brush(&vp->paint);
const float dist = sqrtf(dist_squared);
if (brush->mtex.tex && rgba) {
if (brush->mtex.brush_map_mode == MTEX_MAP_MODE_3D) {
@@ -978,7 +978,7 @@ static float wpaint_blend(VPaint *wp, float weight, float weight_prev,
const float brush_alpha_value,
const short do_flip, const short do_multipaint_totsel)
{
- Brush *brush = paint_brush(&wp->paint);
+ Brush *brush = BKE_paint_brush(&wp->paint);
int tool = brush->vertexpaint_tool;
if (do_flip) {
@@ -1062,7 +1062,7 @@ static int weight_sample_invoke(bContext *C, wmOperator *op, const wmEvent *even
if (v_idx_best != -1) { /* should always be valid */
ToolSettings *ts = vc.scene->toolsettings;
- Brush *brush = paint_brush(&ts->wpaint->paint);
+ Brush *brush = BKE_paint_brush(&ts->wpaint->paint);
const int vgroup_active = vc.obact->actdef - 1;
float vgroup_weight = defvert_find_weight(&me->dvert[v_idx_best], vgroup_active);
BKE_brush_weight_set(vc.scene, brush, vgroup_weight);
@@ -2202,7 +2202,7 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
Scene *scene = CTX_data_scene(C);
ToolSettings *ts = CTX_data_tool_settings(C);
VPaint *wp = ts->wpaint;
- Brush *brush = paint_brush(&wp->paint);
+ Brush *brush = BKE_paint_brush(&wp->paint);
struct WPaintData *wpd = paint_stroke_mode_data(stroke);
ViewContext *vc;
Object *ob;
@@ -2539,7 +2539,7 @@ static int weight_paint_set_exec(bContext *C, wmOperator *op)
struct Scene *scene = CTX_data_scene(C);
Object *obact = CTX_data_active_object(C);
ToolSettings *ts = CTX_data_tool_settings(C);
- Brush *brush = paint_brush(&ts->wpaint->paint);
+ Brush *brush = BKE_paint_brush(&ts->wpaint->paint);
float vgroup_weight = BKE_brush_weight_get(scene, brush);
if (wpaint_ensure_data(C, op) == FALSE) {
@@ -2713,7 +2713,7 @@ static int vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const fl
ToolSettings *ts = CTX_data_tool_settings(C);
struct PaintStroke *stroke = op->customdata;
VPaint *vp = ts->vpaint;
- Brush *brush = paint_brush(&vp->paint);
+ Brush *brush = BKE_paint_brush(&vp->paint);
struct VPaintData *vpd;
Object *ob = CTX_data_active_object(C);
Mesh *me;
@@ -2779,7 +2779,7 @@ static void vpaint_paint_poly(VPaint *vp, VPaintData *vpd, Mesh *me,
const float brush_size_pressure, const float brush_alpha_pressure)
{
ViewContext *vc = &vpd->vc;
- Brush *brush = paint_brush(&vp->paint);
+ Brush *brush = BKE_paint_brush(&vp->paint);
MPoly *mpoly = &me->mpoly[index];
MFace *mf;
MCol *mc;
@@ -2876,7 +2876,7 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
ToolSettings *ts = CTX_data_tool_settings(C);
struct VPaintData *vpd = paint_stroke_mode_data(stroke);
VPaint *vp = ts->vpaint;
- Brush *brush = paint_brush(&vp->paint);
+ Brush *brush = BKE_paint_brush(&vp->paint);
ViewContext *vc = &vpd->vc;
Object *ob = vc->obact;
Mesh *me = ob->data;
@@ -3277,7 +3277,7 @@ static int paint_weight_gradient_exec(bContext *C, wmOperator *op)
{
ToolSettings *ts = CTX_data_tool_settings(C);
VPaint *wp = ts->wpaint;
- struct Brush *brush = paint_brush(&wp->paint);
+ struct Brush *brush = BKE_paint_brush(&wp->paint);
data.brush = brush;
data.weightpaint = BKE_brush_weight_get(scene, brush);
}
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 682e3c7ced2..3dd6decfcff 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -419,7 +419,7 @@ static void paint_mesh_restore_co(Sculpt *sd, Object *ob)
{
SculptSession *ss = ob->sculpt;
StrokeCache *cache = ss->cache;
- const Brush *brush = paint_brush(&sd->paint);
+ const Brush *brush = BKE_paint_brush(&sd->paint);
int i;
PBVHNode **nodes;
@@ -823,7 +823,7 @@ static float calc_symmetry_feather(Sculpt *sd, StrokeCache *cache)
static float brush_strength(Sculpt *sd, StrokeCache *cache, float feather)
{
const Scene *scene = cache->vc->scene;
- Brush *brush = paint_brush(&sd->paint);
+ Brush *brush = BKE_paint_brush(&sd->paint);
/* Primary strength input; square it to make lower values more sensitive */
const float root_alpha = BKE_brush_alpha_get(scene, brush);
@@ -1057,7 +1057,7 @@ static void calc_area_normal(Sculpt *sd, Object *ob, float an[3], PBVHNode **nod
/* Grab brush requires to test on original data (see r33888 and
* bug #25371) */
- original = (paint_brush(&sd->paint)->sculpt_tool == SCULPT_TOOL_GRAB ?
+ original = (BKE_paint_brush(&sd->paint)->sculpt_tool == SCULPT_TOOL_GRAB ?
TRUE : ss->cache->original);
/* In general the original coords are not available with dynamic
@@ -1128,7 +1128,7 @@ static void calc_sculpt_normal(Sculpt *sd, Object *ob,
PBVHNode **nodes, int totnode,
float an[3])
{
- const Brush *brush = paint_brush(&sd->paint);
+ const Brush *brush = BKE_paint_brush(&sd->paint);
const SculptSession *ss = ob->sculpt;
switch (brush->sculpt_plane) {
@@ -1167,7 +1167,7 @@ static void calc_sculpt_normal(Sculpt *sd, Object *ob,
static void update_sculpt_normal(Sculpt *sd, Object *ob,
PBVHNode **nodes, int totnode)
{
- const Brush *brush = paint_brush(&sd->paint);
+ const Brush *brush = BKE_paint_brush(&sd->paint);
StrokeCache *cache = ob->sculpt->cache;
if (cache->mirror_symmetry_pass == 0 &&
@@ -1252,7 +1252,7 @@ static void update_brush_local_mat(Sculpt *sd, Object *ob)
if (cache->mirror_symmetry_pass == 0 &&
cache->radial_symmetry_pass == 0)
{
- calc_brush_local_mat(paint_brush(&sd->paint), ob,
+ calc_brush_local_mat(BKE_paint_brush(&sd->paint), ob,
cache->brush_local_mat);
}
}
@@ -1417,7 +1417,7 @@ static float bmesh_neighbor_average_mask(BMesh *bm, BMVert *v)
static void do_mesh_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *node, float bstrength, int smooth_mask)
{
- Brush *brush = paint_brush(&sd->paint);
+ Brush *brush = BKE_paint_brush(&sd->paint);
PBVHVertexIter vd;
SculptBrushTest test;
@@ -1458,7 +1458,7 @@ static void do_mesh_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *node,
static void do_bmesh_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *node, float bstrength, int smooth_mask)
{
- Brush *brush = paint_brush(&sd->paint);
+ Brush *brush = BKE_paint_brush(&sd->paint);
PBVHVertexIter vd;
SculptBrushTest test;
@@ -1500,7 +1500,7 @@ static void do_bmesh_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *node,
static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *node,
float bstrength, int smooth_mask)
{
- Brush *brush = paint_brush(&sd->paint);
+ Brush *brush = BKE_paint_brush(&sd->paint);
SculptBrushTest test;
CCGElem **griddata, *data;
CCGKey key;
@@ -1699,7 +1699,7 @@ static void do_smooth_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod
static void do_mask_brush_draw(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
{
SculptSession *ss = ob->sculpt;
- Brush *brush = paint_brush(&sd->paint);
+ Brush *brush = BKE_paint_brush(&sd->paint);
float bstrength = ss->cache->bstrength;
int n;
@@ -1731,7 +1731,7 @@ static void do_mask_brush_draw(Sculpt *sd, Object *ob, PBVHNode **nodes, int tot
static void do_mask_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
{
SculptSession *ss = ob->sculpt;
- Brush *brush = paint_brush(&sd->paint);
+ Brush *brush = BKE_paint_brush(&sd->paint);
switch ((BrushMaskTool)brush->mask_tool) {
case BRUSH_MASK_DRAW:
@@ -1746,7 +1746,7 @@ static void do_mask_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
static void do_draw_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
{
SculptSession *ss = ob->sculpt;
- Brush *brush = paint_brush(&sd->paint);
+ Brush *brush = BKE_paint_brush(&sd->paint);
float offset[3];
float bstrength = ss->cache->bstrength;
int n;
@@ -1789,7 +1789,7 @@ static void do_crease_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod
{
SculptSession *ss = ob->sculpt;
const Scene *scene = ss->cache->vc->scene;
- Brush *brush = paint_brush(&sd->paint);
+ Brush *brush = BKE_paint_brush(&sd->paint);
float offset[3];
float bstrength = ss->cache->bstrength;
float flippedbstrength, crease_correction;
@@ -1853,7 +1853,7 @@ static void do_crease_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod
static void do_pinch_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
{
SculptSession *ss = ob->sculpt;
- Brush *brush = paint_brush(&sd->paint);
+ Brush *brush = BKE_paint_brush(&sd->paint);
float bstrength = ss->cache->bstrength;
int n;
@@ -1889,7 +1889,7 @@ static void do_pinch_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode
static void do_grab_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
{
SculptSession *ss = ob->sculpt;
- Brush *brush = paint_brush(&sd->paint);
+ Brush *brush = BKE_paint_brush(&sd->paint);
float bstrength = ss->cache->bstrength;
float grab_delta[3];
int n;
@@ -1943,7 +1943,7 @@ static void do_grab_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
static void do_nudge_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
{
SculptSession *ss = ob->sculpt;
- Brush *brush = paint_brush(&sd->paint);
+ Brush *brush = BKE_paint_brush(&sd->paint);
float bstrength = ss->cache->bstrength;
float grab_delta[3];
float tmp[3], cono[3];
@@ -1984,7 +1984,7 @@ static void do_nudge_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode
static void do_snake_hook_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
{
SculptSession *ss = ob->sculpt;
- Brush *brush = paint_brush(&sd->paint);
+ Brush *brush = BKE_paint_brush(&sd->paint);
float bstrength = ss->cache->bstrength;
float grab_delta[3];
int n;
@@ -2033,7 +2033,7 @@ static void do_snake_hook_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int to
static void do_thumb_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
{
SculptSession *ss = ob->sculpt;
- Brush *brush = paint_brush(&sd->paint);
+ Brush *brush = BKE_paint_brush(&sd->paint);
float bstrength = ss->cache->bstrength;
float grab_delta[3];
float tmp[3], cono[3];
@@ -2082,7 +2082,7 @@ static void do_thumb_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode
static void do_rotate_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
{
SculptSession *ss = ob->sculpt;
- Brush *brush = paint_brush(&sd->paint);
+ Brush *brush = BKE_paint_brush(&sd->paint);
float bstrength = ss->cache->bstrength;
int n;
float m[4][4], rot[4][4], lmat[4][4], ilmat[4][4];
@@ -2138,7 +2138,7 @@ static void do_rotate_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod
static void do_layer_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
{
SculptSession *ss = ob->sculpt;
- Brush *brush = paint_brush(&sd->paint);
+ Brush *brush = BKE_paint_brush(&sd->paint);
float bstrength = ss->cache->bstrength;
float offset[3];
float lim = brush->height;
@@ -2209,7 +2209,7 @@ static void do_layer_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode
static void do_inflate_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
{
SculptSession *ss = ob->sculpt;
- Brush *brush = paint_brush(&sd->paint);
+ Brush *brush = BKE_paint_brush(&sd->paint);
float bstrength = ss->cache->bstrength;
int n;
@@ -2404,7 +2404,7 @@ static void calc_area_normal_and_flatten_center(Sculpt *sd, Object *ob,
static void calc_sculpt_plane(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode, float an[3], float fc[3])
{
SculptSession *ss = ob->sculpt;
- Brush *brush = paint_brush(&sd->paint);
+ Brush *brush = BKE_paint_brush(&sd->paint);
if (ss->cache->mirror_symmetry_pass == 0 &&
ss->cache->radial_symmetry_pass == 0 &&
@@ -2509,7 +2509,7 @@ static int plane_point_side(float co[3], float plane_normal[3], float plane_cent
static float get_offset(Sculpt *sd, SculptSession *ss)
{
- Brush *brush = paint_brush(&sd->paint);
+ Brush *brush = BKE_paint_brush(&sd->paint);
float rv = brush->plane_offset;
@@ -2523,7 +2523,7 @@ static float get_offset(Sculpt *sd, SculptSession *ss)
static void do_flatten_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
{
SculptSession *ss = ob->sculpt;
- Brush *brush = paint_brush(&sd->paint);
+ Brush *brush = BKE_paint_brush(&sd->paint);
float bstrength = ss->cache->bstrength;
const float radius = ss->cache->radius;
@@ -2585,7 +2585,7 @@ static void do_flatten_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totno
static void do_clay_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
{
SculptSession *ss = ob->sculpt;
- Brush *brush = paint_brush(&sd->paint);
+ Brush *brush = BKE_paint_brush(&sd->paint);
float bstrength = ss->cache->bstrength;
float radius = ss->cache->radius;
@@ -2660,7 +2660,7 @@ static void do_clay_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
static void do_clay_strips_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
{
SculptSession *ss = ob->sculpt;
- Brush *brush = paint_brush(&sd->paint);
+ Brush *brush = BKE_paint_brush(&sd->paint);
float bstrength = ss->cache->bstrength;
float radius = ss->cache->radius;
@@ -2762,7 +2762,7 @@ static void do_clay_strips_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int t
static void do_fill_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
{
SculptSession *ss = ob->sculpt;
- Brush *brush = paint_brush(&sd->paint);
+ Brush *brush = BKE_paint_brush(&sd->paint);
float bstrength = ss->cache->bstrength;
const float radius = ss->cache->radius;
@@ -2826,7 +2826,7 @@ static void do_fill_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
static void do_scrape_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
{
SculptSession *ss = ob->sculpt;
- Brush *brush = paint_brush(&sd->paint);
+ Brush *brush = BKE_paint_brush(&sd->paint);
float bstrength = ss->cache->bstrength;
const float radius = ss->cache->radius;
@@ -3128,7 +3128,7 @@ static void sculpt_flush_pbvhvert_deform(Object *ob, PBVHVertexIter *vd)
static void sculpt_combine_proxies(Sculpt *sd, Object *ob)
{
SculptSession *ss = ob->sculpt;
- Brush *brush = paint_brush(&sd->paint);
+ Brush *brush = BKE_paint_brush(&sd->paint);
PBVHNode **nodes;
int totnode, n;
@@ -3209,7 +3209,7 @@ static void sculpt_update_keyblock(Object *ob)
static void sculpt_flush_stroke_deform(Sculpt *sd, Object *ob)
{
SculptSession *ss = ob->sculpt;
- Brush *brush = paint_brush(&sd->paint);
+ Brush *brush = BKE_paint_brush(&sd->paint);
if (ELEM(brush->sculpt_tool, SCULPT_TOOL_SMOOTH, SCULPT_TOOL_LAYER)) {
/* this brushes aren't using proxies, so sculpt_combine_proxies() wouldn't
@@ -3327,7 +3327,7 @@ static void do_radial_symmetry(Sculpt *sd, Object *ob, Brush *brush,
static void sculpt_fix_noise_tear(Sculpt *sd, Object *ob)
{
SculptSession *ss = ob->sculpt;
- Brush *brush = paint_brush(&sd->paint);
+ Brush *brush = BKE_paint_brush(&sd->paint);
MTex *mtex = &brush->mtex;
if (ss->multires && mtex->tex && mtex->tex->type == TEX_NOISE)
@@ -3337,7 +3337,7 @@ static void sculpt_fix_noise_tear(Sculpt *sd, Object *ob)
static void do_symmetrical_brush_actions(Sculpt *sd, Object *ob,
BrushActionFunc action)
{
- Brush *brush = paint_brush(&sd->paint);
+ Brush *brush = BKE_paint_brush(&sd->paint);
SculptSession *ss = ob->sculpt;
StrokeCache *cache = ss->cache;
const char symm = sd->flags & 7;
@@ -3366,7 +3366,7 @@ static void do_symmetrical_brush_actions(Sculpt *sd, Object *ob,
static void sculpt_update_tex(const Scene *scene, Sculpt *sd, SculptSession *ss)
{
- Brush *brush = paint_brush(&sd->paint);
+ Brush *brush = BKE_paint_brush(&sd->paint);
const int radius = BKE_brush_size_get(scene, brush);
if (ss->texcache) {
@@ -3507,7 +3507,7 @@ int sculpt_poll(bContext *C)
static const char *sculpt_tool_name(Sculpt *sd)
{
- Brush *brush = paint_brush(&sd->paint);
+ Brush *brush = BKE_paint_brush(&sd->paint);
switch ((BrushSculptTool)brush->sculpt_tool) {
case SCULPT_TOOL_DRAW:
@@ -3665,7 +3665,7 @@ static void sculpt_update_cache_invariants(bContext *C, Sculpt *sd, SculptSessio
{
StrokeCache *cache = MEM_callocN(sizeof(StrokeCache), "stroke cache");
UnifiedPaintSettings *ups = &CTX_data_tool_settings(C)->unified_paint_settings;
- Brush *brush = paint_brush(&sd->paint);
+ Brush *brush = BKE_paint_brush(&sd->paint);
ViewContext *vc = paint_stroke_view_context(op->customdata);
Object *ob = CTX_data_active_object(C);
float rot[3][3], scale[3], loc[3];
@@ -3715,7 +3715,7 @@ static void sculpt_update_cache_invariants(bContext *C, Sculpt *sd, SculptSessio
br = (Brush *)BKE_libblock_find_name(ID_BR, "Smooth");
if (br) {
- paint_brush_set(p, br);
+ BKE_paint_brush_set(p, br);
brush = br;
}
}
@@ -3876,7 +3876,7 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob,
UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
SculptSession *ss = ob->sculpt;
StrokeCache *cache = ss->cache;
- Brush *brush = paint_brush(&sd->paint);
+ Brush *brush = BKE_paint_brush(&sd->paint);
/* RNA_float_get_array(ptr, "location", cache->traced_location); */
@@ -3982,7 +3982,7 @@ static void sculpt_stroke_modifiers_check(const bContext *C, Object *ob)
if (ss->modifiers_active) {
Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
- Brush *brush = paint_brush(&sd->paint);
+ Brush *brush = BKE_paint_brush(&sd->paint);
sculpt_update_mesh_elements(CTX_data_scene(C), sd, ob,
sculpt_any_smooth_mode(brush, ss->cache, 0), FALSE);
@@ -4075,7 +4075,7 @@ int sculpt_stroke_get_location(bContext *C, float out[3], const float mouse[2])
static void sculpt_brush_init_tex(const Scene *scene, Sculpt *sd, SculptSession *ss)
{
- Brush *brush = paint_brush(&sd->paint);
+ Brush *brush = BKE_paint_brush(&sd->paint);
MTex *mtex = &brush->mtex;
/* init mtex nodes */
@@ -4094,7 +4094,7 @@ static int sculpt_brush_stroke_init(bContext *C, wmOperator *op)
Object *ob = CTX_data_active_object(C);
Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
SculptSession *ss = CTX_data_active_object(C)->sculpt;
- Brush *brush = paint_brush(&sd->paint);
+ Brush *brush = BKE_paint_brush(&sd->paint);
int mode = RNA_enum_get(op->ptr, "mode");
int is_smooth = 0;
int need_mask = FALSE;
@@ -4115,7 +4115,7 @@ static int sculpt_brush_stroke_init(bContext *C, wmOperator *op)
static void sculpt_restore_mesh(Sculpt *sd, Object *ob)
{
SculptSession *ss = ob->sculpt;
- Brush *brush = paint_brush(&sd->paint);
+ Brush *brush = BKE_paint_brush(&sd->paint);
/* Restore the mesh before continuing with anchored stroke */
if ((brush->flag & BRUSH_ANCHORED) ||
@@ -4218,7 +4218,7 @@ static void sculpt_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
Object *ob = CTX_data_active_object(C);
SculptSession *ss = ob->sculpt;
- const Brush *brush = paint_brush(&sd->paint);
+ const Brush *brush = BKE_paint_brush(&sd->paint);
sculpt_stroke_modifiers_check(C, ob);
sculpt_update_cache_variants(C, sd, ob, stroke, itemptr);
@@ -4233,7 +4233,7 @@ static void sculpt_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
do_symmetrical_brush_actions(sd, ob, sculpt_topology_update);
}
- if (paint_brush(&sd->paint)->sculpt_tool != SCULPT_TOOL_SIMPLIFY)
+ if (BKE_paint_brush(&sd->paint)->sculpt_tool != SCULPT_TOOL_SIMPLIFY)
do_symmetrical_brush_actions(sd, ob, do_brush_action);
sculpt_combine_proxies(sd, ob);
@@ -4252,7 +4252,7 @@ static void sculpt_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
static void sculpt_brush_exit_tex(Sculpt *sd)
{
- Brush *brush = paint_brush(&sd->paint);
+ Brush *brush = BKE_paint_brush(&sd->paint);
MTex *mtex = &brush->mtex;
if (mtex->tex && mtex->tex->nodetree)
@@ -4274,7 +4274,7 @@ static void sculpt_stroke_done(const bContext *C, struct PaintStroke *UNUSED(str
/* Finished */
if (ss->cache) {
- Brush *brush = paint_brush(&sd->paint);
+ Brush *brush = BKE_paint_brush(&sd->paint);
brush->flag &= ~BRUSH_INVERTED;
sculpt_stroke_modifiers_check(C, ob);
@@ -4288,7 +4288,7 @@ static void sculpt_stroke_done(const bContext *C, struct PaintStroke *UNUSED(str
Paint *p = &sd->paint;
brush = (Brush *)BKE_libblock_find_name(ID_BR, ss->cache->saved_active_brush_name);
if (brush) {
- paint_brush_set(p, brush);
+ BKE_paint_brush_set(p, brush);
}
}
}
diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c
index 7cdfb6d22b2..5f1a86fe70c 100644
--- a/source/blender/editors/sculpt_paint/sculpt_uv.c
+++ b/source/blender/editors/sculpt_paint/sculpt_uv.c
@@ -152,7 +152,7 @@ static Brush *uv_sculpt_brush(bContext *C)
if (!settings->uvsculpt)
return NULL;
- return paint_brush(&settings->uvsculpt->paint);
+ return BKE_paint_brush(&settings->uvsculpt->paint);
}
@@ -226,7 +226,7 @@ static void HC_relaxation_iteration_uv(BMEditMesh *em, UvSculptData *sculptdata,
float diff[2];
int i;
float radius_root = sqrt(radius);
- Brush *brush = paint_brush(sculptdata->uvsculpt);
+ Brush *brush = BKE_paint_brush(sculptdata->uvsculpt);
tmp_uvdata = (Temp_UVData *)MEM_callocN(sculptdata->totalUniqueUvs * sizeof(Temp_UVData), "Temporal data");
@@ -298,7 +298,7 @@ static void laplacian_relaxation_iteration_uv(BMEditMesh *em, UvSculptData *scul
float diff[2];
int i;
float radius_root = sqrt(radius);
- Brush *brush = paint_brush(sculptdata->uvsculpt);
+ Brush *brush = BKE_paint_brush(sculptdata->uvsculpt);
tmp_uvdata = (Temp_UVData *)MEM_callocN(sculptdata->totalUniqueUvs * sizeof(Temp_UVData), "Temporal data");
@@ -370,7 +370,7 @@ static void uv_sculpt_stroke_apply(bContext *C, wmOperator *op, const wmEvent *e
int width, height;
float aspectRatio;
float alpha, zoomx, zoomy;
- Brush *brush = paint_brush(sculptdata->uvsculpt);
+ Brush *brush = BKE_paint_brush(sculptdata->uvsculpt);
ToolSettings *toolsettings = CTX_data_tool_settings(C);
tool = sculptdata->tool;
invert = sculptdata->invert ? -1 : 1;
@@ -740,7 +740,7 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, const wm
int width, height;
float aspectRatio;
float alpha, zoomx, zoomy;
- Brush *brush = paint_brush(sculptdata->uvsculpt);
+ Brush *brush = BKE_paint_brush(sculptdata->uvsculpt);
alpha = BKE_brush_alpha_get(scene, brush);
diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c
index 072ea504b9f..564f0589b58 100644
--- a/source/blender/editors/space_buttons/buttons_context.c
+++ b/source/blender/editors/space_buttons/buttons_context.c
@@ -353,7 +353,7 @@ static int buttons_context_path_brush(ButsContextPath *path)
scene = path->ptr[path->len - 1].data;
if (scene)
- br = paint_brush(paint_get_active(scene));
+ br = BKE_paint_brush(BKE_paint_get_active(scene));
if (br) {
RNA_id_pointer_create((ID *)br, &path->ptr[path->len]);
diff --git a/source/blender/editors/space_buttons/buttons_texture.c b/source/blender/editors/space_buttons/buttons_texture.c
index 5a7d70d279c..c8a9fb9ac09 100644
--- a/source/blender/editors/space_buttons/buttons_texture.c
+++ b/source/blender/editors/space_buttons/buttons_texture.c
@@ -177,7 +177,7 @@ static void buttons_texture_users_from_context(ListBase *users, const bContext *
if (!(pinid || pinid == &scene->id)) {
ob = (scene->basact) ? scene->basact->object : NULL;
wrld = scene->world;
- brush = paint_brush(paint_get_active_from_context(C));
+ brush = BKE_paint_brush(BKE_paint_get_active_from_context(C));
}
if (ob && ob->type == OB_LAMP && !la)
diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c
index 7fc83809b60..be325478722 100644
--- a/source/blender/editors/space_image/image_draw.c
+++ b/source/blender/editors/space_image/image_draw.c
@@ -693,7 +693,7 @@ static void draw_image_view_tool(Scene *scene)
static unsigned char *get_alpha_clone_image(const bContext *C, Scene *scene, int *width, int *height)
{
- Brush *brush = paint_brush(&scene->toolsettings->imapaint.paint);
+ Brush *brush = BKE_paint_brush(&scene->toolsettings->imapaint.paint);
ImBuf *ibuf;
unsigned int size, alpha;
unsigned char *display_buffer;
@@ -749,7 +749,7 @@ static void draw_image_paint_helpers(const bContext *C, ARegion *ar, Scene *scen
int x, y, w, h;
unsigned char *clonerect;
- brush = paint_brush(&scene->toolsettings->imapaint.paint);
+ brush = BKE_paint_brush(&scene->toolsettings->imapaint.paint);
if (brush && (brush->imagepaint_tool == PAINT_TOOL_CLONE)) {
/* this is not very efficient, but glDrawPixels doesn't allow
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 4727502062d..9f24db3c9a3 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -3332,7 +3332,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
glEnable(GL_LIGHTING);
glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW);
- if (ob->sculpt && (p = paint_get_active(scene))) {
+ if (ob->sculpt && (p = BKE_paint_get_active(scene))) {
float planes[4][4];
float (*fpl)[4] = NULL;
int fast = (p->flags & PAINT_FAST_NAVIGATE) && (rv3d->rflag & RV3D_NAVIGATING);
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index cdecdea415f..522fd8b777c 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -523,7 +523,7 @@ static void viewops_data_create(bContext *C, wmOperator *op, const wmEvent *even
static void viewops_data_free(bContext *C, wmOperator *op)
{
ARegion *ar;
- Paint *p = paint_get_active_from_context(C);
+ Paint *p = BKE_paint_get_active_from_context(C);
if (op->customdata) {
ViewOpsData *vod = op->customdata;
diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c
index cf0e4a1e1e9..7bf206add90 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -285,9 +285,35 @@ static void rna_Brush_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerR
/*WM_main_add_notifier(NC_SPACE|ND_SPACE_VIEW3D, NULL); */
}
+static void rna_Brush_main_tex_update(Main *bmain, Scene *scene, PointerRNA *ptr)
+{
+ Brush *br = (Brush *)ptr->data;
+ BKE_paint_invalidate_overlay_tex(scene, br->mtex.tex);
+ rna_Brush_update(bmain, scene, ptr);
+}
+
+static void rna_Brush_secondary_tex_update(Main *bmain, Scene *scene, PointerRNA *ptr)
+{
+ Brush *br = (Brush *)ptr->data;
+ BKE_paint_invalidate_overlay_tex(scene, br->mask_mtex.tex);
+ rna_Brush_update(bmain, scene, ptr);
+}
+
+static void rna_Brush_size_update(Main *bmain, Scene *scene, PointerRNA *ptr)
+{
+ Brush *br = (Brush *)ptr->data;
+ if (br->mtex.mapping == MTEX_MAP_MODE_VIEW) {
+ BKE_paint_invalidate_overlay_tex(scene, br->mtex.tex);
+ BKE_paint_invalidate_overlay_tex(scene, br->mask_mtex.tex);
+ }
+ BKE_paint_invalidate_cursor_overlay(scene, br->curve);
+ rna_Brush_update(bmain, scene, ptr);
+}
+
static void rna_Brush_sculpt_tool_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
Brush *br = (Brush *)ptr->data;
+ BKE_paint_invalidate_overlay_all();
rna_Brush_reset_icon(br, "sculpt");
rna_Brush_update(bmain, scene, ptr);
}
@@ -295,6 +321,7 @@ static void rna_Brush_sculpt_tool_update(Main *bmain, Scene *scene, PointerRNA *
static void rna_Brush_vertex_tool_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
Brush *br = (Brush *)ptr->data;
+ BKE_paint_invalidate_overlay_all();
rna_Brush_reset_icon(br, "vertex_paint");
rna_Brush_update(bmain, scene, ptr);
}
@@ -302,6 +329,7 @@ static void rna_Brush_vertex_tool_update(Main *bmain, Scene *scene, PointerRNA *
static void rna_Brush_imagepaint_tool_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
Brush *br = (Brush *)ptr->data;
+ BKE_paint_invalidate_overlay_all();
rna_Brush_reset_icon(br, "image_paint");
rna_Brush_update(bmain, scene, ptr);
}
@@ -325,6 +353,16 @@ static void rna_Brush_icon_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Poi
WM_main_add_notifier(NC_BRUSH | NA_EDITED, br);
}
+static void rna_TextureSlot_brush_angle_update(Main *bmain, Scene *scene, PointerRNA *ptr)
+{
+ MTex *mtex = ptr->data;
+ /* skip invalidation of overlay for stencil mode */
+ if (mtex->mapping != MTEX_MAP_MODE_STENCIL)
+ BKE_paint_invalidate_overlay_tex(scene, mtex->tex);
+
+ rna_TextureSlot_update(bmain, scene, ptr);
+}
+
static void rna_Brush_set_size(PointerRNA *ptr, int value)
{
Brush *brush = ptr->data;
@@ -448,6 +486,14 @@ static void rna_def_brush_texture_slot(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL}
};
+ static EnumPropertyItem prop_mask_paint_map_mode_items[] = {
+ {MTEX_MAP_MODE_VIEW, "VIEW_PLANE", 0, "View Plane", ""},
+ {MTEX_MAP_MODE_TILED, "TILED", 0, "Tiled", ""},
+ {MTEX_MAP_MODE_RANDOM, "RANDOM", 0, "Random", ""},
+ {MTEX_MAP_MODE_STENCIL, "STENCIL", 0, "Stencil", ""},
+ {0, NULL, 0, NULL, NULL}
+ };
+
srna = RNA_def_struct(brna, "BrushTextureSlot", "TextureSlot");
RNA_def_struct_sdna(srna, "MTex");
RNA_def_struct_ui_text(srna, "Brush Texture Slot", "Texture slot for textures in a Brush datablock");
@@ -456,18 +502,24 @@ static void rna_def_brush_texture_slot(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "rot");
RNA_def_property_range(prop, 0, M_PI * 2);
RNA_def_property_ui_text(prop, "Angle", "Brush texture rotation");
- RNA_def_property_update(prop, 0, "rna_TextureSlot_update");
+ RNA_def_property_update(prop, 0, "rna_TextureSlot_brush_angle_update");
prop = RNA_def_property(srna, "map_mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "brush_map_mode");
RNA_def_property_enum_items(prop, prop_map_mode_items);
RNA_def_property_ui_text(prop, "Mode", "");
- RNA_def_property_update(prop, 0, "rna_TextureSlot_update");
+ RNA_def_property_update(prop, 0, "rna_TextureSlot_brush_update");
prop = RNA_def_property(srna, "tex_paint_map_mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "brush_map_mode");
RNA_def_property_enum_items(prop, prop_tex_paint_map_mode_items);
RNA_def_property_ui_text(prop, "Mode", "");
+ RNA_def_property_update(prop, 0, "rna_TextureSlot_brush_update");
+
+ prop = RNA_def_property(srna, "mask_map_mode", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "brush_map_mode");
+ RNA_def_property_enum_items(prop, prop_mask_paint_map_mode_items);
+ RNA_def_property_ui_text(prop, "Mode", "");
RNA_def_property_update(prop, 0, "rna_TextureSlot_update");
}
@@ -673,14 +725,14 @@ static void rna_def_brush(BlenderRNA *brna)
RNA_def_property_range(prop, 1, MAX_BRUSH_PIXEL_RADIUS * 10);
RNA_def_property_ui_range(prop, 1, MAX_BRUSH_PIXEL_RADIUS, 1, -1);
RNA_def_property_ui_text(prop, "Radius", "Radius of the brush in pixels");
- RNA_def_property_update(prop, 0, "rna_Brush_update");
+ RNA_def_property_update(prop, 0, "rna_Brush_size_update");
prop = RNA_def_property(srna, "unprojected_radius", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_funcs(prop, NULL, "rna_Brush_set_unprojected_radius", NULL);
RNA_def_property_range(prop, 0.001, FLT_MAX);
RNA_def_property_ui_range(prop, 0.001, 1, 0, -1);
RNA_def_property_ui_text(prop, "Unprojected Radius", "Radius of brush in Blender units");
- RNA_def_property_update(prop, 0, "rna_Brush_update");
+ RNA_def_property_update(prop, 0, "rna_Brush_size_update");
prop = RNA_def_property(srna, "jitter", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "jitter");
@@ -982,7 +1034,7 @@ static void rna_def_brush(BlenderRNA *brna)
RNA_def_property_pointer_sdna(prop, NULL, "mtex.tex");
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Texture", "");
- RNA_def_property_update(prop, NC_TEXTURE, "rna_Brush_update");
+ RNA_def_property_update(prop, NC_TEXTURE, "rna_Brush_main_tex_update");
prop = RNA_def_property(srna, "mask_texture_slot", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "BrushTextureSlot");
@@ -994,7 +1046,7 @@ static void rna_def_brush(BlenderRNA *brna)
RNA_def_property_pointer_sdna(prop, NULL, "mask_mtex.tex");
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Mask Texture", "");
- RNA_def_property_update(prop, NC_TEXTURE, "rna_Brush_update");
+ RNA_def_property_update(prop, NC_TEXTURE, "rna_Brush_secondary_tex_update");
prop = RNA_def_property(srna, "texture_overlay_alpha", PROP_INT, PROP_PERCENTAGE);
RNA_def_property_int_sdna(prop, NULL, "texture_overlay_alpha");
diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h
index e7a8311656f..0a2c876ec50 100644
--- a/source/blender/makesrna/intern/rna_internal.h
+++ b/source/blender/makesrna/intern/rna_internal.h
@@ -232,6 +232,7 @@ int rna_object_shapekey_index_set(struct ID *id, PointerRNA value, int current);
void rna_Object_internal_update_data(struct Main *bmain, struct Scene *scene, struct PointerRNA *ptr);
void rna_Mesh_update_draw(struct Main *bmain, struct Scene *scene, struct PointerRNA *ptr);
void rna_TextureSlot_update(struct Main *bmain, struct Scene *scene, struct PointerRNA *ptr);
+void rna_TextureSlot_brush_update(struct Main *bmain, struct Scene *scene, struct PointerRNA *ptr);
/* basic poll functions for object types */
int rna_Armature_object_poll(struct PointerRNA *ptr, struct PointerRNA value);
diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c
index e8f812506e2..ad8115e52ac 100644
--- a/source/blender/makesrna/intern/rna_texture.c
+++ b/source/blender/makesrna/intern/rna_texture.c
@@ -41,6 +41,7 @@
#include "BLI_utildefines.h"
#include "BKE_node.h"
+#include "BKE_paint.h"
#include "RNA_define.h"
#include "RNA_enum_types.h"
@@ -257,6 +258,23 @@ void rna_TextureSlot_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRN
}
}
+void rna_TextureSlot_brush_update(Main *bmain, Scene *scene, PointerRNA *ptr) {
+ ID *id = ptr->id.data;
+
+ DAG_id_tag_update(id, 0);
+
+ switch (GS(id->name)) {
+ case ID_BR:
+ {
+ MTex *mtex = ptr->data;
+ BKE_paint_invalidate_overlay_tex(scene, mtex->tex);
+ break;
+ }
+ }
+ rna_TextureSlot_update(bmain, scene, ptr);
+}
+
+
char *rna_TextureSlot_path(PointerRNA *ptr)
{
MTex *mtex = ptr->data;
@@ -627,13 +645,13 @@ static void rna_def_mtex(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "ofs");
RNA_def_property_ui_range(prop, -10, 10, 10, RNA_TRANSLATION_PREC_DEFAULT);
RNA_def_property_ui_text(prop, "Offset", "Fine tune of the texture mapping X, Y and Z locations");
- RNA_def_property_update(prop, 0, "rna_TextureSlot_update");
+ RNA_def_property_update(prop, 0, "rna_TextureSlot_brush_update");
prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ);
RNA_def_property_float_sdna(prop, NULL, "size");
RNA_def_property_ui_range(prop, -100, 100, 10, 2);
RNA_def_property_ui_text(prop, "Size", "Set scaling for the texture's X, Y and Z sizes");
- RNA_def_property_update(prop, 0, "rna_TextureSlot_update");
+ RNA_def_property_update(prop, 0, "rna_TextureSlot_brush_update");
prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_sdna(prop, NULL, "r");
diff --git a/source/blender/nodes/texture/node_texture_tree.c b/source/blender/nodes/texture/node_texture_tree.c
index bab8ef0c631..6636957facb 100644
--- a/source/blender/nodes/texture/node_texture_tree.c
+++ b/source/blender/nodes/texture/node_texture_tree.c
@@ -96,9 +96,9 @@ static void texture_get_from_context(const bContext *C, bNodeTreeType *UNUSED(tr
struct Brush *brush = NULL;
if (ob && (ob->mode & OB_MODE_SCULPT))
- brush = paint_brush(&scene->toolsettings->sculpt->paint);
+ brush = BKE_paint_brush(&scene->toolsettings->sculpt->paint);
else
- brush = paint_brush(&scene->toolsettings->imapaint.paint);
+ brush = BKE_paint_brush(&scene->toolsettings->imapaint.paint);
if (brush) {
*r_from = (ID *)brush;
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 5ba94138c5a..8f741402154 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -3677,16 +3677,14 @@ static int radial_control_invoke(bContext *C, wmOperator *op, const wmEvent *eve
return OPERATOR_RUNNING_MODAL;
}
-static void radial_control_set_value(bContext *C, RadialControl *rc, float val)
+static void radial_control_set_value(RadialControl *rc, float val)
{
switch (rc->type) {
case PROP_INT:
RNA_property_int_set(&rc->ptr, rc->prop, val);
- RNA_property_update(C, &rc->ptr, rc->prop);
break;
case PROP_FLOAT:
RNA_property_float_set(&rc->ptr, rc->prop, val);
- RNA_property_update(C, &rc->ptr, rc->prop);
break;
default:
break;
@@ -3760,20 +3758,21 @@ static int radial_control_modal(bContext *C, wmOperator *op, const wmEvent *even
/* clamp and update */
CLAMP(new_value, rc->min_value, rc->max_value);
- radial_control_set_value(C, rc, new_value);
+ radial_control_set_value(rc, new_value);
rc->current_value = new_value;
break;
case ESCKEY:
case RIGHTMOUSE:
/* canceled; restore original value */
- radial_control_set_value(C, rc, rc->initial_value);
+ radial_control_set_value(rc, rc->initial_value);
ret = OPERATOR_CANCELLED;
break;
case LEFTMOUSE:
case PADENTER:
/* done; value already set */
+ RNA_property_update(C, &rc->ptr, rc->prop);
ret = OPERATOR_FINISHED;
break;
}