diff --git a/src/modules/font/freetype/Font.cpp b/src/modules/font/freetype/Font.cpp index 44fda58c4..4113f2e68 100644 --- a/src/modules/font/freetype/Font.cpp +++ b/src/modules/font/freetype/Font.cpp @@ -48,11 +48,13 @@ namespace freetype Rasterizer * Font::newRasterizer(love::image::ImageData * data, std::string glyphs) { int length = glyphs.size(); - unsigned short g[length]; + unsigned short * g = new unsigned short[length]; for (int i = 0; i < length; i++) { g[i] = glyphs[i]; } - return newRasterizer(data, g, length); + Rasterizer * r = newRasterizer(data, g, length); + delete [] g; + return r; } Rasterizer * Font::newRasterizer(love::image::ImageData * data, unsigned short * glyphs, int length) diff --git a/src/modules/physics/box2d/Body.cpp b/src/modules/physics/box2d/Body.cpp index 898b39699..889ceabb4 100644 --- a/src/modules/physics/box2d/Body.cpp +++ b/src/modules/physics/box2d/Body.cpp @@ -309,6 +309,11 @@ namespace box2d return (body->m_flags & b2Body::e_fixedRotationFlag) != 0; } + World * Body::getWorld() const + { + return world; + } + b2Vec2 Body::getVector(lua_State * L) { love::luax_assert_argc(L, 2, 2); diff --git a/src/modules/physics/box2d/Body.h b/src/modules/physics/box2d/Body.h index a05684039..179cdf973 100644 --- a/src/modules/physics/box2d/Body.h +++ b/src/modules/physics/box2d/Body.h @@ -341,6 +341,11 @@ namespace box2d void setFixedRotation(bool fixed); bool getFixedRotation() const; + + /** + * Get the World this Body resides in. + */ + World * getWorld() const; private: /** diff --git a/src/modules/physics/box2d/Shape.cpp b/src/modules/physics/box2d/Shape.cpp index 8ae4a174f..aed67af55 100644 --- a/src/modules/physics/box2d/Shape.cpp +++ b/src/modules/physics/box2d/Shape.cpp @@ -115,7 +115,7 @@ namespace box2d bool Shape::testPoint(float x, float y) const { - return shape->TestPoint(shape->GetBody()->GetXForm(), body->world->scaleDown(b2Vec2(x, y))); + return shape->TestPoint(shape->GetBody()->GetXForm(), body->getWorld()->scaleDown(b2Vec2(x, y))); } int Shape::testSegment(lua_State * L) @@ -129,8 +129,8 @@ namespace box2d s.p2.x = (float)lua_tonumber(L, 3); s.p2.y = (float)lua_tonumber(L, 4); - s.p1 = body->world->scaleDown(s.p1); - s.p2 = body->world->scaleDown(s.p2); + s.p1 = body->getWorld()->scaleDown(s.p1); + s.p2 = body->getWorld()->scaleDown(s.p2); float lambda; b2Vec2 normal; @@ -138,7 +138,7 @@ namespace box2d if(shape->TestSegment(shape->GetBody()->GetXForm(), &lambda, &normal, s, 1.0f)) { lua_pushnumber(L, lambda); - normal = body->world->scaleUp(normal); + normal = body->getWorld()->scaleUp(normal); lua_pushnumber(L, normal.x); lua_pushnumber(L, normal.y); return 3; @@ -229,7 +229,7 @@ namespace box2d int Shape::pushBits(lua_State * L, uint16 bits) { // Create a bitset. - std::bitset<16> b((unsigned long)bits); + std::bitset<16> b((int)bits); // Push all set bits. for(int i = 0;i<16;i++) @@ -270,7 +270,7 @@ namespace box2d love::luax_assert_argc(L, 0, 0); b2AABB bb; shape->ComputeAABB(&bb, shape->GetBody()->GetXForm()); - bb = body->world->scaleUp(bb); + bb = body->getWorld()->scaleUp(bb); // Top left. lua_pushnumber(L, bb.lowerBound.x); diff --git a/src/modules/physics/box2d/graham/GrahamScanConvexHull.cpp b/src/modules/physics/box2d/graham/GrahamScanConvexHull.cpp index 68e84aa5e..e22b21d1a 100644 --- a/src/modules/physics/box2d/graham/GrahamScanConvexHull.cpp +++ b/src/modules/physics/box2d/graham/GrahamScanConvexHull.cpp @@ -1,6 +1,7 @@ #include "GrahamScanConvexHull.h" #include +#include bool GrahamScanConvexHull::operator()(const std::vector < point2d >& pnt, std::vector< point2d >& final_hull) {