瀏覽代碼

Merge branch 'next' of https://github.com/blackberry/GamePlay into next

Darryl Gough 12 年之前
父節點
當前提交
9e1ef71b69
共有 2 個文件被更改,包括 9 次插入22 次删除
  1. 6 16
      gameplay/src/PhysicsVehicleWheel.cpp
  2. 3 6
      gameplay/src/PhysicsVehicleWheel.h

+ 6 - 16
gameplay/src/PhysicsVehicleWheel.cpp

@@ -7,29 +7,20 @@ namespace gameplay
 {
 
 PhysicsVehicleWheel::PhysicsVehicleWheel(Node* node, const PhysicsCollisionShape::Definition& shape, const PhysicsRigidBody::Parameters& parameters)
-    : PhysicsCollisionObject(node), _rigidBody(NULL), _host(NULL), _indexInHost(0)
+    : PhysicsCollisionObject(node), _host(NULL), _indexInHost(0)
 {
-    // Note that the constructor for PhysicsRigidBody calls addCollisionObject and so
-    // that is where the rigid body gets added to the dynamics world.
-    _rigidBody = new PhysicsRigidBody(node, shape, parameters);
-
     findAncestorAndBind();
 }
 
-PhysicsVehicleWheel::PhysicsVehicleWheel(Node* node, PhysicsRigidBody* rigidBody)
-    : PhysicsCollisionObject(node), _rigidBody(NULL), _host(NULL), _indexInHost(0)
+PhysicsVehicleWheel::PhysicsVehicleWheel(Node* node)
+    : PhysicsCollisionObject(node), _host(NULL), _indexInHost(0)
 {
-    _rigidBody = rigidBody;
-
     findAncestorAndBind();
 }
 
 PhysicsVehicleWheel* PhysicsVehicleWheel::create(Node* node, Properties* properties)
 {
-    // Note that the constructor for PhysicsRigidBody calls addCollisionObject and so
-    // that is where the rigid body gets added to the dynamics world.
-    PhysicsRigidBody* rigidBody = PhysicsRigidBody::create(node, properties, "VEHICLE_WHEEL");
-    PhysicsVehicleWheel* wheel = new PhysicsVehicleWheel(node, rigidBody);
+    PhysicsVehicleWheel* wheel = new PhysicsVehicleWheel(node);
 
     // Load the defined wheel parameters.
     properties->rewind();
@@ -100,14 +91,13 @@ PhysicsVehicleWheel* PhysicsVehicleWheel::create(Node* node, Properties* propert
 
 PhysicsVehicleWheel::~PhysicsVehicleWheel()
 {
-    SAFE_DELETE(_rigidBody);
 }
 
 btCollisionObject* PhysicsVehicleWheel::getCollisionObject() const
 {
-    GP_ASSERT(_rigidBody);
+    GP_ASSERT(_host);
 
-    return _rigidBody->getCollisionObject();
+    return _host->getCollisionObject();
 }
 
 PhysicsCollisionObject::Type PhysicsVehicleWheel::getType() const

+ 3 - 6
gameplay/src/PhysicsVehicleWheel.h

@@ -285,16 +285,14 @@ private:
     PhysicsVehicleWheel(Node* node, const PhysicsCollisionShape::Definition& shape, const PhysicsRigidBody::Parameters& parameters);
 
     /**
-     * Creates a vehicle wheel based on the given rigid body and some 'safe' defaults.
+     * Creates a vehicle wheel based on some 'safe' defaults.
      * Also, traverse up the scene graph until we find the first common ancestor with another node
      * of collision type VEHICLE and add ourself as a wheel onto that vehicle. This assumes that the
      * VEHICLE comes before the VEHICLE_WHEEL in the ".scene" (properties) file.
      * 
-     * @param node The node to create a rigid body for; note that the node must have
-     *      a model attached to it prior to creating a rigid body for it.
-     * @param rigidBody The rigid body.
+     * @param node The node to create a vehicle wheel for.
      */
-    PhysicsVehicleWheel(Node* node, PhysicsRigidBody* rigidBody);
+    PhysicsVehicleWheel(Node* node);
 
     /**
      * Private copy constructor to prevent copying.
@@ -380,7 +378,6 @@ private:
      */
     void getWheelPos(Vector3* result) const;
 
-    PhysicsRigidBody* _rigidBody;
     PhysicsVehicle* _host;
     unsigned int _indexInHost;
     Vector3 _initialOffset;