Skip to content
6 changes: 3 additions & 3 deletions example-TwoWorlds/src/testApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ void testApp::drawGravity(ofPoint p, ofPoint gravity) {
ofPushMatrix();
ofTranslate(p.x, p.y);
ofRotate(angle);
ofLine(0, 0, 0, len);
ofTriangle(0, len,
-5, len-10,
ofDrawLine(0, 0, 0, len);
ofDrawTriangle(0, len,
-5, len-10,
5, len-10);
ofPopMatrix();
}
Expand Down
2 changes: 1 addition & 1 deletion libs/Box2D/Collision/Shapes/b2PolygonShape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ void b2PolygonShape::Set(const b2Vec2* vertices, int32 count)
bool unique = true;
for (int32 j = 0; j < tempCount; ++j)
{
if (b2DistanceSquared(v, ps[j]) < 0.5f * b2_linearSlop)
if (b2DistanceSquared(v, ps[j]) < ((0.5f * b2_linearSlop) * (0.5f * b2_linearSlop)))
{
unique = false;
break;
Expand Down
20 changes: 11 additions & 9 deletions libs/Box2D/Common/b2Math.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,28 @@
#define B2_MATH_H

#include <Box2D/Common/b2Settings.h>
#include <cmath>
#include <cstring>
#include <math.h>

/// This function is used to ensure that a floating point number is not a NaN or infinity.
inline bool b2IsValid(float32 x)
{
int32 ix = 0;
memcpy(&ix, &x, sizeof(x));
int32 ix = *reinterpret_cast<int32*>(&x);
return (ix & 0x7f800000) != 0x7f800000;
}

/// This is a approximate yet fast inverse square-root.
inline float32 b2InvSqrt(float32 x)
{
int32 ix = 0;
memcpy(&ix, &x, sizeof(x));

union
{
float32 x;
int32 i;
} convert;

convert.x = x;
float32 xhalf = 0.5f * x;
ix = 0x5f3759df - (ix >> 1);
memcpy(&x, &ix, sizeof(x));
convert.i = 0x5f3759df - (convert.i >> 1);
x = convert.x;
x = x * (1.5f - xhalf * x * x);
return x;
}
Expand Down
Loading