Kaynağa Gözat

Changes calls in gameplay to abs() on a float to the floating point version fabs().
Changes sample03-character so that the jump button has to be released and pressed again to trigger another jump.

Kieran Cunney 13 yıl önce
ebeveyn
işleme
ea6c5a7058

+ 1 - 1
gameplay-encoder/src/GPBFile.cpp

@@ -429,7 +429,7 @@ void GPBFile::decomposeTransformAnimationChannel(Animation* animation, const Ani
 
 static bool isAlmostOne(float value)
 {
-    return std::abs(value - 1.0f) < EPSILON;
+    return std::fabs(value - 1.0f) < EPSILON;
 }
 
 }

+ 2 - 2
gameplay/src/Container.cpp

@@ -683,9 +683,9 @@ void Container::updateScroll()
         _scrollingVelocity.x *= dampening;
         _scrollingVelocity.y *= dampening;
 
-        if (abs(_scrollingVelocity.x) < 100.0f)
+        if (fabs(_scrollingVelocity.x) < 100.0f)
             _scrollingVelocity.x = 0.0f;
-        if (abs(_scrollingVelocity.y) < 100.0f)
+        if (fabs(_scrollingVelocity.y) < 100.0f)
             _scrollingVelocity.y = 0.0f;
     }
 

+ 1 - 1
gameplay/src/Form.cpp

@@ -571,7 +571,7 @@ bool Form::touchEventInternal(Touch::TouchEvent evt, int x, int y, unsigned int
                     // to the plane defined by the same vector and the origin.
                     const float& a = normal.x; const float& b = normal.y; const float& c = normal.z;
                     const float d = -(a*min.x) - (b*min.y) - (c*min.z);
-                    const float distance = abs(d) /  sqrt(a*a + b*b + c*c);
+                    const float distance = fabs(d) /  sqrt(a*a + b*b + c*c);
                     Plane plane(normal, -distance);
 
                     // Check for collision with plane.

+ 2 - 2
gameplay/src/PhysicsCharacter.cpp

@@ -285,7 +285,7 @@ void PhysicsCharacter::updateCurrentVelocity()
         temp.normalize();
         temp *= -_forwardVelocity;
         _normalizedVelocity += btVector3(temp.x, temp.y, temp.z);
-        velocity2 = std::max(std::abs(velocity2), std::abs(_forwardVelocity*_forwardVelocity));
+        velocity2 = std::max(std::fabs(velocity2), std::fabs(_forwardVelocity*_forwardVelocity));
     }
 
     // Add right velocity contribution.
@@ -295,7 +295,7 @@ void PhysicsCharacter::updateCurrentVelocity()
         temp.normalize();
         temp *= _rightVelocity;
         _normalizedVelocity += btVector3(temp.x, temp.y, temp.z);
-        velocity2 = std::max(std::abs(velocity2), std::abs(_rightVelocity*_rightVelocity));
+        velocity2 = std::max(std::fabs(velocity2), std::fabs(_rightVelocity*_rightVelocity));
     }
 
     // Compute final combined movement vectors

+ 1 - 1
gameplay/src/PhysicsController.cpp

@@ -694,7 +694,7 @@ PhysicsCollisionShape* PhysicsController::createShape(Node* node, const PhysicsC
                 // Automatically compute bounding box from mesh's bounding box.
                 BoundingBox box;
                 getBoundingBox(node, &box);
-                collisionShape = createBox(Vector3(std::abs(box.max.x - box.min.x), std::abs(box.max.y - box.min.y), std::abs(box.max.z - box.min.z)), scale);
+                collisionShape = createBox(Vector3(std::fabs(box.max.x - box.min.x), std::fabs(box.max.y - box.min.y), std::fabs(box.max.z - box.min.z)), scale);
 
                 computeCenterOfMass(box.getCenter(), scale, centerOfMassOffset);
             }