Removed a remnant to an unsuccessful attempt to get clipping functional so I can...
[blender.git] / source / blender / blenkernel / intern / paint.c
1 /*
2  * $Id$
3  *
4  * ***** BEGIN GPL LICENSE BLOCK *****
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software  Foundation,
18  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  *
20  * The Original Code is Copyright (C) 2009 by Nicholas Bishop
21  * All rights reserved.
22  *
23  * The Original Code is: all of this file.
24  *
25  * Contributor(s): none yet.
26  *
27  * ***** END GPL LICENSE BLOCK *****
28  */
29
30 /** \file blender/blenkernel/intern/paint.c
31  *  \ingroup bke
32  */
33
34
35
36 #include "DNA_object_types.h"
37 #include "DNA_mesh_types.h"
38 #include "DNA_scene_types.h"
39 #include "DNA_brush_types.h"
40
41 #include "BLI_utildefines.h"
42
43
44 #include "BKE_brush.h"
45 #include "BKE_library.h"
46 #include "BKE_paint.h"
47
48 #include <stdlib.h>
49 #include <string.h>
50
51 const char PAINT_CURSOR_SCULPT[3] = {255, 100, 100};
52 const char PAINT_CURSOR_VERTEX_PAINT[3] = {255, 255, 255};
53 const char PAINT_CURSOR_WEIGHT_PAINT[3] = {200, 200, 255};
54 const char PAINT_CURSOR_TEXTURE_PAINT[3] = {255, 255, 255};
55
56 Paint *paint_get_active(Scene *sce)
57 {
58         if(sce) {
59                 ToolSettings *ts = sce->toolsettings;
60                 
61                 if(sce->basact && sce->basact->object) {
62                         switch(sce->basact->object->mode) {
63                         case OB_MODE_SCULPT:
64                                 return &ts->sculpt->paint;
65                         case OB_MODE_VERTEX_PAINT:
66                                 return &ts->vpaint->paint;
67                         case OB_MODE_WEIGHT_PAINT:
68                                 return &ts->wpaint->paint;
69                         case OB_MODE_TEXTURE_PAINT:
70                                 return &ts->imapaint.paint;
71                         }
72                 }
73
74                 /* default to image paint */
75                 return &ts->imapaint.paint;
76         }
77
78         return NULL;
79 }
80
81 Brush *paint_brush(Paint *p)
82 {
83         return p ? p->brush : NULL;
84 }
85
86 void paint_brush_set(Paint *p, Brush *br)
87 {
88         if(p)
89                 p->brush= br;
90 }
91
92 int paint_facesel_test(Object *ob)
93 {
94         return (ob && ob->type==OB_MESH && ob->data && (((Mesh *)ob->data)->editflag & ME_EDIT_PAINT_MASK) && (ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT)));
95 }
96 /* Jason */
97 int paint_vertsel_test(Object *ob)
98 {
99         return (ob && ob->type==OB_MESH && ob->data && (((Mesh *)ob->data)->editflag & ME_EDIT_VERT_SEL) && (ob->mode & (OB_MODE_WEIGHT_PAINT)));
100 }
101 void paint_init(Paint *p, const char col[3])
102 {
103         Brush *brush;
104
105         /* If there's no brush, create one */
106         brush = paint_brush(p);
107         if(brush == NULL)
108                 brush= add_brush("Brush");
109         paint_brush_set(p, brush);
110
111         memcpy(p->paint_cursor_col, col, 3);
112         p->paint_cursor_col[3] = 128;
113
114         p->flags |= PAINT_SHOW_BRUSH;
115 }
116
117 void free_paint(Paint *UNUSED(paint))
118 {
119         /* nothing */
120 }
121
122 void copy_paint(Paint *src, Paint *tar)
123 {
124         tar->brush= src->brush;
125 }