From 59e166c568a57315b78c5ab812837c95923c300e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 21 Aug 2015 17:46:23 +1000 Subject: 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 --- source/blender/blenkernel/intern/boids.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'source/blender/blenkernel/intern/boids.c') diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c index fdc5524e84c..489e26c5cbe 100644 --- a/source/blender/blenkernel/intern/boids.c +++ b/source/blender/blenkernel/intern/boids.c @@ -189,6 +189,7 @@ static int rule_goal_avoid(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, ParticleData *pa) { + const int raycast_flag = BVH_RAYCAST_DEFAULT & ~(BVH_RAYCAST_WATERTIGHT); BoidRuleAvoidCollision *acbr = (BoidRuleAvoidCollision*) rule; KDTreeNearest *ptn = NULL; ParticleTarget *pt; @@ -225,8 +226,11 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues * col.current = coll->ob; col.md = coll->collmd; - if (col.md && col.md->bvhtree) - BLI_bvhtree_ray_cast(col.md->bvhtree, col.co1, ray_dir, radius, &hit, BKE_psys_collision_neartest_cb, &col); + if (col.md && col.md->bvhtree) { + BLI_bvhtree_ray_cast_ex( + col.md->bvhtree, col.co1, ray_dir, radius, &hit, + BKE_psys_collision_neartest_cb, &col, raycast_flag); + } } /* then avoid that object */ if (hit.index>=0) { @@ -759,6 +763,7 @@ static void set_boid_values(BoidValues *val, BoidSettings *boids, ParticleData * static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float ground_co[3], float ground_nor[3]) { + const int raycast_flag = BVH_RAYCAST_DEFAULT & ~(BVH_RAYCAST_WATERTIGHT); BoidParticle *bpa = pa->boid; if (bpa->data.mode == eBoidMode_Climbing) { @@ -802,8 +807,11 @@ static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float grou col.md = coll->collmd; col.fac1 = col.fac2 = 0.f; - if (col.md && col.md->bvhtree) - BLI_bvhtree_ray_cast(col.md->bvhtree, col.co1, ray_dir, radius, &hit, BKE_psys_collision_neartest_cb, &col); + if (col.md && col.md->bvhtree) { + BLI_bvhtree_ray_cast_ex( + col.md->bvhtree, col.co1, ray_dir, radius, &hit, + BKE_psys_collision_neartest_cb, &col, raycast_flag); + } } /* then use that object */ if (hit.index>=0) { @@ -826,8 +834,11 @@ static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float grou col.current = coll->ob; col.md = coll->collmd; - if (col.md && col.md->bvhtree) - BLI_bvhtree_ray_cast(col.md->bvhtree, col.co1, ray_dir, radius, &hit, BKE_psys_collision_neartest_cb, &col); + if (col.md && col.md->bvhtree) { + BLI_bvhtree_ray_cast_ex( + col.md->bvhtree, col.co1, ray_dir, radius, &hit, + BKE_psys_collision_neartest_cb, &col, raycast_flag); + } } /* then use that object */ if (hit.index>=0) { -- cgit v1.2.3