[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [56915] trunk/blender/source/blender/ blenlib/intern/BLI_kdopbvh.c: code cleanup: simplify fast_ray_nearest_hit()
Campbell Barton
ideasman42 at gmail.com
Sun May 19 17:03:37 CEST 2013
Revision: 56915
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=56915
Author: campbellbarton
Date: 2013-05-19 15:03:36 +0000 (Sun, 19 May 2013)
Log Message:
-----------
code cleanup: simplify fast_ray_nearest_hit()
Modified Paths:
--------------
trunk/blender/source/blender/blenlib/intern/BLI_kdopbvh.c
Modified: trunk/blender/source/blender/blenlib/intern/BLI_kdopbvh.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/BLI_kdopbvh.c 2013-05-19 13:35:19 UTC (rev 56914)
+++ trunk/blender/source/blender/blenlib/intern/BLI_kdopbvh.c 2013-05-19 15:03:36 UTC (rev 56915)
@@ -1414,7 +1414,6 @@
static float fast_ray_nearest_hit(const BVHRayCastData *data, const BVHNode *node)
{
const float *bv = node->bv;
- float dist;
float t1x = (bv[data->index[0]] - data->ray.origin[0]) * data->idot_axis[0];
float t2x = (bv[data->index[1]] - data->ray.origin[0]) * data->idot_axis[0];
@@ -1423,14 +1422,15 @@
float t1z = (bv[data->index[4]] - data->ray.origin[2]) * data->idot_axis[2];
float t2z = (bv[data->index[5]] - data->ray.origin[2]) * data->idot_axis[2];
- if (t1x > t2y || t2x < t1y || t1x > t2z || t2x < t1z || t1y > t2z || t2y < t1z) return FLT_MAX;
- if (t2x < 0.0f || t2y < 0.0f || t2z < 0.0f) return FLT_MAX;
- if (t1x > data->hit.dist || t1y > data->hit.dist || t1z > data->hit.dist) return FLT_MAX;
-
- dist = t1x;
- if (t1y > dist) dist = t1y;
- if (t1z > dist) dist = t1z;
- return dist;
+ if ((t1x > t2y || t2x < t1y || t1x > t2z || t2x < t1z || t1y > t2z || t2y < t1z) ||
+ (t2x < 0.0f || t2y < 0.0f || t2z < 0.0f) ||
+ (t1x > data->hit.dist || t1y > data->hit.dist || t1z > data->hit.dist))
+ {
+ return FLT_MAX;
+ }
+ else {
+ return max_fff(t1x, t1y, t1z);
+ }
}
static void dfs_raycast(BVHRayCastData *data, BVHNode *node)
More information about the Bf-blender-cvs
mailing list