Skip to content

Commit

Permalink
Fixed row-column vs colum-row order issues
Browse files Browse the repository at this point in the history
  • Loading branch information
matt77hias committed Apr 14, 2017
1 parent f3f1805 commit 0c0b04d
Showing 1 changed file with 33 additions and 33 deletions.
66 changes: 33 additions & 33 deletions MAGE/MAGE/src/math/transform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ namespace mage {
@return The object-to-parent rotation matrix of this transform.
*/
const XMMATRIX GetObjectToParentRotationMatrix() const {
return XMMatrixRotationZ(GetRotationZ()) * XMMatrixRotationY(GetRotationY()) * XMMatrixRotationX(GetRotationX());
return XMMatrixRotationY(GetRotationY()) * XMMatrixRotationX(GetRotationX()) * XMMatrixRotationZ(GetRotationZ());
}

/**
Expand All @@ -549,7 +549,7 @@ namespace mage {
@return The parent-to-object rotation matrix of this transform.
*/
const XMMATRIX GetParentToObjectRotationMatrix() const {
return XMMatrixRotationZ(-GetRotationZ()) * XMMatrixRotationY(-GetRotationY()) * XMMatrixRotationX(-GetRotationX());
return XMMatrixRotationZ(-GetRotationZ()) * XMMatrixRotationX(-GetRotationX()) * XMMatrixRotationY(-GetRotationY());
}

//---------------------------------------------------------------------
Expand Down Expand Up @@ -1010,15 +1010,6 @@ namespace mage {
// Member Methods: Transformation
//---------------------------------------------------------------------

/**
Returns the parent-to-object matrix of this transform.
@return The parent-to-object matrix of this transform.
*/
const XMMATRIX GetParentToObjectMatrix() const {
return GetParentToObjectTranslationMatrix() * GetParentToObjectRotationMatrix() * GetParentToObjectScaleMatrix();
}

/**
Returns the object-to-parent matrix of this transform.
Expand All @@ -1029,12 +1020,12 @@ namespace mage {
}

/**
Returns the world-to-object matrix of this transform.
Returns the parent-to-object matrix of this transform.
@return The world-to-object matrix of this transform.
@return The parent-to-object matrix of this transform.
*/
const XMMATRIX GetWorldToObjectMatrix() const {
return m_world_to_object;
const XMMATRIX GetParentToObjectMatrix() const {
return GetParentToObjectTranslationMatrix() * GetParentToObjectRotationMatrix() * GetParentToObjectScaleMatrix();
}

/**
Expand All @@ -1045,26 +1036,24 @@ namespace mage {
const XMMATRIX GetObjectToWorldMatrix() const {
return m_object_to_world;
}

/**
Returns the parent-to-view matrix of this transform.
Returns the world-to-object matrix of this transform.
@return The parent-to-view matrix of this transform.
@note Transforms for cameras should not contain scaling components.
@return The world-to-object matrix of this transform.
*/
const XMMATRIX GetWorldToViewMatrix() const {
const XMMATRIX GetWorldToObjectMatrix() const {
return m_world_to_object;
}

/**
Transforms the given vector expressed in parent space coordinates to object space coordinates.
Returns the parent-to-view matrix of this transform.
@param[in] vector
A reference to the vector expressed in parent space coordinates.
@return The transformed vector expressed in object space coordinates.
@return The parent-to-view matrix of this transform.
@note Transforms for cameras should not contain scaling components.
*/
const XMVECTOR TransformParentToObject(const XMVECTOR &vector) const {
return XMVector4Transform(vector, GetParentToObjectMatrix());
const XMMATRIX GetWorldToViewMatrix() const {
return m_world_to_object;
}

/**
Expand All @@ -1079,14 +1068,14 @@ namespace mage {
}

/**
Transforms the given vector expressed in world space coordinates to object space coordinates.
Transforms the given vector expressed in parent space coordinates to object space coordinates.
@param[in] vector
A reference to the vector expressed in world space coordinates.
A reference to the vector expressed in parent space coordinates.
@return The transformed vector expressed in object space coordinates.
*/
const XMVECTOR TransformWorldToObject(const XMVECTOR &vector) const {
return XMVector4Transform(vector, GetWorldToObjectMatrix());
const XMVECTOR TransformParentToObject(const XMVECTOR &vector) const {
return XMVector4Transform(vector, GetParentToObjectMatrix());
}

/**
Expand All @@ -1100,7 +1089,18 @@ namespace mage {
return XMVector4Transform(vector, GetObjectToWorldMatrix());
}

//---------------------------------------------------------------------
/**
Transforms the given vector expressed in world space coordinates to object space coordinates.
@param[in] vector
A reference to the vector expressed in world space coordinates.
@return The transformed vector expressed in object space coordinates.
*/
const XMVECTOR TransformWorldToObject(const XMVECTOR &vector) const {
return XMVector4Transform(vector, GetWorldToObjectMatrix());
}

//-------)-------------------------------------------------------------
// Member Methods: Update
//---------------------------------------------------------------------

Expand Down Expand Up @@ -1140,8 +1140,8 @@ namespace mage {
A reference to the parent-to-world matrix.
*/
void Update(const XMMATRIX &world_to_parent, const XMMATRIX &parent_to_world) {
m_world_to_object = GetParentToObjectMatrix() * world_to_parent;
m_object_to_world = parent_to_world * GetObjectToParentMatrix();
m_world_to_object = world_to_parent * GetParentToObjectMatrix();
m_object_to_world = GetObjectToParentMatrix() * parent_to_world;
SetNotDirty();
}

Expand Down

0 comments on commit 0c0b04d

Please sign in to comment.