浏览代码

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

Adam Blake 13 年之前
父节点
当前提交
ea978b4692

+ 1 - 0
gameplay/src/Frustum.cpp

@@ -57,6 +57,7 @@ const Plane& Frustum::getTop() const
 
 void Frustum::getMatrix(Matrix* dst) const
 {
+    GP_ASSERT(dst);
     dst->set(_matrix);
 }
 

+ 44 - 27
gameplay/src/Matrix.cpp

@@ -112,12 +112,22 @@ void Matrix::createPerspective(float fieldOfView, float aspectRatio,
                                      float zNearPlane, float zFarPlane, Matrix* dst)
 {
     GP_ASSERT(dst);
+    GP_ASSERT(zFarPlane != zNearPlane);
 
     float f_n = 1.0f / (zFarPlane - zNearPlane);
-    float factor = 1.0f / tanf(MATH_DEG_TO_RAD(fieldOfView) * 0.5f);
+    float theta = MATH_DEG_TO_RAD(fieldOfView) * 0.5f;
+    if (abs(fmod(theta, MATH_PIOVER2)) < MATH_EPSILON)
+    {
+        GP_ERROR("Invalid field of view value (%d) causes attempted calculation tan(%d), which is undefined.", fieldOfView, theta);
+        return;
+    }
+    float divisor = tan(theta);
+    GP_ASSERT(divisor);
+    float factor = 1.0f / divisor;
 
     memset(dst, 0, MATRIX_SIZE);
 
+    GP_ASSERT(aspectRatio);
     dst->m[0] = (1.0f / aspectRatio) * factor;
     dst->m[5] = factor;
     dst->m[10] = (-(zFarPlane + zNearPlane)) * f_n;
@@ -136,6 +146,9 @@ void Matrix::createOrthographicOffCenter(float left, float right, float bottom,
                                          float zNearPlane, float zFarPlane, Matrix* dst)
 {
     GP_ASSERT(dst);
+    GP_ASSERT(right != left);
+    GP_ASSERT(top != bottom);
+    GP_ASSERT(zFarPlane != zNearPlane);
 
     float r_l = 1.0f / (right - left);
     float t_b = 1.0f / (top - bottom);
@@ -464,35 +477,37 @@ bool Matrix::decompose(Vector3* scale, Quaternion* rotation, Vector3* translatio
     {
         float s = 0.5f / sqrt(trace);
         rotation->w = 0.25f / s;
-        rotation->x = ( yaxis.z - zaxis.y ) * s;
-        rotation->y = ( zaxis.x - xaxis.z ) * s;
-        rotation->z = ( xaxis.y - yaxis.x ) * s;
+        rotation->x = (yaxis.z - zaxis.y) * s;
+        rotation->y = (zaxis.x - xaxis.z) * s;
+        rotation->z = (xaxis.y - yaxis.x) * s;
     }
     else
     {
+        // Note: since xaxis, yaxis, and zaxis are normalized, 
+        // we will never divide by zero in the code below.
         if (xaxis.x > yaxis.y && xaxis.x > zaxis.z)
         {
-            float s = 2.0f * sqrt(1.0f + xaxis.x - yaxis.y - zaxis.z);
-            rotation->w = (yaxis.z - zaxis.y ) / s;
-            rotation->x = 0.25f * s;
-            rotation->y = (yaxis.x + xaxis.y ) / s;
-            rotation->z = (zaxis.x + xaxis.z ) / s;
+            float s = 0.5f / sqrt(1.0f + xaxis.x - yaxis.y - zaxis.z);
+            rotation->w = (yaxis.z - zaxis.y) * s;
+            rotation->x = 0.25f / s;
+            rotation->y = (yaxis.x + xaxis.y) * s;
+            rotation->z = (zaxis.x + xaxis.z) * s;
         }
         else if (yaxis.y > zaxis.z)
         {
-            float s = 2.0f * sqrt(1.0f + yaxis.y - xaxis.x - zaxis.z);
-            rotation->w = (zaxis.x - xaxis.z ) / s;
-            rotation->x = (yaxis.x + xaxis.y ) / s;
-            rotation->y = 0.25f * s;
-            rotation->z = (zaxis.y + yaxis.z ) / s;
+            float s = 0.5f / sqrt(1.0f + yaxis.y - xaxis.x - zaxis.z);
+            rotation->w = (zaxis.x - xaxis.z) * s;
+            rotation->x = (yaxis.x + xaxis.y) * s;
+            rotation->y = 0.25f / s;
+            rotation->z = (zaxis.y + yaxis.z) * s;
         }
         else
         {
-            float s = 2.0f * sqrt(1.0f + zaxis.z - xaxis.x - yaxis.y );
-            rotation->w = (xaxis.y - yaxis.x ) / s;
-            rotation->x = (zaxis.x + xaxis.z ) / s;
-            rotation->y = (zaxis.y + yaxis.z ) / s;
-            rotation->z = 0.25f * s;
+            float s = 0.5f / sqrt(1.0f + zaxis.z - xaxis.x - yaxis.y );
+            rotation->w = (xaxis.y - yaxis.x ) * s;
+            rotation->x = (zaxis.x + xaxis.z ) * s;
+            rotation->y = (zaxis.y + yaxis.z ) * s;
+            rotation->z = 0.25f / s;
         }
     }
 
@@ -545,6 +560,7 @@ void Matrix::getUpVector(Vector3* dst) const
 void Matrix::getDownVector(Vector3* dst) const
 {
     GP_ASSERT(dst);
+    
     dst->x = -m[4];
     dst->y = -m[5];
     dst->z = -m[6];
@@ -719,6 +735,8 @@ void Matrix::negate()
 
 void Matrix::negate(Matrix* dst) const
 {
+    GP_ASSERT(dst);
+
     dst->m[0]  = -m[0];
     dst->m[1]  = -m[1];
     dst->m[2]  = -m[2];
@@ -792,8 +810,6 @@ void Matrix::rotateZ(float angle)
 
 void Matrix::rotateZ(float angle, Matrix* dst) const
 {
-    GP_ASSERT(dst);
-
     Matrix r;
     createRotationZ(angle, &r);
     multiply(*this, r, dst);
@@ -816,8 +832,6 @@ void Matrix::scale(float xScale, float yScale, float zScale)
 
 void Matrix::scale(float xScale, float yScale, float zScale, Matrix* dst) const
 {
-    GP_ASSERT(dst);
-
     Matrix s;
     createScale(xScale, yScale, zScale, &s);
     multiply(*this, s, dst);
@@ -881,6 +895,8 @@ void Matrix::subtract(const Matrix& m)
 
 void Matrix::subtract(const Matrix& m1, const Matrix& m2, Matrix* dst)
 {
+    GP_ASSERT(dst);
+
     dst->m[0]  = m1.m[0]  - m2.m[0];
     dst->m[1]  = m1.m[1]  - m2.m[1];
     dst->m[2]  = m1.m[2]  - m2.m[2];
@@ -901,6 +917,7 @@ void Matrix::subtract(const Matrix& m1, const Matrix& m2, Matrix* dst)
 
 void Matrix::transformPoint(Vector3* point) const
 {
+    GP_ASSERT(point);
     transformVector(point->x, point->y, point->z, 1.0f, point);
 }
 
@@ -911,6 +928,7 @@ void Matrix::transformPoint(const Vector3& point, Vector3* dst) const
 
 void Matrix::transformVector(Vector3* vector) const
 {
+    GP_ASSERT(vector);
     transformVector(vector->x, vector->y, vector->z, 0.0f, vector);
 }
 
@@ -926,11 +944,12 @@ void Matrix::transformVector(float x, float y, float z, float w, Vector3* dst) c
     dst->set(
         x * m[0] + y * m[4] + z * m[8] + w * m[12],
         x * m[1] + y * m[5] + z * m[9] + w * m[13],
-        x * m[2] + y * m[6] + z * m[10] + w * m[14] );
+        x * m[2] + y * m[6] + z * m[10] + w * m[14]);
 }
 
 void Matrix::transformVector(Vector4* vector) const
 {
+    GP_ASSERT(vector);
     transformVector(*vector, vector);
 }
 
@@ -942,7 +961,7 @@ void Matrix::transformVector(const Vector4& vector, Vector4* dst) const
         vector.x * m[0] + vector.y * m[4] + vector.z * m[8] + vector.w * m[12],
         vector.x * m[1] + vector.y * m[5] + vector.z * m[9] + vector.w * m[13],
         vector.x * m[2] + vector.y * m[6] + vector.z * m[10] + vector.w * m[14],
-        vector.x * m[3] + vector.y * m[7] + vector.z * m[11] + vector.w * m[15] );
+        vector.x * m[3] + vector.y * m[7] + vector.z * m[11] + vector.w * m[15]);
 }
 
 void Matrix::translate(float x, float y, float z)
@@ -952,8 +971,6 @@ void Matrix::translate(float x, float y, float z)
 
 void Matrix::translate(float x, float y, float z, Matrix* dst) const
 {
-    GP_ASSERT(dst);
-
     Matrix t;
     createTranslation(x, y, z, &t);
     multiply(*this, t, dst);

+ 5 - 1
gameplay/src/Plane.cpp

@@ -54,6 +54,8 @@ float Plane::distance(const Vector3& point) const
 
 void Plane::intersection(const Plane& p1, const Plane& p2, const Plane& p3, Vector3* point)
 {
+    GP_ASSERT(point);
+
     // The planes' normals must be all normalized (which we guarantee in the Plane class).
     // Calculate the determinant of the matrix (i.e | n1 n2 n3 |).
     float det = p1._normal.x * (p2._normal.y * p3._normal.z -
@@ -252,7 +254,9 @@ void Plane::transform(const Matrix& matrix)
         float ny = _normal.x * inverted.m[4] + _normal.y * inverted.m[5] + _normal.z * inverted.m[6] + _distance * inverted.m[7];
         float nz = _normal.x * inverted.m[8] + _normal.y * inverted.m[9] + _normal.z * inverted.m[10] + _distance * inverted.m[11];
         float d = _normal.x * inverted.m[12]+ _normal.y * inverted.m[13] + _normal.z * inverted.m[14] + _distance * inverted.m[15];
-        float factor = 1.0f / sqrt(nx * nx + ny * ny + nz * nz);
+        float divisor = sqrt(nx * nx + ny * ny + nz * nz);
+        GP_ASSERT(divisor);
+        float factor = 1.0f / divisor;
 
         _normal.x = nx * factor;
         _normal.y = ny * factor;

+ 10 - 4
gameplay/src/Quaternion.cpp

@@ -62,8 +62,6 @@ bool Quaternion::isZero() const
 
 void Quaternion::createFromRotationMatrix(const Matrix& m, Quaternion* dst)
 {
-    GP_ASSERT(dst);
-
     m.getRotation(dst);
 }
 
@@ -89,6 +87,8 @@ void Quaternion::conjugate()
 
 void Quaternion::conjugate(Quaternion* dst) const
 {
+    GP_ASSERT(dst);
+
     dst->x = -x;
     dst->y = -y;
     dst->z = -z;
@@ -102,6 +102,8 @@ bool Quaternion::inverse()
 
 bool Quaternion::inverse(Quaternion* dst) const
 {
+    GP_ASSERT(dst);
+
     float n = x * x + y * y + z * z + w * w;
     if (n == 1.0f)
     {
@@ -113,7 +115,7 @@ bool Quaternion::inverse(Quaternion* dst) const
         return true;
     }
 
-    // too close to zero
+    // Too close to zero.
     if (n < 0.000001f)
         return false;
 
@@ -133,6 +135,8 @@ void Quaternion::multiply(const Quaternion& q)
 
 void Quaternion::multiply(const Quaternion& q1, const Quaternion& q2, Quaternion* dst)
 {
+    GP_ASSERT(dst);
+
     float x = q1.w * q2.x + q1.x * q2.w + q1.y * q2.z - q1.z * q2.y;
     float y = q1.w * q2.y - q1.x * q2.z + q1.y * q2.w + q1.z * q2.x;
     float z = q1.w * q2.z + q1.x * q2.y - q1.y * q2.x + q1.z * q2.w;
@@ -263,12 +267,12 @@ void Quaternion::lerp(const Quaternion& q1, const Quaternion& q2, float t, Quate
 
 void Quaternion::slerp(const Quaternion& q1, const Quaternion& q2, float t, Quaternion* dst)
 {
+    GP_ASSERT(dst);
     slerp(q1.x, q1.y, q1.z, q1.w, q2.x, q2.y, q2.z, q2.w, t, &dst->x, &dst->y, &dst->z, &dst->w);
 }
 
 void Quaternion::squad(const Quaternion& q1, const Quaternion& q2, const Quaternion& s1, const Quaternion& s2, float t, Quaternion* dst)
 {
-    GP_ASSERT(dst);
     GP_ASSERT(!(t < 0.0f || t > 1.0f));
 
     Quaternion dstQ(0.0f, 0.0f, 0.0f, 1.0f);
@@ -380,6 +384,8 @@ void Quaternion::slerp(float q1x, float q1y, float q1z, float q1w, float q2x, fl
 
 void Quaternion::slerpForSquad(const Quaternion& q1, const Quaternion& q2, float t, Quaternion* dst)
 {
+    GP_ASSERT(dst);
+
     // cos(omega) = q1 * q2;
     // slerp(q1, q2, t) = (q1*sin((1-t)*omega) + q2*sin(t*omega))/sin(omega);
     // q1 = +- q2, slerp(q1,q2,t) = q1.

+ 12 - 10
gameplay/src/Ray.cpp

@@ -85,20 +85,20 @@ float Ray::intersects(const Frustum& frustum) const
 
     // If the ray's origin is in the negative half-space of one of the frustum's planes
     // and it does not intersect that same plane, then it does not intersect the frustum.
-    if ( (nOD < 0.0f && nD < 0.0f) || (fOD < 0.0f && fD < 0.0f) ||
+    if ((nOD < 0.0f && nD < 0.0f) || (fOD < 0.0f && fD < 0.0f) ||
         (lOD < 0.0f && lD < 0.0f)  || (rOD < 0.0f && rD < 0.0f) ||
-        (bOD < 0.0f && bD < 0.0f)  || (tOD < 0.0f && tD < 0.0f) )
+        (bOD < 0.0f && bD < 0.0f)  || (tOD < 0.0f && tD < 0.0f))
     {
         return Ray::INTERSECTS_NONE;
     }
 
     // Otherwise, the intersection distance is the minimum positive intersection distance.
     float d = (nD > 0.0f) ? nD : 0.0f;
-    d = (fD > 0.0f) ? ( (d == 0.0f) ? fD : min(fD, d) ) : d;
-    d = (lD > 0.0f) ? ( (d == 0.0f) ? lD : min(lD, d) ) : d;
-    d = (rD > 0.0f) ? ( (d == 0.0f) ? rD : min(rD, d) ) : d;
-    d = (tD > 0.0f) ? ( (d == 0.0f) ? bD : min(bD, d) ) : d;
-    d = (bD > 0.0f) ? ( (d == 0.0f) ? tD : min(tD, d) ) : d;
+    d = (fD > 0.0f) ? ((d == 0.0f) ? fD : min(fD, d)) : d;
+    d = (lD > 0.0f) ? ((d == 0.0f) ? lD : min(lD, d)) : d;
+    d = (rD > 0.0f) ? ((d == 0.0f) ? rD : min(rD, d)) : d;
+    d = (tD > 0.0f) ? ((d == 0.0f) ? bD : min(bD, d)) : d;
+    d = (bD > 0.0f) ? ((d == 0.0f) ? tD : min(tD, d)) : d;
 
     return d;
 }
@@ -117,7 +117,7 @@ float Ray::intersects(const Plane& plane) const
     
     // If the dot product of the plane's normal and this ray's direction is zero,
     // then the ray is parallel to the plane and does not intersect it.
-    if ( dot == 0.0f )
+    if (dot == 0.0f)
     {
         return INTERSECTS_NONE;
     }
@@ -156,12 +156,14 @@ void Ray::transform(const Matrix& matrix)
 void Ray::normalize()
 {
     if (_direction.isZero())
+    {
+        GP_ERROR("Invalid ray object; a ray's direction must be non-zero.");
         return;
+    }
 
     // Normalize the ray's direction vector.
     float normalizeFactor = 1.0f / sqrt(_direction.x * _direction.x + _direction.y * _direction.y + _direction.z * _direction.z);
-
-    if ( normalizeFactor != 1.0f )
+    if (normalizeFactor != 1.0f)
     {
         _direction.x *= normalizeFactor;
         _direction.y *= normalizeFactor;

+ 2 - 0
gameplay/src/Rectangle.cpp

@@ -110,6 +110,8 @@ bool Rectangle::intersects(const Rectangle& r) const
 
 void Rectangle::combine(const Rectangle& r1, const Rectangle& r2, Rectangle* dst)
 {
+    GP_ASSERT(dst);
+
     dst->x = min(r1.x, r2.x);
     dst->y = min(r1.y, r2.y);
     dst->width = max(r1.x + r1.width, r2.x + r2.width) - dst->x;

+ 16 - 8
gameplay/src/Transform.cpp

@@ -59,6 +59,7 @@ void Transform::resumeTransformChanged()
         for (unsigned int i = 0; i < transformCount; i++)
         {
             Transform* t = _transformsChanged.at(i);
+            GP_ASSERT(t);
             t->transformChanged();
         }
 
@@ -68,6 +69,7 @@ void Transform::resumeTransformChanged()
         for (unsigned int i = 0; i < transformCount; i++)
         {
             Transform* t = _transformsChanged.at(i);
+            GP_ASSERT(t);
             t->_matrixDirtyBits &= ~DIRTY_NOTIFY;
         }
 
@@ -130,6 +132,7 @@ const Vector3& Transform::getScale() const
 
 void Transform::getScale(Vector3* scale) const
 {
+    GP_ASSERT(scale);
     scale->set(_scale);
 }
 
@@ -156,14 +159,12 @@ const Quaternion& Transform::getRotation() const
 void Transform::getRotation(Quaternion* rotation) const
 {
     GP_ASSERT(rotation);
-
     rotation->set(_rotation);
 }
 
 void Transform::getRotation(Matrix* rotation) const
 {
     GP_ASSERT(rotation);
-
     Matrix::createRotation(_rotation, rotation);
 }
 
@@ -180,6 +181,7 @@ const Vector3& Transform::getTranslation() const
 
 void Transform::getTranslation(Vector3* translation) const
 {
+    GP_ASSERT(translation);
     translation->set(_translation);
 }
 
@@ -573,24 +575,18 @@ void Transform::translateForward(float amount)
 
 void Transform::transformPoint(Vector3* point)
 {
-    GP_ASSERT(point);
-
     getMatrix();
     _matrix.transformPoint(point);
 }
 
 void Transform::transformPoint(const Vector3& point, Vector3* dst)
 {
-    GP_ASSERT(dst);
-
     getMatrix();
     _matrix.transformPoint(point, dst);
 }
 
 void Transform::transformVector(Vector3* normal)
 {
-    GP_ASSERT(normal);
-
     getMatrix();
     _matrix.transformVector(normal);
 }
@@ -635,6 +631,8 @@ unsigned int Transform::getAnimationPropertyComponentCount(int propertyId) const
 
 void Transform::getAnimationPropertyValue(int propertyId, AnimationValue* value)
 {
+    GP_ASSERT(value);
+
     switch (propertyId)
     {
         case ANIMATE_SCALE_UNIT:
@@ -702,6 +700,7 @@ void Transform::getAnimationPropertyValue(int propertyId, AnimationValue* value)
 
 void Transform::setAnimationPropertyValue(int propertyId, AnimationValue* value, float blendWeight)
 {
+    GP_ASSERT(value);
     GP_ASSERT(blendWeight >= 0.0f && blendWeight <= 1.0f);
 
     switch (propertyId)
@@ -798,12 +797,15 @@ bool Transform::isDirty(char matrixDirtyBits) const
 
 void Transform::suspendTransformChange(Transform* transform)
 {
+    GP_ASSERT(transform);
     transform->_matrixDirtyBits |= DIRTY_NOTIFY;
     _transformsChanged.push_back(transform);
 }
 
 void Transform::addListener(Transform::Listener* listener, long cookie)
 {
+    GP_ASSERT(listener);
+
     if (_listeners == NULL)
         _listeners = new std::list<TransformListener>();
 
@@ -815,6 +817,8 @@ void Transform::addListener(Transform::Listener* listener, long cookie)
 
 void Transform::removeListener(Transform::Listener* listener)
 {
+    GP_ASSERT(listener);
+
     if (_listeners)
     {
         for (std::list<TransformListener>::iterator itr = _listeners->begin(); itr != _listeners->end(); itr++)
@@ -835,6 +839,7 @@ void Transform::transformChanged()
         for (std::list<TransformListener>::iterator itr = _listeners->begin(); itr != _listeners->end(); itr++)
         {
             TransformListener& l = *itr;
+            GP_ASSERT(l.listener);
             l.listener->transformChanged(this, l.cookie);
         }
     }
@@ -842,6 +847,8 @@ void Transform::transformChanged()
 
 void Transform::cloneInto(Transform* transform, NodeCloneContext &context) const
 {
+    GP_ASSERT(transform);
+
     AnimationTarget::cloneInto(transform, context);
     transform->_scale.set(_scale);
     transform->_rotation.set(_rotation);
@@ -850,6 +857,7 @@ void Transform::cloneInto(Transform* transform, NodeCloneContext &context) const
 
 void Transform::applyAnimationValueRotation(AnimationValue* value, unsigned int index, float blendWeight)
 {
+    GP_ASSERT(value);
     Quaternion::slerp(_rotation.x, _rotation.y, _rotation.z, _rotation.w, value->getFloat(index), value->getFloat(index + 1), value->getFloat(index + 2), value->getFloat(index + 3), blendWeight, 
         &_rotation.x, &_rotation.y, &_rotation.z, &_rotation.w);
     dirty(DIRTY_ROTATION);

+ 10 - 10
gameplay/src/Vector2.cpp

@@ -89,38 +89,38 @@ void Vector2::add(const Vector2& v1, const Vector2& v2, Vector2* dst)
 
 void Vector2::clamp(const Vector2& min, const Vector2& max)
 {
-    GP_ASSERT(!( min.x > max.x || min.y > max.y ));
+    GP_ASSERT(!(min.x > max.x || min.y > max.y ));
 
     // Clamp the x value.
-    if ( x < min.x )
+    if (x < min.x)
         x = min.x;
-    if ( x > max.x )
+    if (x > max.x)
         x = max.x;
 
     // Clamp the y value.
-    if ( y < min.y )
+    if (y < min.y)
         y = min.y;
-    if ( y > max.y )
+    if (y > max.y)
         y = max.y;
 }
 
 void Vector2::clamp(const Vector2& v, const Vector2& min, const Vector2& max, Vector2* dst)
 {
     GP_ASSERT(dst);
-    GP_ASSERT(!( min.x > max.x || min.y > max.y ));
+    GP_ASSERT(!(min.x > max.x || min.y > max.y ));
 
     // Clamp the x value.
     dst->x = v.x;
-    if ( dst->x < min.x )
+    if (dst->x < min.x)
         dst->x = min.x;
-    if ( dst->x > max.x )
+    if (dst->x > max.x)
         dst->x = max.x;
 
     // Clamp the y value.
     dst->y = v.y;
-    if ( dst->y < min.y )
+    if (dst->y < min.y)
         dst->y = min.y;
-    if ( dst->y > max.y )
+    if (dst->y > max.y)
         dst->y = max.y;
 }
 

+ 14 - 14
gameplay/src/Vector3.cpp

@@ -115,51 +115,51 @@ void Vector3::add(const Vector3& v1, const Vector3& v2, Vector3* dst)
 
 void Vector3::clamp(const Vector3& min, const Vector3& max)
 {
-    GP_ASSERT(!( min.x > max.x || min.y > max.y || min.z > max.z));
+    GP_ASSERT(!(min.x > max.x || min.y > max.y || min.z > max.z));
 
     // Clamp the x value.
-    if ( x < min.x )
+    if (x < min.x)
         x = min.x;
-    if ( x > max.x )
+    if (x > max.x)
         x = max.x;
 
     // Clamp the y value.
-    if ( y < min.y )
+    if (y < min.y)
         y = min.y;
-    if ( y > max.y )
+    if (y > max.y)
         y = max.y;
 
     // Clamp the z value.
-    if ( z < min.z )
+    if (z < min.z)
         z = min.z;
-    if ( z > max.z )
+    if (z > max.z)
         z = max.z;
 }
 
 void Vector3::clamp(const Vector3& v, const Vector3& min, const Vector3& max, Vector3* dst)
 {
     GP_ASSERT(dst);
-    GP_ASSERT(!( min.x > max.x || min.y > max.y || min.z > max.z));
+    GP_ASSERT(!(min.x > max.x || min.y > max.y || min.z > max.z));
 
     // Clamp the x value.
     dst->x = v.x;
-    if ( dst->x < min.x )
+    if (dst->x < min.x)
         dst->x = min.x;
-    if ( dst->x > max.x )
+    if (dst->x > max.x)
         dst->x = max.x;
 
     // Clamp the y value.
     dst->y = v.y;
-    if ( dst->y < min.y )
+    if (dst->y < min.y)
         dst->y = min.y;
-    if ( dst->y > max.y )
+    if (dst->y > max.y)
         dst->y = max.y;
 
     // Clamp the z value.
     dst->z = v.z;
-    if ( dst->z < min.z )
+    if (dst->z < min.z)
         dst->z = min.z;
-    if ( dst->z > max.z )
+    if (dst->z > max.z)
         dst->z = max.z;
 }
 

+ 18 - 18
gameplay/src/Vector4.cpp

@@ -123,64 +123,64 @@ void Vector4::add(const Vector4& v1, const Vector4& v2, Vector4* dst)
 
 void Vector4::clamp(const Vector4& min, const Vector4& max)
 {
-    GP_ASSERT(!( min.x > max.x || min.y > max.y || min.z > max.z || min.w > max.w));
+    GP_ASSERT(!(min.x > max.x || min.y > max.y || min.z > max.z || min.w > max.w));
 
     // Clamp the x value.
-    if ( x < min.x )
+    if (x < min.x)
         x = min.x;
-    if ( x > max.x )
+    if (x > max.x)
         x = max.x;
 
     // Clamp the y value.
-    if ( y < min.y )
+    if (y < min.y)
         y = min.y;
-    if ( y > max.y )
+    if (y > max.y)
         y = max.y;
 
     // Clamp the z value.
-    if ( z < min.z )
+    if (z < min.z)
         z = min.z;
-    if ( z > max.z )
+    if (z > max.z)
         z = max.z;
 
     // Clamp the z value.
-    if ( w < min.w )
+    if (w < min.w)
         w = min.w;
-    if ( w > max.w )
+    if (w > max.w)
         w = max.w;
 }
 
 void Vector4::clamp(const Vector4& v, const Vector4& min, const Vector4& max, Vector4* dst)
 {
     GP_ASSERT(dst);
-    GP_ASSERT(!( min.x > max.x || min.y > max.y || min.z > max.z || min.w > max.w));
+    GP_ASSERT(!(min.x > max.x || min.y > max.y || min.z > max.z || min.w > max.w));
 
     // Clamp the x value.
     dst->x = v.x;
-    if ( dst->x < min.x )
+    if (dst->x < min.x)
         dst->x = min.x;
-    if ( dst->x > max.x )
+    if (dst->x > max.x)
         dst->x = max.x;
 
     // Clamp the y value.
     dst->y = v.y;
-    if ( dst->y < min.y )
+    if (dst->y < min.y)
         dst->y = min.y;
-    if ( dst->y > max.y )
+    if (dst->y > max.y)
         dst->y = max.y;
 
     // Clamp the z value.
     dst->z = v.z;
-    if ( dst->z < min.z )
+    if (dst->z < min.z)
         dst->z = min.z;
-    if ( dst->z > max.z )
+    if (dst->z > max.z)
         dst->z = max.z;
 
     // Clamp the w value.
     dst->w = v.w;
-    if ( dst->w < min.w )
+    if (dst->w < min.w)
         dst->w = min.w;
-    if ( dst->w > max.w )
+    if (dst->w > max.w)
         dst->w = max.w;
 }