use btAssert instead of assert

use __debugbreak for Windows MSVC asserts and asm volatile ("int3");\ on Mac OSX (__i386__ / __x86_64__)
This commit is contained in:
erwin.coumans
2012-09-02 17:54:30 +00:00
parent c28f413e50
commit c1138535f9
6 changed files with 32 additions and 15 deletions

View File

@@ -807,7 +807,7 @@ length(const btQuaternion& q)
/**@brief Return the angle between two quaternions*/
SIMD_FORCE_INLINE btScalar
angle(const btQuaternion& q1, const btQuaternion& q2)
btAngle(const btQuaternion& q1, const btQuaternion& q2)
{
return q1.angle(q2);
}
@@ -875,4 +875,3 @@ shortestArcQuatNormalize2(btVector3& v0,btVector3& v1)

View File

@@ -85,9 +85,14 @@ inline int btGetVersion()
#endif //__MINGW32__
#include <assert.h>
#ifdef BT_DEBUG
#ifdef _MSC_VER
#include <stdio.h>
#define btAssert(x) { if(!(x)){printf("Assert "__FILE__ ":%u ("#x")\n", __LINE__);__debugbreak(); }}
#else//_MSC_VER
#include <assert.h>
#define btAssert assert
#endif//_MSC_VER
#else
#define btAssert(x)
#endif
@@ -190,10 +195,23 @@ inline int btGetVersion()
#endif
#if defined(DEBUG) || defined (_DEBUG)
#if defined (__i386__) || defined (__x86_64__)
#include <stdio.h>
#define btAssert(x)\
{\
if(!(x))\
{\
printf("Assert %s in line %d, file %s\n",#x, __LINE__, __FILE__);\
asm volatile ("int3");\
}\
}
#else//defined (__i386__) || defined (__x86_64__)
#define btAssert assert
#else
#define btAssert(x)
#end//defined (__i386__) || defined (__x86_64__)
#endif
#else//defined(DEBUG) || defined (_DEBUG)
#define btAssert(x)
#endif//defined(DEBUG) || defined (_DEBUG)
//btFullAssert is optional, slows down a lot
#define btFullAssert(x)

View File

@@ -256,7 +256,7 @@ protected:
*/
intPtr = (int*)cp;
assert(strncmp(cp, "TYPE", 4)==0); intPtr++;
btAssert(strncmp(cp, "TYPE", 4)==0); intPtr++;
if (!littleEndian)
*intPtr = btSwapEndian(*intPtr);
@@ -284,7 +284,7 @@ protected:
// Parse type lens
intPtr = (int*)cp;
assert(strncmp(cp, "TLEN", 4)==0); intPtr++;
btAssert(strncmp(cp, "TLEN", 4)==0); intPtr++;
dataLen = (int)mTypes.size();
@@ -311,7 +311,7 @@ protected:
intPtr = (int*)shtPtr;
cp = (char*)intPtr;
assert(strncmp(cp, "STRC", 4)==0); intPtr++;
btAssert(strncmp(cp, "STRC", 4)==0); intPtr++;
if (!littleEndian)
*intPtr = btSwapEndian(*intPtr);