diff options
author | Nicholas Bishop <nicholasbishop@gmail.com> | 2012-03-14 10:31:38 +0400 |
---|---|---|
committer | Nicholas Bishop <nicholasbishop@gmail.com> | 2012-03-14 10:31:38 +0400 |
commit | 82840ef94bce87684b0fcebcc47eb11d3771c1d3 (patch) | |
tree | dc8a883b8f7efa885ee9fc9a672f1b765d27dc5c /source/blender/blenkernel | |
parent | 0c918213646734acbbda110dca3fa2e2198b3894 (diff) |
Add MDisps.hidden bitmap.
Updates SDNA, customdata functions, and file read/write. Also adds
accessor functions to BKE paint.
Diffstat (limited to 'source/blender/blenkernel')
-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 |
3 files changed, 36 insertions, 1 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)); +} |