From d884cb8a82c4abf9b2ce45f8a847d95f49dcda52 Mon Sep 17 00:00:00 2001 From: rude Date: Thu, 25 Nov 2010 16:49:03 +0100 Subject: [PATCH] Removed newWorld(w, h). Added newWorld(x1, y1, x2, y2). --- changes.txt | 2 +- src/modules/physics/box2d/Physics.cpp | 13 ------ src/modules/physics/box2d/Physics.h | 19 -------- src/modules/physics/box2d/wrap_Physics.cpp | 52 +++++++--------------- 4 files changed, 16 insertions(+), 70 deletions(-) diff --git a/changes.txt b/changes.txt index e421b5cd2..6249eb3d7 100644 --- a/changes.txt +++ b/changes.txt @@ -45,10 +45,10 @@ LOVE 0.7.0 [Game Slave] * Changed fonts, they're now po2 safe. * Changed the traceback in the error screen. * Changed font origin to top-left. - * Changed behavior of love.physics.newWorld(w, h), it now creates a w*h world, not a 4*w*h world. * Changed linux save dir location to obey to Freedesktop.org's XDG specs. (~/.local/share/love by default.) * Removed font functions from love.graphics. + * Removed love.physics.newWorld(w, h). Use love.physics.newWorld(x1, y1, x2, y2) instead. LOVE 0.6.2 [Jiggly Juice] ------------------------- diff --git a/src/modules/physics/box2d/Physics.cpp b/src/modules/physics/box2d/Physics.cpp index 50e94db54..16a2893bb 100644 --- a/src/modules/physics/box2d/Physics.cpp +++ b/src/modules/physics/box2d/Physics.cpp @@ -45,19 +45,6 @@ namespace box2d aabb.lowerBound.Set(lx, ly); aabb.upperBound.Set(ux, uy); return new World(aabb, b2Vec2(gx, gy), sleep, meter); - } - - World * Physics::newWorld(float lx, float ly, float ux, float uy, float gx, float gy, bool sleep) - { - b2AABB aabb; - aabb.lowerBound.Set(lx, ly); - aabb.upperBound.Set(ux, uy); - return new World(aabb, b2Vec2(gx, gy), sleep); - } - - World * Physics::newWorld(float w, float h) - { - return newWorld(0, 0, w, h, 0, 0, true); } Body * Physics::newBody(World * world, float x, float y, float mass, float i) diff --git a/src/modules/physics/box2d/Physics.h b/src/modules/physics/box2d/Physics.h index 164d2c4fa..83f2653e4 100644 --- a/src/modules/physics/box2d/Physics.h +++ b/src/modules/physics/box2d/Physics.h @@ -63,25 +63,6 @@ namespace box2d **/ World * newWorld(float lx, float ly, float ux, float uy, float gx, float gy, bool sleep, int meter); - /** - * Creates a new World. - * @param lx Lower bound on the x-axis. - * @param ly Lower bound on the y-axis. - * @param ux Upper bound on the x-axis. - * @param uy Upper bound on the y-axis. - * @param gx Gravity along x-axis. - * @param gy Gravity along y-axis. - * @param sleep Whether the World allows sleep. - **/ - World * newWorld(float lx, float ly, float ux, float uy, float gx, float gy, bool sleep); - - /** - * Creates a new World with with size (w,h). - * @param w The width of the world. - * @param h The height of the world. - **/ - World * newWorld(float w, float h); - /** * Creates a new Body at the specified position. * @param world The world to create the Body in. diff --git a/src/modules/physics/box2d/wrap_Physics.cpp b/src/modules/physics/box2d/wrap_Physics.cpp index 94eac2891..18d6aaba5 100644 --- a/src/modules/physics/box2d/wrap_Physics.cpp +++ b/src/modules/physics/box2d/wrap_Physics.cpp @@ -31,44 +31,22 @@ namespace box2d int w_newWorld(lua_State * L) { - int top = lua_gettop(L); - if (top == 2) - { - float x = (float)luaL_checknumber(L, 1); - float y = (float)luaL_checknumber(L, 2); - World * w = instance->newWorld(x, y); - luax_newtype(L, "World", PHYSICS_WORLD_T, (void*)w); - return 1; - } - else if (top == 6 || top == 7) - { - float lx = (float)luaL_checknumber(L, 1); - float ly = (float)luaL_checknumber(L, 2); - float ux = (float)luaL_checknumber(L, 3); - float uy = (float)luaL_checknumber(L, 4); - float gx = (float)luaL_checknumber(L, 5); - float gy = (float)luaL_checknumber(L, 6); - bool sleep = luax_optboolean(L, 7, true); - World * w = instance->newWorld(lx, ly, ux, uy, gx, gy, sleep); - luax_newtype(L, "World", PHYSICS_WORLD_T, (void*)w); - return 1; - } - else if (top == 8) - { - float lx = (float)luaL_checknumber(L, 1); - float ly = (float)luaL_checknumber(L, 2); - float ux = (float)luaL_checknumber(L, 3); - float uy = (float)luaL_checknumber(L, 4); - float gx = (float)luaL_checknumber(L, 5); - float gy = (float)luaL_checknumber(L, 6); - bool sleep = lua_toboolean(L, 7); - int meter = (int)luaL_checknumber(L, 8); - World * w = instance->newWorld(lx, ly, ux, uy, gx, gy, sleep, meter); - luax_newtype(L, "World", PHYSICS_WORLD_T, (void*)w); - return 1; - } - else + if (lua_gettop(L) < 4) return luaL_error(L, "Incorrect number of parameters"); + + float lx = (float)luaL_checknumber(L, 1); + float ly = (float)luaL_checknumber(L, 2); + float ux = (float)luaL_checknumber(L, 3); + float uy = (float)luaL_checknumber(L, 4); + float gx = (float)luaL_optnumber(L, 5, 0); + float gy = (float)luaL_optnumber(L, 6, 0); + bool sleep = luax_optboolean(L, 7, true); + int meter = (int)luaL_optnumber(L, 8, World::DEFAULT_METER); + + World * w = instance->newWorld(lx, ly, ux, uy, gx, gy, sleep, meter); + luax_newtype(L, "World", PHYSICS_WORLD_T, (void*)w); + + return 1; } int w_newBody(lua_State * L)