Updated CDTestFramework with the OPCODE Array SAP test.

Thanks Pierre Terdiman for the latest update.
This commit is contained in:
erwin.coumans
2008-09-01 18:46:57 +00:00
parent f655eff89f
commit 932de57d4c
41 changed files with 6385 additions and 410 deletions

View File

@@ -1,20 +1,3 @@
/*
* ICE / OPCODE - Optimized Collision Detection
* http://www.codercorner.com/Opcode.htm
*
* Copyright (c) 2001-2008 Pierre Terdiman, pierre@codercorner.com
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Contains AABB-related code. (axis-aligned bounding box)
@@ -26,8 +9,20 @@ subject to the following restrictions:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Include Guard
#ifndef __ICEAABB_H__
#define __ICEAABB_H__
#ifndef ICEAABB_H
#define ICEAABB_H
inline_ void ComputeMinMax(const Point& p, Point& min, Point& max)
{
if(p.x > max.x) max.x = p.x;
if(p.x < min.x) min.x = p.x;
if(p.y > max.y) max.y = p.y;
if(p.y < min.y) min.y = p.y;
if(p.z > max.z) max.z = p.z;
if(p.z < min.z) min.z = p.z;
}
// Forward declarations
class Sphere;
@@ -35,6 +30,7 @@ subject to the following restrictions:
//! Declarations of type-independent methods (most of them implemented in the .cpp)
#define AABB_COMMON_METHODS \
AABB& Add(const AABB& aabb); \
AABB& Sub(const AABB& aabb); \
float MakeCube(AABB& cube) const; \
void MakeSphere(Sphere& sphere) const; \
const sbyte* ComputeOutline(const Point& local_eye, sdword& num) const; \
@@ -69,7 +65,7 @@ subject to the following restrictions:
Point mMax;
};
class ICEMATHS_API AABB
class ICEMATHS_API AABB : public Allocateable
{
public:
//! Constructor
@@ -126,17 +122,8 @@ subject to the following restrictions:
* \param p [in] the next point
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void Extend(const Point& p)
{
if(p.x > mMax.x) mMax.x = p.x;
if(p.x < mMin.x) mMin.x = p.x;
inline_ void Extend(const Point& p) { ComputeMinMax(p, mMin, mMax); }
if(p.y > mMax.y) mMax.y = p.y;
if(p.y < mMin.y) mMin.y = p.y;
if(p.z > mMax.z) mMax.z = p.z;
if(p.z < mMin.z) mMin.z = p.z;
}
// Data access
//! Get min point of the box
@@ -492,18 +479,7 @@ subject to the following restrictions:
#endif
inline_ void ComputeMinMax(const Point& p, Point& min, Point& max)
{
if(p.x > max.x) max.x = p.x;
if(p.x < min.x) min.x = p.x;
if(p.y > max.y) max.y = p.y;
if(p.y < min.y) min.y = p.y;
if(p.z > max.z) max.z = p.z;
if(p.z < min.z) min.z = p.z;
}
//! Computes the AABB around a set of vertices
inline_ void ComputeAABB(AABB& aabb, const Point* list, udword nb_pts)
{
if(list)
@@ -519,4 +495,20 @@ subject to the following restrictions:
}
}
#endif // __ICEAABB_H__
//! Computes the AABB around a set of vertices after transform by a matrix
inline_ void ComputeAABB(AABB& aabb, const Point* list, udword nb_pts, const Matrix4x4& world)
{
if(list)
{
Point Maxi(MIN_FLOAT, MIN_FLOAT, MIN_FLOAT);
Point Mini(MAX_FLOAT, MAX_FLOAT, MAX_FLOAT);
while(nb_pts--)
{
// _prefetch(list+1); // off by one ?
ComputeMinMax((*list++)*world, Mini, Maxi);
}
aabb.SetMinMax(Mini, Maxi);
}
}
#endif // ICEAABB_H