diff options
author | Nicholas Bishop <nicholasbishop@gmail.com> | 2013-01-19 20:10:21 +0400 |
---|---|---|
committer | Nicholas Bishop <nicholasbishop@gmail.com> | 2013-01-19 20:10:21 +0400 |
commit | 9a50f454697e5dea6e8603aa90fadaa6156657d6 (patch) | |
tree | 150f678940c8bb280697a0fde95e203c1fc3f7f4 /source/blender/blenkernel | |
parent | 399763015769ca8e35a5639748c9bb08fbfd984b (diff) |
Skip hidden faces in PBVH BMesh ray intersection test
Moved the GPU function gpu_bmesh_face_visible() to BKE_paint and
inverted the test to match equivalent tests for other mesh types:
paint_is_bmesh_face_hidden().
Changed BKE_pbvh_bmesh_node_save_orig() to not save hidden faces into
the triangle array.
Modified the non-use-original branch of pbvh_bmesh_node_raycast() to
skip hidden faces.
Fixes bug #33914:
projects.blender.org/tracker/index.php?func=detail&aid=33914&group_id=9&atid=498
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_paint.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/paint.c | 18 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/pbvh_bmesh.c | 11 |
3 files changed, 28 insertions, 3 deletions
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h index 0a4a7f75e25..078923ee5f9 100644 --- a/source/blender/blenkernel/BKE_paint.h +++ b/source/blender/blenkernel/BKE_paint.h @@ -34,6 +34,7 @@ struct bContext; struct BMesh; +struct BMFace; struct Brush; struct MDisps; struct MeshElemMap; @@ -72,6 +73,7 @@ int paint_vertsel_test(struct Object *ob); 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); +int paint_is_bmesh_face_hidden(struct BMFace *f); /* paint masks */ float paint_grid_paint_mask(const struct GridPaintMask *gpm, unsigned level, diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index 5847e7508f0..dc8aed91c00 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -47,6 +47,8 @@ #include "BKE_paint.h" #include "BKE_subsurf.h" +#include "bmesh.h" + #include <stdlib.h> #include <string.h> @@ -224,6 +226,22 @@ int paint_is_grid_face_hidden(const unsigned int *grid_hidden, BLI_BITMAP_GET(grid_hidden, (y + 1) * gridsize + x)); } +/* Return TRUE if all vertices in the face are visible, FALSE otherwise */ +int paint_is_bmesh_face_hidden(BMFace *f) +{ + BMLoop *l_iter; + BMLoop *l_first; + + l_iter = l_first = BM_FACE_FIRST_LOOP(f); + do { + if (BM_elem_flag_test(l_iter->v, BM_ELEM_HIDDEN)) { + return true; + } + } while ((l_iter = l_iter->next) != l_first); + + return false; +} + float paint_grid_paint_mask(const GridPaintMask *gpm, unsigned level, unsigned x, unsigned y) { diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c index 7b6ad622deb..f3ac22f0df7 100644 --- a/source/blender/blenkernel/intern/pbvh_bmesh.c +++ b/source/blender/blenkernel/intern/pbvh_bmesh.c @@ -28,6 +28,7 @@ #include "BKE_ccg.h" #include "BKE_DerivedMesh.h" #include "BKE_global.h" +#include "BKE_paint.h" #include "BKE_pbvh.h" #include "GPU_buffers.h" @@ -936,10 +937,9 @@ int pbvh_bmesh_node_raycast(PBVHNode *node, const float ray_start[3], BMFace *f = BLI_ghashIterator_getKey(&gh_iter); BLI_assert(f->len == 3); - if (f->len == 3) { + if (f->len == 3 && !paint_is_bmesh_face_hidden(f)) { BMVert *v_tri[3]; - // BM_iter_as_array(NULL, BM_VERTS_OF_FACE, f, (void **)v_tri, 3); BM_face_as_array_vert_tri(f, v_tri); hit |= ray_face_intersection(ray_start, ray_normal, v_tri[0]->co, @@ -1071,7 +1071,9 @@ BLI_INLINE void bm_face_as_array_index_tri(BMFace *f, int r_index[3]) } /* In order to perform operations on the original node coordinates - * (such as raycast), store the node's triangles and vertices.*/ + * (currently just raycast), store the node's triangles and vertices. + * + * Skips triangles that are hidden. */ void BKE_pbvh_bmesh_node_save_orig(PBVHNode *node) { GHashIterator gh_iter; @@ -1109,6 +1111,9 @@ void BKE_pbvh_bmesh_node_save_orig(PBVHNode *node) GHASH_ITER (gh_iter, node->bm_faces) { BMFace *f = BLI_ghashIterator_getKey(&gh_iter); + if (paint_is_bmesh_face_hidden(f)) + continue; + #if 0 BMIter bm_iter; BMVert *v; |