Updated box2d from 2.2.1 to 2.3.0

--HG--
branch : box2d-2.3
This commit is contained in:
Alex Szpakowski
2013-11-09 04:30:36 -04:00
parent 5179ca5655
commit 5e3a0fbc6e
86 changed files with 1590 additions and 430 deletions
@@ -17,11 +17,9 @@
*/
#include <Box2D/Common/b2BlockAllocator.h>
#include <cstdlib>
#include <climits>
#include <cstring>
#include <memory>
using namespace std;
#include <limits.h>
#include <memory.h>
#include <stddef.h>
int32 b2BlockAllocator::s_blockSizes[b2_blockSizes] =
{
+5
View File
@@ -16,6 +16,9 @@
* 3. This notice may not be removed or altered from any source distribution.
*/
#ifndef B2_DRAW_H
#define B2_DRAW_H
#include <Box2D/Common/b2Math.h>
/// Color for debug drawing. Each value has the range [0,1].
@@ -79,3 +82,5 @@ public:
protected:
uint32 m_drawFlags;
};
#endif
+2 -2
View File
@@ -19,7 +19,7 @@
#ifndef B2_GROWABLE_STACK_H
#define B2_GROWABLE_STACK_H
#include <Box2D/Common/b2Settings.h>
#include <cstring>
#include <memory.h>
/// This is a growable LIFO stack with an initial capacity of N.
/// If the stack size exceeds the initial capacity, the heap is used
@@ -51,7 +51,7 @@ public:
T* old = m_stack;
m_capacity *= 2;
m_stack = (T*)b2Alloc(m_capacity * sizeof(T));
std::memcpy(m_stack, old, m_count * sizeof(T));
memcpy(m_stack, old, m_count * sizeof(T));
if (old != m_array)
{
b2Free(old);
+9 -19
View File
@@ -20,24 +20,14 @@
#define B2_MATH_H
#include <Box2D/Common/b2Settings.h>
#include <math.h>
#include <float.h>
#include <cmath>
#include <cfloat>
#include <cstddef>
#include <limits>
/// This function is used to ensure that a floating point number is
/// not a NaN or infinity.
/// This function is used to ensure that a floating point number is not a NaN or infinity.
inline bool b2IsValid(float32 x)
{
if (x != x)
{
// NaN.
return false;
}
float32 infinity = std::numeric_limits<float32>::infinity();
return -infinity < x && x < infinity;
int32 ix = *reinterpret_cast<int32*>(&x);
return (ix & 0x7f800000) != 0x7f800000;
}
/// This is a approximate yet fast inverse square-root.
@@ -57,8 +47,8 @@ inline float32 b2InvSqrt(float32 x)
return x;
}
#define b2Sqrt(x) std::sqrt(x)
#define b2Atan2(y, x) std::atan2(y, x)
#define b2Sqrt(x) sqrtf(x)
#define b2Atan2(y, x) atan2f(y, x)
/// A 2D column vector.
struct b2Vec2
@@ -714,8 +704,8 @@ inline void b2Sweep::Advance(float32 alpha)
{
b2Assert(alpha0 < 1.0f);
float32 beta = (alpha - alpha0) / (1.0f - alpha0);
c0 = (1.0f - beta) * c0 + beta * c;
a0 = (1.0f - beta) * a0 + beta * a;
c0 += beta * (c - c0);
a0 += beta * (a - a0);
alpha0 = alpha;
}
+5 -5
View File
@@ -17,13 +17,13 @@
*/
#include <Box2D/Common/b2Settings.h>
#include <cstdlib>
#include <cstdio>
#include <cstdarg>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include "common/Exception.h"
b2Version b2_version = {2, 2, 1};
b2Version b2_version = {2, 3, 0};
// Memory allocators. Modify these to use your own allocator.
void* b2Alloc(int32 size)
@@ -48,5 +48,5 @@ void b2Log(const char* string, ...)
void loveAssert(bool test, const char *teststr)
{
if (!test)
throw love::Exception("Box2D error: %s", teststr);
throw love::Exception("Box2D assertion failed: %s", teststr);
}
+3 -2
View File
@@ -19,8 +19,9 @@
#ifndef B2_SETTINGS_H
#define B2_SETTINGS_H
#include <cassert>
#include <cmath>
#include <stddef.h>
#include <assert.h>
#include <float.h>
void loveAssert(bool test, const char *teststr);
+3 -2
View File
@@ -22,6 +22,7 @@
float64 b2Timer::s_invFrequency = 0.0f;
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
b2Timer::b2Timer()
@@ -72,14 +73,14 @@ void b2Timer::Reset()
timeval t;
gettimeofday(&t, 0);
m_start_sec = t.tv_sec;
m_start_msec = t.tv_usec * 0.001f;
m_start_usec = t.tv_usec;
}
float32 b2Timer::GetMilliseconds() const
{
timeval t;
gettimeofday(&t, 0);
return (t.tv_sec - m_start_sec) * 1000 + t.tv_usec * 0.001f - m_start_msec;
return 1000.0f * (t.tv_sec - m_start_sec) + 0.001f * (t.tv_usec - m_start_usec);
}
#else
+6 -1
View File
@@ -16,6 +16,9 @@
* 3. This notice may not be removed or altered from any source distribution.
*/
#ifndef B2_TIMER_H
#define B2_TIMER_H
#include <Box2D/Common/b2Settings.h>
/// Timer for profiling. This has platform specific code and may
@@ -40,6 +43,8 @@ private:
static float64 s_invFrequency;
#elif defined(__linux__) || defined (__APPLE__)
unsigned long m_start_sec;
unsigned long m_start_msec;
unsigned long m_start_usec;
#endif
};
#endif