Commit: 80999ca70a90c6662653f365d2678630f2942354
Author: Nicholas Bishop
Date:   Thu Jan 22 14:31:52 2015 +0100
Branches: cycles-ptex-12
https://developer.blender.org/rB80999ca70a90c6662653f365d2678630f2942354

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 5893c22..f975205 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -4185,6 +4185,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].data = newdataadr(fd, 
loop_ptex[j].data);
+                                       loop_ptex[j].image = NULL;
+                               }
+                       }
                        i++;
                }
        }
diff --git a/source/blender/blenloader/intern/writefile.c 
b/source/blender/blenloader/intern/writefile.c
index 1de2b6b..b2c1166 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"
@@ -1867,6 +1868,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->data) {
+                               const size_t num_bytes = 
BKE_loop_ptex_data_num_bytes(lp);
+                               writedata(wd, DATA, num_bytes, lp->data);
+                       }
+               }
+       }
+}
+
 static void write_customdata(WriteData *wd, ID *id, int count, CustomData 
*data, int partial_type, int partial_count)
 {
        CustomData data_tmp;
@@ -1906,6 +1922,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) {

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to