From 356b3c880d9e98e4b01ff74513c23497a48f33c8 Mon Sep 17 00:00:00 2001 From: Bill Meltsner Date: Mon, 26 Sep 2011 21:35:44 -0400 Subject: [PATCH] Fixture:getShape() returns a Shape of the type it actually is --HG-- branch : box2d-update --- src/modules/physics/box2d/CircleShape.h | 2 +- src/modules/physics/box2d/wrap_Fixture.cpp | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/modules/physics/box2d/CircleShape.h b/src/modules/physics/box2d/CircleShape.h index a48becb06..2b75dff8d 100644 --- a/src/modules/physics/box2d/CircleShape.h +++ b/src/modules/physics/box2d/CircleShape.h @@ -59,7 +59,7 @@ namespace box2d float getRadius() const; /** - * Gets the radius for the circle. + * Sets the radius for the circle. **/ void setRadius(float r); }; diff --git a/src/modules/physics/box2d/wrap_Fixture.cpp b/src/modules/physics/box2d/wrap_Fixture.cpp index bc758f4db..61de81111 100644 --- a/src/modules/physics/box2d/wrap_Fixture.cpp +++ b/src/modules/physics/box2d/wrap_Fixture.cpp @@ -119,7 +119,23 @@ namespace box2d if(shape == 0) return 0; shape->retain(); - luax_newtype(L, "Shape", PHYSICS_SHAPE_T, (void*)shape); + switch (shape->getType()) { + case Shape::SHAPE_EDGE: + luax_newtype(L, "EdgeShape", PHYSICS_EDGE_SHAPE_T, (void*)shape); + break; + case Shape::SHAPE_CHAIN: + luax_newtype(L, "ChainShape", PHYSICS_CHAIN_SHAPE_T, (void*)shape); + break; + case Shape::SHAPE_CIRCLE: + luax_newtype(L, "CircleShape", PHYSICS_CIRCLE_SHAPE_T, (void*)shape); + break; + case Shape::SHAPE_POLYGON: + luax_newtype(L, "PolygonShape", PHYSICS_POLYGON_SHAPE_T, (void*)shape); + break; + default: + luax_newtype(L, "Shape", PHYSICS_SHAPE_T, (void*)shape); + break; + } return 1; }