Explorar el Código

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

Steve Grenier hace 13 años
padre
commit
275377abfa

+ 2 - 1
.gitignore

@@ -155,4 +155,5 @@ Thumbs.db
 
 /gameplay-samples/sample04-particles/Device-Debug
 /gameplay-samples/sample04-particles/Debug
-/gameplay-samples/sample04-particles/DebugMem
+/gameplay-samples/sample04-particles/DebugMem
+/gameplay-samples/sample03-character/res/gamepad.xcf

+ 0 - 0
gameplay/res/icon_black_transparent.psd → gameplay/res/icon.psd


+ 0 - 0
gameplay/res/icon_black_transparent128.ico → gameplay/res/icon_128.ico


+ 0 - 0
gameplay/res/icon_black_transparent16.ico → gameplay/res/icon_16.ico


+ 0 - 0
gameplay/res/icon_black_transparent32.ico → gameplay/res/icon_32.ico


+ 0 - 0
gameplay/res/icon_black_transparent64.ico → gameplay/res/icon_64.ico


BIN
gameplay/res/icon_black.psd


BIN
gameplay/res/icon_black128.ico


BIN
gameplay/res/icon_black16.ico


BIN
gameplay/res/icon_black32.ico


BIN
gameplay/res/icon_black64.ico


BIN
gameplay/res/icon_white_transparent.psd


BIN
gameplay/res/icon_white_transparent128.ico


BIN
gameplay/res/icon_white_transparent16.ico


BIN
gameplay/res/icon_white_transparent32.ico


BIN
gameplay/res/icon_white_transparent64.ico


+ 2 - 2
gameplay/src/AnimationClip.h

@@ -108,7 +108,7 @@ public:
     /**
      * Sets the AnimationClip's repeat count. Overrides repeat duration.
      *
-     * Use ANIMATION_REPEAT_INDEFINITE to play the AnimationClip indefinitely.
+     * Use REPEAT_INDEFINITE to play the AnimationClip indefinitely.
      * 
      * @param repeatCount The repeat count to set on the AnimationClip.
      */
@@ -124,7 +124,7 @@ public:
     /**
      * Sets the AnimationClip's active duration. Overrides repeat count.
      *
-     * Use ANIMATION_REPEAT_INDEFINITE to play the AnimationClip indefinitely.
+     * Use REPEAT_INDEFINITE to play the AnimationClip indefinitely.
      *
      * @param duration The active duration that is set on the AnimationClip.
      */

+ 1 - 1
gameplay/src/Node.cpp

@@ -1021,7 +1021,7 @@ PhysicsCollisionObject* Node::setCollisionObject(Properties* properties)
         strcmp(properties->getNamespace(), "ghostObject") == 0 || 
         strcmp(properties->getNamespace(), "rigidBody") == 0))
     {
-        WARN("Failed to load collision object from properties object: must be non-null object and have namespace equal to \'character\', \'ghost\', or \'rigidbody\'.");
+        WARN("Failed to load collision object from properties object: must be non-null object and have namespace equal to \'character\', \'ghostObject\', or \'rigidBody\'.");
         return NULL;
     }
 

+ 26 - 9
gameplay/src/PhysicsCharacter.cpp

@@ -451,17 +451,34 @@ void PhysicsCharacter::stepDown(btCollisionWorld* collisionWorld, btScalar time)
 
     if (callback.hasHit())
     {
-        // Collision detected, fix it
-        _currentPosition.setInterpolate3(_currentPosition, targetPosition, callback.m_closestHitFraction);
+        // Collision detected, fix it.
+        Vector3 normal(callback.m_hitNormalWorld.x(), callback.m_hitNormalWorld.y(), callback.m_hitNormalWorld.z());
+        normal.normalize();
 
-        // Zero out fall velocity when we hit an object
-        _verticalVelocity.setZero();
-    }
-    else
-    {
-        // We can move here
-        _currentPosition = targetPosition;
+        float dot = normal.dot(Vector3::unitY());
+        if (dot > 1.0f - MATH_EPSILON)
+        {
+            targetPosition.setInterpolate3(_currentPosition, targetPosition, callback.m_closestHitFraction);
+
+            // Zero out fall velocity when we hit an object going straight down.
+            _verticalVelocity.setZero();
+        }
+        else
+        {
+            PhysicsCollisionObject* o = Game::getInstance()->getPhysicsController()->getCollisionObject(callback.m_hitCollisionObject);
+            if (o->getType() == PhysicsCollisionObject::RIGID_BODY && o->isDynamic())
+            {
+                PhysicsRigidBody* rb = static_cast<PhysicsRigidBody*>(o);
+                normal.normalize();
+                rb->applyImpulse(_mass * -normal * dot);
+            }
+
+            updateTargetPositionFromCollision(targetPosition, BV(normal));
+            _currentPosition = targetPosition;
+        }
     }
+
+    _currentPosition = targetPosition;
 }
 
 /*

+ 2 - 2
gameplay/src/PhysicsCollisionShape.cpp

@@ -124,7 +124,7 @@ PhysicsCollisionShape::Definition* PhysicsCollisionShape::Definition::create(Nod
         strcmp(properties->getNamespace(), "ghostObject") == 0 || 
         strcmp(properties->getNamespace(), "rigidBody") == 0))
     {
-        WARN("Failed to load physics collision shape from properties object: must be non-null object and have namespace equal to \'character\', \'ghost\', or \'rigidbody\'.");
+        WARN("Failed to load physics collision shape from properties object: must be non-null object and have namespace equal to \'character\', \'ghostObject\', or \'rigidBody\'.");
         return NULL;
     }
 
@@ -186,7 +186,7 @@ PhysicsCollisionShape::Definition* PhysicsCollisionShape::Definition::create(Nod
             center = new Vector3();
             properties->getVector3("center", center);
         }
-        else if (strcmp(name, "center-absolute") == 0)
+        else if (strcmp(name, "centerAbsolute") == 0)
         {
             centerIsAbsolute = properties->getBool();
         }

+ 1 - 1
gameplay/src/PhysicsRigidBody.h

@@ -294,7 +294,7 @@ private:
      * 
      * @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 properties The properties object defining the rigid body (must have namespace equal to 'rigidbody').
+     * @param properties The properties object defining the rigid body (must have namespace equal to 'rigidBody').
      * @return The newly created rigid body, or <code>NULL</code> if the rigid body failed to load.
      */
     static PhysicsRigidBody* create(Node* node, Properties* properties);