diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2014-03-23 01:35:07 +0400 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2014-03-23 01:35:41 +0400 |
commit | e732c5809c2be01a0c622987bf9fbe7b37d3ed4c (patch) | |
tree | 0f6717db6a0da358500ade55715034a584f20f9c /source/blender/blenkernel | |
parent | c45c472e1b373c5125955056bcf3dd9b5edb8d18 (diff) |
Detail sampling operator
Located on topology panel.
To use just click on button and click on mesh.
Operator will just use the dimensions of the triangles below to set the
constant detail setting.
Also changed pair of scale/detail size with nice separate float
percentage value.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_pbvh.h | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/pbvh_bmesh.c | 44 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/pbvh_intern.h | 3 |
3 files changed, 50 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h index 0828ea54280..3601ff1ce04 100644 --- a/source/blender/blenkernel/BKE_pbvh.h +++ b/source/blender/blenkernel/BKE_pbvh.h @@ -98,6 +98,9 @@ int BKE_pbvh_node_raycast(PBVH *bvh, PBVHNode *node, float (*origco)[3], int use const float ray_start[3], const float ray_normal[3], float *dist); +int BKE_pbvh_bmesh_node_raycast_detail(PBVHNode *node, const float ray_start[3], + const float ray_normal[3], float *detail, float *dist); + /* for orthographic cameras, project the far away ray segment points to the root node so * we can have better precision. */ void BKE_pbvh_raycast_project_ray_root(PBVH *bvh, bool original, float ray_start[3], diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c index 3fae446f1f4..808b3faad9b 100644 --- a/source/blender/blenkernel/intern/pbvh_bmesh.c +++ b/source/blender/blenkernel/intern/pbvh_bmesh.c @@ -1035,6 +1035,50 @@ int pbvh_bmesh_node_raycast(PBVHNode *node, const float ray_start[3], return hit; } +int BKE_pbvh_bmesh_node_raycast_detail(PBVHNode *node, const float ray_start[3], + const float ray_normal[3], float *detail, float *dist) +{ + GHashIterator gh_iter; + int hit = 0; + BMFace *f_hit = NULL; + + if (node->flag & PBVH_FullyHidden) + return 0; + + GHASH_ITER (gh_iter, node->bm_faces) { + BMFace *f = BLI_ghashIterator_getKey(&gh_iter); + + BLI_assert(f->len == 3); + if (f->len == 3 && !paint_is_bmesh_face_hidden(f)) { + BMVert *v_tri[3]; + int hit_local; + BM_face_as_array_vert_tri(f, v_tri); + hit_local = ray_face_intersection(ray_start, ray_normal, + v_tri[0]->co, + v_tri[1]->co, + v_tri[2]->co, + NULL, dist); + if (hit_local) { + f_hit = f; + } + hit |= hit_local; + } + } + + if (hit) { + float len1, len2, len3; + BMVert *v_tri[3]; + BM_face_as_array_vert_tri(f_hit, v_tri); + len1 = len_v3v3(v_tri[0]->co, v_tri[1]->co); + len2 = len_v3v3(v_tri[1]->co, v_tri[2]->co); + len3 = len_v3v3(v_tri[2]->co, v_tri[0]->co); + + *detail = (len1 + len2 + len3)/3.0f; + } + + return hit; +} + void pbvh_bmesh_normals_update(PBVHNode **nodes, int totnode) { diff --git a/source/blender/blenkernel/intern/pbvh_intern.h b/source/blender/blenkernel/intern/pbvh_intern.h index d4cd6bcf9d8..75d2a8333a1 100644 --- a/source/blender/blenkernel/intern/pbvh_intern.h +++ b/source/blender/blenkernel/intern/pbvh_intern.h @@ -185,6 +185,9 @@ int pbvh_bmesh_node_raycast(PBVHNode *node, const float ray_start[3], const float ray_normal[3], float *dist, int use_original); +int pbvh_bmesh_node_raycast_detail(PBVHNode *node, const float ray_start[3], + const float ray_normal[3], float *detail, float *dist); + void pbvh_bmesh_normals_update(PBVHNode **nodes, int totnode); #endif |