Revision: 56092
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=56092
Author:   campbellbarton
Date:     2013-04-16 15:16:48 +0000 (Tue, 16 Apr 2013)
Log Message:
-----------
add distance arg to BKE_bmbvh_ray_cast(). currently unused.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_editmesh_bvh.h
    trunk/blender/source/blender/blenkernel/intern/editmesh_bvh.c
    trunk/blender/source/blender/editors/mesh/editmesh_knife.c
    trunk/blender/source/blender/editors/mesh/editmesh_utils.c

Modified: trunk/blender/source/blender/blenkernel/BKE_editmesh_bvh.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_editmesh_bvh.h  2013-04-16 
15:02:41 UTC (rev 56091)
+++ trunk/blender/source/blender/blenkernel/BKE_editmesh_bvh.h  2013-04-16 
15:16:48 UTC (rev 56092)
@@ -45,7 +45,7 @@
 void            BKE_bmbvh_free(BMBVHTree *tree);
 struct BVHTree *BKE_bmbvh_tree_get(BMBVHTree *tree);
 struct BMFace  *BKE_bmbvh_ray_cast(BMBVHTree *tree, const float co[3], const 
float dir[3],
-                                   float r_hitout[3], float r_cagehit[3]);
+                                   float *r_dist, float r_hitout[3], float 
r_cagehit[3]);
 /* find a vert closest to co in a sphere of radius maxdist */
 struct BMVert  *BKE_bmbvh_find_vert_closest(BMBVHTree *tree, const float 
co[3], const float maxdist);
 

Modified: trunk/blender/source/blender/blenkernel/intern/editmesh_bvh.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/editmesh_bvh.c       
2013-04-16 15:02:41 UTC (rev 56091)
+++ trunk/blender/source/blender/blenkernel/intern/editmesh_bvh.c       
2013-04-16 15:16:48 UTC (rev 56092)
@@ -237,17 +237,18 @@
 }
 
 BMFace *BKE_bmbvh_ray_cast(BMBVHTree *tree, const float co[3], const float 
dir[3],
-                           float r_hitout[3], float r_cagehit[3])
+                           float *r_dist, float r_hitout[3], float 
r_cagehit[3])
 {
        BVHTreeRayHit hit;
+       const float dist = r_dist ? *r_dist : FLT_MAX;
 
-       hit.dist = FLT_MAX;
+       hit.dist = dist;
        hit.index = -1;
+
+       zero_v2(tree->uv);
        
-       tree->uv[0] = tree->uv[1] = 0.0f;
-       
        BLI_bvhtree_ray_cast(tree->tree, co, dir, 0.0f, &hit, raycallback, 
tree);
-       if (hit.dist != FLT_MAX && hit.index != -1) {
+       if (hit.index != -1 && hit.dist != dist) {
                if (r_hitout) {
                        if (tree->flag & BMBVH_RETURN_ORIG) {
                                const float *co1, *co2, *co3;
@@ -271,6 +272,10 @@
                        }
                }
 
+               if (r_dist) {
+                       *r_dist = hit.dist;
+               }
+
                return tree->em->looptris[hit.index][0]->f;
        }
 

Modified: trunk/blender/source/blender/editors/mesh/editmesh_knife.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/editmesh_knife.c  2013-04-16 
15:02:41 UTC (rev 56091)
+++ trunk/blender/source/blender/editors/mesh/editmesh_knife.c  2013-04-16 
15:16:48 UTC (rev 56092)
@@ -1268,7 +1268,7 @@
                                        add_v3_v3(p1, no);
                                                
                                        /* ray cast */
-                                       f_hit = BKE_bmbvh_ray_cast(bmtree, p1, 
no, NULL, NULL);
+                                       f_hit = BKE_bmbvh_ray_cast(bmtree, p1, 
no, NULL, NULL, NULL);
                                }
 
                                /* ok, if visible add the new point */
@@ -1502,7 +1502,7 @@
        knife_input_ray_segment(kcd, kcd->curr.mval, 1.0f, origin, origin_ofs);
        sub_v3_v3v3(ray, origin_ofs, origin);
 
-       f = BKE_bmbvh_ray_cast(kcd->bmbvh, origin, ray, co, cageco);
+       f = BKE_bmbvh_ray_cast(kcd->bmbvh, origin, ray, NULL, co, cageco);
 
        if (is_space)
                *is_space = !f;

Modified: trunk/blender/source/blender/editors/mesh/editmesh_utils.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/editmesh_utils.c  2013-04-16 
15:02:41 UTC (rev 56091)
+++ trunk/blender/source/blender/editors/mesh/editmesh_utils.c  2013-04-16 
15:16:48 UTC (rev 56092)
@@ -1391,7 +1391,7 @@
 
 static BMFace *edge_ray_cast(struct BMBVHTree *tree, const float co[3], const 
float dir[3], float *r_hitout, BMEdge *e)
 {
-       BMFace *f = BKE_bmbvh_ray_cast(tree, co, dir, r_hitout, NULL);
+       BMFace *f = BKE_bmbvh_ray_cast(tree, co, dir, NULL, r_hitout, NULL);
 
        if (f && BM_edge_in_face(f, e))
                return NULL;

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to