[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [22247] branches/soc-2009-jaguarandi/ source/blender/render/intern: no need to calculate the exact nearest distance if we are not using any heuristic based on that
André Pinto
andresusanopinto at gmail.com
Wed Aug 5 23:09:42 CEST 2009
Revision: 22247
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=22247
Author: jaguarandi
Date: 2009-08-05 23:09:41 +0200 (Wed, 05 Aug 2009)
Log Message:
-----------
no need to calculate the exact nearest distance if we are not using any heuristic based on that
Modified Paths:
--------------
branches/soc-2009-jaguarandi/source/blender/render/intern/include/rayobject.h
branches/soc-2009-jaguarandi/source/blender/render/intern/raytrace/bvh.h
branches/soc-2009-jaguarandi/source/blender/render/intern/source/rayobject.c
Modified: branches/soc-2009-jaguarandi/source/blender/render/intern/include/rayobject.h
===================================================================
--- branches/soc-2009-jaguarandi/source/blender/render/intern/include/rayobject.h 2009-08-05 15:52:20 UTC (rev 22246)
+++ branches/soc-2009-jaguarandi/source/blender/render/intern/include/rayobject.h 2009-08-05 21:09:41 UTC (rev 22247)
@@ -164,7 +164,8 @@
* 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
Modified: branches/soc-2009-jaguarandi/source/blender/render/intern/raytrace/bvh.h
===================================================================
--- branches/soc-2009-jaguarandi/source/blender/render/intern/raytrace/bvh.h 2009-08-05 15:52:20 UTC (rev 22246)
+++ branches/soc-2009-jaguarandi/source/blender/render/intern/raytrace/bvh.h 2009-08-05 21:09:41 UTC (rev 22247)
@@ -26,7 +26,48 @@
*
* ***** 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 @@
/* 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);
}
Modified: branches/soc-2009-jaguarandi/source/blender/render/intern/source/rayobject.c
===================================================================
--- branches/soc-2009-jaguarandi/source/blender/render/intern/source/rayobject.c 2009-08-05 15:52:20 UTC (rev 22246)
+++ branches/soc-2009-jaguarandi/source/blender/render/intern/source/rayobject.c 2009-08-05 21:09:41 UTC (rev 22247)
@@ -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,8 +68,29 @@
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) */
static int intersection2(VlakRen *face, float r0, float r1, float r2, float rx1, float ry1, float rz1)
{
More information about the Bf-blender-cvs
mailing list