Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2015-08-21 10:46:23 +0300
committerCampbell Barton <ideasman42@gmail.com>2015-08-21 10:48:33 +0300
commit59e166c568a57315b78c5ab812837c95923c300e (patch)
tree3bb1f901f1f1209fbee7449aeaa672c3487c88c6 /source/blender/blenlib/BLI_kdopbvh.h
parent71919efd78149a305bea4db18d80f9434abeca33 (diff)
BVH-raycast: Use watertight intersections
By default watertight intersections are used, For callbacks where its not needed, BLI_bvhtree_ray_cast_ex can be called without the BVH_RAYCAST_WATERTIGHT flag. Fixes T45286
Diffstat (limited to 'source/blender/blenlib/BLI_kdopbvh.h')
-rw-r--r--source/blender/blenlib/BLI_kdopbvh.h31
1 files changed, 25 insertions, 6 deletions
diff --git a/source/blender/blenlib/BLI_kdopbvh.h b/source/blender/blenlib/BLI_kdopbvh.h
index ce7f3ab25fe..0c359c7f090 100644
--- a/source/blender/blenlib/BLI_kdopbvh.h
+++ b/source/blender/blenlib/BLI_kdopbvh.h
@@ -41,6 +41,7 @@ extern "C" {
struct BVHTree;
typedef struct BVHTree BVHTree;
+#define USE_KDOPBVH_WATERTIGHT
typedef struct BVHTreeOverlap {
int indexA;
@@ -59,6 +60,9 @@ typedef struct BVHTreeRay {
float origin[3]; /* ray origin */
float direction[3]; /* ray direction */
float radius; /* radius around ray */
+#ifdef USE_KDOPBVH_WATERTIGHT
+ struct IsectRayPrecalc *isect_precalc;
+#endif
} BVHTreeRay;
typedef struct BVHTreeRayHit {
@@ -68,6 +72,12 @@ typedef struct BVHTreeRayHit {
float dist; /* distance to the hit point */
} BVHTreeRayHit;
+enum {
+ /* calculate IsectRayPrecalc data */
+ BVH_RAYCAST_WATERTIGHT = (1 << 0),
+};
+#define BVH_RAYCAST_DEFAULT (BVH_RAYCAST_WATERTIGHT)
+
/* callback must update nearest in case it finds a nearest result */
typedef void (*BVHTree_NearestPointCallback)(void *userdata, int index, const float co[3], BVHTreeNearest *nearest);
@@ -105,12 +115,21 @@ float BLI_bvhtree_getepsilon(const BVHTree *tree);
int BLI_bvhtree_find_nearest(BVHTree *tree, const float co[3], BVHTreeNearest *nearest,
BVHTree_NearestPointCallback callback, void *userdata);
-int BLI_bvhtree_ray_cast(BVHTree *tree, const float co[3], const float dir[3], float radius, BVHTreeRayHit *hit,
- BVHTree_RayCastCallback callback, void *userdata);
-
-/* Calls the callback for every ray intersection */
-int BLI_bvhtree_ray_cast_all(BVHTree *tree, const float co[3], const float dir[3], float radius,
- BVHTree_RayCastCallback callback, void *userdata);
+int BLI_bvhtree_ray_cast_ex(
+ BVHTree *tree, const float co[3], const float dir[3], float radius, BVHTreeRayHit *hit,
+ BVHTree_RayCastCallback callback, void *userdata,
+ int flag);
+int BLI_bvhtree_ray_cast(
+ BVHTree *tree, const float co[3], const float dir[3], float radius, BVHTreeRayHit *hit,
+ BVHTree_RayCastCallback callback, void *userdata);
+
+int BLI_bvhtree_ray_cast_all_ex(
+ BVHTree *tree, const float co[3], const float dir[3], float radius,
+ BVHTree_RayCastCallback callback, void *userdata,
+ int flag);
+int BLI_bvhtree_ray_cast_all(
+ BVHTree *tree, const float co[3], const float dir[3], float radius,
+ BVHTree_RayCastCallback callback, void *userdata);
float BLI_bvhtree_bb_raycast(const float bv[6], const float light_start[3], const float light_end[3], float pos[3]);