Browse Source

- You can now call "createPolygonBoxCollisionShape()" with no arguments which will create a box using the objects current size.

MelvMay-GG 12 years ago
parent
commit
7bc97e4
1 changed files with 11 additions and 1 deletions
  1. 11 1
      engine/source/2d/sceneobject/SceneObject_ScriptBinding.h

+ 11 - 1
engine/source/2d/sceneobject/SceneObject_ScriptBinding.h

@@ -2380,13 +2380,23 @@ ConsoleMethod( SceneObject, createPolygonCollisionShape, S32, 3, 3,  "(localPoin
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 
 
-ConsoleMethod( SceneObject, createPolygonBoxCollisionShape, S32, 3, 7,  "(width, height, [localCentroidX, localCentroidY], [angle]) Creates a polygon box collision shape.\n"
+ConsoleMethod( SceneObject, createPolygonBoxCollisionShape, S32, 2, 7,  "(width, height, [localCentroidX, localCentroidY], [angle]) Creates a polygon box collision shape.\n"
                                                                             "@param width The width of the box."
                                                                             "@param width The width of the box."
                                                                             "@param height The height of the box."
                                                                             "@param height The height of the box."
                                                                             "@param localCentroidX/Y The local position of the box centroid."
                                                                             "@param localCentroidX/Y The local position of the box centroid."
                                                                             "@param angle The angle of the box."
                                                                             "@param angle The angle of the box."
                                                                             "@return (int shapeIndex) The index of the collision shape or (-1) if not created.")
                                                                             "@return (int shapeIndex) The index of the collision shape or (-1) if not created.")
 {
 {
+    // Were any dimensions specified?
+    if( argc == 2 )
+    {
+        // No, so fetch the objects size.
+        const Vector2& size = object->getSize();
+
+        // Create a box surrounding the object.
+        return object->createPolygonBoxCollisionShape( size.x, size.y );
+    }
+
     // Width and height.
     // Width and height.
     const U32 widthHeightElementCount = Utility::mGetStringElementCount(argv[2]);
     const U32 widthHeightElementCount = Utility::mGetStringElementCount(argv[2]);