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:
authorAndre Susano Pinto <andresusanopinto@gmail.com>2009-08-06 01:09:41 +0400
committerAndre Susano Pinto <andresusanopinto@gmail.com>2009-08-06 01:09:41 +0400
commitf7179efde35689ad915948298fe905e36704c126 (patch)
tree344681c834586d042edae9507d1aed59c3d9ab4a /source/blender/render/intern
parent9565ef3087a17894fab4847bd5d8d6003e3d2a68 (diff)
no need to calculate the exact nearest distance if we are not using any heuristic based on that
Diffstat (limited to 'source/blender/render/intern')
-rw-r--r--source/blender/render/intern/include/rayobject.h3
-rw-r--r--source/blender/render/intern/raytrace/bvh.h43
-rw-r--r--source/blender/render/intern/source/rayobject.c22
3 files changed, 66 insertions, 2 deletions
diff --git a/source/blender/render/intern/include/rayobject.h b/source/blender/render/intern/include/rayobject.h
index 8f0dbed3176..2c63c8ceae9 100644
--- a/source/blender/render/intern/include/rayobject.h
+++ b/source/blender/render/intern/include/rayobject.h
@@ -164,7 +164,8 @@ int RE_rayobject_intersect(RayObject *r, Isect *i);
* Returns distance ray must travel to hit the given bounding box
* BB should be in format [2][3]
*/
-float RE_rayobject_bb_intersect(const Isect *i, const float *bb);
+/* float RE_rayobject_bb_intersect(const Isect *i, const float *bb); */
+int RE_rayobject_bb_intersect_test(const Isect *i, const float *bb); /* same as bb_intersect but doens't calculates distance */
/*
* Returns the expected cost of raycast on this node, primitives have a cost of 1
diff --git a/source/blender/render/intern/raytrace/bvh.h b/source/blender/render/intern/raytrace/bvh.h
index 8f7e6111684..56bb907acfc 100644
--- a/source/blender/render/intern/raytrace/bvh.h
+++ b/source/blender/render/intern/raytrace/bvh.h
@@ -26,6 +26,47 @@
*
* ***** END GPL LICENSE BLOCK *****
*/
+/*
+template<int SIZE>
+struct BBGroup
+{
+ float bb[6][SIZE];
+};
+
+
+static inline int test_bb_group(BBGroup<4> *bb_group, Isect *isec)
+{
+ const float *bb = _bb;
+ __m128 tmin={0}, tmax = {isec->labda};
+
+ tmin = _mm_max_ps(tmin, _mm_mul_ps( _mm_sub_ps( group->bb[isec->bv_index[0]], isec->sse_start[0] ), isec->sse_idot_axis[0]) );
+ tmax = _mm_min_ps(tmax, _mm_mul_ps( _mm_sub_ps( group->bb[isec->bv_index[1]], isec->sse_start[0] ), isec->sse_idot_axis[0]) );
+ tmin = _mm_max_ps(tmin, _mm_mul_ps( _mm_sub_ps( group->bb[isec->bv_index[2]], isec->sse_start[1] ), isec->sse_idot_axis[1]) );
+ tmax = _mm_min_ps(tmax, _mm_mul_ps( _mm_sub_ps( group->bb[isec->bv_index[3]], isec->sse_start[1] ), isec->sse_idot_axis[1]) );
+ tmin = _mm_max_ps(tmin, _mm_mul_ps( _mm_sub_ps( group->bb[isec->bv_index[4]], isec->sse_start[2] ), isec->sse_idot_axis[2]) );
+ tmax = _mm_min_ps(tmax, _mm_mul_ps( _mm_sub_ps( group->bb[isec->bv_index[5]], isec->sse_start[2] ), isec->sse_idot_axis[2]) );
+
+ return _mm_movemask_ps(_mm_cmpge_ps(tmax, tmin));
+}
+
+static inline int test_bb_group(BBGroup<1> *bb_group, Isect *isec)
+{
+ float t1x = (bb[isec->bv_index[0]] - isec->start[0]) * isec->idot_axis[0];
+ float t2x = (bb[isec->bv_index[1]] - isec->start[0]) * isec->idot_axis[0];
+ float t1y = (bb[isec->bv_index[2]] - isec->start[1]) * isec->idot_axis[1];
+ float t2y = (bb[isec->bv_index[3]] - isec->start[1]) * isec->idot_axis[1];
+ float t1z = (bb[isec->bv_index[4]] - isec->start[2]) * isec->idot_axis[2];
+ float t2z = (bb[isec->bv_index[5]] - isec->start[2]) * isec->idot_axis[2];
+
+ RE_RC_COUNT(isec->raycounter->bb.test);
+ if(t1x > t2y || t2x < t1y || t1x > t2z || t2x < t1z || t1y > t2z || t2y < t1z) return 0;
+ if(t2x < 0.0 || t2y < 0.0 || t2z < 0.0) return 0;
+ if(t1x > isec->labda || t1y > isec->labda || t1z > isec->labda) return 0;
+
+ RE_RC_COUNT(isec->raycounter->bb.hit);
+ return 1;
+}
+*/
/* bvh tree generics */
template<class Tree> static int bvh_intersect(Tree *obj, Isect *isec);
@@ -68,7 +109,7 @@ static float bvh_cost(Tree *obj)
/* bvh tree nodes generics */
template<class Node> static inline int bvh_node_hit_test(Node *node, Isect *isec)
{
- return RE_rayobject_bb_intersect(isec, (const float*)node->bb) != FLT_MAX;
+ return RE_rayobject_bb_intersect_test(isec, (const float*)node->bb);
}
diff --git a/source/blender/render/intern/source/rayobject.c b/source/blender/render/intern/source/rayobject.c
index 7316120e477..5639080c406 100644
--- a/source/blender/render/intern/source/rayobject.c
+++ b/source/blender/render/intern/source/rayobject.c
@@ -42,6 +42,7 @@
* Based on Tactical Optimization of Ray/Box Intersection, by Graham Fyffe
* [http://tog.acm.org/resources/RTNews/html/rtnv21n1.html#art9]
*/
+/*
float RE_rayobject_bb_intersect(const Isect *isec, const float *_bb)
{
const float *bb = _bb;
@@ -67,6 +68,27 @@ float RE_rayobject_bb_intersect(const Isect *isec, const float *_bb)
if (t1z > dist) dist = t1z;
return dist;
}
+*/
+int RE_rayobject_bb_intersect_test(const Isect *isec, const float *_bb)
+{
+ const float *bb = _bb;
+
+ float t1x = (bb[isec->bv_index[0]] - isec->start[0]) * isec->idot_axis[0];
+ float t2x = (bb[isec->bv_index[1]] - isec->start[0]) * isec->idot_axis[0];
+ float t1y = (bb[isec->bv_index[2]] - isec->start[1]) * isec->idot_axis[1];
+ float t2y = (bb[isec->bv_index[3]] - isec->start[1]) * isec->idot_axis[1];
+ float t1z = (bb[isec->bv_index[4]] - isec->start[2]) * isec->idot_axis[2];
+ float t2z = (bb[isec->bv_index[5]] - isec->start[2]) * isec->idot_axis[2];
+
+ RE_RC_COUNT(isec->raycounter->bb.test);
+
+ if(t1x > t2y || t2x < t1y || t1x > t2z || t2x < t1z || t1y > t2z || t2y < t1z) return 0;
+ if(t2x < 0.0 || t2y < 0.0 || t2z < 0.0) return 0;
+ if(t1x > isec->labda || t1y > isec->labda || t1z > isec->labda) return 0;
+ RE_RC_COUNT(isec->raycounter->bb.hit);
+
+ return 1;
+}
/* only for self-intersecting test with current render face (where ray left) */