[Bf-blender-cvs] [ad1293f] cycles-ptex-49: Update Blend file saving/loading for Ptex

Nicholas Bishop noreply at git.blender.org
Fri Feb 6 17:35:14 CET 2015


Commit: ad1293f636face153f5155009ccde78bb3264988
Author: Nicholas Bishop
Date:   Thu Jan 22 14:31:52 2015 +0100
Branches: cycles-ptex-49
https://developer.blender.org/rBad1293f636face153f5155009ccde78bb3264988

Update Blend file saving/loading for Ptex

===================================================================

M	source/blender/blenloader/intern/readfile.c
M	source/blender/blenloader/intern/writefile.c

===================================================================

diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index b892d3d..b4c8aca 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -4190,6 +4190,14 @@ static void direct_link_customdata(FileData *fd, CustomData *data, int count)
 				direct_link_mdisps(fd, count, layer->data, layer->flag & CD_FLAG_EXTERNAL);
 			else if (layer->type == CD_GRID_PAINT_MASK)
 				direct_link_grid_paint_mask(fd, count, layer->data);
+			else if (layer->type == CD_LOOP_PTEX) {
+				MLoopPtex *loop_ptex = layer->data;
+				int j;
+				for (j = 0; j < count; ++j) {
+					loop_ptex[j].rect = newdataadr(fd, loop_ptex[j].rect);
+					loop_ptex[j].image = NULL;
+				}
+			}
 			i++;
 		}
 	}
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 3eeb30a..46c1ae7 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -153,6 +153,7 @@
 #include "BKE_library.h" // for  set_listbasepointers
 #include "BKE_main.h"
 #include "BKE_node.h"
+#include "BKE_ptex.h"
 #include "BKE_report.h"
 #include "BKE_sequencer.h"
 #include "BKE_subsurf.h"
@@ -1871,6 +1872,21 @@ static void write_grid_paint_mask(WriteData *wd, int count, GridPaintMask *grid_
 	}
 }
 
+static void write_loop_ptex(WriteData *wd, int count, MLoopPtex *loop_ptex)
+{
+	if (loop_ptex) {
+		int i;
+		writestruct(wd, DATA, "MLoopPtex", count, loop_ptex);
+		for (i = 0; i < count; ++i) {
+			MLoopPtex *lp = &loop_ptex[i];
+			if (lp->rect) {
+				const size_t num_bytes = BKE_loop_ptex_rect_num_bytes(lp);
+				writedata(wd, DATA, num_bytes, lp->rect);
+			}
+		}
+	}
+}
+
 static void write_customdata(WriteData *wd, ID *id, int count, CustomData *data, int partial_type, int partial_count)
 {
 	CustomData data_tmp;
@@ -1910,6 +1926,9 @@ static void write_customdata(WriteData *wd, ID *id, int count, CustomData *data,
 		else if (layer->type == CD_GRID_PAINT_MASK) {
 			write_grid_paint_mask(wd, count, layer->data);
 		}
+		else if (layer->type == CD_LOOP_PTEX) {
+			write_loop_ptex(wd, count, layer->data);
+		}
 		else {
 			CustomData_file_write_info(layer->type, &structname, &structnum);
 			if (structnum) {




More information about the Bf-blender-cvs mailing list