2.5 Paint:
[blender.git] / source / blender / blenkernel / intern / paint.c
index 79d1df3d67f3200779c5c088cf2be3a3a78e8aa6..7c5b2b82b4b7663b83390bcc4ed787ea3209bc41 100644 (file)
 #include <stdlib.h>
 #include <string.h>
 
+const char PAINT_CURSOR_SCULPT[3] = {255, 100, 100};
+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)
 {
        if(sce && sce->basact && sce->basact->object) {
@@ -52,8 +57,7 @@ Paint *paint_get_active(Scene *sce)
                case OB_MODE_WEIGHT_PAINT:
                        return &ts->wpaint->paint;
                case OB_MODE_TEXTURE_PAINT:
-                       break;
-                       //return &ts->imapaint->paint;
+                       return &ts->imapaint.paint;
                }
        }
 
@@ -67,14 +71,14 @@ Brush *paint_brush(Paint *p)
 
 void paint_brush_set(Paint *p, Brush *br)
 {
-       if(!br) {
+       if(p && !br) {
                /* Setting to NULL removes the current slot */
                paint_brush_slot_remove(p);
        }
-       else {
+       else if(p) {
                int found = 0;
        
-               if(p && p->brushes) {
+               if(p->brushes) {
                        int i;
                        
                        /* See if there's already a slot with the brush */
@@ -88,8 +92,10 @@ void paint_brush_set(Paint *p, Brush *br)
                        
                }
                
-               if(!found)
+               if(!found) {
                        paint_brush_slot_add(p);
+                       id_us_plus(&br->id);
+               }
                
                /* Make sure the current slot is the new brush */
                p->brushes[p->active_brush_index] = br;
@@ -153,14 +159,17 @@ int paint_facesel_test(Object *ob)
 
 }
 
-void paint_init(Paint *p, const char *name)
+void paint_init(Paint *p, const char col[3])
 {
        Brush *brush;
 
        /* If there's no brush, create one */
        brush = paint_brush(p);
-       brush_check_exists(&brush, name);
+       brush_check_exists(&brush, "Brush");
        paint_brush_set(p, brush);
+
+       memcpy(p->paint_cursor_col, col, 3);
+       p->paint_cursor_col[3] = 128;
 }
 
 void free_paint(Paint *paint)