diff options
-rw-r--r-- | source/blender/blenkernel/BKE_paint.h | 6 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/customdata.c | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/paint.c | 27 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 1 | ||||
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 13 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_meshdata_types.h | 6 |
6 files changed, 52 insertions, 5 deletions
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h index 045e11c18b8..ff3e3c81724 100644 --- a/source/blender/blenkernel/BKE_paint.h +++ b/source/blender/blenkernel/BKE_paint.h @@ -33,6 +33,7 @@ */ struct Brush; +struct MDisps; struct MFace; struct MultireModifierData; struct MVert; @@ -61,6 +62,11 @@ void paint_brush_set(struct Paint *paint, struct Brush *br); int paint_facesel_test(struct Object *ob); int paint_vertsel_test(struct Object *ob); +/* partial visibility */ +int paint_is_face_hidden(const struct MFace *f, const struct MVert *mvert); +int paint_is_grid_face_hidden(const unsigned int *grid_hidden, + int gridsize, int x, int y); + /* Session data (mode-specific) */ typedef struct SculptSession { diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 2520c9b666e..e7af73c5e0f 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -484,6 +484,7 @@ static void layerCopy_mdisps(const void *source, void *dest, int count) for(i = 0; i < count; ++i) { if(s[i].disps) { d[i].disps = MEM_dupallocN(s[i].disps); + d[i].hidden = MEM_dupallocN(s[i].hidden); d[i].totdisp = s[i].totdisp; d[i].level = s[i].level; } @@ -504,7 +505,10 @@ static void layerFree_mdisps(void *data, int count, int UNUSED(size)) for(i = 0; i < count; ++i) { if(d[i].disps) MEM_freeN(d[i].disps); + if(d[i].hidden) + MEM_freeN(d[i].hidden); d[i].disps = NULL; + d[i].hidden = NULL; d[i].totdisp = 0; d[i].level = 0; } diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index 2b3f792f777..fe4fdb58951 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -33,15 +33,17 @@ #include "DNA_object_types.h" #include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" #include "DNA_scene_types.h" #include "DNA_brush_types.h" +#include "BLI_bitmap.h" #include "BLI_utildefines.h" - #include "BKE_brush.h" #include "BKE_library.h" #include "BKE_paint.h" +#include "BKE_subsurf.h" #include <stdlib.h> #include <string.h> @@ -147,3 +149,26 @@ void copy_paint(Paint *src, Paint *tar) tar->brush= src->brush; id_us_plus((ID *)tar->brush); } + +/* returns non-zero if any of the face's vertices + are hidden, zero otherwise */ +int paint_is_face_hidden(const MFace *f, const MVert *mvert) +{ + return ((mvert[f->v1].flag & ME_HIDE) || + (mvert[f->v2].flag & ME_HIDE) || + (mvert[f->v3].flag & ME_HIDE) || + (f->v4 && (mvert[f->v4].flag & ME_HIDE))); +} + +/* returns non-zero if any of the corners of the grid + face whose inner corner is at (x,y) are hidden, + zero otherwise */ +int paint_is_grid_face_hidden(const unsigned int *grid_hidden, + int gridsize, int x, int y) +{ + /* skip face if any of its corners are hidden */ + return (BLI_BITMAP_GET(grid_hidden, y * gridsize + x) || + BLI_BITMAP_GET(grid_hidden, y * gridsize + x+1) || + BLI_BITMAP_GET(grid_hidden, (y+1) * gridsize + x+1) || + BLI_BITMAP_GET(grid_hidden, (y+1) * gridsize + x)); +} diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 2cbb8a300ed..0ba4c7a63d0 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -3750,6 +3750,7 @@ static void direct_link_mdisps(FileData *fd, int count, MDisps *mdisps, int exte for(i = 0; i < count; ++i) { mdisps[i].disps = newdataadr(fd, mdisps[i].disps); + mdisps[i].hidden = newdataadr(fd, mdisps[i].hidden); if (mdisps[i].totdisp && !mdisps[i].level) { /* this calculation is only correct for loop mdisps; diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 42c0ed1e55d..37e2308a0c1 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -135,6 +135,7 @@ Any case: direct data is ALWAYS after the lib block #include "DNA_movieclip_types.h" #include "MEM_guardedalloc.h" // MEM_freeN +#include "BLI_bitmap.h" #include "BLI_blenlib.h" #include "BLI_linklist.h" #include "BLI_bpath.h" @@ -1638,11 +1639,15 @@ static void write_mdisps(WriteData *wd, int count, MDisps *mdlist, int external) int i; writestruct(wd, DATA, "MDisps", count, mdlist); - if(!external) { - for(i = 0; i < count; ++i) { - if(mdlist[i].disps) - writedata(wd, DATA, sizeof(float)*3*mdlist[i].totdisp, mdlist[i].disps); + for(i = 0; i < count; ++i) { + MDisps *md = &mdlist[i]; + if(md->disps) { + if(!external) + writedata(wd, DATA, sizeof(float)*3*md->totdisp, md->disps); } + + if(md->hidden) + writedata(wd, DATA, BLI_BITMAP_SIZE(md->totdisp), md->hidden); } } } diff --git a/source/blender/makesdna/DNA_meshdata_types.h b/source/blender/makesdna/DNA_meshdata_types.h index f5a8a185556..6b526c6463e 100644 --- a/source/blender/makesdna/DNA_meshdata_types.h +++ b/source/blender/makesdna/DNA_meshdata_types.h @@ -166,6 +166,12 @@ typedef struct MDisps { int totdisp; int level; float (*disps)[3]; + + /* Used for hiding parts of a multires mesh. Essentially the multires + equivalent of MVert.flag's ME_HIDE bit. + + This is a bitmap, keep in sync with type used in BLI_bitmap.h */ + unsigned int *hidden; } MDisps; /** Multires structs kept for compatibility with old files **/ |