Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Bishop <nicholasbishop@gmail.com>2009-08-17 08:40:59 +0400
committerNicholas Bishop <nicholasbishop@gmail.com>2009-08-17 08:40:59 +0400
commita3b317daf7fbaa2359afbfdf0524b590d3622f2e (patch)
treeaf7876365655c372b4a7a3e16c41fde9b725d3ad /source/blender
parent3425925a7702c0a5527c60b2da044dad378d7f2c (diff)
2.5 Texture paint:
* Converted to use Paint struct. Now all the brush modes are done. TODO: * Make the UI better
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/BKE_paint.h6
-rw-r--r--source/blender/blenkernel/intern/brush.c7
-rw-r--r--source/blender/blenkernel/intern/paint.c6
-rw-r--r--source/blender/blenkernel/intern/scene.c5
-rw-r--r--source/blender/blenloader/intern/readfile.c6
-rw-r--r--source/blender/blenloader/intern/writefile.c2
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c25
-rw-r--r--source/blender/editors/space_buttons/buttons_context.c12
-rw-r--r--source/blender/editors/space_image/image_buttons.c6
-rw-r--r--source/blender/editors/space_image/image_draw.c5
-rw-r--r--source/blender/editors/space_node/node_edit.c13
-rw-r--r--source/blender/makesdna/DNA_scene_types.h21
-rw-r--r--source/blender/makesrna/intern/rna_sculpt_paint.c6
-rw-r--r--source/blender/makesrna/intern/rna_space.c4
14 files changed, 64 insertions, 60 deletions
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index ae18d0e9561..67b260b2348 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -33,9 +33,9 @@ struct Object;
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);
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index 3524550925e..612f6d2051d 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -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"
@@ -153,7 +154,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 +176,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--;
}
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index 8e774e4c85a..5ae84118356 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -158,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]);
+ }
}
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index dc1a55ed0eb..8488d7ab247 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -177,7 +177,7 @@ Scene *copy_scene(Main *bmain, Scene *sce, int type)
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;
@@ -284,7 +284,8 @@ void free_scene(Scene *sce)
free_paint(&sce->toolsettings->sculpt->paint);
MEM_freeN(sce->toolsettings->sculpt);
}
-
+ free_paint(&sce->toolsettings->imapaint.paint);
+
MEM_freeN(sce->toolsettings);
sce->toolsettings = NULL;
}
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 685c379dab2..9272c6fe353 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -4042,12 +4042,10 @@ static void lib_link_scene(FileData *fd, Main *main)
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);
@@ -4159,6 +4157,8 @@ static void direct_link_scene(FileData *fd, Scene *sce)
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;
}
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index f59fc769d5d..cd388cdf9cc 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -1726,6 +1726,8 @@ static void write_scenes(WriteData *wd, ListBase *scebase)
write_paint(wd, &tos->sculpt->paint);
}
+ write_paint(wd, &tos->imapaint.paint);
+
ed= sce->ed;
if(ed) {
writestruct(wd, DATA, "Editing", 1, ed);
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index 93744072fff..975bfd8dbe7 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -71,6 +71,7 @@
#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"
@@ -4375,7 +4376,7 @@ static Brush *image_paint_brush(bContext *C)
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)
@@ -4486,11 +4487,12 @@ static void paint_redraw(bContext *C, ImagePaintState *s, int final)
}
}
-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;
@@ -4518,10 +4520,11 @@ static int paint_init(bContext *C, wmOperator *op)
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;
@@ -4672,7 +4675,7 @@ static void paint_exit(bContext *C, wmOperator *op)
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;
}
@@ -4746,7 +4749,7 @@ static int paint_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
PaintOperation *pop;
- if(!paint_init(C, op)) {
+ if(!texture_paint_init(C, op)) {
MEM_freeN(op->customdata);
return OPERATOR_CANCELLED;
}
@@ -4874,7 +4877,7 @@ static int paint_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *eve
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);
}
@@ -4893,7 +4896,7 @@ static int paint_radial_control_exec(bContext *C, wmOperator *op)
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;
@@ -5167,7 +5170,7 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op)
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();
@@ -5202,13 +5205,13 @@ static int texture_paint_radial_control_invoke(bContext *C, wmOperator *op, wmEv
{
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);
diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c
index 318e0b0f558..6b89532cdaf 100644
--- a/source/blender/editors/space_buttons/buttons_context.c
+++ b/source/blender/editors/space_buttons/buttons_context.c
@@ -322,16 +322,8 @@ static int buttons_context_path_brush(const bContext *C, ButsContextPath *path)
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]);
diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c
index e4fbaad656f..ac0a5c7f53a 100644
--- a/source/blender/editors/space_image/image_buttons.c
+++ b/source/blender/editors/space_image/image_buttons.c
@@ -451,7 +451,7 @@ void brush_buttons(const bContext *C, uiBlock *block, short fromsima,
{
// 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);
@@ -473,7 +473,7 @@ void brush_buttons(const bContext *C, uiBlock *block, short fromsima,
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) {
@@ -575,7 +575,7 @@ static void image_panel_paintcolor(const bContext *C, Panel *pa)
{
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];
diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c
index ff25a2635d2..2f5fc805367 100644
--- a/source/blender/editors/space_image/image_draw.c
+++ b/source/blender/editors/space_image/image_draw.c
@@ -47,6 +47,7 @@
#include "BKE_colortools.h"
#include "BKE_global.h"
#include "BKE_image.h"
+#include "BKE_paint.h"
#include "BKE_utildefines.h"
#include "BIF_gl.h"
@@ -577,7 +578,7 @@ static void draw_image_view_tool(Scene *scene)
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;
@@ -615,7 +616,7 @@ static void draw_image_paint_helpers(SpaceImage *sima, ARegion *ar, Scene *scene
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
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c
index d19dc897a89..d66cbb55baa 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -624,17 +624,18 @@ void snode_set_context(SpaceNode *snode, Scene *scene)
}
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;
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 28eddeb6f2e..f00813b58f1 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -429,8 +429,18 @@ typedef struct TimeMarker {
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 */
@@ -465,15 +475,6 @@ typedef struct TransformOrientation {
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;
diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c
index f3b970c7659..c2c906e38f2 100644
--- a/source/blender/makesrna/intern/rna_sculpt_paint.c
+++ b/source/blender/makesrna/intern/rna_sculpt_paint.c
@@ -204,14 +204,10 @@ static void rna_def_image_paint(BlenderRNA *brna)
{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", "");
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 24337c0fc70..6ecf533e39d 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -37,6 +37,8 @@
#include "DNA_space_types.h"
#include "DNA_view3d_types.h"
+#include "BKE_paint.h"
+
#include "WM_types.h"
EnumPropertyItem space_type_items[] = {
@@ -145,7 +147,7 @@ static void rna_SpaceImageEditor_paint_update(bContext *C, PointerRNA *ptr)
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)