[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [58276] branches/soc-2013-paint/source/ blender: File saving code for palettes.

Antony Riakiotakis kalast at gmail.com
Mon Jul 15 20:39:19 CEST 2013


Revision: 58276
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58276
Author:   psy-fi
Date:     2013-07-15 18:39:18 +0000 (Mon, 15 Jul 2013)
Log Message:
-----------
File saving code for palettes.

Modified Paths:
--------------
    branches/soc-2013-paint/source/blender/blenloader/intern/readfile.c
    branches/soc-2013-paint/source/blender/blenloader/intern/writefile.c
    branches/soc-2013-paint/source/blender/makesdna/DNA_brush_types.h

Modified: branches/soc-2013-paint/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/soc-2013-paint/source/blender/blenloader/intern/readfile.c	2013-07-15 16:17:21 UTC (rev 58275)
+++ branches/soc-2013-paint/source/blender/blenloader/intern/readfile.c	2013-07-15 18:39:18 UTC (rev 58276)
@@ -1839,6 +1839,26 @@
 	brush->icon_imbuf = NULL;
 }
 
+/* ************ READ Palette *************** */
+static void lib_link_palette(FileData *UNUSED(fd), Main *main)
+{
+	Palette *palette;
+
+	/* only link ID pointers */
+	for (palette = main->palettes.first; palette; palette = palette->id.next) {
+		if (palette->id.flag & LIB_NEED_LINK) {
+			palette->id.flag -= LIB_NEED_LINK;
+		}
+	}
+}
+
+static void direct_link_palette(FileData *fd, Palette *palette)
+{
+	/* palette itself has been read */
+	palette->colours = newdataadr(fd, palette->colours);
+}
+
+
 static void direct_link_script(FileData *UNUSED(fd), Script *script)
 {
 	script->id.us = 1;
@@ -5042,6 +5062,7 @@
 {
 	if (p) {
 		p->brush = newlibadr_us(fd, sce->id.lib, p->brush);
+		p->palette = newlibadr_us(fd, sce->id.lib, p->palette);
 		p->paint_cursor = NULL;
 	}
 }
@@ -7178,6 +7199,9 @@
 		case ID_LS:
 			direct_link_linestyle(fd, (FreestyleLineStyle *)id);
 			break;
+		case ID_PAL:
+			direct_link_palette(fd, (Palette *)id);
+			break;
 	}
 	
 	oldnewmap_free_unused(fd->datamap);
@@ -9566,6 +9590,7 @@
 	lib_link_vfont(fd, main);
 	lib_link_nodetree(fd, main);	/* has to be done after scene/materials, this will verify group nodes */
 	lib_link_brush(fd, main);
+	lib_link_palette(fd, main);
 	lib_link_particlesettings(fd, main);
 	lib_link_movieclip(fd, main);
 	lib_link_mask(fd, main);

Modified: branches/soc-2013-paint/source/blender/blenloader/intern/writefile.c
===================================================================
--- branches/soc-2013-paint/source/blender/blenloader/intern/writefile.c	2013-07-15 16:17:21 UTC (rev 58275)
+++ branches/soc-2013-paint/source/blender/blenloader/intern/writefile.c	2013-07-15 18:39:18 UTC (rev 58276)
@@ -2855,6 +2855,21 @@
 	}
 }
 
+static void write_palettes(WriteData *wd, ListBase *idbase)
+{
+	Palette *palette;
+
+	for (palette = idbase->first; palette; palette= palette->id.next) {
+		if (palette->id.us > 0 || wd->current) {
+			writestruct(wd, ID_PAL, "Palette", 1, palette);
+			if (palette->id.properties) IDP_WriteProperty(palette->id.properties, wd);
+
+			if (palette->colours)
+				writestruct(wd, DATA, "PaletteColors", palette->num_of_colours, palette->colours);
+		}
+	}
+}
+
 static void write_scripts(WriteData *wd, ListBase *idbase)
 {
 	Script *script;
@@ -3296,6 +3311,7 @@
 	write_particlesettings(wd, &mainvar->particle);
 	write_nodetrees(wd, &mainvar->nodetree);
 	write_brushes  (wd, &mainvar->brush);
+	write_palettes (wd, &mainvar->palettes);
 	write_scripts  (wd, &mainvar->script);
 	write_gpencils (wd, &mainvar->gpencil);
 	write_linestyles(wd, &mainvar->linestyle);

Modified: branches/soc-2013-paint/source/blender/makesdna/DNA_brush_types.h
===================================================================
--- branches/soc-2013-paint/source/blender/makesdna/DNA_brush_types.h	2013-07-15 16:17:21 UTC (rev 58275)
+++ branches/soc-2013-paint/source/blender/makesdna/DNA_brush_types.h	2013-07-15 18:39:18 UTC (rev 58276)
@@ -128,7 +128,7 @@
 	ID id;
 
 	/* pointer to individual colours */
-	float *colours[3];
+	float (*colours)[3];
 
 	int num_of_colours;
 	int pad;




More information about the Bf-blender-cvs mailing list