[Scummvm-git-logs] scummvm master -> 12630382adff35b26025046b500332901c2468b5

aquadran noreply at scummvm.org
Tue Oct 22 16:27:55 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:
12630382ad WINTERMUTE: Synced simple shadow code with original


Commit: 12630382adff35b26025046b500332901c2468b5
    https://github.com/scummvm/scummvm/commit/12630382adff35b26025046b500332901c2468b5
Author: Paweł Kołodziejski (aquadran at gmail.com)
Date: 2024-10-22T18:27:50+02:00

Commit Message:
WINTERMUTE: Synced simple shadow code with original

Changed paths:
    engines/wintermute/base/gfx/opengl/base_render_opengl3d.cpp
    engines/wintermute/base/gfx/xmath.cpp
    engines/wintermute/base/gfx/xmath.h


diff --git a/engines/wintermute/base/gfx/opengl/base_render_opengl3d.cpp b/engines/wintermute/base/gfx/opengl/base_render_opengl3d.cpp
index ae534415132..5931ea29159 100644
--- a/engines/wintermute/base/gfx/opengl/base_render_opengl3d.cpp
+++ b/engines/wintermute/base/gfx/opengl/base_render_opengl3d.cpp
@@ -35,6 +35,7 @@
 
 #if defined(USE_OPENGL_GAME)
 
+#include "engines/wintermute/math/math_util.h"
 #include "engines/wintermute/base/gfx/opengl/base_render_opengl3d.h"
 #include "engines/wintermute/base/gfx/opengl/base_surface_opengl3d.h"
 #include "engines/wintermute/base/gfx/opengl/mesh3ds_opengl.h"
@@ -160,42 +161,25 @@ bool BaseRenderOpenGL3D::disableShadows() {
 }
 
 void BaseRenderOpenGL3D::displayShadow(BaseObject *object, const DXVector3 *lightPos, bool lightPosRelative) {
-	BaseSurface *shadowImage = _gameRef->_shadowImage;
-
+	BaseSurface *shadowImage;
 	if (object->_shadowImage) {
 		shadowImage = object->_shadowImage;
+	} else {
+		shadowImage = _gameRef->_shadowImage;
 	}
 
 	if (!shadowImage) {
 		return;
 	}
 
-	DXMatrix scale;
-	DXMatrixIdentity(&scale);
-	scale.matrix._11 = object->_shadowSize * object->_scale3D;
-	scale.matrix._22 = 1.0f;
-	scale.matrix._33 = object->_shadowSize * object->_scale3D;
-
-	Math::Angle angle = object->_angle;
-	float sinOfAngle = angle.getSine();
-	float cosOfAngle = angle.getCosine();
-
-	DXMatrix rotation;
-	DXMatrixIdentity(&rotation);
-	rotation.matrix._11 = cosOfAngle;
-	rotation.matrix._13 = sinOfAngle;
-	rotation.matrix._31 = -sinOfAngle;
-	rotation.matrix._33 = cosOfAngle;
-
-	DXMatrix translation;
-	DXMatrixTranslation(&translation, object->_posVector._x, object->_posVector._y, object->_posVector._z);
-	DXMatrixTranspose(&translation, &translation);
-
-	DXMatrix worldTransformation = translation * rotation * scale;
-	DXMatrixTranspose(&worldTransformation, &worldTransformation);
-	DXMatrixMultiply(&worldTransformation, &worldTransformation, &_viewMatrix);
 
-	glLoadMatrixf(worldTransformation);
+	DXMatrix scale, trans, rot, finalm;
+	DXMatrixScaling(&scale, object->_shadowSize * object->_scale3D, 1.0f, object->_shadowSize * object->_scale3D);
+	DXMatrixRotationY(&rot, degToRad(object->_angle));
+	DXMatrixTranslation(&trans, object->_posVector._x, object->_posVector._y, object->_posVector._z);
+	DXMatrixMultiply(&finalm, &scale, &rot);
+	DXMatrixMultiply(&finalm, &finalm, &trans);
+	setWorldTransform(finalm);
 
 	glDepthMask(GL_FALSE);
 	glEnable(GL_TEXTURE_2D);
@@ -216,7 +200,6 @@ void BaseRenderOpenGL3D::displayShadow(BaseObject *object, const DXVector3 *ligh
 	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
 
 	glDepthMask(GL_TRUE);
-	glLoadMatrixf(_viewMatrix);
 }
 
 bool BaseRenderOpenGL3D::usingStencilBuffer() {
diff --git a/engines/wintermute/base/gfx/xmath.cpp b/engines/wintermute/base/gfx/xmath.cpp
index 5547b76b8b1..bdb2b5e097d 100644
--- a/engines/wintermute/base/gfx/xmath.cpp
+++ b/engines/wintermute/base/gfx/xmath.cpp
@@ -403,6 +403,15 @@ DXMatrix *DXMatrixScaling(DXMatrix *pout, float sx, float sy, float sz) {
 	return pout;
 }
 
+DXMatrix *DXMatrixRotationY(DXMatrix *pout, float angle) {
+	DXMatrixIdentity(pout);
+	pout->_m[0][0] = cosf(angle);
+	pout->_m[2][2] = cosf(angle);
+	pout->_m[0][2] = -sinf(angle);
+	pout->_m[2][0] = sinf(angle);
+	return pout;
+}
+
 DXMatrix *DXMatrixRotationZ(DXMatrix *pout, float angle) {
 	DXMatrixIdentity(pout);
 	pout->_m[0][0] = cosf(angle);
diff --git a/engines/wintermute/base/gfx/xmath.h b/engines/wintermute/base/gfx/xmath.h
index 8d9cfe20c9f..c94c5ea5519 100644
--- a/engines/wintermute/base/gfx/xmath.h
+++ b/engines/wintermute/base/gfx/xmath.h
@@ -149,6 +149,7 @@ DXVector3 *DXPlaneIntersectLine(DXVector3 *pout, const DXPlane *pp, const DXVect
 DXVector3 *DXVec3Normalize(DXVector3 *pout, const DXVector3 *pv);
 DXMatrix *DXMatrixTranslation(DXMatrix *pout, float x, float y, float z);
 DXMatrix *DXMatrixScaling(DXMatrix *pout, float sx, float sy, float sz);
+DXMatrix *DXMatrixRotationY(DXMatrix *pout, float angle);
 DXMatrix *DXMatrixRotationZ(DXMatrix *pout, float angle);
 DXMatrix *DXMatrixRotationYawPitchRoll(DXMatrix *out, float yaw, float pitch, float roll);
 DXMatrix *DXMatrixRotationQuaternion(DXMatrix *pout, const DXQuaternion *pq);




More information about the Scummvm-git-logs mailing list