[Scummvm-git-logs] scummvm master -> 2c459789dea72c45370891c4ffe3b161a6f25e2a
aquadran
noreply at scummvm.org
Sun Nov 3 07:38:11 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:
2c459789de WINTERMUTE: Added some DX math
Commit: 2c459789dea72c45370891c4ffe3b161a6f25e2a
https://github.com/scummvm/scummvm/commit/2c459789dea72c45370891c4ffe3b161a6f25e2a
Author: PaweÅ KoÅodziejski (aquadran at gmail.com)
Date: 2024-11-03T08:38:06+01:00
Commit Message:
WINTERMUTE: Added some DX math
Changed paths:
engines/wintermute/base/gfx/xmath.cpp
engines/wintermute/base/gfx/xmath.h
diff --git a/engines/wintermute/base/gfx/xmath.cpp b/engines/wintermute/base/gfx/xmath.cpp
index cb9f0d4bd04..3485d5906e0 100644
--- a/engines/wintermute/base/gfx/xmath.cpp
+++ b/engines/wintermute/base/gfx/xmath.cpp
@@ -32,6 +32,11 @@
namespace Wintermute {
+DXVector2::DXVector2(float fx, float fy) {
+ _x = fx;
+ _y = fy;
+}
+
DXVector3::DXVector3(const float *pf) {
_x = pf[0];
_y = pf[1];
@@ -142,6 +147,10 @@ DXMatrix::DXMatrix(const float *pf) {
memcpy(&matrix._11, pf, sizeof(DXMatrix::matrix));
}
+float &DXMatrix::operator () (uint32 row, uint32 col) {
+ return _m[row][col];
+}
+
DXMatrix::operator float* () {
return (float *)&matrix._11;
}
@@ -527,6 +536,17 @@ DXVector3 *DXVec3TransformNormal(DXVector3 *pout, const DXVector3 *pv, const DXM
return pout;
}
+DXVector4 *DXVec4Transform(DXVector4 *pout, const DXVector4 *pv, const DXMatrix *pm) {
+ DXVector4 out;
+
+ out._x = pm->_m[0][0] * pv->_x + pm->_m[1][0] * pv->_y + pm->_m[2][0] * pv->_z + pm->_m[3][0] * pv->_w;
+ out._y = pm->_m[0][1] * pv->_x + pm->_m[1][1] * pv->_y + pm->_m[2][1] * pv->_z + pm->_m[3][1] * pv->_w;
+ out._z = pm->_m[0][2] * pv->_x + pm->_m[1][2] * pv->_y + pm->_m[2][2] * pv->_z + pm->_m[3][2] * pv->_w;
+ out._w = pm->_m[0][3] * pv->_x + pm->_m[1][3] * pv->_y + pm->_m[2][3] * pv->_z + pm->_m[3][3] * pv->_w;
+ *pout = out;
+ return pout;
+}
+
DXMatrix *DXMatrixMultiply(DXMatrix *pout, const DXMatrix *pm1, const DXMatrix *pm2) {
DXMatrix out;
@@ -621,4 +641,24 @@ DXMatrix *DXMatrixLookAtRH(DXMatrix *out, const DXVector3 *eye, const DXVector3
return out;
}
+DXMatrix *DXMatrixOrthoLH(DXMatrix *pout, float w, float h, float zn, float zf) {
+ DXMatrixIdentity(pout);
+ pout->_m[0][0] = 2.0f / w;
+ pout->_m[1][1] = 2.0f / h;
+ pout->_m[2][2] = 1.0f / (zf - zn);
+ pout->_m[3][2] = zn / (zn - zf);
+ return pout;
+}
+
+DXMatrix *DXMatrixOrthoOffCenterLH(DXMatrix *pout, float l, float r, float b, float t, float zn, float zf) {
+ DXMatrixIdentity(pout);
+ pout->_m[0][0] = 2.0f / (r - l);
+ pout->_m[1][1] = 2.0f / (t - b);
+ pout->_m[2][2] = 1.0f / (zf -zn);
+ pout->_m[3][0] = -1.0f -2.0f * l / (r - l);
+ pout->_m[3][1] = 1.0f + 2.0f * t / (b - t);
+ pout->_m[3][2] = zn / (zn -zf);
+ return pout;
+}
+
} // End of namespace Wintermute
diff --git a/engines/wintermute/base/gfx/xmath.h b/engines/wintermute/base/gfx/xmath.h
index 47bf12854ce..5c8cf9567d0 100644
--- a/engines/wintermute/base/gfx/xmath.h
+++ b/engines/wintermute/base/gfx/xmath.h
@@ -44,6 +44,7 @@ struct DXVector2 {
float _y;
DXVector2() {}
+ DXVector2(float fx, float fy);
};
struct DXVector3 {
@@ -127,6 +128,8 @@ struct DXMatrix {
DXMatrix() {}
DXMatrix(const float *pf);
+ float &operator () (uint32 row, uint32 col);
+
operator float* ();
operator const float* () const;
@@ -151,6 +154,8 @@ DXMatrix *DXMatrixPerspectiveFovLH(DXMatrix *pout,float fovy, float aspect, floa
DXMatrix *DXMatrixPerspectiveFovRH(DXMatrix *pout, float fovy, float aspect, float zn, float zf);
DXMatrix *DXMatrixLookAtLH(DXMatrix *out, const DXVector3 *eye, const DXVector3 *at, const DXVector3 *up);
DXMatrix *DXMatrixLookAtRH(DXMatrix *out, const DXVector3 *eye, const DXVector3 *at, const DXVector3 *up);
+DXMatrix *DXMatrixOrthoLH(DXMatrix *pout, float w, float h, float zn, float zf);
+DXMatrix *DXMatrixOrthoOffCenterLH(DXMatrix *pout, float l, float r, float b, float t, float zn, float zf);
DXMatrix *DXMatrixInverse(DXMatrix *pout, float *pdeterminant, const DXMatrix *pm);
DXPlane *DXPlaneFromPointNormal(DXPlane *pout, const DXVector3 *pvpoint, const DXVector3 *pvnormal);
DXPlane *DXPlaneFromPoints(DXPlane *pout, const DXVector3 *pv1, const DXVector3 *pv2, const DXVector3 *pv3);
@@ -170,6 +175,7 @@ DXMatrix *DXMatrixMultiply(DXMatrix *pout, const DXMatrix *pm1, const DXMatrix *
DXVector3 *DXVec3Project(DXVector3 *pout, const DXVector3 *pv, const DXViewport *pviewport,
const DXMatrix *pprojection, const DXMatrix *pview, const DXMatrix *pworld);
DXMatrix *DXMatrixTranspose(DXMatrix *pout, const DXMatrix *pm);
+DXVector4 *DXVec4Transform(DXVector4 *pout, const DXVector4 *pv, const DXMatrix *pm);
static inline DXMatrix *DXMatrixIdentity(DXMatrix *pout) {
(*pout)._m[0][1] = 0.0f;
More information about the Scummvm-git-logs
mailing list