Fixed warnings in Bullet/src core library

Thanks Martijn Reuvers from Two Tribes B.V. (www.twotribes.com) for the patch

To make this work more visible, suppress warnings in external libraries in Extras (COLLADA_DOM, libxml and glui contain many warnings)
Added PreprocessorDefinitions: _CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE to vcproj files
This commit is contained in:
erwin.coumans
2008-05-10 18:00:21 +00:00
parent 739d09a7af
commit bd97c5e569
285 changed files with 11554 additions and 11205 deletions

View File

@@ -120,35 +120,41 @@ void btAlignedFreeInternal (void* ptr)
#else
void* btAlignedAllocInternal (size_t size, int alignment)
{
void *ret;
char *real;
unsigned long offset;
gNumAlignedAllocs++;
void* btAlignedAllocInternal (std::size_t size, int alignment);
real = (char *)malloc(size + sizeof(void *) + (alignment-1));
if (real) {
offset = (alignment - (unsigned long)(real + sizeof(void *))) & (alignment-1);
ret = (void *)((real + sizeof(void *)) + offset);
*((void **)(ret)-1) = (void *)(real);
} else {
ret = (void *)(real);
}
return (ret);
void* btAlignedAllocInternal (std::size_t size, int alignment)
{
void *ret;
char *real;
unsigned long offset;
gNumAlignedAllocs++;
real = (char*) malloc(size + sizeof(void *) + (alignment-1));
if (real != 0)
{
offset = (alignment - (unsigned long)(real + sizeof(void *))) & (alignment-1);
ret = (void *)((real + sizeof(void *)) + offset);
*((void **)(ret)-1) = (void *)(real);
}
else
{
ret = (void *)(real);
}
return (ret);
}
void btAlignedFreeInternal (void* ptr)
{
void* real;
gNumAlignedFree++;
void* real;
gNumAlignedFree++;
if (ptr) {
real = *((void **)(ptr)-1);
free(real);
}
if (ptr != 0)
{
real = *((void **)(ptr)-1);
//::operator delete(real);
free(real);
}
}
#endif //

View File

@@ -35,7 +35,7 @@ void* btAlignedAllocInternal (size_t size, int alignment,int line,char* filename
void btAlignedFreeInternal (void* ptr,int line,char* filename);
#else
void* btAlignedAllocInternal (size_t size, int alignment);
void* btAlignedAllocInternal (std::size_t size, int alignment);
void btAlignedFreeInternal (void* ptr);
#define btAlignedAlloc(a,b) btAlignedAllocInternal(a,b)

View File

@@ -57,6 +57,7 @@ inline int coplanar( const btPlane &a, const btPlane &b ) { return (a==b || a==P
btVector3 PlaneLineIntersection(const btPlane &plane, const btVector3 &p0, const btVector3 &p1);
btVector3 PlaneProject(const btPlane &plane, const btVector3 &point);
btVector3 ThreePlaneIntersection(const btPlane &p0,const btPlane &p1, const btPlane &p2);
btVector3 ThreePlaneIntersection(const btPlane &p0,const btPlane &p1, const btPlane &p2)
{
btVector3 N1 = p0.normal;
@@ -167,13 +168,14 @@ ConvexH::ConvexH(int vertices_size,int edges_size,int facets_size)
}
int PlaneTest(const btPlane &p, const btVector3 &v);
int PlaneTest(const btPlane &p, const btVector3 &v) {
btScalar a = dot(v,p.normal)+p.dist;
int flag = (a>planetestepsilon)?OVER:((a<-planetestepsilon)?UNDER:COPLANAR);
return flag;
}
int SplitTest(ConvexH &convex,const btPlane &plane);
int SplitTest(ConvexH &convex,const btPlane &plane) {
int flag=0;
for(int i=0;i<convex.vertices.size();i++) {
@@ -233,6 +235,7 @@ int maxdirfiltered(const T *p,int count,const T &dir,btAlignedObjectArray<int> &
return m;
}
btVector3 orth(const btVector3 &v);
btVector3 orth(const btVector3 &v)
{
btVector3 a=cross(v,btVector3(0,0,1));
@@ -295,6 +298,7 @@ int maxdirsterid(const T *p,int count,const T &dir,btAlignedObjectArray<int> &al
int operator ==(const int3 &a,const int3 &b);
int operator ==(const int3 &a,const int3 &b)
{
for(int i=0;i<3;i++)
@@ -305,12 +309,13 @@ int operator ==(const int3 &a,const int3 &b)
}
int above(btVector3* vertices,const int3& t, const btVector3 &p, btScalar epsilon);
int above(btVector3* vertices,const int3& t, const btVector3 &p, btScalar epsilon)
{
btVector3 n=TriNormal(vertices[t[0]],vertices[t[1]],vertices[t[2]]);
return (dot(n,p-vertices[t[0]]) > epsilon); // EPSILON???
}
int hasedge(const int3 &t, int a,int b);
int hasedge(const int3 &t, int a,int b)
{
for(int i=0;i<3;i++)
@@ -320,10 +325,12 @@ int hasedge(const int3 &t, int a,int b)
}
return 0;
}
int hasvert(const int3 &t, int v);
int hasvert(const int3 &t, int v)
{
return (t[0]==v || t[1]==v || t[2]==v) ;
}
int shareedge(const int3 &a,const int3 &b);
int shareedge(const int3 &a,const int3 &b)
{
int i;
@@ -398,6 +405,8 @@ void HullLibrary::removeb2b(Tri* s,Tri*t)
void HullLibrary::checkit(Tri *t)
{
(void)t;
int i;
btAssert(m_tris[t->id]==t);
for(i=0;i<3;i++)
@@ -406,6 +415,13 @@ void HullLibrary::checkit(Tri *t)
int i2=(i+2)%3;
int a = (*t)[i1];
int b = (*t)[i2];
// release compile fix
(void)i1;
(void)i2;
(void)a;
(void)b;
btAssert(a!=b);
btAssert( m_tris[t->n[i]]->neib(b,a) == t->id);
}
@@ -552,7 +568,7 @@ int HullLibrary::calchullgen(btVector3 *verts,int verts_count, int vlimit)
}
Tri *te;
vlimit-=4;
while(vlimit >0 && (te=extrudable(epsilon)))
while(vlimit >0 && ((te=extrudable(epsilon)) != 0))
{
int3 ti=*te;
int v=te->vmax;
@@ -627,7 +643,7 @@ int HullLibrary::calchull(btVector3 *verts,int verts_count, TUIntArray& tris_out
for (i=0;i<ts.size();i++)
{
tris_out[i] = ts[i];
tris_out[i] = static_cast<unsigned int>(ts[i]);
}
m_tris.resize(0);
@@ -642,7 +658,7 @@ bool HullLibrary::ComputeHull(unsigned int vcount,const btVector3 *vertices,PHul
{
int tris_count;
int ret = calchull( (btVector3 *) vertices, (int) vcount, result.m_Indices, tris_count, vlimit );
int ret = calchull( (btVector3 *) vertices, (int) vcount, result.m_Indices, tris_count, static_cast<int>(vlimit) );
if(!ret) return false;
result.mIndexCount = (unsigned int) (tris_count*3);
result.mFaceCount = (unsigned int) tris_count;
@@ -653,6 +669,7 @@ bool HullLibrary::ComputeHull(unsigned int vcount,const btVector3 *vertices,PHul
}
void ReleaseHull(PHullResult &result);
void ReleaseHull(PHullResult &result)
{
if ( result.m_Indices.size() )
@@ -690,7 +707,7 @@ HullError HullLibrary::CreateConvexHull(const HullDesc &desc, //
if ( vcount < 8 ) vcount = 8;
btAlignedObjectArray<btVector3> vertexSource;
vertexSource.resize(vcount);
vertexSource.resize(static_cast<int>(vcount));
btVector3 scale;
@@ -702,11 +719,11 @@ HullError HullLibrary::CreateConvexHull(const HullDesc &desc, //
{
if ( 1 ) // scale vertices back to their original size.
// if ( 1 ) // scale vertices back to their original size.
{
for (unsigned int i=0; i<ovcount; i++)
{
btVector3& v = vertexSource[i];
btVector3& v = vertexSource[static_cast<int>(i)];
v[0]*=scale[0];
v[1]*=scale[1];
v[2]*=scale[2];
@@ -720,7 +737,7 @@ HullError HullLibrary::CreateConvexHull(const HullDesc &desc, //
// re-index triangle mesh so it refers to only used vertices, rebuild a new vertex table.
btAlignedObjectArray<btVector3> vertexScratch;
vertexScratch.resize(hr.mVcount);
vertexScratch.resize(static_cast<int>(hr.mVcount));
BringOutYourDead(hr.mVertices,hr.mVcount, &vertexScratch[0], ovcount, &hr.m_Indices[0], hr.mIndexCount );
@@ -730,11 +747,11 @@ HullError HullLibrary::CreateConvexHull(const HullDesc &desc, //
{
result.mPolygons = false;
result.mNumOutputVertices = ovcount;
result.m_OutputVertices.resize(ovcount);
result.m_OutputVertices.resize(static_cast<int>(ovcount));
result.mNumFaces = hr.mFaceCount;
result.mNumIndices = hr.mIndexCount;
result.m_Indices.resize(hr.mIndexCount);
result.m_Indices.resize(static_cast<int>(hr.mIndexCount));
memcpy(&result.m_OutputVertices[0], &vertexScratch[0], sizeof(btVector3)*ovcount );
@@ -763,13 +780,13 @@ HullError HullLibrary::CreateConvexHull(const HullDesc &desc, //
{
result.mPolygons = true;
result.mNumOutputVertices = ovcount;
result.m_OutputVertices.resize(ovcount);
result.m_OutputVertices.resize(static_cast<int>(ovcount));
result.mNumFaces = hr.mFaceCount;
result.mNumIndices = hr.mIndexCount+hr.mFaceCount;
result.m_Indices.resize(result.mNumIndices);
result.m_Indices.resize(static_cast<int>(result.mNumIndices));
memcpy(&result.m_OutputVertices[0], &vertexScratch[0], sizeof(btVector3)*ovcount );
if ( 1 )
// if ( 1 )
{
const unsigned int *source = &hr.m_Indices[0];
unsigned int *dest = &result.m_Indices[0];
@@ -829,7 +846,7 @@ static void addPoint(unsigned int &vcount,btVector3 *p,btScalar x,btScalar y,btS
vcount++;
}
btScalar GetDist(btScalar px,btScalar py,btScalar pz,const btScalar *p2);
btScalar GetDist(btScalar px,btScalar py,btScalar pz,const btScalar *p2)
{
@@ -871,7 +888,7 @@ bool HullLibrary::CleanupVertices(unsigned int svcount,
const char *vtx = (const char *) svertices;
if ( 1 )
// if ( 1 )
{
for (unsigned int i=0; i<svcount; i++)
{
@@ -979,7 +996,7 @@ bool HullLibrary::CleanupVertices(unsigned int svcount,
pz = pz*recip[2]; // normalize
}
if ( 1 )
// if ( 1 )
{
unsigned int j;
@@ -1028,7 +1045,7 @@ bool HullLibrary::CleanupVertices(unsigned int svcount,
}
// ok..now make sure we didn't prune so many vertices it is now invalid.
if ( 1 )
// if ( 1 )
{
btScalar bmin[3] = { FLT_MAX, FLT_MAX, FLT_MAX };
btScalar bmax[3] = { -FLT_MAX, -FLT_MAX, -FLT_MAX };
@@ -1100,7 +1117,7 @@ bool HullLibrary::CleanupVertices(unsigned int svcount,
void HullLibrary::BringOutYourDead(const btVector3* verts,unsigned int vcount, btVector3* overts,unsigned int &ocount,unsigned int *indices,unsigned indexcount)
{
TUIntArray usedIndices;
usedIndices.resize(vcount);
usedIndices.resize(static_cast<int>(vcount));
memset(&usedIndices[0],0,sizeof(unsigned int)*vcount);
ocount = 0;
@@ -1111,9 +1128,9 @@ void HullLibrary::BringOutYourDead(const btVector3* verts,unsigned int vcount, b
btAssert( v >= 0 && v < vcount );
if ( usedIndices[v] ) // if already remapped
if ( usedIndices[static_cast<int>(v)] ) // if already remapped
{
indices[i] = usedIndices[v]-1; // index to new array
indices[i] = usedIndices[static_cast<int>(v)]-1; // index to new array
}
else
{
@@ -1128,7 +1145,7 @@ void HullLibrary::BringOutYourDead(const btVector3* verts,unsigned int vcount, b
btAssert( ocount >=0 && ocount <= vcount );
usedIndices[v] = ocount; // assign new index remapping
usedIndices[static_cast<int>(v)] = ocount; // assign new index remapping
}
}

View File

@@ -22,7 +22,12 @@ subject to the following restrictions:
can be used by probes that are checking whether the
library is actually installed.
*/
extern "C" void btBulletMathProbe () {}
extern "C"
{
void btBulletMathProbe ();
void btBulletMathProbe () {}
}
bool btGeometryUtil::isPointInsidePlanes(const btAlignedObjectArray<btVector3>& planeEquations, const btVector3& point, btScalar margin)
@@ -57,6 +62,8 @@ bool btGeometryUtil::areVerticesBehindPlane(const btVector3& planeNormal, const
return true;
}
bool notExist(const btVector3& planeEquation,const btAlignedObjectArray<btVector3>& planeEquations);
bool notExist(const btVector3& planeEquation,const btAlignedObjectArray<btVector3>& planeEquations)
{
int numbrushes = planeEquations.size();

View File

@@ -298,4 +298,4 @@ class btHashMap
};
#endif //BT_HASH_MAP_H
#endif //BT_HASH_MAP_H

View File

@@ -56,11 +56,11 @@ class btIDebugDraw
virtual void drawLine(const btVector3& from,const btVector3& to,const btVector3& color)=0;
virtual void drawTriangle(const btVector3& v0,const btVector3& v1,const btVector3& v2,const btVector3& n0,const btVector3& n1,const btVector3& n2,const btVector3& color, btScalar alpha)
virtual void drawTriangle(const btVector3& v0,const btVector3& v1,const btVector3& v2,const btVector3& /*n0*/,const btVector3& /*n1*/,const btVector3& /*n2*/,const btVector3& color, btScalar alpha)
{
drawTriangle(v0,v1,v2,color,alpha);
}
virtual void drawTriangle(const btVector3& v0,const btVector3& v1,const btVector3& v2,const btVector3& color, btScalar alpha)
virtual void drawTriangle(const btVector3& v0,const btVector3& v1,const btVector3& v2,const btVector3& color, btScalar /*alpha*/)
{
drawLine(v0,v1,color);
drawLine(v1,v2,color);

View File

@@ -33,7 +33,7 @@ public:
:m_elemSize(elemSize),
m_maxElements(maxElements)
{
m_pool = (unsigned char*) btAlignedAlloc(m_elemSize*m_maxElements,16);
m_pool = (unsigned char*) btAlignedAlloc( static_cast<unsigned int>(m_elemSize*m_maxElements),16);
unsigned char* p = m_pool;
m_firstFree = p;
@@ -58,6 +58,8 @@ public:
void* allocate(int size)
{
// release mode fix
(void)size;
btAssert(!size || size<=m_elemSize);
btAssert(m_freeCount>0);
void* result = m_firstFree;

View File

@@ -44,9 +44,11 @@ inline int btGetVersion()
#define ATTRIBUTE_ALIGNED128(a) a
#else
#define BT_HAS_ALIGNED_ALLOCATOR
#pragma warning(disable:4530)
#pragma warning(disable:4996)
#pragma warning(disable:4786)
#pragma warning(disable : 4324) // disable padding warning
// #pragma warning(disable:4530) // Disable the exception disable but used in MSCV Stl warning.
// #pragma warning(disable:4996) //Turn off warnings about deprecated C routines
// #pragma warning(disable:4786) // Disable the "debug name too long" warning
#define SIMD_FORCE_INLINE __forceinline
#define ATTRIBUTE_ALIGNED16(a) __declspec(align(16)) a
#define ATTRIBUTE_ALIGNED128(a) __declspec (align(128)) a
@@ -142,9 +144,9 @@ typedef float btScalar;
#define BT_DECLARE_ALIGNED_ALLOCATOR() \
SIMD_FORCE_INLINE void* operator new(size_t sizeInBytes) { return btAlignedAlloc(sizeInBytes,16); } \
SIMD_FORCE_INLINE void* operator new(std::size_t sizeInBytes) { return btAlignedAlloc(sizeInBytes,16); } \
SIMD_FORCE_INLINE void operator delete(void* ptr) { btAlignedFree(ptr); } \
SIMD_FORCE_INLINE void* operator new(size_t, void* ptr) { return ptr; } \
SIMD_FORCE_INLINE void* operator new(std::size_t, void* ptr) { return ptr; } \
SIMD_FORCE_INLINE void operator delete(void*, void*) { } \
@@ -289,7 +291,7 @@ SIMD_FORCE_INLINE int btSelect(unsigned condition, int valueIfConditionNonZero,
{
unsigned testNz = (unsigned)(((int)condition | -(int)condition) >> 31);
unsigned testEqz = ~testNz;
return ((valueIfConditionNonZero & testNz) | (valueIfConditionZero & testEqz));
return static_cast<int>((valueIfConditionNonZero & testNz) | (valueIfConditionZero & testEqz));
}
SIMD_FORCE_INLINE float btSelect(unsigned condition, float valueIfConditionNonZero, float valueIfConditionZero)
{
@@ -316,7 +318,7 @@ SIMD_FORCE_INLINE unsigned btSwapEndian(unsigned val)
SIMD_FORCE_INLINE unsigned short btSwapEndian(unsigned short val)
{
return (((val & 0xff00) >> 8) | ((val & 0x00ff) << 8));
return static_cast<unsigned short>(((val & 0xff00) >> 8) | ((val & 0x00ff) << 8));
}
SIMD_FORCE_INLINE unsigned btSwapEndian(int val)
@@ -337,7 +339,7 @@ SIMD_FORCE_INLINE unsigned short btSwapEndian(short val)
///so instead of returning a float/double, we return integer/long long integer
SIMD_FORCE_INLINE unsigned int btSwapEndianFloat(float d)
{
unsigned int a;
unsigned int a = 0;
unsigned char *dst = (unsigned char *)&a;
unsigned char *src = (unsigned char *)&d;
@@ -351,7 +353,7 @@ SIMD_FORCE_INLINE unsigned int btSwapEndianFloat(float d)
// unswap using char pointers
SIMD_FORCE_INLINE float btUnswapEndianFloat(unsigned int a)
{
float d;
float d = 0.0f;
unsigned char *src = (unsigned char *)&a;
unsigned char *dst = (unsigned char *)&d;
@@ -383,7 +385,7 @@ SIMD_FORCE_INLINE void btSwapEndianDouble(double d, unsigned char* dst)
// unswap using char pointers
SIMD_FORCE_INLINE double btUnswapEndianDouble(const unsigned char *src)
{
double d;
double d = 0.0;
unsigned char *dst = (unsigned char *)&d;
dst[0] = src[7];

View File

@@ -61,7 +61,7 @@ public:
int getAvailableMemory() const
{
return totalsize - usedsize;
return static_cast<int>(totalsize - usedsize);
}
unsigned char* allocate(unsigned int size)