[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [22546] branches/blender2.5/blender/source /blender/blenloader/intern: 2.5 Paint:

Nicholas Bishop nicholasbishop at gmail.com
Mon Aug 17 02:39:00 CEST 2009


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

Log Message:
-----------
2.5 Paint:

* Refactored the file write/read code for the new Paint type. Just used for sculpt for now, but this'll make it easier when the other paint modes are converted.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
    branches/blender2.5/blender/source/blender/blenloader/intern/writefile.c

Modified: branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c	2009-08-17 00:24:49 UTC (rev 22545)
+++ branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c	2009-08-17 00:39:00 UTC (rev 22546)
@@ -4011,6 +4011,14 @@
 			node->id= &scene->id;
 }
 
+static void link_paint(FileData *fd, Scene *sce, Paint *p)
+{
+	if(p && p->brushes) {
+		int i;
+		for(i = 0; i < p->brush_count; ++i)
+			p->brushes[i]= newlibadr_us(fd, sce->id.lib, p->brushes[i]);
+	}
+}
 
 static void lib_link_scene(FileData *fd, Main *main)
 {
@@ -4036,12 +4044,9 @@
 			
 			sce->toolsettings->imapaint.brush=
 				newlibadr_us(fd, sce->id.lib, sce->toolsettings->imapaint.brush);
-			if(sce->toolsettings->sculpt && sce->toolsettings->sculpt->paint.brushes) {
-				int i;
-				for(i = 0; i < sce->toolsettings->sculpt->paint.brush_count; ++i)
-					sce->toolsettings->sculpt->paint.brushes[i]=
-						newlibadr_us(fd, sce->id.lib, sce->toolsettings->sculpt->paint.brushes[i]);
-			}
+
+			link_paint(fd, sce, &sce->toolsettings->sculpt->paint);
+
 			if(sce->toolsettings->vpaint)
 				sce->toolsettings->vpaint->brush=
 					newlibadr_us(fd, sce->id.lib, sce->toolsettings->vpaint->brush);
@@ -4121,6 +4126,13 @@
 			link_recurs_seq(fd, &seq->seqbase);
 }
 
+static void direct_link_paint(FileData *fd, Paint **paint)
+{
+	(*paint)= newdataadr(fd, (*paint));
+	if(*paint)
+		(*paint)->brushes= newdataadr(fd, (*paint)->brushes);
+}
+
 static void direct_link_scene(FileData *fd, Scene *sce)
 {
 	Editing *ed;
@@ -4150,9 +4162,8 @@
 	if(sce->toolsettings) {
 		sce->toolsettings->vpaint= newdataadr(fd, sce->toolsettings->vpaint);
 		sce->toolsettings->wpaint= newdataadr(fd, sce->toolsettings->wpaint);
-		sce->toolsettings->sculpt= newdataadr(fd, sce->toolsettings->sculpt);
-		if(sce->toolsettings->sculpt)
-			sce->toolsettings->sculpt->paint.brushes= newdataadr(fd, sce->toolsettings->sculpt->paint.brushes);
+		direct_link_paint(fd, (Paint**)&sce->toolsettings->sculpt);
+
 		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 00:24:49 UTC (rev 22545)
+++ branches/blender2.5/blender/source/blender/blenloader/intern/writefile.c	2009-08-17 00:39:00 UTC (rev 22546)
@@ -1676,6 +1676,11 @@
 	}
 }
 
+static void write_paint(WriteData *wd, Paint *p)
+{
+	if(p && p->brushes)
+		writedata(wd, DATA, p->brush_count * sizeof(Brush*), p->brushes);
+}
 
 static void write_scenes(WriteData *wd, ListBase *scebase)
 {
@@ -1688,6 +1693,7 @@
 	TimeMarker *marker;
 	TransformOrientation *ts;
 	SceneRenderLayer *srl;
+	ToolSettings *tos;
 	
 	sce= scebase->first;
 	while(sce) {
@@ -1705,17 +1711,15 @@
 			base= base->next;
 		}
 		
-		writestruct(wd, DATA, "ToolSettings", 1, sce->toolsettings);
-		if(sce->toolsettings->vpaint)
-			writestruct(wd, DATA, "VPaint", 1, sce->toolsettings->vpaint);
-		if(sce->toolsettings->wpaint)
-			writestruct(wd, DATA, "VPaint", 1, sce->toolsettings->wpaint);
-		if(sce->toolsettings->sculpt) {
-			writestruct(wd, DATA, "Sculpt", 1, sce->toolsettings->sculpt);
-			if(sce->toolsettings->sculpt->paint.brushes) {
-				Paint *p = &sce->toolsettings->sculpt->paint;
-				writedata(wd, DATA, p->brush_count * sizeof(Brush*), p->brushes);
-			}
+		tos = sce->toolsettings;
+		writestruct(wd, DATA, "ToolSettings", 1, tos);
+		if(tos->vpaint)
+			writestruct(wd, DATA, "VPaint", 1, tos->vpaint);
+		if(tos->wpaint)
+			writestruct(wd, DATA, "VPaint", 1, tos->wpaint);
+		if(tos->sculpt) {
+			writestruct(wd, DATA, "Sculpt", 1, tos->sculpt);
+			write_paint(wd, &tos->sculpt->paint);
 		}
 
 		ed= sce->ed;





More information about the Bf-blender-cvs mailing list