change x.f to be x.0f as per the coding standard

This commit is contained in:
Andrew Meadows 2014-04-23 13:27:43 -07:00
parent f46a5dc966
commit fe42f66cc9

View file

@ -23,18 +23,18 @@
#include "ShapeColliderTests.h" #include "ShapeColliderTests.h"
const glm::vec3 origin(0.f); const glm::vec3 origin(0.0f);
static const glm::vec3 xAxis(1.f, 0.f, 0.f); static const glm::vec3 xAxis(1.0f, 0.0f, 0.0f);
static const glm::vec3 yAxis(0.f, 1.f, 0.f); static const glm::vec3 yAxis(0.0f, 1.0f, 0.0f);
static const glm::vec3 zAxis(0.f, 0.f, 1.f); static const glm::vec3 zAxis(0.0f, 0.0f, 1.0f);
void ShapeColliderTests::sphereMissesSphere() { void ShapeColliderTests::sphereMissesSphere() {
// non-overlapping spheres of unequal size // non-overlapping spheres of unequal size
float radiusA = 7.f; float radiusA = 7.0f;
float radiusB = 3.f; float radiusB = 3.0f;
float alpha = 1.2f; float alpha = 1.2f;
float beta = 1.3f; float beta = 1.3f;
glm::vec3 offsetDirection = glm::normalize(glm::vec3(1.f, 2.f, 3.f)); glm::vec3 offsetDirection = glm::normalize(glm::vec3(1.0f, 2.0f, 3.0f));
float offsetDistance = alpha * radiusA + beta * radiusB; float offsetDistance = alpha * radiusA + beta * radiusB;
SphereShape sphereA(radiusA, origin); SphereShape sphereA(radiusA, origin);
@ -77,13 +77,13 @@ void ShapeColliderTests::sphereMissesSphere() {
void ShapeColliderTests::sphereTouchesSphere() { void ShapeColliderTests::sphereTouchesSphere() {
// overlapping spheres of unequal size // overlapping spheres of unequal size
float radiusA = 7.f; float radiusA = 7.0f;
float radiusB = 3.f; float radiusB = 3.0f;
float alpha = 0.2f; float alpha = 0.2f;
float beta = 0.3f; float beta = 0.3f;
glm::vec3 offsetDirection = glm::normalize(glm::vec3(1.f, 2.f, 3.f)); glm::vec3 offsetDirection = glm::normalize(glm::vec3(1.0f, 2.0f, 3.0f));
float offsetDistance = alpha * radiusA + beta * radiusB; float offsetDistance = alpha * radiusA + beta * radiusB;
float expectedPenetrationDistance = (1.f - alpha) * radiusA + (1.f - beta) * radiusB; float expectedPenetrationDistance = (1.0f - alpha) * radiusA + (1.0f - beta) * radiusB;
glm::vec3 expectedPenetration = expectedPenetrationDistance * offsetDirection; glm::vec3 expectedPenetration = expectedPenetrationDistance * offsetDirection;
SphereShape sphereA(radiusA, origin); SphereShape sphereA(radiusA, origin);
@ -118,8 +118,7 @@ void ShapeColliderTests::sphereTouchesSphere() {
if (fabs(inaccuracy) > EPSILON) { if (fabs(inaccuracy) > EPSILON) {
std::cout << __FILE__ << ":" << __LINE__ std::cout << __FILE__ << ":" << __LINE__
<< " ERROR: bad penetration: expected = " << expectedPenetration << " ERROR: bad penetration: expected = " << expectedPenetration
<< " actual = " << collision->_penetration << " actual = " << collision->_penetration;
<< std::endl;
} }
// contactPoint is on surface of sphereA // contactPoint is on surface of sphereA
@ -129,8 +128,7 @@ void ShapeColliderTests::sphereTouchesSphere() {
if (fabs(inaccuracy) > EPSILON) { if (fabs(inaccuracy) > EPSILON) {
std::cout << __FILE__ << ":" << __LINE__ std::cout << __FILE__ << ":" << __LINE__
<< " ERROR: bad contactPoint: expected = " << expectedContactPoint << " ERROR: bad contactPoint: expected = " << expectedContactPoint
<< " actual = " << collision->_contactPoint << " actual = " << collision->_contactPoint;
<< std::endl;
} }
} }
@ -150,8 +148,7 @@ void ShapeColliderTests::sphereTouchesSphere() {
if (fabs(inaccuracy) > EPSILON) { if (fabs(inaccuracy) > EPSILON) {
std::cout << __FILE__ << ":" << __LINE__ std::cout << __FILE__ << ":" << __LINE__
<< " ERROR: bad penetration: expected = " << expectedPenetration << " ERROR: bad penetration: expected = " << expectedPenetration
<< " actual = " << collision->_penetration << " actual = " << collision->_penetration;
<< std::endl;
} }
// contactPoint is on surface of sphereA // contactPoint is on surface of sphereA
@ -161,8 +158,7 @@ void ShapeColliderTests::sphereTouchesSphere() {
if (fabs(inaccuracy) > EPSILON) { if (fabs(inaccuracy) > EPSILON) {
std::cout << __FILE__ << ":" << __LINE__ std::cout << __FILE__ << ":" << __LINE__
<< " ERROR: bad contactPoint: expected = " << expectedContactPoint << " ERROR: bad contactPoint: expected = " << expectedContactPoint
<< " actual = " << collision->_contactPoint << " actual = " << collision->_contactPoint;
<< std::endl;
} }
} }
} }
@ -181,7 +177,7 @@ void ShapeColliderTests::sphereMissesCapsule() {
// give the capsule some arbirary transform // give the capsule some arbirary transform
float angle = 37.8f; float angle = 37.8f;
glm::vec3 axis = glm::normalize( glm::vec3(-7.f, 2.8f, 9.3f) ); glm::vec3 axis = glm::normalize( glm::vec3(-7.0f, 2.8f, 9.3f) );
glm::quat rotation = glm::angleAxis(angle, axis); glm::quat rotation = glm::angleAxis(angle, axis);
glm::vec3 translation(15.1f, -27.1f, -38.6f); glm::vec3 translation(15.1f, -27.1f, -38.6f);
capsuleB.setRotation(rotation); capsuleB.setRotation(rotation);
@ -190,7 +186,7 @@ void ShapeColliderTests::sphereMissesCapsule() {
CollisionList collisions(16); CollisionList collisions(16);
// walk sphereA along the local yAxis next to, but not touching, capsuleB // walk sphereA along the local yAxis next to, but not touching, capsuleB
glm::vec3 localStartPosition(radialOffset, axialOffset, 0.f); glm::vec3 localStartPosition(radialOffset, axialOffset, 0.0f);
int numberOfSteps = 10; int numberOfSteps = 10;
float delta = 1.3f * (totalRadius + halfHeightB) / (numberOfSteps - 1); float delta = 1.3f * (totalRadius + halfHeightB) / (numberOfSteps - 1);
for (int i = 0; i < numberOfSteps; ++i) { for (int i = 0; i < numberOfSteps; ++i) {
@ -224,10 +220,10 @@ void ShapeColliderTests::sphereMissesCapsule() {
void ShapeColliderTests::sphereTouchesCapsule() { void ShapeColliderTests::sphereTouchesCapsule() {
// overlapping sphere and capsule // overlapping sphere and capsule
float radiusA = 2.f; float radiusA = 2.0f;
float radiusB = 1.f; float radiusB = 1.0f;
float totalRadius = radiusA + radiusB; float totalRadius = radiusA + radiusB;
float halfHeightB = 2.f; float halfHeightB = 2.0f;
float alpha = 0.5f; float alpha = 0.5f;
float beta = 0.5f; float beta = 0.5f;
float radialOffset = alpha * radiusA + beta * radiusB; float radialOffset = alpha * radiusA + beta * radiusB;
@ -257,8 +253,7 @@ void ShapeColliderTests::sphereTouchesCapsule() {
if (fabs(inaccuracy) > EPSILON) { if (fabs(inaccuracy) > EPSILON) {
std::cout << __FILE__ << ":" << __LINE__ std::cout << __FILE__ << ":" << __LINE__
<< " ERROR: bad penetration: expected = " << expectedPenetration << " ERROR: bad penetration: expected = " << expectedPenetration
<< " actual = " << collision->_penetration << " actual = " << collision->_penetration;
<< std::endl;
} }
// contactPoint is on surface of sphereA // contactPoint is on surface of sphereA
@ -267,8 +262,7 @@ void ShapeColliderTests::sphereTouchesCapsule() {
if (fabs(inaccuracy) > EPSILON) { if (fabs(inaccuracy) > EPSILON) {
std::cout << __FILE__ << ":" << __LINE__ std::cout << __FILE__ << ":" << __LINE__
<< " ERROR: bad contactPoint: expected = " << expectedContactPoint << " ERROR: bad contactPoint: expected = " << expectedContactPoint
<< " actual = " << collision->_contactPoint << " actual = " << collision->_contactPoint;
<< std::endl;
} }
// capsuleB collides with sphereA // capsuleB collides with sphereA
@ -288,8 +282,7 @@ void ShapeColliderTests::sphereTouchesCapsule() {
if (fabs(inaccuracy) > EPSILON) { if (fabs(inaccuracy) > EPSILON) {
std::cout << __FILE__ << ":" << __LINE__ std::cout << __FILE__ << ":" << __LINE__
<< " ERROR: bad penetration: expected = " << expectedPenetration << " ERROR: bad penetration: expected = " << expectedPenetration
<< " actual = " << collision->_penetration << " actual = " << collision->_penetration;
<< std::endl;
} }
// contactPoint is on surface of capsuleB // contactPoint is on surface of capsuleB
@ -300,8 +293,7 @@ void ShapeColliderTests::sphereTouchesCapsule() {
if (fabs(inaccuracy) > EPSILON) { if (fabs(inaccuracy) > EPSILON) {
std::cout << __FILE__ << ":" << __LINE__ std::cout << __FILE__ << ":" << __LINE__
<< " ERROR: bad contactPoint: expected = " << expectedContactPoint << " ERROR: bad contactPoint: expected = " << expectedContactPoint
<< " actual = " << collision->_contactPoint << " actual = " << collision->_contactPoint;
<< std::endl;
} }
} }
{ // sphereA hits end cap at axis { // sphereA hits end cap at axis
@ -319,13 +311,12 @@ void ShapeColliderTests::sphereTouchesCapsule() {
// penetration points from sphereA into capsuleB // penetration points from sphereA into capsuleB
CollisionInfo* collision = collisions.getCollision(numCollisions - 1); CollisionInfo* collision = collisions.getCollision(numCollisions - 1);
glm::vec3 expectedPenetration = - ((1.f - alpha) * radiusA + (1.f - beta) * radiusB) * yAxis; glm::vec3 expectedPenetration = - ((1.0f - alpha) * radiusA + (1.0f - beta) * radiusB) * yAxis;
float inaccuracy = glm::length(collision->_penetration - expectedPenetration); float inaccuracy = glm::length(collision->_penetration - expectedPenetration);
if (fabs(inaccuracy) > EPSILON) { if (fabs(inaccuracy) > EPSILON) {
std::cout << __FILE__ << ":" << __LINE__ std::cout << __FILE__ << ":" << __LINE__
<< " ERROR: bad penetration: expected = " << expectedPenetration << " ERROR: bad penetration: expected = " << expectedPenetration
<< " actual = " << collision->_penetration << " actual = " << collision->_penetration;
<< std::endl;
} }
// contactPoint is on surface of sphereA // contactPoint is on surface of sphereA
@ -334,8 +325,7 @@ void ShapeColliderTests::sphereTouchesCapsule() {
if (fabs(inaccuracy) > EPSILON) { if (fabs(inaccuracy) > EPSILON) {
std::cout << __FILE__ << ":" << __LINE__ std::cout << __FILE__ << ":" << __LINE__
<< " ERROR: bad contactPoint: expected = " << expectedContactPoint << " ERROR: bad contactPoint: expected = " << expectedContactPoint
<< " actual = " << collision->_contactPoint << " actual = " << collision->_contactPoint;
<< std::endl;
} }
// capsuleB collides with sphereA // capsuleB collides with sphereA
@ -350,13 +340,12 @@ void ShapeColliderTests::sphereTouchesCapsule() {
// penetration points from sphereA into capsuleB // penetration points from sphereA into capsuleB
collision = collisions.getCollision(numCollisions - 1); collision = collisions.getCollision(numCollisions - 1);
expectedPenetration = ((1.f - alpha) * radiusA + (1.f - beta) * radiusB) * yAxis; expectedPenetration = ((1.0f - alpha) * radiusA + (1.0f - beta) * radiusB) * yAxis;
inaccuracy = glm::length(collision->_penetration - expectedPenetration); inaccuracy = glm::length(collision->_penetration - expectedPenetration);
if (fabs(inaccuracy) > EPSILON) { if (fabs(inaccuracy) > EPSILON) {
std::cout << __FILE__ << ":" << __LINE__ std::cout << __FILE__ << ":" << __LINE__
<< " ERROR: bad penetration: expected = " << expectedPenetration << " ERROR: bad penetration: expected = " << expectedPenetration
<< " actual = " << collision->_penetration << " actual = " << collision->_penetration;
<< std::endl;
} }
// contactPoint is on surface of capsuleB // contactPoint is on surface of capsuleB
@ -367,8 +356,7 @@ void ShapeColliderTests::sphereTouchesCapsule() {
if (fabs(inaccuracy) > EPSILON) { if (fabs(inaccuracy) > EPSILON) {
std::cout << __FILE__ << ":" << __LINE__ std::cout << __FILE__ << ":" << __LINE__
<< " ERROR: bad contactPoint: expected = " << expectedContactPoint << " ERROR: bad contactPoint: expected = " << expectedContactPoint
<< " actual = " << collision->_contactPoint << " actual = " << collision->_contactPoint;
<< std::endl;
} }
} }
{ // sphereA hits start cap at axis { // sphereA hits start cap at axis
@ -386,13 +374,12 @@ void ShapeColliderTests::sphereTouchesCapsule() {
// penetration points from sphereA into capsuleB // penetration points from sphereA into capsuleB
CollisionInfo* collision = collisions.getCollision(numCollisions - 1); CollisionInfo* collision = collisions.getCollision(numCollisions - 1);
glm::vec3 expectedPenetration = ((1.f - alpha) * radiusA + (1.f - beta) * radiusB) * yAxis; glm::vec3 expectedPenetration = ((1.0f - alpha) * radiusA + (1.0f - beta) * radiusB) * yAxis;
float inaccuracy = glm::length(collision->_penetration - expectedPenetration); float inaccuracy = glm::length(collision->_penetration - expectedPenetration);
if (fabs(inaccuracy) > EPSILON) { if (fabs(inaccuracy) > EPSILON) {
std::cout << __FILE__ << ":" << __LINE__ std::cout << __FILE__ << ":" << __LINE__
<< " ERROR: bad penetration: expected = " << expectedPenetration << " ERROR: bad penetration: expected = " << expectedPenetration
<< " actual = " << collision->_penetration << " actual = " << collision->_penetration;
<< std::endl;
} }
// contactPoint is on surface of sphereA // contactPoint is on surface of sphereA
@ -401,8 +388,7 @@ void ShapeColliderTests::sphereTouchesCapsule() {
if (fabs(inaccuracy) > EPSILON) { if (fabs(inaccuracy) > EPSILON) {
std::cout << __FILE__ << ":" << __LINE__ std::cout << __FILE__ << ":" << __LINE__
<< " ERROR: bad contactPoint: expected = " << expectedContactPoint << " ERROR: bad contactPoint: expected = " << expectedContactPoint
<< " actual = " << collision->_contactPoint << " actual = " << collision->_contactPoint;
<< std::endl;
} }
// capsuleB collides with sphereA // capsuleB collides with sphereA
@ -417,13 +403,12 @@ void ShapeColliderTests::sphereTouchesCapsule() {
// penetration points from sphereA into capsuleB // penetration points from sphereA into capsuleB
collision = collisions.getCollision(numCollisions - 1); collision = collisions.getCollision(numCollisions - 1);
expectedPenetration = - ((1.f - alpha) * radiusA + (1.f - beta) * radiusB) * yAxis; expectedPenetration = - ((1.0f - alpha) * radiusA + (1.0f - beta) * radiusB) * yAxis;
inaccuracy = glm::length(collision->_penetration - expectedPenetration); inaccuracy = glm::length(collision->_penetration - expectedPenetration);
if (fabs(inaccuracy) > EPSILON) { if (fabs(inaccuracy) > EPSILON) {
std::cout << __FILE__ << ":" << __LINE__ std::cout << __FILE__ << ":" << __LINE__
<< " ERROR: bad penetration: expected = " << expectedPenetration << " ERROR: bad penetration: expected = " << expectedPenetration
<< " actual = " << collision->_penetration << " actual = " << collision->_penetration;
<< std::endl;
} }
// contactPoint is on surface of capsuleB // contactPoint is on surface of capsuleB
@ -434,8 +419,7 @@ void ShapeColliderTests::sphereTouchesCapsule() {
if (fabs(inaccuracy) > EPSILON) { if (fabs(inaccuracy) > EPSILON) {
std::cout << __FILE__ << ":" << __LINE__ std::cout << __FILE__ << ":" << __LINE__
<< " ERROR: bad contactPoint: expected = " << expectedContactPoint << " ERROR: bad contactPoint: expected = " << expectedContactPoint
<< " actual = " << collision->_contactPoint << " actual = " << collision->_contactPoint;
<< std::endl;
} }
} }
if (collisions.size() != numCollisions) { if (collisions.size() != numCollisions) {
@ -447,10 +431,10 @@ void ShapeColliderTests::sphereTouchesCapsule() {
void ShapeColliderTests::capsuleMissesCapsule() { void ShapeColliderTests::capsuleMissesCapsule() {
// non-overlapping capsules // non-overlapping capsules
float radiusA = 2.f; float radiusA = 2.0f;
float halfHeightA = 3.f; float halfHeightA = 3.0f;
float radiusB = 3.f; float radiusB = 3.0f;
float halfHeightB = 4.f; float halfHeightB = 4.0f;
float totalRadius = radiusA + radiusB; float totalRadius = radiusA + radiusB;
float totalHalfLength = totalRadius + halfHeightA + halfHeightB; float totalHalfLength = totalRadius + halfHeightA + halfHeightB;
@ -516,10 +500,10 @@ void ShapeColliderTests::capsuleMissesCapsule() {
void ShapeColliderTests::capsuleTouchesCapsule() { void ShapeColliderTests::capsuleTouchesCapsule() {
// overlapping capsules // overlapping capsules
float radiusA = 2.f; float radiusA = 2.0f;
float halfHeightA = 3.f; float halfHeightA = 3.0f;
float radiusB = 3.f; float radiusB = 3.0f;
float halfHeightB = 4.f; float halfHeightB = 4.0f;
float totalRadius = radiusA + radiusB; float totalRadius = radiusA + radiusB;
float totalHalfLength = totalRadius + halfHeightA + halfHeightB; float totalHalfLength = totalRadius + halfHeightA + halfHeightB;
@ -617,8 +601,7 @@ void ShapeColliderTests::capsuleTouchesCapsule() {
if (fabs(inaccuracy) > EPSILON) { if (fabs(inaccuracy) > EPSILON) {
std::cout << __FILE__ << ":" << __LINE__ std::cout << __FILE__ << ":" << __LINE__
<< " ERROR: bad penetration: expected = " << expectedPenetration << " ERROR: bad penetration: expected = " << expectedPenetration
<< " actual = " << collision->_penetration << " actual = " << collision->_penetration;
<< std::endl;
} }
glm::vec3 expectedContactPoint = capsuleA.getPosition() + radiusA * xAxis; glm::vec3 expectedContactPoint = capsuleA.getPosition() + radiusA * xAxis;
@ -626,8 +609,7 @@ void ShapeColliderTests::capsuleTouchesCapsule() {
if (fabs(inaccuracy) > EPSILON) { if (fabs(inaccuracy) > EPSILON) {
std::cout << __FILE__ << ":" << __LINE__ std::cout << __FILE__ << ":" << __LINE__
<< " ERROR: bad contactPoint: expected = " << expectedContactPoint << " ERROR: bad contactPoint: expected = " << expectedContactPoint
<< " actual = " << collision->_contactPoint << " actual = " << collision->_contactPoint;
<< std::endl;
} }
// capsuleB vs capsuleA // capsuleB vs capsuleA
@ -706,7 +688,7 @@ void ShapeColliderTests::sphereTouchesAACube() {
float cubeSide = 2.0f; float cubeSide = 2.0f;
float sphereRadius = 1.0f; float sphereRadius = 1.0f;
glm::vec3 sphereCenter(0.f); glm::vec3 sphereCenter(0.0f);
SphereShape sphere(sphereRadius, sphereCenter); SphereShape sphere(sphereRadius, sphereCenter);
float sphereOffset = (0.5f * cubeSide + sphereRadius - 0.25f); float sphereOffset = (0.5f * cubeSide + sphereRadius - 0.25f);