add PE_REF macro to allow Win32 SIMD for Physics Effects box-boxBoxDistance (although performance hardly differs)

This commit is contained in:
erwin.coumans
2008-11-15 22:40:09 +00:00
parent 29bfd06af7
commit 4d0c11cd95
3 changed files with 70 additions and 53 deletions

View File

@@ -17,6 +17,11 @@ subject to the following restrictions:
#ifndef __BOX_H__ #ifndef __BOX_H__
#define __BOX_H__ #define __BOX_H__
#ifndef PE_REF
#define PE_REF(a) a
#define PE_REF(a) const a&
#endif
#include <math.h> #include <math.h>
#include <vectormath_aos.h> #include <vectormath_aos.h>
@@ -35,17 +40,17 @@ public:
inline Box() inline Box()
{} {}
inline Box(Vector3 half_); inline Box(PE_REF(Vector3) half_);
inline Box(float hx, float hy, float hz); inline Box(float hx, float hy, float hz);
inline void Set(Vector3 half_); inline void Set(PE_REF(Vector3) half_);
inline void Set(float hx, float hy, float hz); inline void Set(float hx, float hy, float hz);
inline Vector3 GetAABB(const Matrix3& rotation) const; inline Vector3 GetAABB(const Matrix3& rotation) const;
}; };
inline inline
Box::Box(Vector3 half_) Box::Box(PE_REF(Vector3) half_)
{ {
Set(half_); Set(half_);
} }
@@ -58,7 +63,7 @@ Box::Box(float hx, float hy, float hz)
inline inline
void void
Box::Set(Vector3 half_) Box::Set(PE_REF(Vector3) half_)
{ {
half = half_; half = half_;
} }

View File

@@ -115,12 +115,12 @@ VertexBFaceATest(
float & t0, float & t0,
float & t1, float & t1,
const Vector3 & hA, const Vector3 & hA,
Vector3 faceOffsetAB, PE_REF(Vector3) faceOffsetAB,
Vector3 faceOffsetBA, PE_REF(Vector3) faceOffsetBA,
const Matrix3 & matrixAB, const Matrix3 & matrixAB,
const Matrix3 & matrixBA, const Matrix3 & matrixBA,
Vector3 signsB, PE_REF(Vector3) signsB,
Vector3 scalesB ) PE_REF(Vector3) scalesB )
{ {
// compute a corner of box B in A's coordinate system // compute a corner of box B in A's coordinate system
@@ -174,14 +174,18 @@ VertexBFaceATests(
FeatureType & featureA, FeatureType & featureA,
FeatureType & featureB, FeatureType & featureB,
const Vector3 & hA, const Vector3 & hA,
Vector3 faceOffsetAB, PE_REF(Vector3) faceOffsetAB,
Vector3 faceOffsetBA, PE_REF(Vector3) faceOffsetBA,
const Matrix3 & matrixAB, const Matrix3 & matrixAB,
const Matrix3 & matrixBA, const Matrix3 & matrixBA,
Vector3 signsB, PE_REF(Vector3) signsB1,
Vector3 scalesB, PE_REF(Vector3) scalesB1,
bool first ) bool first )
{ {
Vector3 signsB = signsB1;
Vector3 scalesB = scalesB;
float t0, t1; float t0, t1;
float distSqr; float distSqr;
@@ -247,12 +251,12 @@ VertexAFaceBTest(
float & t0, float & t0,
float & t1, float & t1,
const Vector3 & hB, const Vector3 & hB,
Vector3 faceOffsetAB, PE_REF(Vector3) faceOffsetAB,
Vector3 faceOffsetBA, PE_REF(Vector3) faceOffsetBA,
const Matrix3 & matrixAB, const Matrix3 & matrixAB,
const Matrix3 & matrixBA, const Matrix3 & matrixBA,
Vector3 signsA, PE_REF(Vector3) signsA,
Vector3 scalesA ) PE_REF(Vector3) scalesA )
{ {
Vector3 corner = Vector3 corner =
Vector3( faceOffsetBA + matrixBA.getCol0() * scalesA.getX() + matrixBA.getCol1() * scalesA.getY() ); Vector3( faceOffsetBA + matrixBA.getCol0() * scalesA.getX() + matrixBA.getCol1() * scalesA.getY() );
@@ -299,14 +303,16 @@ VertexAFaceBTests(
FeatureType & featureA, FeatureType & featureA,
FeatureType & featureB, FeatureType & featureB,
const Vector3 & hB, const Vector3 & hB,
Vector3 faceOffsetAB, PE_REF(Vector3) faceOffsetAB,
Vector3 faceOffsetBA, PE_REF(Vector3) faceOffsetBA,
const Matrix3 & matrixAB, const Matrix3 & matrixAB,
const Matrix3 & matrixBA, const Matrix3 & matrixBA,
Vector3 signsA, PE_REF(Vector3) signsA1,
Vector3 scalesA, PE_REF(Vector3) scalesA1,
bool first ) bool first )
{ {
Vector3 signsA = signsA1;
Vector3 scalesA = scalesA1;
float t0, t1; float t0, t1;
float distSqr; float distSqr;
@@ -441,14 +447,14 @@ EdgeEdgeTest_0101(
float & tB, float & tB,
const Vector3 & hA, const Vector3 & hA,
const Vector3 & hB, const Vector3 & hB,
Vector3 faceOffsetAB, PE_REF(Vector3) faceOffsetAB,
Vector3 faceOffsetBA, PE_REF(Vector3) faceOffsetBA,
const Matrix3 & matrixAB, const Matrix3 & matrixAB,
const Matrix3 & matrixBA, const Matrix3 & matrixBA,
Vector3 signsA, PE_REF(Vector3) signsA,
Vector3 signsB, PE_REF(Vector3) signsB,
Vector3 scalesA, PE_REF(Vector3) scalesA,
Vector3 scalesB ) PE_REF(Vector3) scalesB )
{ {
EdgeEdgeTest( 0, X, 1, Y, 0, X, 1, Y ); EdgeEdgeTest( 0, X, 1, Y, 0, X, 1, Y );
} }
@@ -460,14 +466,14 @@ EdgeEdgeTest_0110(
float & tB, float & tB,
const Vector3 & hA, const Vector3 & hA,
const Vector3 & hB, const Vector3 & hB,
Vector3 faceOffsetAB, PE_REF(Vector3) faceOffsetAB,
Vector3 faceOffsetBA, PE_REF(Vector3) faceOffsetBA,
const Matrix3 & matrixAB, const Matrix3 & matrixAB,
const Matrix3 & matrixBA, const Matrix3 & matrixBA,
Vector3 signsA, PE_REF(Vector3) signsA,
Vector3 signsB, PE_REF(Vector3) signsB,
Vector3 scalesA, PE_REF(Vector3) scalesA,
Vector3 scalesB ) PE_REF(Vector3) scalesB )
{ {
EdgeEdgeTest( 0, X, 1, Y, 1, Y, 0, X ); EdgeEdgeTest( 0, X, 1, Y, 1, Y, 0, X );
} }
@@ -479,14 +485,14 @@ EdgeEdgeTest_1001(
float & tB, float & tB,
const Vector3 & hA, const Vector3 & hA,
const Vector3 & hB, const Vector3 & hB,
Vector3 faceOffsetAB, PE_REF(Vector3) faceOffsetAB,
Vector3 faceOffsetBA, PE_REF(Vector3) faceOffsetBA,
const Matrix3 & matrixAB, const Matrix3 & matrixAB,
const Matrix3 & matrixBA, const Matrix3 & matrixBA,
Vector3 signsA, PE_REF(Vector3) signsA,
Vector3 signsB, PE_REF(Vector3) signsB,
Vector3 scalesA, PE_REF(Vector3) scalesA,
Vector3 scalesB ) PE_REF(Vector3) scalesB )
{ {
EdgeEdgeTest( 1, Y, 0, X, 0, X, 1, Y ); EdgeEdgeTest( 1, Y, 0, X, 0, X, 1, Y );
} }
@@ -498,14 +504,14 @@ EdgeEdgeTest_1010(
float & tB, float & tB,
const Vector3 & hA, const Vector3 & hA,
const Vector3 & hB, const Vector3 & hB,
Vector3 faceOffsetAB, PE_REF(Vector3) faceOffsetAB,
Vector3 faceOffsetBA, PE_REF(Vector3) faceOffsetBA,
const Matrix3 & matrixAB, const Matrix3 & matrixAB,
const Matrix3 & matrixBA, const Matrix3 & matrixBA,
Vector3 signsA, PE_REF(Vector3) signsA,
Vector3 signsB, PE_REF(Vector3) signsB,
Vector3 scalesA, PE_REF(Vector3) scalesA,
Vector3 scalesB ) PE_REF(Vector3) scalesB )
{ {
EdgeEdgeTest( 1, Y, 0, X, 1, Y, 0, X ); EdgeEdgeTest( 1, Y, 0, X, 1, Y, 0, X );
} }
@@ -535,16 +541,22 @@ EdgeEdgeTests(
FeatureType & featureB, FeatureType & featureB,
const Vector3 & hA, const Vector3 & hA,
const Vector3 & hB, const Vector3 & hB,
Vector3 faceOffsetAB, PE_REF(Vector3) faceOffsetAB,
Vector3 faceOffsetBA, PE_REF(Vector3) faceOffsetBA,
const Matrix3 & matrixAB, const Matrix3 & matrixAB,
const Matrix3 & matrixBA, const Matrix3 & matrixBA,
Vector3 signsA, PE_REF(Vector3) signsA1,
Vector3 signsB, PE_REF(Vector3) signsB1,
Vector3 scalesA, PE_REF(Vector3) scalesA1,
Vector3 scalesB, PE_REF(Vector3) scalesB1,
bool first ) bool first )
{ {
Vector3 signsA=signsA1;
Vector3 signsB=signsB1;
Vector3 scalesA=scalesA1;
Vector3 scalesB=scalesB1;
float distSqr; float distSqr;
float tA, tB; float tA, tB;
@@ -771,8 +783,8 @@ boxBoxDistance(
Vector3& normal, Vector3& normal,
BoxPoint& boxPointA, BoxPoint& boxPointA,
BoxPoint& boxPointB, BoxPoint& boxPointB,
Box boxA, const Transform3& transformA, PE_REF(Box) boxA, const Transform3& transformA,
Box boxB, const Transform3& transformB, PE_REF(Box) boxB, const Transform3& transformB,
float distanceThreshold ) float distanceThreshold )
{ {
Matrix3 identity; Matrix3 identity;

View File

@@ -59,7 +59,7 @@ using namespace Vectormath::Aos;
float float
boxBoxDistance(Vector3& normal, BoxPoint& boxPointA, BoxPoint& boxPointB, boxBoxDistance(Vector3& normal, BoxPoint& boxPointA, BoxPoint& boxPointB,
Box boxA, const Transform3 & transformA, Box boxB, PE_REF(Box) boxA, const Transform3 & transformA, PE_REF(Box) boxB,
const Transform3 & transformB, const Transform3 & transformB,
float distanceThreshold = FLT_MAX ); float distanceThreshold = FLT_MAX );