Commits

Bill Meltsner committed 56378b5

World no longer has an explicit size

Comments (0)

Files changed (5)

src/modules/physics/box2d/Physics.cpp

 		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)

src/modules/physics/box2d/Physics.h

 		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.

src/modules/physics/box2d/World.cpp

 
 	}
 
-	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);
 	}
 

src/modules/physics/box2d/World.h

 	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();
 

src/modules/physics/box2d/wrap_Physics.cpp

 
 	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;