Commit edac25e8 authored by cutealien's avatar cutealien

Add a CMatrix4::getRotationDegrees where you can pass the scale vector if you...

Add a CMatrix4::getRotationDegrees where you can pass the scale vector if you know it (faster and useful otherwise sometimes).


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4556 dfc29bdd-3216-0410-991c-e03cc46cb475
parent c82757aa
......@@ -173,8 +173,15 @@ namespace core
//! Make a rotation matrix from Euler angles. The 4th row and column are unmodified.
CMatrix4<T>& setRotationDegrees( const vector3d<T>& rotation );
//! Get the rotation, as set by setRotation() when you already know the scale.
/** If you already know the scale then this function is faster than the other getRotationDegrees overload.
NOTE: You will have the same end-rotation as used in setRotation, but it might not use the same axis values.
*/
core::vector3d<T> getRotationDegrees(const vector3d<T>& scale) const;
//! Returns the rotation, as set by setRotation().
/** This code was orginally written by by Chev. */
/** NOTE: You will have the same end-rotation as used in setRotation, but it might not use the same axis values.
*/
core::vector3d<T> getRotationDegrees() const;
//! Make an inverted rotation matrix from Euler angles.
......@@ -855,12 +862,14 @@ namespace core
//! Returns a rotation that is equivalent to that set by setRotationDegrees().
/** This code was sent in by Chev. Note that it does not necessarily return
the *same* Euler angles as those set by setRotationDegrees(), but the rotation will
be equivalent, i.e. will have the same result when used to rotate a vector or node. */
be equivalent, i.e. will have the same result when used to rotate a vector or node.
This code was orginally written by by Chev.
*/
template <class T>
inline core::vector3d<T> CMatrix4<T>::getRotationDegrees() const
inline core::vector3d<T> CMatrix4<T>::getRotationDegrees(const vector3d<T>& scale_) const
{
const CMatrix4<T> &mat = *this;
core::vector3d<T> scale = getScale();
core::vector3d<T> scale(scale_);
// we need to check for negative scale on to axes, which would bring up wrong results
if (scale.Y<0 && scale.Z<0)
{
......@@ -911,6 +920,17 @@ namespace core
return vector3d<T>((T)X,(T)Y,(T)Z);
}
//! Returns a rotation that is equivalent to that set by setRotationDegrees().
/** This code was sent in by Chev. Note that it does not necessarily return
the *same* Euler angles as those set by setRotationDegrees(), but the rotation will
be equivalent, i.e. will have the same result when used to rotate a vector or node.
This code was orginally written by by Chev. */
template <class T>
inline core::vector3d<T> CMatrix4<T>::getRotationDegrees() const
{
return getRotationDegrees(getScale());
}
//! Sets matrix to rotation matrix of inverse angles given as parameters
template <class T>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment