* Converted to use Paint struct. Now all the brush modes are done.
TODO:
* Make the UI better
struct Paint;
struct Scene;
-void paint_init(Paint *p, const char *brush_name);
-void free_paint(Paint *p);
-void copy_paint(Paint *orig, Paint *new);
+void paint_init(struct Paint *p, const char *brush_name);
+void free_paint(struct Paint *p);
+void copy_paint(struct Paint *orig, struct Paint *new);
struct Paint *paint_get_active(struct Scene *sce);
struct Brush *paint_brush(struct Paint *paint);
#include "BKE_image.h"
#include "BKE_library.h"
#include "BKE_main.h"
+#include "BKE_paint.h"
#include "BKE_texture.h"
#include "BKE_utildefines.h"
}
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;
}
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--;
}
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]);
+ }
}
copy_paint(&ts->sculpt->paint, &ts->sculpt->paint);
}
- id_us_plus((ID *)ts->imapaint.brush);
+ copy_paint(&ts->imapaint.paint, &ts->imapaint.paint);
ts->imapaint.paintcursor= NULL;
ts->particle.paintcursor= NULL;
free_paint(&sce->toolsettings->sculpt->paint);
MEM_freeN(sce->toolsettings->sculpt);
}
-
+ free_paint(&sce->toolsettings->imapaint.paint);
+
MEM_freeN(sce->toolsettings);
sce->toolsettings = NULL;
}
sce->set= newlibadr(fd, sce->id.lib, sce->set);
sce->ima= newlibadr_us(fd, sce->id.lib, sce->ima);
- sce->toolsettings->imapaint.brush=
- newlibadr_us(fd, sce->id.lib, sce->toolsettings->imapaint.brush);
-
link_paint(fd, sce, &sce->toolsettings->sculpt->paint);
link_paint(fd, sce, &sce->toolsettings->vpaint->paint);
link_paint(fd, sce, &sce->toolsettings->wpaint->paint);
+ link_paint(fd, sce, &sce->toolsettings->imapaint.paint);
sce->toolsettings->skgen_template = newlibadr(fd, sce->id.lib, sce->toolsettings->skgen_template);
direct_link_paint(fd, (Paint**)&sce->toolsettings->vpaint);
direct_link_paint(fd, (Paint**)&sce->toolsettings->wpaint);
+ sce->toolsettings->imapaint.paint.brushes= newdataadr(fd, sce->toolsettings->imapaint.paint.brushes);
+
sce->toolsettings->imapaint.paintcursor= NULL;
sce->toolsettings->particle.paintcursor= NULL;
}
write_paint(wd, &tos->sculpt->paint);
}
+ write_paint(wd, &tos->imapaint.paint);
+
ed= sce->ed;
if(ed) {
writestruct(wd, DATA, "Editing", 1, ed);
#include "BKE_main.h"
#include "BKE_mesh.h"
#include "BKE_node.h"
+#include "BKE_paint.h"
#include "BKE_utildefines.h"
#include "BKE_DerivedMesh.h"
#include "BKE_report.h"
Scene *scene= CTX_data_scene(C);
ToolSettings *settings= scene->toolsettings;
- return settings->imapaint.brush;
+ return paint_brush(&settings->imapaint.paint);
}
static int image_paint_poll(bContext *C)
}
}
-static int paint_init(bContext *C, wmOperator *op)
+static int texture_paint_init(bContext *C, wmOperator *op)
{
Scene *scene= CTX_data_scene(C);
ToolSettings *settings= scene->toolsettings;
PaintOperation *pop;
+ Brush *brush;
pop= MEM_callocN(sizeof(PaintOperation), "PaintOperation");
pop->first= 1;
pop->ps.ar= CTX_wm_region(C);
/* intialize brush */
- if(!settings->imapaint.brush)
+ brush= paint_brush(&settings->imapaint.paint);
+ if(!brush)
return 0;
- pop->s.brush = settings->imapaint.brush;
+ pop->s.brush = brush;
pop->s.tool = settings->imapaint.tool;
if(pop->mode == PAINT_MODE_3D && (pop->s.tool == PAINT_TOOL_CLONE))
pop->s.tool = PAINT_TOOL_DRAW;
static int paint_exec(bContext *C, wmOperator *op)
{
- if(!paint_init(C, op)) {
+ if(!texture_paint_init(C, op)) {
MEM_freeN(op->customdata);
return OPERATOR_CANCELLED;
}
{
PaintOperation *pop;
- if(!paint_init(C, op)) {
+ if(!texture_paint_init(C, op)) {
MEM_freeN(op->customdata);
return OPERATOR_CANCELLED;
}
ToolSettings *ts = CTX_data_scene(C)->toolsettings;
get_imapaint_zoom(C, &zoom, &zoom);
toggle_paint_cursor(C, !ts->imapaint.paintcursor);
- brush_radial_control_invoke(op, ts->imapaint.brush, 0.5 * zoom);
+ brush_radial_control_invoke(op, paint_brush(&ts->imapaint.paint), 0.5 * zoom);
return WM_radial_control_invoke(C, op, event);
}
int ret;
char str[256];
get_imapaint_zoom(C, &zoom, &zoom);
- ret = brush_radial_control_exec(op, CTX_data_scene(C)->toolsettings->imapaint.brush, 2.0 / zoom);
+ ret = brush_radial_control_exec(op, paint_brush(&CTX_data_scene(C)->toolsettings->imapaint.paint), 2.0 / zoom);
WM_radial_control_string(op, str, 256);
return ret;
me->mtface= CustomData_add_layer(&me->fdata, CD_MTFACE, CD_DEFAULT,
NULL, me->totface);
- brush_check_exists(&scene->toolsettings->imapaint.brush, "Brush");
+ paint_init(&scene->toolsettings->imapaint.paint, "Brush");
if(U.glreslimit != 0)
GPU_free_images();
{
ToolSettings *ts = CTX_data_scene(C)->toolsettings;
toggle_paint_cursor(C, !ts->imapaint.paintcursor);
- brush_radial_control_invoke(op, ts->imapaint.brush, 0.5);
+ brush_radial_control_invoke(op, paint_brush(&ts->imapaint.paint), 0.5);
return WM_radial_control_invoke(C, op, event);
}
static int texture_paint_radial_control_exec(bContext *C, wmOperator *op)
{
- int ret = brush_radial_control_exec(op, CTX_data_scene(C)->toolsettings->imapaint.brush, 2);
+ int ret = brush_radial_control_exec(op, paint_brush(&CTX_data_scene(C)->toolsettings->imapaint.paint), 2);
char str[256];
WM_radial_control_string(op, str, 256);
scene= path->ptr[path->len-1].data;
ts= scene->toolsettings;
- if(obact) {
- if(obact->mode & OB_MODE_SCULPT)
- paint_brush(&ts->sculpt->paint);
- else if(obact->mode & OB_MODE_VERTEX_PAINT)
- paint_brush(&ts->vpaint->paint);
- else if(obact->mode & OB_MODE_WEIGHT_PAINT)
- paint_brush(&ts->wpaint->paint);
- else if(obact->mode & OB_MODE_TEXTURE_PAINT)
- br= ts->imapaint.brush;
- }
+ if(scene)
+ br= paint_brush(paint_get_active(scene));
if(br) {
RNA_id_pointer_create(&br->id, &path->ptr[path->len]);
{
// SpaceImage *sima= CTX_wm_space_image(C);
ToolSettings *settings= CTX_data_tool_settings(C);
- Brush *brush= settings->imapaint.brush;
+ Brush *brush= paint_brush(&settings->imapaint.paint);
ID *id;
int yco, xco, butw, but_idx;
// short *menupoin = &(sima->menunr); // XXX : &(G.buts->menunr);
uiBlockEndAlign(block);
yco -= 30;
- id= (ID*)settings->imapaint.brush;
+ id= (ID*)brush;
xco= 200; // std_libbuttons(block, 0, yco, 0, NULL, evt_browse, ID_BR, 0, id, NULL, menupoin, 0, evt_local, evt_del, 0, evt_keepdata);
if(brush && !brush->id.lib) {
{
SpaceImage *sima= CTX_wm_space_image(C);
ToolSettings *settings= CTX_data_tool_settings(C);
- Brush *brush= settings->imapaint.brush;
+ Brush *brush= paint_brush(&settings->imapaint.paint);
uiBlock *block;
static float hsv[3], old[3]; // used as temp mem for picker
static char hexcol[128];
#include "BKE_colortools.h"
#include "BKE_global.h"
#include "BKE_image.h"
+#include "BKE_paint.h"
#include "BKE_utildefines.h"
#include "BIF_gl.h"
static unsigned char *get_alpha_clone_image(Scene *scene, int *width, int *height)
{
- Brush *brush = scene->toolsettings->imapaint.brush;
+ Brush *brush = paint_brush(&scene->toolsettings->imapaint.paint);
ImBuf *ibuf;
unsigned int size, alpha;
unsigned char *rect, *cp;
int x, y, w, h;
unsigned char *clonerect;
- brush= scene->toolsettings->imapaint.brush;
+ brush= paint_brush(&scene->toolsettings->imapaint.paint);
if(brush && (scene->toolsettings->imapaint.tool == PAINT_TOOL_CLONE)) {
/* this is not very efficient, but glDrawPixels doesn't allow
}
else {
MTex *mtex= NULL;
+ Brush *brush= NULL;
if(ob && ob->mode & OB_MODE_SCULPT) {
- Brush *brush = paint_brush(&scene->toolsettings->sculpt->paint);
+ brush= paint_brush(&scene->toolsettings->sculpt->paint);
+ }
+ else
+ brush= paint_brush(&scene->toolsettings->imapaint.paint);
+
+ if(brush) {
if(brush && brush->texact != -1)
mtex= brush->mtex[brush->texact];
}
- else {
- Brush *br= scene->toolsettings->imapaint.brush;
- if(br)
- mtex= br->mtex[br->texact];
- }
if(mtex) {
snode->from= (ID *)scene;
unsigned int flag;
} TimeMarker;
+typedef struct Paint {
+ /* Array of brushes selected for use in this paint mode */
+ Brush **brushes;
+ int active_brush_index, brush_count;
+
+ /* WM handle */
+ void *paint_cursor;
+} Paint;
+
typedef struct ImagePaintSettings {
- struct Brush *brush;
+ Paint paint;
+
short flag, tool;
/* for projection painting only */
float mat[3][3];
} TransformOrientation;
-typedef struct Paint {
- /* Array of brushes selected for use in this paint mode */
- Brush **brushes;
- int active_brush_index, brush_count;
-
- /* WM handle */
- void *paint_cursor;
-} Paint;
-
typedef struct Sculpt {
Paint paint;
{PAINT_TOOL_CLONE, "CLONE", 0, "Clone", ""},
{0, NULL, 0, NULL, NULL}};
- srna= RNA_def_struct(brna, "ImagePaint", NULL);
+ srna= RNA_def_struct(brna, "ImagePaint", "Paint");
RNA_def_struct_sdna(srna, "ImagePaintSettings");
RNA_def_struct_ui_text(srna, "Image Paint", "Properties of image and texture painting mode.");
- prop= RNA_def_property(srna, "brush", PROP_POINTER, PROP_NONE);
- RNA_def_property_struct_type(prop, "Brush");
- RNA_def_property_ui_text(prop, "Brush", "");
-
prop= RNA_def_property(srna, "tool", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, tool_items);
RNA_def_property_ui_text(prop, "Tool", "");
#include "DNA_space_types.h"
#include "DNA_view3d_types.h"
+#include "BKE_paint.h"
+
#include "WM_types.h"
EnumPropertyItem space_type_items[] = {
Scene *scene= CTX_data_scene(C);
if(scene)
- brush_check_exists(&scene->toolsettings->imapaint.brush, "Brush");
+ paint_init(&scene->toolsettings->imapaint.paint, "Brush");
}
static int rna_SpaceImageEditor_show_render_get(PointerRNA *ptr)