diff options
author | Nicholas Bishop <nicholasbishop@gmail.com> | 2012-05-11 00:33:24 +0400 |
---|---|---|
committer | Nicholas Bishop <nicholasbishop@gmail.com> | 2012-05-11 00:33:24 +0400 |
commit | aa77bbd38daff45725d7e726e89f2e681cee863d (patch) | |
tree | b2db3709f12af1c7a67700ffc3c095cafdd1fa5c /source/blender/blenloader | |
parent | f751d0f6ae7de155343e24e36965956bd7a061e3 (diff) |
Add DNA and customdata entries for paint masks.
CD_PAINT_MASK is a layer of per-vertex floats for non-multires
meshes. Multires meshes use CD_GRID_PAINT_MASK, which is a layer of
per-loop GridPaintMask structures. GridPaintMask is similar to MDisp,
but contains an array of scalar floats.
Note: the GridPaintMask could be folded into MDisp, but this way
should be easier to add mask layers in the future (if we do fold
GridPaintMask into MDisp, the mask array should probably be an array
of arrays with a 'totmask' field so that mask layers can be easily
supported.)
Includes blenload read/write support for CD_PAINT_MASK and
CD_GRID_PAINT_MASK.
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 15 | ||||
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 26 |
2 files changed, 41 insertions, 0 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 8c8066e9bd0..5bf2c8e53e2 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -3828,6 +3828,19 @@ static void direct_link_mdisps(FileData *fd, int count, MDisps *mdisps, int exte } } +static void direct_link_grid_paint_mask(FileData *fd, int count, GridPaintMask *grid_paint_mask) +{ + if(grid_paint_mask) { + int i; + + for(i = 0; i < count; ++i) { + GridPaintMask *gpm = &grid_paint_mask[i]; + if(gpm->data) + gpm->data = newdataadr(fd, gpm->data); + } + } +} + /*this isn't really a public api function, so prototyped here*/ static void direct_link_customdata(FileData *fd, CustomData *data, int count) { @@ -3854,6 +3867,8 @@ static void direct_link_customdata(FileData *fd, CustomData *data, int count) layer->data = newdataadr(fd, layer->data); if (layer->type == CD_MDISPS) 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); i++; } } diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 91ce94ae6ed..27ecf25fa91 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -152,6 +152,7 @@ Any case: direct data is ALWAYS after the lib block #include "BKE_node.h" #include "BKE_report.h" #include "BKE_sequencer.h" +#include "BKE_subsurf.h" #include "BKE_utildefines.h" #include "BKE_modifier.h" #include "BKE_fcurve.h" @@ -1654,6 +1655,24 @@ static void write_mdisps(WriteData *wd, int count, MDisps *mdlist, int external) } } +static void write_grid_paint_mask(WriteData *wd, int count, GridPaintMask *grid_paint_mask) +{ + if(grid_paint_mask) { + int i; + + writestruct(wd, DATA, "GridPaintMask", count, grid_paint_mask); + for(i = 0; i < count; ++i) { + GridPaintMask *gpm = &grid_paint_mask[i]; + if(gpm->data) { + const int gridsize = ccg_gridsize(gpm->level); + writedata(wd, DATA, + sizeof(*gpm->data) * gridsize * gridsize, + gpm->data); + } + } + } +} + static void write_customdata(WriteData *wd, ID *id, int count, CustomData *data, int partial_type, int partial_count) { int i; @@ -1676,6 +1695,13 @@ static void write_customdata(WriteData *wd, ID *id, int count, CustomData *data, else if (layer->type == CD_MDISPS) { write_mdisps(wd, count, layer->data, layer->flag & CD_FLAG_EXTERNAL); } + else if (layer->type == CD_PAINT_MASK) { + float *layer_data = layer->data; + writedata(wd, DATA, sizeof(*layer_data) * count, layer_data); + } + else if (layer->type == CD_GRID_PAINT_MASK) { + write_grid_paint_mask(wd, count, layer->data); + } else { CustomData_file_write_info(layer->type, &structname, &structnum); if (structnum) { |