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)); // btCollisionShape* groundShape = new btBoxShape(btVector3(50,3,50));
btDefaultCollisionConfiguration* collisionConfiguration = new btDefaultCollisionConfiguration();
#ifdef USE_PARALLEL_DISPATCHER #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 ///you can hook it up to your custom task scheduler by deriving from btThreadSupportInterface
#endif #endif
btCollisionDispatcher* dispatcher = new SpuGatheringCollisionDispatcher(threadSupport,maxNumOutstandingTasks); btCollisionDispatcher* dispatcher = new SpuGatheringCollisionDispatcher(threadSupport,maxNumOutstandingTasks,collisionConfiguration);
#else #else
btDefaultCollisionConfiguration* collisionConfiguration = new btDefaultCollisionConfiguration();
btCollisionDispatcher* dispatcher = new btCollisionDispatcher(collisionConfiguration); btCollisionDispatcher* dispatcher = new btCollisionDispatcher(collisionConfiguration);
#endif//USE_PARALLEL_DISPATCHER #endif//USE_PARALLEL_DISPATCHER
@@ -284,10 +284,10 @@ void ConcaveDemo::initPhysics()
{ {
for (int i=0;i<10;i++) for (int i=0;i<10;i++)
{ {
btCollisionShape* boxShape = new btBoxShape(btVector3(1,1,1)); //btCollisionShape* colShape = new btBoxShape(btVector3(1,1,1));
//btCollisionShape* boxShape = new btSphereShape(1.f); btCollisionShape* colShape = new btCapsuleShape(0.5,2.0);//boxShape = new btSphereShape(1.f);
startTransform.setOrigin(btVector3(2*i,10,1)); 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 class btQuadWordStorage
{ {
protected: protected:
#ifdef BT_USE_DOUBLE_PRECISION btScalar m_x;
union { btScalar m_x; unsigned char m_charx[8] ;}; btScalar m_y;
union { btScalar m_y; unsigned char m_chary[8] ; }; btScalar m_z;
union { btScalar m_z; unsigned char m_charz[8] ; }; btScalar m_unusedW;
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
}; };
@@ -70,86 +63,7 @@ class btQuadWord : public btQuadWordStorage
SIMD_FORCE_INLINE operator btScalar *() { return &m_x; } SIMD_FORCE_INLINE operator btScalar *() { return &m_x; }
SIMD_FORCE_INLINE operator const btScalar *() const { 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) 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 ///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 #ifdef BT_USE_DOUBLE_PRECISION
unsigned char tmp[8]; unsigned char* dest = (unsigned char*) &destVec;
btSwapEndianDouble(source.getX(),tmp); unsigned char* src = (unsigned char*) &sourceVec;
dest.setXValueByLongInt(tmp); dest[0] = src[7];
btSwapEndianDouble(source.getY(),tmp); dest[1] = src[6];
dest.setYValueByLongInt(tmp); dest[2] = src[5];
btSwapEndianDouble(source.getZ(),tmp); dest[3] = src[4];
dest.setZValueByLongInt(tmp); dest[4] = src[3];
btSwapEndianDouble(source[3],tmp); dest[5] = src[2];
dest.setWValueByLongInt(tmp); dest[6] = src[1];
dest[7] = src[0];
#else #else
unsigned int tmp; unsigned char* dest = (unsigned char*) &destVec;
tmp = btSwapEndianFloat(source.getX()); unsigned char* src = (unsigned char*) &sourceVec;
dest.setXValueByInt(tmp); dest[0] = src[3];
tmp = btSwapEndianFloat(source.getY()); dest[1] = src[2];
dest.setYValueByInt(tmp); dest[2] = src[1];
tmp = btSwapEndianFloat(source.getZ()); dest[3] = src[0];
dest.setZValueByInt(tmp);
tmp = btSwapEndianFloat(source[3]);
dest.setWValueByInt(tmp);
#endif //BT_USE_DOUBLE_PRECISION #endif //BT_USE_DOUBLE_PRECISION
} }
///btUnSwapVector3Endian swaps vector endianness, useful for network and cross-platform serialization ///btUnSwapVector3Endian swaps vector endianness, useful for network and cross-platform serialization
SIMD_FORCE_INLINE void btUnSwapVector3Endian(btVector3& vector) SIMD_FORCE_INLINE void btUnSwapVector3Endian(btVector3& vector)
{ {
#ifdef BT_USE_DOUBLE_PRECISION #ifdef BT_USE_DOUBLE_PRECISION
const unsigned char* tmp; btVector3 swappedVec;
tmp = vector.getLongIntXValue(); unsigned char* dest = (unsigned char*) &swappedVec;
vector.setX( btUnswapEndianDouble(tmp)); unsigned char* src = (unsigned char*) &vector;
tmp = vector.getLongIntYValue();
vector.setY( btUnswapEndianDouble(tmp)); dest[0] = src[7];
tmp = vector.getLongIntZValue(); dest[1] = src[6];
vector.setZ( btUnswapEndianDouble(tmp)); dest[2] = src[5];
tmp = vector.getLongIntWValue(); dest[3] = src[4];
vector[3] = btUnswapEndianDouble(tmp); dest[4] = src[3];
dest[5] = src[2];
dest[6] = src[1];
dest[7] = src[0];
vector = swappedVec;
#else #else
unsigned int tmp; btVector3 swappedVec;
tmp = vector.getIntXValue(); unsigned char* dest = (unsigned char*) &swappedVec;
vector.setX( btUnswapEndianFloat(tmp)); unsigned char* src = (unsigned char*) &vector;
tmp = vector.getIntYValue();
vector.setY( btUnswapEndianFloat(tmp));
tmp = vector.getIntZValue();
vector.setZ( btUnswapEndianFloat(tmp));
tmp = vector.getIntWValue();
vector[3] = btUnswapEndianFloat(tmp);
dest[0] = src[3];
dest[1] = src[2];
dest[2] = src[1];
dest[3] = src[0];
vector = swappedVec;
#endif //BT_USE_DOUBLE_PRECISION #endif //BT_USE_DOUBLE_PRECISION
} }
#endif //SIMD__VECTOR3_H #endif //SIMD__VECTOR3_H