[Scummvm-git-logs] scummvm master -> 8f41b62eed8318c0dde182f2e72f2cd202833d3f
aquadran
noreply at scummvm.org
Sun Oct 13 09:51:20 UTC 2024
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
8f41b62eed WINTERMUTE: Added few more match helpers
Commit: 8f41b62eed8318c0dde182f2e72f2cd202833d3f
https://github.com/scummvm/scummvm/commit/8f41b62eed8318c0dde182f2e72f2cd202833d3f
Author: PaweÅ KoÅodziejski (aquadran at gmail.com)
Date: 2024-10-13T11:51:15+02:00
Commit Message:
WINTERMUTE: Added few more match helpers
Changed paths:
engines/wintermute/math/math_util.cpp
engines/wintermute/math/math_util.h
diff --git a/engines/wintermute/math/math_util.cpp b/engines/wintermute/math/math_util.cpp
index e692ee46fa8..83bad7b6bd3 100644
--- a/engines/wintermute/math/math_util.cpp
+++ b/engines/wintermute/math/math_util.cpp
@@ -125,6 +125,52 @@ bool pickGetIntersect(const Math::Vector3d &lineStart, const Math::Vector3d &lin
return true;
}
+void decomposeMatrixSimple(const DXMatrix *mat, DXVector3 *transVec, DXVector3 *scaleVec, DXQuaternion *rotQ) {
+ *transVec = DXVector3(mat->matrix._41, mat->matrix._42, mat->matrix._43);
+ *scaleVec = DXVector3(sqrtf(mat->matrix._11 * mat->matrix._11 + mat->matrix._21 * mat->matrix._21 + mat->matrix._31 * mat->matrix._31),
+ sqrtf(mat->matrix._12 * mat->matrix._12 + mat->matrix._22 * mat->matrix._22 + mat->matrix._32 * mat->matrix._32),
+ sqrtf(mat->matrix._13 * mat->matrix._13 + mat->matrix._23 * mat->matrix._23 + mat->matrix._33 * mat->matrix._33));
+
+ DXQuaternion q;
+ DXQuaternionRotationMatrix(&q, mat);
+
+ *rotQ = q;
+}
+
+DXMatrix *matrixSetTranslation(DXMatrix *mat, DXVector3 *vec) {
+ mat->matrix._41 = vec->_x;
+ mat->matrix._42 = vec->_y;
+ mat->matrix._43 = vec->_z;
+
+ return mat;
+}
+
+DXMatrix *matrixSetRotation(DXMatrix *mat, DXVector3 *vec) {
+ double cr = cos(vec->_x);
+ double sr = sin(vec->_x);
+ double cp = cos(vec->_y);
+ double sp = sin(vec->_y);
+ double cy = cos(vec->_z);
+ double sy = sin(vec->_z);
+
+ mat->matrix._11 = (float)(cp * cy);
+ mat->matrix._12 = (float)(cp * sy);
+ mat->matrix._13 = (float)(-sp);
+
+ double srsp = sr * sp;
+ double crsp = cr * sp;
+
+ mat->matrix._21 = (float)(srsp * cy - cr * sy);
+ mat->matrix._22 = (float)(srsp * sy + cr * cy);
+ mat->matrix._23 = (float)(sr * cp);
+
+ mat->matrix._31 = (float)(crsp * cy + sr * sy);
+ mat->matrix._32 = (float)(crsp * sy - sr * cy);
+ mat->matrix._33 = (float)(cr * cp);
+
+ return mat;
+}
+
#endif
} // End of namespace Wintermute
diff --git a/engines/wintermute/math/math_util.h b/engines/wintermute/math/math_util.h
index 7f181a078b8..b006c81ce3f 100644
--- a/engines/wintermute/math/math_util.h
+++ b/engines/wintermute/math/math_util.h
@@ -30,6 +30,7 @@
#ifdef ENABLE_WME3D
#include "math/vector3d.h"
+#include "engines/wintermute/base/gfx/xmath.h"
#endif
namespace Wintermute {
@@ -52,6 +53,9 @@ bool intersectTriangle(const Math::Vector3d &origin, const Math::Vector3d &direc
bool pickGetIntersect(const Math::Vector3d &lineStart, const Math::Vector3d &lineEnd,
const Math::Vector3d &v0, const Math::Vector3d &v1, const Math::Vector3d &v2,
Math::Vector3d &intersection, float &distance);
+DXMatrix *matrixSetTranslation(DXMatrix *mat, DXVector3 *vec);
+DXMatrix *matrixSetRotation(DXMatrix *mat, DXVector3 *vec);
+void decomposeMatrixSimple(const DXMatrix *mat, DXVector3 *transVec, DXVector3 *scaleVec, DXQuaternion *rotQ);
#endif
More information about the Scummvm-git-logs
mailing list