Applied FSelUsage.patch, thanks a lot Marten Svanfeldt, Starbreeze Studios

This commit is contained in:
ejcoumans
2007-07-12 05:28:10 +00:00
parent 7cd651c266
commit 7eea7092de
4 changed files with 65 additions and 37 deletions

View File

@@ -37,15 +37,11 @@ public:
virtual btVector3 localGetSupportingVertex(const btVector3& vec) const
{
btVector3 halfExtents = getHalfExtents();
btVector3 supVertex;
supVertex = btPoint3(vec.x() < btScalar(0.0) ? -halfExtents.x() : halfExtents.x(),
vec.y() < btScalar(0.0) ? -halfExtents.y() : halfExtents.y(),
vec.z() < btScalar(0.0) ? -halfExtents.z() : halfExtents.z());
return supVertex;
return btVector3(btFsels(vec.x(), halfExtents.x(), -halfExtents.x()),
btFsels(vec.y(), halfExtents.y(), -halfExtents.y()),
btFsels(vec.z(), halfExtents.z(), -halfExtents.z()));
}
virtual inline btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec)const
@@ -54,9 +50,9 @@ public:
btVector3 margin(getMargin(),getMargin(),getMargin());
halfExtents -= margin;
return btVector3(vec.x() < btScalar(0.0) ? -halfExtents.x() : halfExtents.x(),
vec.y() < btScalar(0.0) ? -halfExtents.y() : halfExtents.y(),
vec.z() < btScalar(0.0) ? -halfExtents.z() : halfExtents.z());
return btVector3(btFsels(vec.x(), halfExtents.x(), -halfExtents.x()),
btFsels(vec.y(), halfExtents.y(), -halfExtents.y()),
btFsels(vec.z(), halfExtents.z(), -halfExtents.z()));
}
virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const
@@ -69,9 +65,9 @@ public:
for (int i=0;i<numVectors;i++)
{
const btVector3& vec = vectors[i];
supportVerticesOut[i].setValue(vec.x() < btScalar(0.0) ? -halfExtents.x() : halfExtents.x(),
vec.y() < btScalar(0.0) ? -halfExtents.y() : halfExtents.y(),
vec.z() < btScalar(0.0) ? -halfExtents.z() : halfExtents.z());
supportVerticesOut[i].setValue(btFsels(vec.x(), halfExtents.x(), -halfExtents.x()),
btFsels(vec.y(), halfExtents.y(), -halfExtents.y()),
btFsels(vec.z(), halfExtents.z(), -halfExtents.z()));
}
}
@@ -291,3 +287,4 @@ public:
#endif //OBB_BOX_MINKOWSKI_H

View File

@@ -17,8 +17,7 @@ subject to the following restrictions:
#define SIMD_QUADWORD_H
#include "btScalar.h"
#include "btSimdMinMax.h"
///btQuadWord is base-class for vectors, points
@@ -104,32 +103,18 @@ class btQuadWord
SIMD_FORCE_INLINE void setMax(const btQuadWord& other)
{
if (other.m_x > m_x)
m_x = other.m_x;
if (other.m_y > m_y)
m_y = other.m_y;
if (other.m_z > m_z)
m_z = other.m_z;
if (other.m_unusedW > m_unusedW)
m_unusedW = other.m_unusedW;
btSetMax(m_x, other.m_x);
btSetMax(m_y, other.m_y);
btSetMax(m_z, other.m_z);
btSetMax(m_unusedW, other.m_unusedW);
}
SIMD_FORCE_INLINE void setMin(const btQuadWord& other)
{
if (other.m_x < m_x)
m_x = other.m_x;
if (other.m_y < m_y)
m_y = other.m_y;
if (other.m_z < m_z)
m_z = other.m_z;
if (other.m_unusedW < m_unusedW)
m_unusedW = other.m_unusedW;
btSetMin(m_x, other.m_x);
btSetMin(m_y, other.m_y);
btSetMin(m_z, other.m_z);
btSetMin(m_unusedW, other.m_unusedW);
}

View File

@@ -37,6 +37,10 @@ subject to the following restrictions:
#define ATTRIBUTE_ALIGNED16(a) __declspec(align(16)) a
#ifdef _XBOX
#define BT_USE_VMX128
#include <ppcintrinsics.h>
#define BT_HAVE_NATIVE_FSEL
#define btFsel(a,b,c) __fsel((a),(b),(c))
#else
#define BT_USE_SSE
#endif
@@ -177,5 +181,12 @@ SIMD_FORCE_INLINE btScalar btDegrees(btScalar x) { return x * SIMD_DEGS_PER_RAD;
#define BT_DECLARE_HANDLE(name) typedef struct name##__ { int unused; } *name
#ifndef btFsel
SIMD_FORCE_INLINE btScalar btFsel(btScalar a, btScalar b, btScalar c)
{
return a >= 0 ? b : c;
}
#endif
#define btFsels(a,b,c) (btScalar)btFsel(a,b,c)
#endif //SIMD___SCALAR_H

View File

@@ -38,4 +38,39 @@ SIMD_FORCE_INLINE void btSetMax(T& a, const T& b) {
if (a < b) a = b;
}
// Specialize on float/double for platforms that have btFsel natively
#ifdef BT_HAVE_NATIVE_FSEL
SIMD_FORCE_INLINE float btMin( float a, float b) {
return (float)btFsel((a-b), b, a);
}
SIMD_FORCE_INLINE float btMax( float a, float b) {
return (float)btFsel((a-b), a, b);
}
SIMD_FORCE_INLINE void btSetMin(float& a, float b) {
a = (float)btFsel((a-b), b, a);
}
SIMD_FORCE_INLINE void btSetMax(float& a, float b) {
a = (float)btFsel((a-b), a, b);
}
SIMD_FORCE_INLINE double btMin( double a, double b) {
return btFsel((a-b), b, a);
}
SIMD_FORCE_INLINE double btMax( double a, double b) {
return btFsel((a-b), a, b);
}
SIMD_FORCE_INLINE void btSetMin(double& a, double b) {
a = btFsel((a-b), b, a);
}
SIMD_FORCE_INLINE void btSetMax(double& a, double b) {
a = btFsel((a-b), a, b);
}
#endif
#endif