Remove unnecessary calls to Quaternion.getMatrix()

This commit is contained in:
Daniel Chappuis 2017-11-28 17:46:45 +01:00
parent 317dea90bd
commit e754711a84
2 changed files with 4 additions and 6 deletions

View File

@ -75,10 +75,9 @@ GJKAlgorithm::GJKResult GJKAlgorithm::testCollision(NarrowPhaseInfo* narrowPhase
Transform transform1Inverse = transform1.getInverse();
Transform body2Tobody1 = transform1Inverse * transform2;
// Matrix that transform a direction from local
// Quaternion that transform a direction from local
// space of body 1 into local space of body 2
Matrix3x3 rotateToBody2 = transform2.getOrientation().getMatrix().getTranspose() *
transform1.getOrientation().getMatrix();
Quaternion rotateToBody2 = transform2.getOrientation().getInverse() * transform1.getOrientation();
// Initialize the margin (sum of margins of both objects)
decimal margin = shape1->getMargin() + shape2->getMargin();

View File

@ -169,8 +169,7 @@ inline void Transform::getOpenGLMatrix(decimal* openglMatrix) const {
// Return the inverse of the transform
inline Transform Transform::getInverse() const {
const Quaternion& invQuaternion = mOrientation.getInverse();
Matrix3x3 invMatrix = invQuaternion.getMatrix();
return Transform(invMatrix * (-mPosition), invQuaternion);
return Transform(invQuaternion * (-mPosition), invQuaternion);
}
// Return an interpolated transform
@ -200,7 +199,7 @@ inline Vector3 Transform::operator*(const Vector3& vector) const {
// Operator of multiplication of a transform with another one
inline Transform Transform::operator*(const Transform& transform2) const {
return Transform(mPosition + mOrientation.getMatrix() * transform2.mPosition,
return Transform(mPosition + mOrientation * transform2.mPosition,
mOrientation * transform2.mOrientation);
}