[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47219] trunk/blender/source/blender: Provide ray hit/nearest information on which side of the quad the ray hit.

Daniel Genrich daniel.genrich at gmx.net
Wed May 30 14:53:13 CEST 2012


Revision: 47219
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47219
Author:   genscher
Date:     2012-05-30 12:53:13 +0000 (Wed, 30 May 2012)
Log Message:
-----------
Provide ray hit/nearest information on which side of the quad the ray hit.

Patch by MiikaH.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/bvhutils.c
    trunk/blender/source/blender/blenlib/BLI_kdopbvh.h

Modified: trunk/blender/source/blender/blenkernel/intern/bvhutils.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/bvhutils.c	2012-05-30 12:08:08 UTC (rev 47218)
+++ trunk/blender/source/blender/blenkernel/intern/bvhutils.c	2012-05-30 12:53:13 UTC (rev 47219)
@@ -383,6 +383,9 @@
 			nearest->dist = dist;
 			copy_v3_v3(nearest->co, nearest_tmp);
 			normal_tri_v3(nearest->no, t0, t1, t2);
+
+			if (t1 == vert[face->v3].co)
+				nearest->flags |= BVH_ONQUAD;
 		}
 
 		t1 = t2;
@@ -420,6 +423,9 @@
 			madd_v3_v3v3fl(hit->co, ray->origin, ray->direction, dist);
 
 			normal_tri_v3(hit->no, t0, t1, t2);
+
+			if (t1 == vert[face->v3].co)
+				hit->flags |= BVH_ONQUAD;
 		}
 
 		t1 = t2;

Modified: trunk/blender/source/blender/blenlib/BLI_kdopbvh.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_kdopbvh.h	2012-05-30 12:08:08 UTC (rev 47218)
+++ trunk/blender/source/blender/blenlib/BLI_kdopbvh.h	2012-05-30 12:53:13 UTC (rev 47219)
@@ -49,11 +49,15 @@
 	int indexB;
 } BVHTreeOverlap;
 
+/* flags */
+#define BVH_ONQUAD (1<<0)
+
 typedef struct BVHTreeNearest {
 	int index;          /* the index of the nearest found (untouched if none is found within a dist radius from the given coordinates) */
 	float co[3];        /* nearest coordinates (untouched it none is found within a dist radius from the given coordinates) */
 	float no[3];        /* normal at nearest coordinates (untouched it none is found within a dist radius from the given coordinates) */
 	float dist;         /* squared distance to search arround */
+	int flags;
 } BVHTreeNearest;
 
 typedef struct BVHTreeRay {
@@ -67,6 +71,7 @@
 	float co[3];        /* coordinates of the hit point */
 	float no[3];        /* normal on hit point */
 	float dist;         /* distance to the hit point */
+	int flags;
 } BVHTreeRayHit;
 
 /* callback must update nearest in case it finds a nearest result */




More information about the Bf-blender-cvs mailing list