Revision: 48555
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=48555
Author:   psy-fi
Date:     2012-07-03 16:59:27 +0000 (Tue, 03 Jul 2012)
Log Message:
-----------
Cleanup, move 2D paint stuff to their own file.

Modified Paths:
--------------
    branches/soc-2012-bratwurst/source/blender/blenkernel/BKE_brush.h
    branches/soc-2012-bratwurst/source/blender/blenkernel/intern/brush.c
    branches/soc-2012-bratwurst/source/blender/blenkernel/intern/paint.c
    
branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/CMakeLists.txt
    
branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/paint_cursor.c

Added Paths:
-----------
    branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/paint_2D.c
    branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/paint_2D.h

Modified: branches/soc-2012-bratwurst/source/blender/blenkernel/BKE_brush.h
===================================================================
--- branches/soc-2012-bratwurst/source/blender/blenkernel/BKE_brush.h   
2012-07-03 16:41:25 UTC (rev 48554)
+++ branches/soc-2012-bratwurst/source/blender/blenkernel/BKE_brush.h   
2012-07-03 16:59:27 UTC (rev 48555)
@@ -92,6 +92,7 @@
 struct ImBuf *BKE_brush_gen_radial_control_imbuf(struct Brush *br);
 
 /* unified strength and size */
+void BKE_brush_randomize_size(struct Brush *brush);
 int BKE_brush_size_randomized_get(const struct Scene *scene, struct Brush 
*brush);
 int  BKE_brush_size_get(const struct Scene *scene, struct Brush *brush);
 void BKE_brush_size_set(struct Scene *scene, struct Brush *brush, int value);
@@ -100,8 +101,9 @@
 void  BKE_brush_unprojected_radius_set(struct Scene *scene, struct Brush 
*brush, float value);
 
 float BKE_brush_alpha_get(const struct Scene *scene, struct Brush *brush);
-float BKE_brush_weight_get(const Scene *scene, struct Brush *brush);
-void BKE_brush_weight_set(const Scene *scene, struct Brush *brush, float 
value);
+void BKE_brush_alpha_set(struct Scene *scene, struct Brush *brush, float 
alpha);
+float BKE_brush_weight_get(const struct Scene *scene, struct Brush *brush);
+void BKE_brush_weight_set(const struct Scene *scene, struct Brush *brush, 
float value);
 
 int  BKE_brush_use_locked_size(const struct Scene *scene, struct Brush *brush);
 int  BKE_brush_use_alpha_pressure(const struct Scene *scene, struct Brush 
*brush);

Modified: branches/soc-2012-bratwurst/source/blender/blenkernel/intern/brush.c
===================================================================
--- branches/soc-2012-bratwurst/source/blender/blenkernel/intern/brush.c        
2012-07-03 16:41:25 UTC (rev 48554)
+++ branches/soc-2012-bratwurst/source/blender/blenkernel/intern/brush.c        
2012-07-03 16:59:27 UTC (rev 48555)
@@ -29,27 +29,16 @@
  *  \ingroup bke
  */
 
-
-#include <math.h>
-#include <string.h>
-
 #include "MEM_guardedalloc.h"
 
 #include "DNA_brush_types.h"
 #include "DNA_color_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_object_types.h"
-#include "DNA_windowmanager_types.h"
 
-#include "WM_types.h"
-
-#include "RNA_access.h"
-
-#include "BLI_bpath.h"
 #include "BLI_math.h"
 #include "BLI_blenlib.h"
 #include "BLI_rand.h"
-#include "BLI_utildefines.h"
 
 #include "BKE_brush.h"
 #include "BKE_colortools.h"
@@ -775,7 +764,7 @@
               brush->unprojected_radius;
 }
 
-static void brush_alpha_set(Scene *scene, Brush *brush, float alpha)
+void BKE_brush_alpha_set(Scene *scene, Brush *brush, float alpha)
 {
        UnifiedPaintSettings *ups = 
&scene->toolsettings->unified_paint_settings;
 
@@ -833,319 +822,7 @@
        (*BKE_brush_size_get) = (int)((float)(*BKE_brush_size_get) * scale);
 }
 
-/* Brush Painting */
 
-typedef struct BrushPainterCache {
-       short enabled;
-
-       int size;           /* size override, if 0 uses 
2*BKE_brush_size_get(brush) */
-       short flt;          /* need float imbuf? */
-       short texonly;      /* no alpha, color or fallof, only texture in imbuf 
*/
-
-       int lastsize;
-       float lastalpha;
-       float lastjitter;
-       float lastrotation;
-
-       ImBuf *ibuf;
-       ImBuf *texibuf;
-       ImBuf *maskibuf;
-} BrushPainterCache;
-
-struct BrushPainter {
-       Scene *scene;
-       Brush *brush;
-
-       float lastmousepos[2];  /* mouse position of last paint call */
-
-       float accumdistance;    /* accumulated distance of brush since last 
paint op */
-       float lastpaintpos[2];  /* position of last paint op */
-       float startpaintpos[2]; /* position of first paint */
-
-       double accumtime;       /* accumulated time since last paint op 
(airbrush) */
-       double lasttime;        /* time of last update */
-
-       float lastpressure;
-
-       short firsttouch;       /* first paint op */
-
-       float startsize;
-       float startalpha;
-       float startjitter;
-       float startspacing;
-
-       BrushPainterCache cache;
-};
-
-BrushPainter *BKE_brush_painter_new(Scene *scene, Brush *brush)
-{
-       BrushPainter *painter = MEM_callocN(sizeof(BrushPainter), 
"BrushPainter");
-
-       painter->brush = brush;
-       painter->scene = scene;
-       painter->firsttouch = 1;
-       painter->cache.lastsize = -1; /* force ibuf create in refresh */
-
-       painter->startsize = BKE_brush_size_get(scene, brush);
-       painter->startalpha = BKE_brush_alpha_get(scene, brush);
-       painter->startjitter = brush->jitter;
-       painter->startspacing = brush->spacing;
-
-       return painter;
-}
-
-void BKE_brush_painter_require_imbuf(BrushPainter *painter, short flt, short 
texonly, int size)
-{
-       if ((painter->cache.flt != flt) || (painter->cache.size != size) ||
-           ((painter->cache.texonly != texonly) && texonly))
-       {
-               if (painter->cache.ibuf) IMB_freeImBuf(painter->cache.ibuf);
-               if (painter->cache.maskibuf) 
IMB_freeImBuf(painter->cache.maskibuf);
-               painter->cache.ibuf = painter->cache.maskibuf = NULL;
-               painter->cache.lastsize = -1; /* force ibuf create in refresh */
-       }
-
-       if (painter->cache.flt != flt) {
-               if (painter->cache.texibuf) 
IMB_freeImBuf(painter->cache.texibuf);
-               painter->cache.texibuf = NULL;
-               painter->cache.lastsize = -1; /* force ibuf create in refresh */
-       }
-
-       painter->cache.size = size;
-       painter->cache.flt = flt;
-       painter->cache.texonly = texonly;
-       painter->cache.enabled = 1;
-}
-
-void BKE_brush_painter_free(BrushPainter *painter)
-{
-       Brush *brush = painter->brush;
-
-       BKE_brush_size_set(painter->scene, brush, painter->startsize);
-       brush_alpha_set(painter->scene, brush, painter->startalpha);
-       brush->jitter = painter->startjitter;
-       brush->spacing = painter->startspacing;
-
-       if (painter->cache.ibuf) IMB_freeImBuf(painter->cache.ibuf);
-       if (painter->cache.texibuf) IMB_freeImBuf(painter->cache.texibuf);
-       if (painter->cache.maskibuf) IMB_freeImBuf(painter->cache.maskibuf);
-       MEM_freeN(painter);
-}
-
-static void brush_painter_do_partial(BrushPainter *painter, ImBuf *oldtexibuf,
-                                     int x, int y, int w, int h, int xt, int 
yt,
-                                     const float pos[2])
-{
-       Scene *scene = painter->scene;
-       Brush *brush = painter->brush;
-       ImBuf *ibuf, *maskibuf, *texibuf;
-       float *bf, *mf, *tf, *otf = NULL, xoff, yoff, xy[2], rgba[4];
-       unsigned char *b, *m, *t, *ot = NULL;
-       int dotexold, origx = x, origy = y;
-       const int radius = BKE_brush_size_get(painter->scene, brush);
-
-       xoff = -radius + 0.5f;
-       yoff = -radius + 0.5f;
-       xoff += (int)pos[0] - (int)painter->startpaintpos[0];
-       yoff += (int)pos[1] - (int)painter->startpaintpos[1];
-
-       ibuf = painter->cache.ibuf;
-       texibuf = painter->cache.texibuf;
-       maskibuf = painter->cache.maskibuf;
-
-       dotexold = (oldtexibuf != NULL);
-
-       /* not sure if it's actually needed or it's a mistake in coords/sizes
-        * calculation in brush_painter_fixed_tex_partial_update(), but without 
this
-        * limitation memory gets corrupted at fast strokes with quite big 
spacing (sergey) */
-       w = MIN2(w, ibuf->x);
-       h = MIN2(h, ibuf->y);
-
-       if (painter->cache.flt) {
-               for (; y < h; y++) {
-                       bf = ibuf->rect_float + (y * ibuf->x + origx) * 4;
-                       tf = texibuf->rect_float + (y * texibuf->x + origx) * 4;
-                       mf = maskibuf->rect_float + (y * maskibuf->x + origx) * 
4;
-
-                       if (dotexold)
-                               otf = oldtexibuf->rect_float + ((y - origy + 
yt) * oldtexibuf->x + xt) * 4;
-
-                       for (x = origx; x < w; x++, bf += 4, mf += 4, tf += 4) {
-                               if (dotexold) {
-                                       copy_v3_v3(tf, otf);
-                                       tf[3] = otf[3];
-                                       otf += 4;
-                               }
-                               else {
-                                       xy[0] = x + xoff;
-                                       xy[1] = y + yoff;
-
-                                       BKE_brush_sample_tex(scene, brush, xy, 
tf, 0, 0);
-                               }
-
-                               bf[0] = tf[0] * mf[0];
-                               bf[1] = tf[1] * mf[1];
-                               bf[2] = tf[2] * mf[2];
-                               bf[3] = tf[3] * mf[3];
-                       }
-               }
-       }
-       else {
-               for (; y < h; y++) {
-                       b = (unsigned char *)ibuf->rect + (y * ibuf->x + origx) 
* 4;
-                       t = (unsigned char *)texibuf->rect + (y * texibuf->x + 
origx) * 4;
-                       m = (unsigned char *)maskibuf->rect + (y * maskibuf->x 
+ origx) * 4;
-
-                       if (dotexold)
-                               ot = (unsigned char *)oldtexibuf->rect + ((y - 
origy + yt) * oldtexibuf->x + xt) * 4;
-
-                       for (x = origx; x < w; x++, b += 4, m += 4, t += 4) {
-                               if (dotexold) {
-                                       t[0] = ot[0];
-                                       t[1] = ot[1];
-                                       t[2] = ot[2];
-                                       t[3] = ot[3];
-                                       ot += 4;
-                               }
-                               else {
-                                       xy[0] = x + xoff;
-                                       xy[1] = y + yoff;
-
-                                       BKE_brush_sample_tex(scene, brush, xy, 
rgba, 0, 0);
-                                       rgba_float_to_uchar(t, rgba);
-                               }
-
-                               b[0] = t[0] * m[0] / 255;
-                               b[1] = t[1] * m[1] / 255;
-                               b[2] = t[2] * m[2] / 255;
-                               b[3] = t[3] * m[3] / 255;
-                       }
-               }
-       }
-}
-
-static void brush_painter_fixed_tex_partial_update(BrushPainter *painter, 
const float pos[2])
-{
-       const Scene *scene = painter->scene;
-       Brush *brush = painter->brush;
-       BrushPainterCache *cache = &painter->cache;
-       ImBuf *oldtexibuf, *ibuf;
-       int imbflag, destx, desty, srcx, srcy, w, h, x1, y1, x2, y2;
-       const int diameter = 2 * BKE_brush_size_get(scene, brush);
-
-       imbflag = (cache->flt) ? IB_rectfloat : IB_rect;
-       if (!cache->ibuf)
-               cache->ibuf = IMB_allocImBuf(diameter, diameter, 32, imbflag);
-       ibuf = cache->ibuf;
-
-       oldtexibuf = cache->texibuf;
-       cache->texibuf = IMB_allocImBuf(diameter, diameter, 32, imbflag);
-
-       if (oldtexibuf) {
-               srcx = srcy = 0;
-               destx = (int)painter->lastpaintpos[0] - (int)pos[0];
-               desty = (int)painter->lastpaintpos[1] - (int)pos[1];
-               w = oldtexibuf->x;
-               h = oldtexibuf->y;
-
-               IMB_rectclip(cache->texibuf, oldtexibuf, &destx, &desty, &srcx, 
&srcy, &w, &h);
-       }
-       else {
-               srcx = srcy = 0;
-               destx = desty = 0;
-               w = h = 0;
-       }
-       
-       x1 = destx;
-       y1 = desty;
-       x2 = destx + w;
-       y2 = desty + h;
-
-       /* blend existing texture in new position */
-       if ((x1 < x2) && (y1 < y2))
-               brush_painter_do_partial(painter, oldtexibuf, x1, y1, x2, y2, 
srcx, srcy, pos);
-
-       if (oldtexibuf)
-               IMB_freeImBuf(oldtexibuf);
-
-       /* sample texture in new areas */
-       if ((0 < x1) && (0 < ibuf->y))
-               brush_painter_do_partial(painter, NULL, 0, 0, x1, ibuf->y, 0, 
0, pos);
-       if ((x2 < ibuf->x) && (0 < ibuf->y))
-               brush_painter_do_partial(painter, NULL, x2, 0, ibuf->x, 
ibuf->y, 0, 0, pos);
-       if ((x1 < x2) && (0 < y1))
-               brush_painter_do_partial(painter, NULL, x1, 0, x2, y1, 0, 0, 
pos);
-       if ((x1 < x2) && (y2 < ibuf->y))
-               brush_painter_do_partial(painter, NULL, x1, y2, x2, ibuf->y, 0, 
0, pos);
-}
-
-static void brush_painter_refresh_cache(BrushPainter *painter, const float 
pos[2], int use_color_correction, float special_rotation)
-{
-       const Scene *scene = painter->scene;
-       Brush *brush = painter->brush;
-       BrushPainterCache *cache = &painter->cache;
-       MTex *mtex = &brush->mtex;
-       int size;
-       short flt;

@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to