2.5 Texture paint:
[blender.git] / source / blender / blenkernel / intern / paint.c
index 3f6eed8528ad9842f3ed8b09ff10718df814ec35..5ae8411835609a0d7e8bdde12d0c75b534cb897c 100644 (file)
 Paint *paint_get_active(Scene *sce)
 {
        if(sce && sce->basact && sce->basact->object) {
+               ToolSettings *ts = sce->toolsettings;
+
                switch(sce->basact->object->mode) {
                case OB_MODE_SCULPT:
-                       return &sce->toolsettings->sculpt->paint;
+                       return &ts->sculpt->paint;
+               case OB_MODE_VERTEX_PAINT:
+                       return &ts->vpaint->paint;
+               case OB_MODE_WEIGHT_PAINT:
+                       return &ts->wpaint->paint;
+               case OB_MODE_TEXTURE_PAINT:
+                       break;
+                       //return &ts->imapaint->paint;
                }
        }
-       /*else if(G.f & G_VERTEXPAINT)
-               return &sce->toolsettings->vpaint->paint;
-       else if(G.f & G_WEIGHTPAINT)
-               return &sce->toolsettings->wpaint->paint;
-       else if(G.f & G_TEXTUREPAINT)
-       return &sce->toolsettings->imapaint.paint;*/
 
        return NULL;
 }
@@ -137,6 +140,16 @@ int paint_facesel_test(Object *ob)
 
 }
 
+void paint_init(Paint *p, const char *name)
+{
+       Brush *brush;
+
+       /* If there's no brush, create one */
+       brush = paint_brush(p);
+       brush_check_exists(&brush, name);
+       paint_brush_set(p, brush);
+}
+
 void free_paint(Paint *paint)
 {
        if(paint->brushes)
@@ -145,6 +158,10 @@ void free_paint(Paint *paint)
 
 void copy_paint(Paint *orig, Paint *new)
 {
-       if(orig->brushes)
+       if(orig->brushes) {
+               int i;
                new->brushes = MEM_dupallocN(orig->brushes);
+               for(i = 0; i < orig->brush_count; ++i)
+                       id_us_plus((ID *)new->brushes[i]);
+       }
 }