Browse Source

Add mandatory density argument to Body:createFixture

--HG--
branch : box2d-update
Bill Meltsner 14 years ago
parent
commit
0d4569d28b

+ 2 - 2
src/modules/physics/box2d/Body.cpp

@@ -365,9 +365,9 @@ namespace box2d
 		return world;
 		return world;
 	}
 	}
 	
 	
-	Fixture * Body::createFixture(Shape * shape)
+	Fixture * Body::createFixture(Shape * shape, float density)
 	{
 	{
-		return new Fixture(this, shape);
+		return new Fixture(this, shape, density);
 	}
 	}
 	
 	
 	void Body::destroyFixture(Fixture * fixture)
 	void Body::destroyFixture(Fixture * fixture)

+ 1 - 1
src/modules/physics/box2d/Body.h

@@ -368,7 +368,7 @@ namespace box2d
 		*/
 		*/
 		World * getWorld() const;
 		World * getWorld() const;
 		
 		
-		Fixture * createFixture(Shape * shape);
+		Fixture * createFixture(Shape * shape, float density);
 		
 		
 		void destroyFixture(Fixture * fixture);
 		void destroyFixture(Fixture * fixture);
 	private:
 	private:

+ 2 - 1
src/modules/physics/box2d/Fixture.cpp

@@ -34,7 +34,7 @@ namespace physics
 {
 {
 namespace box2d
 namespace box2d
 {
 {
-	Fixture::Fixture(Body * body, Shape * shape)
+	Fixture::Fixture(Body * body, Shape * shape, float density)
 		: body(body), shape(shape), fixture(NULL)
 		: body(body), shape(shape), fixture(NULL)
 	{
 	{
 		body->retain();
 		body->retain();
@@ -44,6 +44,7 @@ namespace box2d
 		b2FixtureDef def;
 		b2FixtureDef def;
 		def.shape = shape->shape;
 		def.shape = shape->shape;
 		def.userData = (void *)data;
 		def.userData = (void *)data;
+		def.density = density;
 		fixture = body->body->CreateFixture(&def);
 		fixture = body->body->CreateFixture(&def);
 	}
 	}
 
 

+ 1 - 1
src/modules/physics/box2d/Fixture.h

@@ -69,7 +69,7 @@ namespace box2d
 		/**
 		/**
 		* Creates a Fixture.
 		* Creates a Fixture.
 		**/
 		**/
-		Fixture(Body * body, Shape * shape);
+		Fixture(Body * body, Shape * shape, float density);
 
 
 		virtual ~Fixture();
 		virtual ~Fixture();
 
 

+ 2 - 1
src/modules/physics/box2d/wrap_Body.cpp

@@ -497,7 +497,8 @@ namespace box2d
 	{
 	{
 		Body * t = luax_checkbody(L, 1);
 		Body * t = luax_checkbody(L, 1);
 		Shape * s = luax_checktype<Shape>(L, 2, "Shape", PHYSICS_SHAPE_T);
 		Shape * s = luax_checktype<Shape>(L, 2, "Shape", PHYSICS_SHAPE_T);
-		Fixture * f = t->createFixture(s);
+		float d = (float)luaL_checknumber(L, 3);
+		Fixture * f = t->createFixture(s, d);
 		luax_newtype(L, "Fixture", PHYSICS_FIXTURE_T, (void*)f);
 		luax_newtype(L, "Fixture", PHYSICS_FIXTURE_T, (void*)f);
 		return 1;
 		return 1;
 	}
 	}