rewrote vector/quadword storage, it was incompatible with gcc compiler (causing some run-time problems)

This commit is contained in:
ejcoumans
2007-09-11 20:40:55 +00:00
parent cf3da19ee4
commit a7841c7775
3 changed files with 50 additions and 133 deletions

View File

@@ -239,6 +239,7 @@ void ConcaveDemo::initPhysics()
// btCollisionShape* groundShape = new btBoxShape(btVector3(50,3,50));
btDefaultCollisionConfiguration* collisionConfiguration = new btDefaultCollisionConfiguration();
#ifdef USE_PARALLEL_DISPATCHER
@@ -258,9 +259,8 @@ void ConcaveDemo::initPhysics()
///you can hook it up to your custom task scheduler by deriving from btThreadSupportInterface
#endif
btCollisionDispatcher* dispatcher = new SpuGatheringCollisionDispatcher(threadSupport,maxNumOutstandingTasks);
btCollisionDispatcher* dispatcher = new SpuGatheringCollisionDispatcher(threadSupport,maxNumOutstandingTasks,collisionConfiguration);
#else
btDefaultCollisionConfiguration* collisionConfiguration = new btDefaultCollisionConfiguration();
btCollisionDispatcher* dispatcher = new btCollisionDispatcher(collisionConfiguration);
#endif//USE_PARALLEL_DISPATCHER
@@ -284,10 +284,10 @@ void ConcaveDemo::initPhysics()
{
for (int i=0;i<10;i++)
{
btCollisionShape* boxShape = new btBoxShape(btVector3(1,1,1));
//btCollisionShape* boxShape = new btSphereShape(1.f);
//btCollisionShape* colShape = new btBoxShape(btVector3(1,1,1));
btCollisionShape* colShape = new btCapsuleShape(0.5,2.0);//boxShape = new btSphereShape(1.f);
startTransform.setOrigin(btVector3(2*i,10,1));
localCreateRigidBody(1, startTransform,boxShape);
localCreateRigidBody(1, startTransform,colShape);
}
}

View File

@@ -22,17 +22,10 @@ subject to the following restrictions:
class btQuadWordStorage
{
protected:
#ifdef BT_USE_DOUBLE_PRECISION
union { btScalar m_x; unsigned char m_charx[8] ;};
union { btScalar m_y; unsigned char m_chary[8] ; };
union { btScalar m_z; unsigned char m_charz[8] ; };
union { btScalar m_unusedW; unsigned char m_charw[8] ; };
#else
union { btScalar m_x; unsigned int m_intx; unsigned char m_charx[4] ;};
union { btScalar m_y; unsigned int m_inty; unsigned char m_chary[4] ; };
union { btScalar m_z; unsigned int m_intz; unsigned char m_charz[4] ; };
union { btScalar m_unusedW; unsigned int m_intw; unsigned char m_charw[4] ; };
#endif //BT_USE_DOUBLE_PRECISION
btScalar m_x;
btScalar m_y;
btScalar m_z;
btScalar m_unusedW;
};
@@ -70,86 +63,7 @@ class btQuadWord : public btQuadWordStorage
SIMD_FORCE_INLINE operator btScalar *() { return &m_x; }
SIMD_FORCE_INLINE operator const btScalar *() const { return &m_x; }
#ifdef BT_USE_DOUBLE_PRECISION
SIMD_FORCE_INLINE const unsigned char* getLongIntXValue() const
{
return &m_charx[0];
}
SIMD_FORCE_INLINE const unsigned char* getLongIntYValue() const
{
return &m_chary[0];;
}
SIMD_FORCE_INLINE const unsigned char* getLongIntZValue() const
{
return &m_charz[0];;
}
SIMD_FORCE_INLINE const unsigned char* getLongIntWValue() const
{
return &m_charw[0];;
}
SIMD_FORCE_INLINE void setXValueByLongInt(unsigned char* intval)
{
int i;
for (i=0;i<8;i++)
m_charx[i] = intval[i];
}
SIMD_FORCE_INLINE void setYValueByLongInt(unsigned char* intval)
{
int i;
for (i=0;i<8;i++)
m_chary[i] = intval[i];
}
SIMD_FORCE_INLINE void setZValueByLongInt(unsigned char* intval)
{
int i;
for (i=0;i<8;i++)
m_charz[i] = intval[i];
}
SIMD_FORCE_INLINE void setWValueByLongInt(unsigned char* intval)
{
int i;
for (i=0;i<8;i++)
m_charw[i] = intval[i];
}
#else
SIMD_FORCE_INLINE unsigned int getIntXValue() const
{
return m_intx;
}
SIMD_FORCE_INLINE unsigned int getIntYValue() const
{
return m_inty;
}
SIMD_FORCE_INLINE unsigned int getIntZValue() const
{
return m_intz;
}
SIMD_FORCE_INLINE unsigned int getIntWValue() const
{
return m_intw;
}
SIMD_FORCE_INLINE void setXValueByInt(unsigned int intval)
{
m_intx = intval;
}
SIMD_FORCE_INLINE void setYValueByInt(unsigned int intval)
{
m_inty = intval;
}
SIMD_FORCE_INLINE void setZValueByInt(unsigned int intval)
{
m_intz = intval;
}
SIMD_FORCE_INLINE void setWValueByInt(unsigned int intval)
{
m_intw = intval;
}
#endif//BT_USE_DOUBLE_PRECISION
SIMD_FORCE_INLINE void setValue(const btScalar& x, const btScalar& y, const btScalar& z)
{

View File

@@ -405,56 +405,59 @@ public:
///btSwapVector3Endian swaps vector endianness, useful for network and cross-platform serialization
SIMD_FORCE_INLINE void btSwapVector3Endian(const btVector3& source, btVector3& dest)
SIMD_FORCE_INLINE void btSwapVector3Endian(const btVector3& sourceVec, btVector3& destVec)
{
#ifdef BT_USE_DOUBLE_PRECISION
unsigned char tmp[8];
btSwapEndianDouble(source.getX(),tmp);
dest.setXValueByLongInt(tmp);
btSwapEndianDouble(source.getY(),tmp);
dest.setYValueByLongInt(tmp);
btSwapEndianDouble(source.getZ(),tmp);
dest.setZValueByLongInt(tmp);
btSwapEndianDouble(source[3],tmp);
dest.setWValueByLongInt(tmp);
unsigned char* dest = (unsigned char*) &destVec;
unsigned char* src = (unsigned char*) &sourceVec;
dest[0] = src[7];
dest[1] = src[6];
dest[2] = src[5];
dest[3] = src[4];
dest[4] = src[3];
dest[5] = src[2];
dest[6] = src[1];
dest[7] = src[0];
#else
unsigned int tmp;
tmp = btSwapEndianFloat(source.getX());
dest.setXValueByInt(tmp);
tmp = btSwapEndianFloat(source.getY());
dest.setYValueByInt(tmp);
tmp = btSwapEndianFloat(source.getZ());
dest.setZValueByInt(tmp);
tmp = btSwapEndianFloat(source[3]);
dest.setWValueByInt(tmp);
unsigned char* dest = (unsigned char*) &destVec;
unsigned char* src = (unsigned char*) &sourceVec;
dest[0] = src[3];
dest[1] = src[2];
dest[2] = src[1];
dest[3] = src[0];
#endif //BT_USE_DOUBLE_PRECISION
}
///btUnSwapVector3Endian swaps vector endianness, useful for network and cross-platform serialization
SIMD_FORCE_INLINE void btUnSwapVector3Endian(btVector3& vector)
{
#ifdef BT_USE_DOUBLE_PRECISION
const unsigned char* tmp;
tmp = vector.getLongIntXValue();
vector.setX( btUnswapEndianDouble(tmp));
tmp = vector.getLongIntYValue();
vector.setY( btUnswapEndianDouble(tmp));
tmp = vector.getLongIntZValue();
vector.setZ( btUnswapEndianDouble(tmp));
tmp = vector.getLongIntWValue();
vector[3] = btUnswapEndianDouble(tmp);
btVector3 swappedVec;
unsigned char* dest = (unsigned char*) &swappedVec;
unsigned char* src = (unsigned char*) &vector;
dest[0] = src[7];
dest[1] = src[6];
dest[2] = src[5];
dest[3] = src[4];
dest[4] = src[3];
dest[5] = src[2];
dest[6] = src[1];
dest[7] = src[0];
vector = swappedVec;
#else
unsigned int tmp;
tmp = vector.getIntXValue();
vector.setX( btUnswapEndianFloat(tmp));
tmp = vector.getIntYValue();
vector.setY( btUnswapEndianFloat(tmp));
tmp = vector.getIntZValue();
vector.setZ( btUnswapEndianFloat(tmp));
tmp = vector.getIntWValue();
vector[3] = btUnswapEndianFloat(tmp);
btVector3 swappedVec;
unsigned char* dest = (unsigned char*) &swappedVec;
unsigned char* src = (unsigned char*) &vector;
dest[0] = src[3];
dest[1] = src[2];
dest[2] = src[1];
dest[3] = src[0];
vector = swappedVec;
#endif //BT_USE_DOUBLE_PRECISION
}
#endif //SIMD__VECTOR3_H