Add mandatory density argument to Body:createFixture

--HG--
branch : box2d-update
This commit is contained in:
Bill Meltsner
2011-09-24 02:34:27 -04:00
parent 8592b98525
commit 0d4569d28b
5 changed files with 8 additions and 6 deletions
+2 -2
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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;
} }