Fix issues in some unit tests
This commit is contained in:
parent
a871bfdd6a
commit
d6b88baee7
|
@ -610,7 +610,7 @@ class TestCollisionWorld : public Test {
|
|||
Transform initTransform2 = mSphereBody2->getTransform();
|
||||
|
||||
Transform transform1(Vector3(10, 20, 50), Quaternion::identity());
|
||||
Transform transform2(Vector3(17, 20, 50), Quaternion::fromEulerAngles(rp3d::PI / 8.0f, rp3d::PI / 4.0f, rp3d::PI / 16.0f));
|
||||
Transform transform2(Vector3(17, 20, 50), Quaternion::fromEulerAngles(rp3d::PI_RP3D / 8.0f, rp3d::PI_RP3D / 4.0f, rp3d::PI_RP3D / 16.0f));
|
||||
|
||||
// Move spheres to collide with each other
|
||||
mSphereBody1->setTransform(transform1);
|
||||
|
@ -2200,7 +2200,7 @@ class TestCollisionWorld : public Test {
|
|||
*********************************************************************************/
|
||||
|
||||
Transform transform1(Vector3(10, 20, 50), Quaternion::identity());
|
||||
Transform transform2(Vector3(17, 21, 50), Quaternion::fromEulerAngles(0, 0, rp3d::PI * 0.5f));
|
||||
Transform transform2(Vector3(17, 21, 50), Quaternion::fromEulerAngles(0, 0, rp3d::PI_RP3D * 0.5f));
|
||||
|
||||
// Move spheres to collide with each other
|
||||
mBoxBody1->setTransform(transform1);
|
||||
|
@ -2315,7 +2315,7 @@ class TestCollisionWorld : public Test {
|
|||
*********************************************************************************/
|
||||
|
||||
Transform transform1(Vector3(10, 20, 50), Quaternion::identity());
|
||||
Transform transform2(Vector3(17, 21, 50), Quaternion::fromEulerAngles(0, 0, rp3d::PI * 0.5f));
|
||||
Transform transform2(Vector3(17, 21, 50), Quaternion::fromEulerAngles(0, 0, rp3d::PI_RP3D * 0.5f));
|
||||
|
||||
// Move spheres to collide with each other
|
||||
mConvexMeshBody1->setTransform(transform1);
|
||||
|
@ -2626,7 +2626,7 @@ class TestCollisionWorld : public Test {
|
|||
*********************************************************************************/
|
||||
|
||||
Transform transform1(Vector3(10, 20, 50), Quaternion::identity());
|
||||
Transform transform2(Vector3(16, 23, 50), Quaternion::fromEulerAngles(0, 0, rp3d::PI * 0.5f));
|
||||
Transform transform2(Vector3(16, 23, 50), Quaternion::fromEulerAngles(0, 0, rp3d::PI_RP3D * 0.5f));
|
||||
|
||||
// Move spheres to collide with each other
|
||||
mCapsuleBody1->setTransform(transform1);
|
||||
|
@ -2732,7 +2732,7 @@ class TestCollisionWorld : public Test {
|
|||
*********************************************************************************/
|
||||
|
||||
transform1 = Transform(Vector3(10, 20, 50), Quaternion::identity());
|
||||
transform2 = Transform(Vector3(10, 27, 50), Quaternion::fromEulerAngles(0, 0, rp3d::PI * 0.5f));
|
||||
transform2 = Transform(Vector3(10, 27, 50), Quaternion::fromEulerAngles(0, 0, rp3d::PI_RP3D * 0.5f));
|
||||
|
||||
// Move spheres to collide with each other
|
||||
mCapsuleBody1->setTransform(transform1);
|
||||
|
|
|
@ -101,7 +101,7 @@ class TestPointInside : public Test {
|
|||
|
||||
// Body transform
|
||||
Vector3 position(-3, 2, 7);
|
||||
Quaternion orientation = Quaternion::fromEulerAngles(PI / 5, PI / 6, PI / 7);
|
||||
Quaternion orientation = Quaternion::fromEulerAngles(PI_RP3D / 5, PI_RP3D / 6, PI_RP3D / 7);
|
||||
mBodyTransform = Transform(position, orientation);
|
||||
|
||||
// Create the bodies
|
||||
|
@ -117,7 +117,7 @@ class TestPointInside : public Test {
|
|||
|
||||
// Collision shape transform
|
||||
Vector3 shapePosition(1, -4, -3);
|
||||
Quaternion shapeOrientation = Quaternion::fromEulerAngles(3 * PI / 6 , -PI / 8, PI / 3);
|
||||
Quaternion shapeOrientation = Quaternion::fromEulerAngles(3 * PI_RP3D / 6 , -PI_RP3D / 8, PI_RP3D / 3);
|
||||
mShapeTransform = Transform(shapePosition, shapeOrientation);
|
||||
|
||||
// Compute the the transform from a local shape point to world-space
|
||||
|
@ -167,7 +167,7 @@ class TestPointInside : public Test {
|
|||
|
||||
// Compound shape is a capsule and a sphere
|
||||
Vector3 positionShape2(Vector3(4, 2, -3));
|
||||
Quaternion orientationShape2 = Quaternion::fromEulerAngles(-3 * PI / 8, 1.5 * PI/ 3, PI / 13);
|
||||
Quaternion orientationShape2 = Quaternion::fromEulerAngles(-3 * PI_RP3D / 8, 1.5 * PI_RP3D/ 3, PI_RP3D / 13);
|
||||
Transform shapeTransform2(positionShape2, orientationShape2);
|
||||
mLocalShape2ToWorld = mBodyTransform * shapeTransform2;
|
||||
mCompoundBody->addCollider(mCapsuleShape, mShapeTransform);
|
||||
|
|
|
@ -176,7 +176,7 @@ class TestRaycast : public Test {
|
|||
|
||||
// Body transform
|
||||
Vector3 position(-3, 2, 7);
|
||||
Quaternion orientation = Quaternion::fromEulerAngles(PI / 5, PI / 6, PI / 7);
|
||||
Quaternion orientation = Quaternion::fromEulerAngles(PI_RP3D / 5, PI_RP3D / 6, PI_RP3D / 7);
|
||||
mBodyTransform = Transform(position, orientation);
|
||||
|
||||
// Create the bodies
|
||||
|
@ -191,7 +191,7 @@ class TestRaycast : public Test {
|
|||
|
||||
// Collision shape transform
|
||||
Vector3 shapePosition(1, -4, -3);
|
||||
Quaternion shapeOrientation = Quaternion::fromEulerAngles(3 * PI / 6 , -PI / 8, PI / 3);
|
||||
Quaternion shapeOrientation = Quaternion::fromEulerAngles(3 * PI_RP3D / 6 , -PI_RP3D / 8, PI_RP3D / 3);
|
||||
mShapeTransform = Transform(shapePosition, shapeOrientation);
|
||||
|
||||
// Compute the the transform from a local shape point to world-space
|
||||
|
@ -243,7 +243,7 @@ class TestRaycast : public Test {
|
|||
|
||||
// Compound shape is a cylinder and a sphere
|
||||
Vector3 positionShape2(Vector3(4, 2, -3));
|
||||
Quaternion orientationShape2 = Quaternion::fromEulerAngles(-3 *PI / 8, 1.5 * PI/ 3, PI / 13);
|
||||
Quaternion orientationShape2 = Quaternion::fromEulerAngles(-3 * PI_RP3D / 8, 1.5 * PI_RP3D/ 3, PI_RP3D / 13);
|
||||
Transform shapeTransform2(positionShape2, orientationShape2);
|
||||
mLocalShape2ToWorld = mBodyTransform * shapeTransform2;
|
||||
mCompoundCapsuleCollider = mCompoundBody->addCollider(mCapsuleShape, mShapeTransform);
|
||||
|
|
|
@ -56,8 +56,8 @@ class TestQuaternion : public Test {
|
|||
/// Constructor
|
||||
TestQuaternion(const std::string& name) : Test(name), mIdentity(Quaternion::identity()) {
|
||||
|
||||
decimal sinA = sin(decimal(PI/8.0));
|
||||
decimal cosA = cos(decimal(PI/8.0));
|
||||
decimal sinA = sin(decimal(PI_RP3D/8.0));
|
||||
decimal cosA = cos(decimal(PI_RP3D/8.0));
|
||||
Vector3 vector(2, 3, 4);
|
||||
vector.normalize();
|
||||
mQuaternion1 = Quaternion(vector.x * sinA, vector.y * sinA, vector.z * sinA, cosA);
|
||||
|
@ -92,7 +92,7 @@ class TestQuaternion : public Test {
|
|||
|
||||
// Test conversion from Euler angles to quaternion
|
||||
|
||||
const decimal PI_OVER_2 = PI * decimal(0.5);
|
||||
const decimal PI_OVER_2 = PI_RP3D * decimal(0.5);
|
||||
const decimal PI_OVER_4 = PI_OVER_2 * decimal(0.5);
|
||||
Quaternion quaternion5 = Quaternion::fromEulerAngles(PI_OVER_2, 0, 0);
|
||||
Quaternion quaternionTest5(std::sin(PI_OVER_4), 0, 0, std::cos(PI_OVER_4));
|
||||
|
@ -189,7 +189,7 @@ class TestQuaternion : public Test {
|
|||
Vector3 originalAxis = Vector3(2, 3, 4).getUnit();
|
||||
mQuaternion1.getRotationAngleAxis(angle, axis);
|
||||
rp3d_test(approxEqual(axis.x, originalAxis.x));
|
||||
rp3d_test(approxEqual(angle, decimal(PI/4.0), decimal(10e-6)));
|
||||
rp3d_test(approxEqual(angle, decimal(PI_RP3D/4.0), decimal(10e-6)));
|
||||
|
||||
// Test the method that returns the corresponding matrix
|
||||
Matrix3x3 matrix = mQuaternion1.getMatrix();
|
||||
|
@ -207,14 +207,14 @@ class TestQuaternion : public Test {
|
|||
Quaternion test2 = Quaternion::slerp(quatStart, quatEnd, 1.0);
|
||||
rp3d_test(test1 == quatStart);
|
||||
rp3d_test(test2 == quatEnd);
|
||||
decimal sinA = sin(decimal(PI/4.0));
|
||||
decimal cosA = cos(decimal(PI/4.0));
|
||||
decimal sinA = sin(decimal(PI_RP3D/4.0));
|
||||
decimal cosA = cos(decimal(PI_RP3D/4.0));
|
||||
Quaternion quat(sinA, 0, 0, cosA);
|
||||
Quaternion test3 = Quaternion::slerp(mIdentity, quat, decimal(0.5));
|
||||
rp3d_test(approxEqual(test3.x, sin(decimal(PI/8.0))));
|
||||
rp3d_test(approxEqual(test3.x, sin(decimal(PI_RP3D/8.0))));
|
||||
rp3d_test(approxEqual(test3.y, 0.0));
|
||||
rp3d_test(approxEqual(test3.z, 0.0));
|
||||
rp3d_test(approxEqual(test3.w, cos(decimal(PI/8.0)), decimal(10e-6)));
|
||||
rp3d_test(approxEqual(test3.w, cos(decimal(PI_RP3D/8.0)), decimal(10e-6)));
|
||||
}
|
||||
|
||||
/// Test overloaded operators
|
||||
|
|
|
@ -65,12 +65,12 @@ class TestTransform : public Test {
|
|||
Vector3 unitVec(1, 1, 1);
|
||||
unitVec.normalize();
|
||||
|
||||
decimal sinA = std::sin(PI/8.0f);
|
||||
decimal cosA = std::cos(PI/8.0f);
|
||||
decimal sinA = std::sin(PI_RP3D/8.0f);
|
||||
decimal cosA = std::cos(PI_RP3D/8.0f);
|
||||
mTransform1 = Transform(Vector3(4, 5, 6), Quaternion(sinA * unitVec, cosA));
|
||||
|
||||
decimal sinB = std::sin(PI/3.0f);
|
||||
decimal cosB = std::cos(PI/3.0f);
|
||||
decimal sinB = std::sin(PI_RP3D/3.0f);
|
||||
decimal cosB = std::cos(PI_RP3D/3.0f);
|
||||
mTransform2 = Transform(Vector3(8, 45, -6), Quaternion(sinB * unitVec, cosB));
|
||||
}
|
||||
|
||||
|
@ -162,10 +162,10 @@ class TestTransform : public Test {
|
|||
rp3d_test(transformStart == mTransform1);
|
||||
rp3d_test(transformEnd == mTransform2);
|
||||
|
||||
decimal sinA = sin(PI/3.0f);
|
||||
decimal cosA = cos(PI/3.0f);
|
||||
decimal sinB = sin(PI/6.0f);
|
||||
decimal cosB = cos(PI/6.0f);
|
||||
decimal sinA = sin(PI_RP3D/3.0f);
|
||||
decimal cosA = cos(PI_RP3D/3.0f);
|
||||
decimal sinB = sin(PI_RP3D/6.0f);
|
||||
decimal cosB = cos(PI_RP3D/6.0f);
|
||||
Transform transform1(Vector3(4, 5, 6), Quaternion::identity());
|
||||
Transform transform2(Vector3(8, 11, 16), Quaternion(sinA, sinA, sinA, cosA));
|
||||
Transform transform = Transform::interpolateTransforms(transform1, transform2, 0.5);
|
||||
|
|
Loading…
Reference in New Issue
Block a user