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:
authorAntony Riakiotakis <kalast@gmail.com>2013-04-12 21:21:31 +0400
committerAntony Riakiotakis <kalast@gmail.com>2013-04-12 21:21:31 +0400
commita305452275207a555d2812c3a5ea6647f0f594e4 (patch)
tree991400d761e7895e84841bfe63c5b9f71078dc9e /source/blender/blenkernel/intern/paint.c
parent8f658d42643b5edb03d4ae16ca8f9f611b1fbf74 (diff)
Paint refactoring commit, non-disruptive (in theory :p)
* Fix precision overflow issue with overlay previews, * Expose alpha mask mapping to UI (still not functional but coming soon). * More overlay refactoring: Overlay now does minimal checking for texture refresh. Instead, we now have invalidation flags to set an aspect of the brush overlay as invalid. This is necessary because this way we will be able to separate and preview different brush attributes on the overlays, using different textures: These attributes/aspects are: Primary texture (main texture for sculpt, vertex, imapaint) Secondary texture (mask/alpha texture for imapaint) Cursor texture (cursor texture. It involves brush strength and curves) Modified the relevant RNA property update functions and C update callback functions to call the relevant cursor invalidation functions instead of checking every frame for multiple properties. Properties that affect this are: Image changes, if image is used by current brush, Texture slot changes, similarly Curve changes, Object mode change invalidates the cursor Paint tool change invalidates the cursor. These changes give slightly more invalidation cases than simply comparing the relevant properties each frame, but these do not occur in performance critical moments and it's a much more elegant system than adding more variables to check per frame each time we add something on the system.
Diffstat (limited to 'source/blender/blenkernel/intern/paint.c')
-rw-r--r--source/blender/blenkernel/intern/paint.c54
1 files changed, 47 insertions, 7 deletions
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;