part 1 of cleaning up my little array macro library to be a formal API. also removed...
[blender.git] / source / blender / blenkernel / intern / brush.c
index ebde6e0077f225c9e86d78cc2f55b8dad5f05529..76a26762abeb55e13b8b36d43085be38d45b1e5f 100644 (file)
@@ -51,6 +51,7 @@
 #include "BKE_image.h"
 #include "BKE_library.h"
 #include "BKE_main.h"
+#include "BKE_paint.h"
 #include "BKE_texture.h"
 #include "BKE_utildefines.h"
 
@@ -74,6 +75,8 @@ Brush *add_brush(const char *name)
        brush->alpha= 0.2f;
        brush->size= 25;
        brush->spacing= 10.0f;
+       brush->smooth_stroke_radius= 75;
+       brush->smooth_stroke_factor= 0.9;
        brush->rate= 0.1f;
        brush->innerradius= 0.5f;
        brush->clone.alpha= 0.5;
@@ -153,7 +156,7 @@ void make_local_brush(Brush *brush)
        }
 
        for(scene= G.main->scene.first; scene; scene=scene->id.next)
-               if(scene->toolsettings->imapaint.brush==brush) {
+               if(paint_brush(&scene->toolsettings->imapaint.paint)==brush) {
                        if(scene->id.lib) lib= 1;
                        else local= 1;
                }
@@ -175,9 +178,9 @@ void make_local_brush(Brush *brush)
                brushn->id.flag |= LIB_FAKEUSER;
                
                for(scene= G.main->scene.first; scene; scene=scene->id.next)
-                       if(scene->toolsettings->imapaint.brush==brush)
+                       if(paint_brush(&scene->toolsettings->imapaint.paint)==brush)
                                if(scene->id.lib==0) {
-                                       scene->toolsettings->imapaint.brush= brushn;
+                                       paint_brush_set(&scene->toolsettings->imapaint.paint, brushn);
                                        brushn->id.us++;
                                        brush->id.us--;
                                }
@@ -186,7 +189,7 @@ void make_local_brush(Brush *brush)
 
 /* Library Operations */
 
-int brush_set_nr(Brush **current_brush, int nr)
+int brush_set_nr(Brush **current_brush, int nr, const char *name)
 {
        ID *idtest, *id;
        
@@ -195,7 +198,7 @@ int brush_set_nr(Brush **current_brush, int nr)
        
        if(idtest==0) { /* new brush */
                if(id) idtest= (ID *)copy_brush((Brush *)id);
-               else idtest= (ID *)add_brush("Brush");
+               else idtest= (ID *)add_brush(name);
                idtest->us--;
        }
        if(idtest!=id) {
@@ -369,10 +372,10 @@ int brush_clone_image_delete(Brush *brush)
        return 0;
 }
 
-void brush_check_exists(Brush **brush)
+void brush_check_exists(Brush **brush, const char *name)
 {
        if(*brush==NULL)
-               brush_set_nr(brush, 1);
+               brush_set_nr(brush, 1, name);
 }
 
 /* Brush Sampling */
@@ -406,23 +409,6 @@ float brush_sample_falloff(Brush *brush, float dist)
                return 0.0f;
 }
 
-float brush_sample_falloff_noalpha(Brush *brush, float dist)
-{
-       float outer, inner;
-
-       outer = brush->size >> 1;
-       inner = outer*brush->innerradius;
-
-       if (dist <= inner) {
-               return 1.0f;
-       }
-       else if ((dist < outer) && (inner < outer)) {
-               return 1.0f - sqrt((dist - inner)/(outer - inner));
-       }
-       else 
-               return 0.0f;
-}
-
 void brush_sample_tex(Brush *brush, float *xy, float *rgba)
 {
        MTex *mtex= brush->mtex[brush->texact];
@@ -725,7 +711,7 @@ static void brush_painter_do_partial(BrushPainter *painter, ImBuf *oldtexibuf, i
        }
 }
 
-void brush_painter_fixed_tex_partial_update(BrushPainter *painter, float *pos)
+static void brush_painter_fixed_tex_partial_update(BrushPainter *painter, float *pos)
 {
        Brush *brush= painter->brush;
        BrushPainterCache *cache= &painter->cache;