[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [22552] branches/blender2.5/blender/source /blender: 2.5 Texture paint:

Nicholas Bishop nicholasbishop at gmail.com
Mon Aug 17 06:40:59 CEST 2009


Revision: 22552
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=22552
Author:   nicholasbishop
Date:     2009-08-17 06:40:59 +0200 (Mon, 17 Aug 2009)

Log Message:
-----------
2.5 Texture paint:

* Converted to use Paint struct. Now all the brush modes are done.

TODO:
* Make the UI better

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/blenkernel/BKE_paint.h
    branches/blender2.5/blender/source/blender/blenkernel/intern/brush.c
    branches/blender2.5/blender/source/blender/blenkernel/intern/paint.c
    branches/blender2.5/blender/source/blender/blenkernel/intern/scene.c
    branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
    branches/blender2.5/blender/source/blender/blenloader/intern/writefile.c
    branches/blender2.5/blender/source/blender/editors/sculpt_paint/paint_image.c
    branches/blender2.5/blender/source/blender/editors/space_buttons/buttons_context.c
    branches/blender2.5/blender/source/blender/editors/space_image/image_buttons.c
    branches/blender2.5/blender/source/blender/editors/space_image/image_draw.c
    branches/blender2.5/blender/source/blender/editors/space_node/node_edit.c
    branches/blender2.5/blender/source/blender/makesdna/DNA_scene_types.h
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_sculpt_paint.c
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_space.c

Modified: branches/blender2.5/blender/source/blender/blenkernel/BKE_paint.h
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/BKE_paint.h	2009-08-17 04:15:53 UTC (rev 22551)
+++ branches/blender2.5/blender/source/blender/blenkernel/BKE_paint.h	2009-08-17 04:40:59 UTC (rev 22552)
@@ -33,9 +33,9 @@
 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);

Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/brush.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/brush.c	2009-08-17 04:15:53 UTC (rev 22551)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/brush.c	2009-08-17 04:40:59 UTC (rev 22552)
@@ -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 @@
 	}
 
 	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 @@
 		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--;
 				}

Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/paint.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/paint.c	2009-08-17 04:15:53 UTC (rev 22551)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/paint.c	2009-08-17 04:40:59 UTC (rev 22552)
@@ -158,6 +158,10 @@
 
 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]);
+	}
 }

Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/scene.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/scene.c	2009-08-17 04:15:53 UTC (rev 22551)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/scene.c	2009-08-17 04:40:59 UTC (rev 22552)
@@ -177,7 +177,7 @@
 				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 @@
 			free_paint(&sce->toolsettings->sculpt->paint);
 			MEM_freeN(sce->toolsettings->sculpt);
 		}
-		
+		free_paint(&sce->toolsettings->imapaint.paint);
+
 		MEM_freeN(sce->toolsettings);
 		sce->toolsettings = NULL;	
 	}

Modified: branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c	2009-08-17 04:15:53 UTC (rev 22551)
+++ branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c	2009-08-17 04:40:59 UTC (rev 22552)
@@ -4042,12 +4042,10 @@
 			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 @@
 		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;
 	}

Modified: branches/blender2.5/blender/source/blender/blenloader/intern/writefile.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenloader/intern/writefile.c	2009-08-17 04:15:53 UTC (rev 22551)
+++ branches/blender2.5/blender/source/blender/blenloader/intern/writefile.c	2009-08-17 04:40:59 UTC (rev 22552)
@@ -1726,6 +1726,8 @@
 			write_paint(wd, &tos->sculpt->paint);
 		}
 
+		write_paint(wd, &tos->imapaint.paint);
+
 		ed= sce->ed;
 		if(ed) {
 			writestruct(wd, DATA, "Editing", 1, ed);

Modified: branches/blender2.5/blender/source/blender/editors/sculpt_paint/paint_image.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/sculpt_paint/paint_image.c	2009-08-17 04:15:53 UTC (rev 22551)
+++ branches/blender2.5/blender/source/blender/editors/sculpt_paint/paint_image.c	2009-08-17 04:40:59 UTC (rev 22552)
@@ -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 @@
 	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 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 @@
 	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 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 @@
 {
 	PaintOperation *pop;
 
-	if(!paint_init(C, op)) {
+	if(!texture_paint_init(C, op)) {
 		MEM_freeN(op->customdata);
 		return OPERATOR_CANCELLED;
 	}
@@ -4874,7 +4877,7 @@
 	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 @@
 	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 @@
 			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 @@
 {
 	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);
 

Modified: branches/blender2.5/blender/source/blender/editors/space_buttons/buttons_context.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_buttons/buttons_context.c	2009-08-17 04:15:53 UTC (rev 22551)
+++ branches/blender2.5/blender/source/blender/editors/space_buttons/buttons_context.c	2009-08-17 04:40:59 UTC (rev 22552)
@@ -322,16 +322,8 @@
 		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]);

Modified: branches/blender2.5/blender/source/blender/editors/space_image/image_buttons.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_image/image_buttons.c	2009-08-17 04:15:53 UTC (rev 22551)
+++ branches/blender2.5/blender/source/blender/editors/space_image/image_buttons.c	2009-08-17 04:40:59 UTC (rev 22552)
@@ -451,7 +451,7 @@
 {
 //	SpaceImage *sima= CTX_wm_space_image(C);

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list