Explorar el Código

Merge branch 'next' of https://github.com/blackberry/GamePlay into next
Also moving the triggering of Gamepad disconnect events in Windows to the message pump to avoid deleting a Gamepad that is currently in use.

Conflicts:
gameplay-tests/src/GamepadTest.cpp
gameplay-tests/src/GamepadTest.h
gameplay/src/PlatformMacOSX.mm

Adam Blake hace 13 años
padre
commit
a0a1da2fc5

+ 45 - 40
gameplay/src/PhysicsCollisionObject.h

@@ -21,6 +21,8 @@ class PhysicsCollisionObject
 {
     friend class PhysicsController;
     friend class PhysicsConstraint;
+    friend class PhysicsRigidBody;
+    friend class PhysicsGhostObject;
 
 public:
 
@@ -289,6 +291,7 @@ public:
     PhysicsVehicleWheel* asVehicleWheel();
 
 protected:
+
     /**
      * Handles collision event callbacks to Lua script functions.
      */
@@ -311,6 +314,40 @@ protected:
         std::string function;
     };
 
+    /**
+     * Constructor.
+     */
+    PhysicsCollisionObject(Node* node);
+
+    /**
+     * Returns the Bullet Physics collision object.
+     *
+     * @return The Bullet collision object.
+     */
+    virtual btCollisionObject* getCollisionObject() const = 0;
+
+    /**
+     * Pointer to Node contained by this collision object.
+     */ 
+    Node* _node;
+    
+    /**
+     * The PhysicsCollisionObject's collision shape.
+     */
+    PhysicsCollisionShape* _collisionShape;
+
+    /**
+     * If the collision object is enabled or not.
+     */
+    bool _enabled;
+
+    /**
+     * The list of script listeners.
+     */
+    std::vector<ScriptListener*>* _scriptListeners;
+
+private:
+
     /**
      * Interface between GamePlay and Bullet to keep object transforms synchronized properly.
      * 
@@ -321,7 +358,7 @@ protected:
         friend class PhysicsConstraint;
         
     public:
-
+        
         /**
          * Creates a physics motion state for a rigid body.
          * 
@@ -330,76 +367,44 @@ protected:
          * @param centerOfMassOffset The translation offset to the center of mass of the rigid body.
          */
         PhysicsMotionState(Node* node, PhysicsCollisionObject* collisionObject, const Vector3* centerOfMassOffset = NULL);
-
+        
         /**
          * Destructor.
          */
         virtual ~PhysicsMotionState();
-
+        
         /**
          * @see btMotionState::getWorldTransform
          */
         virtual void getWorldTransform(btTransform &transform) const;
-
+        
         /**
          * @see btMotionState::setWorldTransform
          */
         virtual void setWorldTransform(const btTransform &transform);
-
+        
         /**
          * Updates the motion state's world transform from the GamePlay Node object's world transform.
          */
         void updateTransformFromNode() const;
-
+        
         /**
          * Sets the center of mass offset for the associated collision shape.
          */
         void setCenterOfMassOffset(const Vector3& centerOfMassOffset);
-
+        
     private:
-
+        
         Node* _node;
         PhysicsCollisionObject* _collisionObject;
         btTransform _centerOfMassOffset;
         mutable btTransform _worldTransform;
     };
 
-    /**
-     * Constructor.
-     */
-    PhysicsCollisionObject(Node* node);
-
-    /**
-     * Returns the Bullet Physics collision object.
-     *
-     * @return The Bullet collision object.
-     */
-    virtual btCollisionObject* getCollisionObject() const = 0;
-
-    /**
-     * Pointer to Node contained by this collision object.
-     */ 
-    Node* _node;
-
     /** 
      * The PhysicsCollisionObject's motion state.
      */
     PhysicsMotionState* _motionState;
-    
-    /**
-     * The PhysicsCollisionObject's collision shape.
-     */
-    PhysicsCollisionShape* _collisionShape;
-
-    /**
-     * If the collision object is enabled or not.
-     */
-    bool _enabled;
-
-    /**
-     * The list of script listeners.
-     */
-    std::vector<ScriptListener*>* _scriptListeners;
 };
 
 }

+ 0 - 2
gameplay/src/PhysicsGhostObject.h

@@ -8,8 +8,6 @@
 namespace gameplay
 {
 
-class PhysicsMotionState;
-
 /**
  * Defines a class for physics ghost objects.
  */

+ 6 - 6
gameplay/src/PlatformWindows.cpp

@@ -982,6 +982,12 @@ int Platform::enterMessagePump()
                     Platform::gamepadEventConnectedInternal(i, XINPUT_BUTTON_COUNT, XINPUT_JOYSTICK_COUNT, XINPUT_TRIGGER_COUNT, 0, 0, "Microsoft", "XBox360 Controller");
                     __connectedXInput[i] = true;
                 }
+                else if (XInputGetState(i, &__xInputState) != NO_ERROR && __connectedXInput[i])
+                {
+                    // Gamepad was just disconnected.
+                    __connectedXInput[i] = false;
+                    Platform::gamepadEventDisconnectedInternal(i);
+                }
             }
 #endif
 
@@ -1232,12 +1238,6 @@ void Platform::pollGamepadState(Gamepad* gamepad)
             }
         }
     }
-    else
-    {
-        // Gamepad was disconnected.
-        __connectedXInput[gamepad->_handle] = false;
-        Platform::gamepadEventDisconnectedInternal(gamepad->_handle);
-    }
 }
 #else
 void Platform::pollGamepadState(Gamepad* gamepad)