Преглед изворни кода

Renamed Quaternion definition methods to define() to match the convention of Matrix, BoundingBox etc.

Lasse Öörni пре 14 година
родитељ
комит
d8f7e6a688

+ 3 - 3
Engine/Engine/RegisterMath.cpp

@@ -361,9 +361,9 @@ static void registerQuaternion(asIScriptEngine* engine)
     engine->RegisterObjectMethod("Quaternion", "Quaternion opSub(const Quaternion& in) const", asMETHODPR(Quaternion, operator +, (const Quaternion&) const, Quaternion), asCALL_THISCALL);
     engine->RegisterObjectMethod("Quaternion", "Quaternion opMul(const Quaternion& in) const", asMETHODPR(Quaternion, operator *, (const Quaternion&) const, Quaternion), asCALL_THISCALL);
     engine->RegisterObjectMethod("Quaternion", "void normalize()", asMETHOD(Quaternion, normalize), asCALL_THISCALL);
-    engine->RegisterObjectMethod("Quaternion", "void fromAngleAxis(float, const Vector3& in)", asMETHOD(Quaternion, fromAngleAxis), asCALL_THISCALL);
-    engine->RegisterObjectMethod("Quaternion", "void fromEulerAngles(const Vector3& in)", asMETHOD(Quaternion, fromEulerAngles), asCALL_THISCALL);
-    engine->RegisterObjectMethod("Quaternion", "void fromRotation(const Vector3& in, const Vector3& in)", asMETHOD(Quaternion, fromRotationTo), asCALL_THISCALL);
+    engine->RegisterObjectMethod("Quaternion", "void define(float, const Vector3& in)", asMETHODPR(Quaternion, define, (float, const Vector3&), void), asCALL_THISCALL);
+    engine->RegisterObjectMethod("Quaternion", "void define(const Vector3& in)", asMETHODPR(Quaternion, define, (const Vector3&), void), asCALL_THISCALL);
+    engine->RegisterObjectMethod("Quaternion", "void fromRotation(const Vector3& in, const Vector3& in)", asMETHODPR(Quaternion, define, (const Vector3&, const Vector3&), void), asCALL_THISCALL);
     engine->RegisterObjectMethod("Quaternion", "Quaternion getNormalized() const", asMETHOD(Quaternion, getNormalized), asCALL_THISCALL);
     engine->RegisterObjectMethod("Quaternion", "Quaternion getInverse() const", asMETHOD(Quaternion, getInverse), asCALL_THISCALL);
     engine->RegisterObjectMethod("Quaternion", "float dotProduct(const Quaternion& in) const", asMETHOD(Quaternion, dotProduct), asCALL_THISCALL);

+ 1 - 1
Engine/Math/Matrix4.cpp

@@ -54,7 +54,7 @@ void Matrix4::getDecomposition(Vector3& translation, Quaternion& rotation, Vecto
     row1 /= scale.mX;
     row2 /= scale.mY;
     row3 /= scale.mZ;
-    rotation.fromRotationMatrix(Matrix3(row1.mX, row2.mX, row3.mX, row1.mY, row2.mY, row3.mY, row1.mZ, row2.mZ, row3.mZ));
+    rotation.define(Matrix3(row1.mX, row2.mX, row3.mX, row1.mY, row2.mY, row3.mY, row1.mZ, row2.mZ, row3.mZ));
 }
 
 Matrix4 Matrix4::getInverse() const

+ 1 - 1
Engine/Math/Matrix4x3.cpp

@@ -80,7 +80,7 @@ void Matrix4x3::getDecomposition(Vector3& translation, Quaternion& rotation, Vec
     row1 /= scale.mX;
     row2 /= scale.mY;
     row3 /= scale.mZ;
-    rotation.fromRotationMatrix(Matrix3(row1.mX, row2.mX, row3.mX, row1.mY, row2.mY, row3.mY, row1.mZ, row2.mZ, row3.mZ));
+    rotation.define(Matrix3(row1.mX, row2.mX, row3.mX, row1.mY, row2.mY, row3.mY, row1.mZ, row2.mZ, row3.mZ));
 }
 
 Matrix4x3 Matrix4x3::getInverse() const

+ 10 - 10
Engine/Math/Quaternion.cpp

@@ -28,30 +28,30 @@ const Quaternion Quaternion::sIdentity(1.0f, 0.0f, 0.0f, 0.0f);
 
 Quaternion::Quaternion(float angle, const Vector3& Axis)
 {
-    fromAngleAxis(angle, Axis);
+    define(angle, Axis);
 }
 
 Quaternion::Quaternion(const Vector3& euler)
 {
-    fromEulerAngles(euler);
+    define(euler);
 }
 
 Quaternion::Quaternion(float angleX, float angleY, float angleZ)
 {
-    fromEulerAngles(Vector3(angleX, angleY, angleZ));
+    define(Vector3(angleX, angleY, angleZ));
 }
 
 Quaternion::Quaternion(const Vector3& start, const Vector3& end)
 {
-    fromRotationTo(start, end);
+    define(start, end);
 }
 
 Quaternion::Quaternion(const Matrix3& matrix)
 {
-    fromRotationMatrix(matrix);
+    define(matrix);
 }
 
-void Quaternion::fromAngleAxis(float angle, const Vector3& axis)
+void Quaternion::define(float angle, const Vector3& axis)
 {
     Vector3 normAxis = axis.getNormalized();
     float sinAngle = sinf((angle * M_DEGTORAD) * 0.5f);
@@ -63,7 +63,7 @@ void Quaternion::fromAngleAxis(float angle, const Vector3& axis)
     mZ = normAxis.mZ * sinAngle;
 }
 
-void Quaternion::fromEulerAngles(const Vector3& euler)
+void Quaternion::define(const Vector3& euler)
 {
     // Order of rotations: Z first, then X, then Y (mimics typical FPS camera with gimbal lock at top/bottom)
     float sinX = sinf((euler.mX * M_DEGTORAD) * 0.5f);
@@ -79,7 +79,7 @@ void Quaternion::fromEulerAngles(const Vector3& euler)
     mZ = cosY * cosX * sinZ - sinY * sinX * cosZ;
 }
 
-void Quaternion::fromRotationTo(const Vector3& start, const Vector3& end)
+void Quaternion::define(const Vector3& start, const Vector3& end)
 {
     Vector3 normStart = start.getNormalized();
     Vector3 normEnd = end.getNormalized();
@@ -103,11 +103,11 @@ void Quaternion::fromRotationTo(const Vector3& start, const Vector3& end)
         if (tempAxis.getLength() < M_EPSILON)
             tempAxis = Vector3::sUp.crossProduct(normStart);
         
-        fromAngleAxis(180.0f, tempAxis);
+        define(180.0f, tempAxis);
     }
 }
 
-void Quaternion::fromRotationMatrix(const Matrix3& matrix)
+void Quaternion::define(const Matrix3& matrix)
 {
     float t = matrix.m00 + matrix.m11 + matrix.m22 + 1.0f;
     if (t > 0.0f)

+ 8 - 8
Engine/Math/Quaternion.h

@@ -181,14 +181,14 @@ public:
         mZ *= invLen;
     }
     
-    //! Set from an angle (in degrees) and axis
-    void fromAngleAxis(float angle, const Vector3& axis);
-    //! Set from Euler angles (in degrees)
-    void fromEulerAngles(const Vector3& euler);
-    //! Set from the rotation difference between two vectors
-    void fromRotationTo(const Vector3& start, const Vector3& end);
-    //! Set from a rotation matrix
-    void fromRotationMatrix(const Matrix3& matrix);
+    //! Define from an angle (in degrees) and axis
+    void define(float angle, const Vector3& axis);
+    //! Define from Euler angles (in degrees)
+    void define(const Vector3& euler);
+    //! Define from the rotation difference between two vectors
+    void define(const Vector3& start, const Vector3& end);
+    //! Define from a rotation matrix
+    void define(const Matrix3& matrix);
     
     //! Return normalized to unit length
     Quaternion getNormalized() const