World no longer has an explicit size

--HG--
branch : box2d-update
This commit is contained in:
Bill Meltsner
2011-09-23 16:27:59 -04:00
parent a956f9b0c1
commit 4980797afc
5 changed files with 24 additions and 39 deletions
+3 -5
View File
@@ -39,12 +39,10 @@ namespace box2d
return "love.physics.box2d";
}
World * Physics::newWorld(float lx, float ly, float ux, float uy, float gx, float gy, bool sleep, int meter)
World * Physics::newWorld(float gx, float gy, bool sleep, int meter)
{
b2AABB aabb;
aabb.lowerBound.Set(lx, ly);
aabb.upperBound.Set(ux, uy);
return new World(aabb, b2Vec2(gx, gy), sleep, meter);
Physics::setMeter(meter);
return new World(b2Vec2(gx, gy), sleep);
}
Body * Physics::newBody(World * world, float x, float y, float mass, float i)
+6 -5
View File
@@ -57,22 +57,23 @@ namespace box2d
static int meter;
public:
/**
* 30 pixels in one meter by default.
**/
static const int DEFAULT_METER = 30;
// Implements Module.
const char * getName() const;
/**
* 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.
* @param meter The scale in px/m.
**/
World * newWorld(float lx, float ly, float ux, float uy, float gx, float gy, bool sleep, int meter);
World * newWorld(float gx, float gy, bool sleep, int meter);
/**
* Creates a new Body at the specified position.
+6 -6
View File
@@ -96,19 +96,19 @@ namespace box2d
}
World::World(b2AABB aabb)
: world(NULL), meter(DEFAULT_METER)
World::World()
: world(NULL)
{
world = new b2World(Physics::scaleDown(aabb), b2Vec2(0,0), true);
world = new b2World(b2Vec2(0,0), true);
world->SetContactListener(this);
b2BodyDef def;
groundBody = world->CreateBody(def);
}
World::World(b2AABB aabb, b2Vec2 gravity, bool sleep, int meter)
: world(NULL), meter(meter)
World::World(b2Vec2 gravity, bool sleep)
: world(NULL)
{
world = new b2World(Physics::scaleDown(aabb), Physics::scaleDown(gravity), sleep);
world = new b2World(Physics::scaleDown(gravity), sleep);
world->SetContactListener(this);
}
+4 -11
View File
@@ -87,25 +87,18 @@ namespace box2d
public:
/**
* 30 pixels in one meter by default.
* Creates a new world.
**/
static const int DEFAULT_METER = 30;
World();
/**
* Creates a new world with the given bounding box.
* @param aabb The bounding box.
**/
World(b2AABB aabb);
/**
* Creates a new world with the given bounding box, gravity
* Creates a new world with the given gravity
* and whether or not the bodies should sleep when appropriate.
* @param aabb The bounding box.
* @param gravity The gravity of the World.
* @param sleep True if the bodies should be able to sleep,
* false otherwise.
**/
World(b2AABB aabb, b2Vec2 gravity, bool sleep, int meter = DEFAULT_METER);
World(b2Vec2 gravity, bool sleep);
virtual ~World();
+5 -12
View File
@@ -31,19 +31,12 @@ namespace box2d
int w_newWorld(lua_State * L)
{
if (lua_gettop(L) < 4)
return luaL_error(L, "Incorrect number of parameters");
float gx = (float)luaL_optnumber(L, 1, 0);
float gy = (float)luaL_optnumber(L, 2, 0);
bool sleep = luax_optboolean(L, 3, true);
int meter = (int)luaL_optnumber(L, 4, Physics::DEFAULT_METER);
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);
World * w = instance->newWorld(gx, gy, sleep, meter);
luax_newtype(L, "World", PHYSICS_WORLD_T, (void*)w);
return 1;