[Scummvm-git-logs] scummvm master -> f18edb5d7a467497f490598dd0fc448bf2765029

aquadran noreply at scummvm.org
Mon Oct 14 05:21:06 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:
f18edb5d7a WINTERMUTE: Sync BaseObject::getMatrix with original code


Commit: f18edb5d7a467497f490598dd0fc448bf2765029
    https://github.com/scummvm/scummvm/commit/f18edb5d7a467497f490598dd0fc448bf2765029
Author: Paweł Kołodziejski (aquadran at gmail.com)
Date: 2024-10-14T07:21:01+02:00

Commit Message:
WINTERMUTE: Sync BaseObject::getMatrix with original code

Changed paths:
    engines/wintermute/base/base_object.cpp


diff --git a/engines/wintermute/base/base_object.cpp b/engines/wintermute/base/base_object.cpp
index 2563e9a97f7..144c86bd09f 100644
--- a/engines/wintermute/base/base_object.cpp
+++ b/engines/wintermute/base/base_object.cpp
@@ -41,6 +41,8 @@
 #include "engines/wintermute/base/gfx/base_surface.h"
 #include "engines/wintermute/base/gfx/base_renderer3d.h"
 #include "engines/wintermute/base/gfx/xmodel.h"
+#include "engines/wintermute/base/gfx/xmath.h"
+#include "engines/wintermute/math/math_util.h"
 #include "engines/wintermute/wintermute.h"
 #endif
 
@@ -1367,31 +1369,26 @@ bool BaseObject::afterMove() {
 }
 
 #ifdef ENABLE_WME3D
-bool BaseObject::getMatrix(Math::Matrix4 *modelMatrix, Math::Vector3d *posVect) {
-	if (posVect == nullptr) {
-		posVect = &_posVector;
-	}
-
-	Math::Matrix4 scale;
-	scale.setToIdentity();
-	scale(0, 0) = _scale3D;
-	scale(1, 1) = _scale3D;
-	scale(2, 2) = _scale3D;
-
-	Math::Angle angle = _angle;
-	float sinOfAngle = angle.getSine();
-	float cosOfAngle = angle.getCosine();
-	Math::Matrix4 rotation;
-	rotation.setToIdentity();
-	rotation(0, 0) = cosOfAngle;
-	rotation(0, 2) = sinOfAngle;
-	rotation(2, 0) = -sinOfAngle;
-	rotation(2, 2) = cosOfAngle;
-	Math::Matrix4 translation;
-	translation.setToIdentity();
-	translation.setPosition(*posVect);
-
-	*modelMatrix = translation * rotation * scale;
+bool BaseObject::getMatrix(Math::Matrix4 *model, Math::Vector3d *pos) {
+	if (pos == nullptr) {
+		pos = &_posVector;
+	}
+	DXVector3 posVect = DXVector3(pos->x(), pos->y(), pos->z());
+	Math::Matrix4 m = *model;
+	m.transpose();
+	DXMatrix modelMatrix = DXMatrix(m.getData());
+
+	DXMatrix matRot, matScale, matTrans;
+	DXMatrixRotationYawPitchRoll(&matRot, degToRad(_angle), 0, 0);
+	DXMatrixScaling(&matScale, _scale3D, _scale3D, _scale3D);
+
+	DXMatrixTranslation(&matTrans, posVect._x, posVect._y, posVect._z);
+	DXMatrixMultiply(&modelMatrix, &matRot, &matScale);
+	DXMatrixMultiply(&modelMatrix, &modelMatrix, &matTrans);
+
+	model->setData(modelMatrix._m4x4);
+	model->transpose();
+
 	return true;
 }
 




More information about the Scummvm-git-logs mailing list