[Scummvm-git-logs] scummvm master -> 1847c274eef8493d5f04c4a55294bf603634fe93

aquadran noreply at scummvm.org
Thu Sep 4 21:45:21 UTC 2025


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .

Summary:
1847c274ee WINTERMUTE: Switch to DX vector2


Commit: 1847c274eef8493d5f04c4a55294bf603634fe93
    https://github.com/scummvm/scummvm/commit/1847c274eef8493d5f04c4a55294bf603634fe93
Author: Paweł Kołodziejski (aquadran at gmail.com)
Date: 2025-09-04T23:45:15+02:00

Commit Message:
WINTERMUTE: Switch to DX vector2

Changed paths:
  R engines/wintermute/math/floatpoint.h
  R engines/wintermute/math/matrix4.cpp
  R engines/wintermute/math/matrix4.h
  R engines/wintermute/math/vector2.cpp
  R engines/wintermute/math/vector2.h
    engines/wintermute/base/base_persistence_manager.cpp
    engines/wintermute/base/base_persistence_manager.h
    engines/wintermute/base/gfx/3dutils.h
    engines/wintermute/base/gfx/base_renderer3d.cpp
    engines/wintermute/base/gfx/base_renderer3d.h
    engines/wintermute/base/gfx/opengl/base_render_opengl3d.cpp
    engines/wintermute/base/gfx/opengl/base_render_opengl3d.h
    engines/wintermute/base/gfx/opengl/base_render_opengl3d_shader.cpp
    engines/wintermute/base/gfx/opengl/base_render_opengl3d_shader.h
    engines/wintermute/base/gfx/opengl/base_surface_opengl3d.cpp
    engines/wintermute/base/gfx/xmath.cpp
    engines/wintermute/base/gfx/xmath.h
    engines/wintermute/base/particles/part_emitter.cpp
    engines/wintermute/base/particles/part_force.cpp
    engines/wintermute/base/particles/part_force.h
    engines/wintermute/base/particles/part_particle.cpp
    engines/wintermute/base/particles/part_particle.h
    engines/wintermute/module.mk


diff --git a/engines/wintermute/base/base_persistence_manager.cpp b/engines/wintermute/base/base_persistence_manager.cpp
index 62eba017b78..bc48a3277ed 100644
--- a/engines/wintermute/base/base_persistence_manager.cpp
+++ b/engines/wintermute/base/base_persistence_manager.cpp
@@ -31,7 +31,6 @@
 #include "engines/wintermute/base/base_engine.h"
 #include "engines/wintermute/base/base_persistence_manager.h"
 #include "engines/wintermute/platform_osystem.h"
-#include "engines/wintermute/math/vector2.h"
 #include "engines/wintermute/base/gfx/base_image.h"
 #include "engines/wintermute/base/save_thumb_helper.h"
 #include "engines/wintermute/base/sound/base_sound.h"
@@ -815,17 +814,17 @@ bool BasePersistenceManager::transferPoint32(const char *name, Common::Point32 *
 
 //////////////////////////////////////////////////////////////////////////
 // Vector2
-bool BasePersistenceManager::transferVector2(const char *name, Vector2 *val) {
+bool BasePersistenceManager::transferVector2(const char *name, DXVector2 *val) {
 	if (_saving) {
-		putFloat(val->x);
-		putFloat(val->y);
+		putFloat(val->_x);
+		putFloat(val->_y);
 		if (_saveStream->err()) {
 			return STATUS_FAILED;
 		}
 		return STATUS_OK;
 	} else {
-		val->x = getFloat();
-		val->y = getFloat();
+		val->_x = getFloat();
+		val->_y = getFloat();
 		if (_loadStream->err()) {
 			return STATUS_FAILED;
 		}
diff --git a/engines/wintermute/base/base_persistence_manager.h b/engines/wintermute/base/base_persistence_manager.h
index c2c8fda05ed..6b1411e2c6c 100644
--- a/engines/wintermute/base/base_persistence_manager.h
+++ b/engines/wintermute/base/base_persistence_manager.h
@@ -96,7 +96,7 @@ public:
 	bool transferConstChar(const char *name, const char **val);
 	bool transferCharPtr(const char *name, char **val);
 	bool transferString(const char *name, Common::String *val);
-	bool transferVector2(const char *name, Vector2 *val);
+	bool transferVector2(const char *name, DXVector2 *val);
 	bool transferVector3d(const char *name, DXVector3 *val);
 	bool transferVector4d(const char *name, DXVector4 *val);
 	bool transferMatrix4(const char *name, DXMatrix *val);
diff --git a/engines/wintermute/base/gfx/3dutils.h b/engines/wintermute/base/gfx/3dutils.h
index 6601b2420e8..9f9d9134096 100644
--- a/engines/wintermute/base/gfx/3dutils.h
+++ b/engines/wintermute/base/gfx/3dutils.h
@@ -34,8 +34,6 @@
 
 namespace Wintermute {
 
-#ifdef ENABLE_WME3D
-
 #define DX_PI    ((float)3.141592654)
 #define degToRad(_val) (_val * DX_PI * (1.0f / 180.0f))
 #define radToDeg(_val) (_val * (180.0f / DX_PI))
@@ -54,8 +52,6 @@ public:
 	                                  DXVector3 *scaleVec, DXQuaternion *rotQ);
 };
 
-#endif
-
 } // End of namespace Wintermute
 
 #endif
diff --git a/engines/wintermute/base/gfx/base_renderer3d.cpp b/engines/wintermute/base/gfx/base_renderer3d.cpp
index 72febbda6a8..98b7a0bf6f7 100644
--- a/engines/wintermute/base/gfx/base_renderer3d.cpp
+++ b/engines/wintermute/base/gfx/base_renderer3d.cpp
@@ -55,11 +55,11 @@ void BaseRenderer3D::initLoop() {
 }
 
 bool BaseRenderer3D::drawSprite(BaseSurface *texture, const Common::Rect32 &rect,
-	                        float zoomX, float zoomY, const Wintermute::Vector2 &pos,
+	                        float zoomX, float zoomY, const DXVector2 &pos,
 	                        uint32 color, bool alphaDisable, Graphics::TSpriteBlendMode blendMode,
 	                        bool mirrorX, bool mirrorY) {
-	Vector2 scale(zoomX / 100.0f, zoomY / 100.0f);
-	return drawSpriteEx(texture, rect, pos, Vector2(0.0f, 0.0f), scale, 0.0f, color, alphaDisable, blendMode, mirrorX, mirrorY);
+	DXVector2 scale(zoomX / 100.0f, zoomY / 100.0f);
+	return drawSpriteEx(texture, rect, pos, DXVector2(0.0f, 0.0f), scale, 0.0f, color, alphaDisable, blendMode, mirrorX, mirrorY);
 }
 
 bool BaseRenderer3D::getProjectionParams(float *resWidth, float *resHeight, float *layerWidth, float *layerHeight,
diff --git a/engines/wintermute/base/gfx/base_renderer3d.h b/engines/wintermute/base/gfx/base_renderer3d.h
index 4e4ae5b5883..757942a16e2 100644
--- a/engines/wintermute/base/gfx/base_renderer3d.h
+++ b/engines/wintermute/base/gfx/base_renderer3d.h
@@ -25,7 +25,6 @@
 #include "engines/wintermute/base/gfx/base_renderer.h"
 #include "engines/wintermute/coll_templ.h"
 #include "engines/wintermute/dctypes.h"
-#include "engines/wintermute/math/vector2.h"
 
 #include "graphics/transform_struct.h"
 #include "graphics/surface.h"
@@ -86,9 +85,9 @@ public:
 	virtual bool restoreDeviceObjects() = 0;
 	BaseSurfaceOpenGL3D *_lastTexture;
 	void fade(uint16 alpha) override;
-	bool drawSprite(BaseSurface *texture, const Common::Rect32 &rect, float zoomX, float zoomY, const Vector2 &pos,
+	bool drawSprite(BaseSurface *texture, const Common::Rect32 &rect, float zoomX, float zoomY, const DXVector2 &pos,
 	                uint32 color, bool alphaDisable, Graphics::TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY);
-	virtual bool drawSpriteEx(BaseSurface *texture, const Common::Rect32 &rect, const Vector2 &pos, const Vector2 &rot, const Vector2 &scale,
+	virtual bool drawSpriteEx(BaseSurface *texture, const Common::Rect32 &rect, const DXVector2 &pos, const DXVector2 &rot, const DXVector2 &scale,
 	                float angle, uint32 color, bool alphaDisable, Graphics::TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) = 0;
 	Camera3D *_camera;
 	virtual bool resetDevice() = 0;
diff --git a/engines/wintermute/base/gfx/opengl/base_render_opengl3d.cpp b/engines/wintermute/base/gfx/opengl/base_render_opengl3d.cpp
index e57d920cd04..81f992366d5 100644
--- a/engines/wintermute/base/gfx/opengl/base_render_opengl3d.cpp
+++ b/engines/wintermute/base/gfx/opengl/base_render_opengl3d.cpp
@@ -314,8 +314,8 @@ bool BaseRenderOpenGL3D::setupLines() {
 }
 
 bool BaseRenderOpenGL3D::drawSpriteEx(BaseSurface *tex, const Common::Rect32 &rect,
-	                              const Wintermute::Vector2 &pos, const Wintermute::Vector2 &rot,
-	                              const Wintermute::Vector2 &scale,
+	                              const DXVector2 &pos, const DXVector2 &rot,
+	                              const DXVector2 &scale,
 	                              float angle, uint32 color, bool alphaDisable,
 	                              Graphics::TSpriteBlendMode blendMode,
 	                              bool mirrorX, bool mirrorY) {
@@ -327,8 +327,8 @@ bool BaseRenderOpenGL3D::drawSpriteEx(BaseSurface *tex, const Common::Rect32 &re
 		color = _forceAlphaColor;
 	}
 
-	float width = (rect.right - rect.left) * scale.x;
-	float height = (rect.bottom - rect.top) * scale.y;
+	float width = (rect.right - rect.left) * scale._x;
+	float height = (rect.bottom - rect.top) * scale._y;
 
 	int texWidth = texture->getGLTextureWidth();
 	int texHeight = texture->getGLTextureHeight();
@@ -362,25 +362,25 @@ bool BaseRenderOpenGL3D::drawSpriteEx(BaseSurface *tex, const Common::Rect32 &re
 	vertices[3].v = texTop;
 
 	// position coords
-	vertices[0].x = pos.x;
-	vertices[0].y = pos.y + height;
+	vertices[0].x = pos._x;
+	vertices[0].y = pos._y + height;
 	vertices[0].z = 0.9f;
 
-	vertices[1].x = pos.x;
-	vertices[1].y = pos.y;
+	vertices[1].x = pos._x;
+	vertices[1].y = pos._y;
 	vertices[1].z = 0.9f;
 
-	vertices[2].x = pos.x + width;
-	vertices[2].y = pos.y + height;
+	vertices[2].x = pos._x + width;
+	vertices[2].y = pos._y + height;
 	vertices[2].z = 0.9f;
 
-	vertices[3].x = pos.x + width;
-	vertices[3].y = pos.y;
+	vertices[3].x = pos._x + width;
+	vertices[3].y = pos._y;
 	vertices[3].z = 0.9f;
 
 	if (angle != 0) {
 		DXVector2 sc(1.0f, 1.0f);
-		DXVector2 rotation(rot.x, rot.y);
+		DXVector2 rotation(rot._x, rot._y);
 		transformVertices(vertices, &rotation, &sc, angle);
 	}
 
diff --git a/engines/wintermute/base/gfx/opengl/base_render_opengl3d.h b/engines/wintermute/base/gfx/opengl/base_render_opengl3d.h
index 8467759c242..5bd426658a0 100644
--- a/engines/wintermute/base/gfx/opengl/base_render_opengl3d.h
+++ b/engines/wintermute/base/gfx/opengl/base_render_opengl3d.h
@@ -23,7 +23,6 @@
 #define WINTERMUTE_BASE_RENDER_OPENGL3D_H
 
 #include "engines/wintermute/base/gfx/base_renderer3d.h"
-#include "engines/wintermute/math/vector2.h"
 #include "engines/wintermute/dctypes.h"
 
 #include "graphics/transform_struct.h"
@@ -142,7 +141,7 @@ public:
 	bool endSpriteBatch() override;
 	bool commitSpriteBatch() override;
 
-	bool drawSpriteEx(BaseSurface *texture, const Common::Rect32 &rect, const Vector2 &pos, const Vector2 &rot, const Vector2 &scale,
+	bool drawSpriteEx(BaseSurface *texture, const Common::Rect32 &rect, const DXVector2 &pos, const DXVector2 &rot, const DXVector2 &scale,
 	                  float angle, uint32 color, bool alphaDisable, Graphics::TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) override;
 
 	void renderSceneGeometry(const BaseArray<AdWalkplane *> &planes, const BaseArray<AdBlock *> &blocks,
diff --git a/engines/wintermute/base/gfx/opengl/base_render_opengl3d_shader.cpp b/engines/wintermute/base/gfx/opengl/base_render_opengl3d_shader.cpp
index 30e0fdd9e05..2fac81a812d 100644
--- a/engines/wintermute/base/gfx/opengl/base_render_opengl3d_shader.cpp
+++ b/engines/wintermute/base/gfx/opengl/base_render_opengl3d_shader.cpp
@@ -409,8 +409,8 @@ bool BaseRenderOpenGL3DShader::setupLines() {
 }
 
 bool BaseRenderOpenGL3DShader::drawSpriteEx(BaseSurface *tex, const Common::Rect32 &rect,
-	                                    const Wintermute::Vector2 &pos, const Wintermute::Vector2 &rot,
-	                                    const Wintermute::Vector2 &scale,
+	                                    const DXVector2 &pos, const DXVector2 &rot,
+	                                    const DXVector2 &scale,
 	                                    float angle, uint32 color, bool alphaDisable,
 	                                    Graphics::TSpriteBlendMode blendMode,
 	                                    bool mirrorX, bool mirrorY) {
@@ -422,8 +422,8 @@ bool BaseRenderOpenGL3DShader::drawSpriteEx(BaseSurface *tex, const Common::Rect
 		color = _forceAlphaColor;
 	}
 
-	float width = (rect.right - rect.left) * scale.x;
-	float height = (rect.bottom - rect.top) * scale.y;
+	float width = (rect.right - rect.left) * scale._x;
+	float height = (rect.bottom - rect.top) * scale._y;
 
 	int texWidth = texture->getGLTextureWidth();
 	int texHeight = texture->getGLTextureHeight();
@@ -457,25 +457,25 @@ bool BaseRenderOpenGL3DShader::drawSpriteEx(BaseSurface *tex, const Common::Rect
 	vertices[3].v = texTop;
 
 	// position coords
-	vertices[0].x = pos.x;
-	vertices[0].y = pos.y + height;
+	vertices[0].x = pos._x;
+	vertices[0].y = pos._y + height;
 	vertices[0].z = 0.9f;
 
-	vertices[1].x = pos.x;
-	vertices[1].y = pos.y;
+	vertices[1].x = pos._x;
+	vertices[1].y = pos._y;
 	vertices[1].z = 0.9f;
 
-	vertices[2].x = pos.x + width;
-	vertices[2].y = pos.y + height;
+	vertices[2].x = pos._x + width;
+	vertices[2].y = pos._y + height;
 	vertices[2].z = 0.9f;
 
-	vertices[3].x = pos.x + width;
-	vertices[3].y = pos.y;
+	vertices[3].x = pos._x + width;
+	vertices[3].y = pos._y;
 	vertices[3].z = 0.9f;
 
 	if (angle != 0) {
 		DXVector2 sc(1.0f, 1.0f);
-		DXVector2 rotation(rot.x, rot.y);
+		DXVector2 rotation(rot._x, rot._y);
 		transformVertices(vertices, &rotation, &sc, angle);
 	}
 
diff --git a/engines/wintermute/base/gfx/opengl/base_render_opengl3d_shader.h b/engines/wintermute/base/gfx/opengl/base_render_opengl3d_shader.h
index 74c06005264..8600cea8d66 100644
--- a/engines/wintermute/base/gfx/opengl/base_render_opengl3d_shader.h
+++ b/engines/wintermute/base/gfx/opengl/base_render_opengl3d_shader.h
@@ -24,7 +24,6 @@
 
 #include "engines/wintermute/base/gfx/base_renderer3d.h"
 #include "engines/wintermute/dctypes.h"
-#include "engines/wintermute/math/vector2.h"
 
 #include "graphics/opengl/system_headers.h"
 #include "graphics/transform_struct.h"
@@ -143,7 +142,7 @@ public:
 	bool endSpriteBatch() override;
 	bool commitSpriteBatch() override;
 
-	bool drawSpriteEx(BaseSurface *texture, const Common::Rect32 &rect, const Vector2 &pos, const Vector2 &rot, const Vector2 &scale,
+	bool drawSpriteEx(BaseSurface *texture, const Common::Rect32 &rect, const DXVector2 &pos, const DXVector2 &rot, const DXVector2 &scale,
 	                  float angle, uint32 color, bool alphaDisable, Graphics::TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) override;
 
 	void renderSceneGeometry(const BaseArray<AdWalkplane *> &planes, const BaseArray<AdBlock *> &blocks,
diff --git a/engines/wintermute/base/gfx/opengl/base_surface_opengl3d.cpp b/engines/wintermute/base/gfx/opengl/base_surface_opengl3d.cpp
index 52cd55304d4..d0bcdebfcb2 100644
--- a/engines/wintermute/base/gfx/opengl/base_surface_opengl3d.cpp
+++ b/engines/wintermute/base/gfx/opengl/base_surface_opengl3d.cpp
@@ -75,21 +75,21 @@ bool BaseSurfaceOpenGL3D::invalidate() {
 bool BaseSurfaceOpenGL3D::displayTransZoom(int x, int y, Common::Rect32 rect, float zoomX, float zoomY, uint32 alpha, Graphics::TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) {
 	prepareToDraw();
 
-	_renderer->drawSprite(dynamic_cast<BaseSurface *>(this), rect, zoomX, zoomY, Vector2(x, y), alpha, false, blendMode, mirrorX, mirrorY);
+	_renderer->drawSprite(dynamic_cast<BaseSurface *>(this), rect, zoomX, zoomY, DXVector2(x, y), alpha, false, blendMode, mirrorX, mirrorY);
 	return true;
 }
 
 bool BaseSurfaceOpenGL3D::displayTrans(int x, int y, Common::Rect32 rect, uint32 alpha, Graphics::TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) {
 	prepareToDraw();
 
-	_renderer->drawSprite(dynamic_cast<BaseSurface *>(this), rect, 100, 100, Vector2(x + offsetX, y + offsetY), alpha, false, blendMode, mirrorX, mirrorY);
+	_renderer->drawSprite(dynamic_cast<BaseSurface *>(this), rect, 100, 100, DXVector2(x + offsetX, y + offsetY), alpha, false, blendMode, mirrorX, mirrorY);
 	return true;
 }
 
 bool BaseSurfaceOpenGL3D::display(int x, int y, Common::Rect32 rect, Graphics::TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) {
 	prepareToDraw();
 
-	_renderer->drawSprite(dynamic_cast<BaseSurface *>(this), rect, 100, 100, Vector2(x, y), 0xFFFFFFFF, true, blendMode, mirrorX, mirrorY);
+	_renderer->drawSprite(dynamic_cast<BaseSurface *>(this), rect, 100, 100, DXVector2(x, y), 0xFFFFFFFF, true, blendMode, mirrorX, mirrorY);
 	return true;
 }
 
@@ -99,11 +99,11 @@ bool BaseSurfaceOpenGL3D::displayTransRotate(int x, int y, float rotate, int32 h
 	x -= hotspotX;
 	y -= hotspotY;
 
-	Vector2 position(x, y);
-	Vector2 rotation;
-	rotation.x = x + hotspotX * (zoomX / 100.0f);
-	rotation.y = y + hotspotY * (zoomY / 100.0f);
-	Vector2 scale(zoomX / 100.0f, zoomY / 100.0f);
+	DXVector2 position(x, y);
+	DXVector2 rotation;
+	rotation._x = x + hotspotX * (zoomX / 100.0f);
+	rotation._y = y + hotspotY * (zoomY / 100.0f);
+	DXVector2 scale(zoomX / 100.0f, zoomY / 100.0f);
 	float angle = degToRad(rotate);
 
 	_renderer->drawSpriteEx(dynamic_cast<BaseSurface *>(this), rect, position, rotation, scale, angle, alpha, false, blendMode, mirrorX, mirrorY);
@@ -113,8 +113,8 @@ bool BaseSurfaceOpenGL3D::displayTransRotate(int x, int y, float rotate, int32 h
 bool BaseSurfaceOpenGL3D::displayTiled(int x, int y, Common::Rect32 rect, int numTimesX, int numTimesY) {
 	prepareToDraw();
 
-	Vector2 scale(numTimesX, numTimesY);
-	_renderer->drawSpriteEx(dynamic_cast<BaseSurface *>(this), rect, Vector2(x, y), Vector2(0, 0), scale, 0, 0xFFFFFFFF, false, Graphics::BLEND_NORMAL, false, false);
+	DXVector2 scale(numTimesX, numTimesY);
+	_renderer->drawSpriteEx(dynamic_cast<BaseSurface *>(this), rect, DXVector2(x, y), DXVector2(0, 0), scale, 0, 0xFFFFFFFF, false, Graphics::BLEND_NORMAL, false, false);
 	return true;
 }
 
diff --git a/engines/wintermute/base/gfx/xmath.cpp b/engines/wintermute/base/gfx/xmath.cpp
index 78db54ec3db..1afda86c73f 100644
--- a/engines/wintermute/base/gfx/xmath.cpp
+++ b/engines/wintermute/base/gfx/xmath.cpp
@@ -32,11 +32,89 @@
 
 namespace Wintermute {
 
+DXVector2::DXVector2() {
+}
+
+DXVector2::DXVector2(const float *pf) {
+	if (!pf)
+		return;
+	_x = pf[0];
+	_y = pf[1];
+}
+
 DXVector2::DXVector2(float fx, float fy) {
 	_x = fx;
 	_y = fy;
 }
 
+DXVector2::operator float* () {
+	return (float *)&_x;
+}
+
+DXVector2::operator const float* () const {
+	return (const float *)&_x;
+}
+
+DXVector2 &DXVector2::operator += (const DXVector2 &v) {
+	_x += v._x;
+	_y += v._y;
+	return *this;
+}
+
+DXVector2 &DXVector2::operator -= (const DXVector2 &v) {
+	_x -= v._x;
+	_y -= v._y;
+	return *this;
+}
+
+DXVector2 &DXVector2::operator *= (float f) {
+	_x *= f;
+	_y *= f;
+	return *this;
+}
+
+DXVector2 &DXVector2::operator /= (float f) {
+	_x /= f;
+	_y /= f;
+	return *this;
+}
+
+DXVector2 DXVector2::operator + () const {
+	return *this;
+}
+
+DXVector2 DXVector2::operator - () const {
+	return DXVector2(-_x, -_y);
+}
+
+DXVector2 DXVector2::operator + (const DXVector2 &v) const {
+	return DXVector2(_x + v._x, _y + v._y);
+}
+
+DXVector2 DXVector2::operator - (const DXVector2 &v) const {
+	return DXVector2(_x - v._x, _y - v._y);
+}
+
+DXVector2 DXVector2::operator * (float f) const {
+	return DXVector2(_x * f, _y * f);
+}
+
+DXVector2 DXVector2::operator / (float f) const {
+	return DXVector2(_x / f, _y / f);
+}
+
+DXVector2 operator * (float f, const DXVector2 &v) {
+	return DXVector2(f * v._x, f * v._y);
+}
+
+bool DXVector2::operator == (const DXVector2 &v) const {
+	return _x == v._x && _y == v._y;
+}
+
+bool DXVector2::operator != (const DXVector2 &v) const {
+	return _x != v._x || _y != v._y;
+}
+
 DXVector3::DXVector3(const float *pf) {
 	_x = pf[0];
 	_y = pf[1];
@@ -712,4 +790,17 @@ DXMatrix *DXMatrixShadow(DXMatrix *pout, const DXVector4 *plight, const DXPlane
 	return pout;
 }
 
+DXVector2 *DXVec2TransformCoord(DXVector2 *pout, const DXVector2 *pv, const DXMatrix *pm) {
+	DXVector2 v;
+	float norm;
+	
+	v = *pv;
+	norm = pm->_m[0][3] * pv->_x + pm->_m[1][3] * pv->_y + pm->_m[3][3];
+
+	pout->_x = (pm->_m[0][0] * v._x + pm->_m[1][0] * v._y + pm->_m[3][0]) / norm;
+	pout->_y = (pm->_m[0][1] * v._x + pm->_m[1][1] * v._y + pm->_m[3][1]) / norm;
+
+	return pout;
+}
+
 } // End of namespace Wintermute
diff --git a/engines/wintermute/base/gfx/xmath.h b/engines/wintermute/base/gfx/xmath.h
index ebfb191b364..ff42fb5f7de 100644
--- a/engines/wintermute/base/gfx/xmath.h
+++ b/engines/wintermute/base/gfx/xmath.h
@@ -43,8 +43,30 @@ struct DXVector2 {
 	float           _x;
 	float           _y;
 
-	DXVector2() {}
+	DXVector2();
+	DXVector2(const float *pf);
 	DXVector2(float fx, float fy);
+
+	operator float* ();
+	operator const float* () const;
+
+	DXVector2 &operator += (const DXVector2 &);
+	DXVector2 &operator -= (const DXVector2 &);
+	DXVector2 &operator *= (float);
+	DXVector2 &operator /= (float);
+
+	DXVector2 operator + () const;
+	DXVector2 operator - () const;
+
+	DXVector2 operator + (const DXVector2 &) const;
+	DXVector2 operator - (const DXVector2 &) const;
+	DXVector2 operator * (float) const;
+	DXVector2 operator / (float) const;
+
+	friend DXVector2 operator * (float, const DXVector2 &);
+
+	bool operator == (const DXVector2 &) const;
+	bool operator != (const DXVector2 &) const;
 };
 
 struct DXVector3 {
@@ -174,10 +196,11 @@ DXVector3 *DXVec3TransformCoord(DXVector3 *pout, const DXVector3 *pv, const DXMa
 DXVector3 *DXVec3TransformNormal(DXVector3 *pout, const DXVector3 *pv, const DXMatrix *pm);
 DXMatrix *DXMatrixMultiply(DXMatrix *pout, const DXMatrix *pm1, const DXMatrix *pm2);
 DXVector3 *DXVec3Project(DXVector3 *pout, const DXVector3 *pv, const DXViewport *pviewport,
-                         const DXMatrix *pprojection, const DXMatrix *pview, const DXMatrix *pworld);
+						 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);
 DXMatrix *DXMatrixShadow(DXMatrix *pout, const DXVector4 *plight, const DXPlane *pplane);
+DXVector2 *DXVec2TransformCoord(DXVector2 *pout, const DXVector2 *pv, const DXMatrix *pm);
 
 static inline DXMatrix *DXMatrixIdentity(DXMatrix *pout) {
 	(*pout)._m[0][1] = 0.0f;
@@ -243,6 +266,11 @@ static inline float DXPlaneDot(const DXPlane *pp, const DXVector4 *pv) {
 	return ((pp->_a) * (pv->_x) + (pp->_b) * (pv->_y) + (pp->_c) * (pv->_z) + (pp->_d) * (pv->_w) );
 }
 
+static inline float DXVec2Length(const DXVector2 *pv) {
+	if (!pv)
+		return 0.0f;
+	return sqrtf(pv->_x * pv->_x + pv->_y * pv->_y);
+}
 
 } // End of namespace Wintermute
 
diff --git a/engines/wintermute/base/particles/part_emitter.cpp b/engines/wintermute/base/particles/part_emitter.cpp
index 6e9e717d510..6e91ae7d55a 100644
--- a/engines/wintermute/base/particles/part_emitter.cpp
+++ b/engines/wintermute/base/particles/part_emitter.cpp
@@ -27,8 +27,6 @@
 
 #include "engines/wintermute/base/particles/part_emitter.h"
 #include "engines/wintermute/base/particles/part_particle.h"
-#include "engines/wintermute/math/vector2.h"
-#include "engines/wintermute/math/matrix4.h"
 #include "engines/wintermute/base/scriptables/script_value.h"
 #include "engines/wintermute/base/scriptables/script_stack.h"
 #include "engines/wintermute/base/base_engine.h"
@@ -36,6 +34,7 @@
 #include "engines/wintermute/base/base_file_manager.h"
 #include "engines/wintermute/base/base_game.h"
 #include "engines/wintermute/base/gfx/base_renderer.h"
+#include "engines/wintermute/base/gfx/3dutils.h"
 #include "engines/wintermute/utils/utils.h"
 #include "engines/wintermute/platform_osystem.h"
 #include "engines/wintermute/dcgf.h"
@@ -209,13 +208,12 @@ bool PartEmitter::initParticle(PartParticle *particle, uint32 currentTime, uint3
 		particle->_border.bottom -= thicknessBottom;
 	}
 
-	Vector2 vecPos((float)posX, (float)posY);
-	Vector2 vecVel(0, velocity);
+	DXVector2 vecPos((float)posX, (float)posY);
+	DXVector2 vecVel(0, velocity);
 
-	Matrix4 matRot;
-	float radZrot = Math::deg2rad<float>(BaseUtils::normalizeAngle(angle - 180.0));
-	matRot.rotationZ(radZrot);
-	matRot.transformVector2(vecVel);
+	DXMatrix matRot;
+	DXMatrixRotationZ(&matRot, degToRad(BaseUtils::normalizeAngle(angle - 180.0)));
+	DXVec2TransformCoord(&vecVel, &vecVel, &matRot);
 
 	if (_alphaTimeBased) {
 		particle->_alpha1 = _alpha1;
@@ -326,7 +324,7 @@ bool PartEmitter::display(BaseRegion *region) {
 
 	for (int32 i = 0; i < _particles.getSize(); i++) {
 		if (region != nullptr && _useRegion) {
-			if (!region->pointInRegion((int)_particles[i]->_pos.x, (int)_particles[i]->_pos.y)) {
+			if (!region->pointInRegion((int)_particles[i]->_pos._x, (int)_particles[i]->_pos._y)) {
 				continue;
 			}
 		}
@@ -433,13 +431,12 @@ bool PartEmitter::addForce(const Common::String &name, PartForce::TForceType typ
 	}
 
 	force->_type = type;
-	force->_pos = Vector2(posX, posY);
+	force->_pos = DXVector2(posX, posY);
 
-	force->_direction = Vector2(0, strength);
-	Matrix4 matRot;
-	float radZrot = Math::deg2rad<float>(BaseUtils::normalizeAngle(angle - 180.0));
-	matRot.rotationZ(radZrot);
-	matRot.transformVector2(force->_direction);
+	force->_direction = DXVector2(0, strength);
+	DXMatrix matRot;
+	DXMatrixRotationZ(&matRot, degToRad(BaseUtils::normalizeAngle(angle - 180.0)));
+	DXVec2TransformCoord(&force->_direction, &force->_direction, &matRot);
 
 	return STATUS_OK;
 }
diff --git a/engines/wintermute/base/particles/part_force.cpp b/engines/wintermute/base/particles/part_force.cpp
index b118d8bb1ad..bc1ea083302 100644
--- a/engines/wintermute/base/particles/part_force.cpp
+++ b/engines/wintermute/base/particles/part_force.cpp
@@ -33,8 +33,8 @@ namespace Wintermute {
 
 //////////////////////////////////////////////////////////////////////////
 PartForce::PartForce(BaseGame *inGame) : BaseNamedObject(inGame) {
-	_pos = Vector2(0.0f, 0.0f);
-	_direction = Vector2(0.0f, 0.0f);
+	_pos = DXVector2(0.0f, 0.0f);
+	_direction = DXVector2(0.0f, 0.0f);
 	_type = FORCE_POINT;
 }
 
diff --git a/engines/wintermute/base/particles/part_force.h b/engines/wintermute/base/particles/part_force.h
index e0b0d1cb84e..0e11ea74df6 100644
--- a/engines/wintermute/base/particles/part_force.h
+++ b/engines/wintermute/base/particles/part_force.h
@@ -31,7 +31,7 @@
 
 #include "engines/wintermute/base/base.h"
 #include "engines/wintermute/base/base_named_object.h"
-#include "engines/wintermute/math/vector2.h"
+#include "engines/wintermute/base/gfx/xmath.h"
 
 namespace Wintermute {
 
@@ -45,8 +45,8 @@ public:
 	PartForce(BaseGame *inGame);
 	~PartForce() override;
 
-	Vector2 _pos;
-	Vector2 _direction;
+	DXVector2 _pos;
+	DXVector2 _direction;
 	TForceType _type;
 
 	bool persist(BasePersistenceManager *PersistMgr) override;
diff --git a/engines/wintermute/base/particles/part_particle.cpp b/engines/wintermute/base/particles/part_particle.cpp
index 8e2e767cb90..26352c1c645 100644
--- a/engines/wintermute/base/particles/part_particle.cpp
+++ b/engines/wintermute/base/particles/part_particle.cpp
@@ -38,9 +38,9 @@ namespace Wintermute {
 
 //////////////////////////////////////////////////////////////////////////
 PartParticle::PartParticle(BaseGame *inGame) : BaseClass(inGame) {
-	_pos = Vector2(0.0f, 0.0f);
+	_pos = DXVector2(0.0f, 0.0f);
 	_posZ = 0.0f;
-	_velocity = Vector2(0.0f, 0.0f);
+	_velocity = DXVector2(0.0f, 0.0f);
 	_scale = 100.0f;
 	_sprite = nullptr;
 	_creationTime = 0;
@@ -125,8 +125,8 @@ bool PartParticle::update(PartEmitter *emitter, uint32 currentTime, uint32 timer
 		// particle hit the border
 		if (!_isDead && !BasePlatform::isRectEmpty(&_border)) {
 			Common::Point32 p;
-			p.x = (int32)_pos.x;
-			p.y = (int32)_pos.y;
+			p.x = (int32)_pos._x;
+			p.y = (int32)_pos._y;
 			if (!BasePlatform::ptInRect(&_border, p)) {
 				fadeOut(currentTime, emitter->_fadeOutTime);
 			}
@@ -154,8 +154,8 @@ bool PartParticle::update(PartEmitter *emitter, uint32 currentTime, uint32 timer
 				break;
 
 			case PartForce::FORCE_POINT: {
-				Vector2 vecDist = force->_pos - _pos;
-				float dist = fabs(vecDist.length());
+				DXVector2 vecDist = force->_pos - _pos;
+				float dist = fabs(DXVec2Length(&vecDist));
 
 				dist = 100.0f / dist;
 
@@ -199,7 +199,7 @@ bool PartParticle::display(PartEmitter *emitter) {
 	}
 
 	_sprite->getCurrentFrame();
-	return _sprite->display((int)_pos.x, (int)_pos.y,
+	return _sprite->display((int)_pos._x, (int)_pos._y,
 	                        nullptr,
 	                        _scale, _scale,
 	                        BYTETORGBA(255, 255, 255, _currentAlpha),
diff --git a/engines/wintermute/base/particles/part_particle.h b/engines/wintermute/base/particles/part_particle.h
index 321b680e498..947714eee1c 100644
--- a/engines/wintermute/base/particles/part_particle.h
+++ b/engines/wintermute/base/particles/part_particle.h
@@ -30,7 +30,7 @@
 
 #include "common/rect.h"
 #include "engines/wintermute/base/base.h"
-#include "engines/wintermute/math/vector2.h"
+#include "engines/wintermute/base/gfx/xmath.h"
 
 namespace Wintermute {
 
@@ -59,9 +59,9 @@ public:
 	int32 _alpha2;
 
 	Common::Rect32 _border;
-	Vector2 _pos;
+	DXVector2 _pos;
 	float _posZ;
-	Vector2 _velocity;
+	DXVector2 _velocity;
 	float _scale;
 	BaseSprite *_sprite;
 	uint32 _creationTime;
diff --git a/engines/wintermute/math/floatpoint.h b/engines/wintermute/math/floatpoint.h
deleted file mode 100644
index 2e78bb6ea3f..00000000000
--- a/engines/wintermute/math/floatpoint.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef WINTERMUTE_FLOATPOINT_H
-#define WINTERMUTE_FLOATPOINT_H
-
-namespace Wintermute {
-
-struct FloatPoint {
-	float x;
-	float y;
-	FloatPoint() : x(0), y(0) {}
-	FloatPoint(float x1, float y1) : x(x1), y(y1) {}
-	bool operator==(const FloatPoint &p) const { return x == p.x && y == p.y; }
-	bool operator!=(const FloatPoint  &p) const { return x != p.x || y != p.y; }
-	FloatPoint operator+(const FloatPoint &delta) const { return FloatPoint (x + delta.x, y + delta.y); }
-	FloatPoint operator-(const FloatPoint &delta) const { return FloatPoint (x - delta.x, y - delta.y); }
-
-	FloatPoint& operator+=(const FloatPoint &delta) {
-		x += delta.x;
-		y += delta.y;
-		return *this;
-	}
-	FloatPoint& operator-=(const FloatPoint &delta) {
-		x -= delta.x;
-		y -= delta.y;
-		return *this;
-	}
-};
-
-} // End of namespace Wintermute
-
-#endif
diff --git a/engines/wintermute/math/matrix4.cpp b/engines/wintermute/math/matrix4.cpp
deleted file mode 100644
index 430f128b4ca..00000000000
--- a/engines/wintermute/math/matrix4.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-/*
- * This file is based on WME Lite.
- * http://dead-code.org/redir.php?target=wmelite
- * Copyright (c) 2011 Jan Nedoma
- */
-
-#include "engines/wintermute/math/matrix4.h"
-#include "engines/wintermute/math/vector2.h"
-#include "common/scummsys.h"
-
-namespace Wintermute {
-
-//////////////////////////////////////////////////////////////////////////
-Matrix4::Matrix4() {
-	for (int i = 0; i < 4; i++) {
-		for (int j = 0; j < 4; j++) {
-			m[i][j] = 0.0f;
-		}
-	}
-}
-
-//////////////////////////////////////////////////////////////////////////
-Matrix4::~Matrix4() {
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-void Matrix4::identity() {
-	for (int i = 0; i < 4; i++) {
-		for (int j = 0; j < 4; j++) {
-			m[i][j] = 0.0f;
-		}
-	}
-	m[0][0] = 1.0f;
-	m[1][1] = 1.0f;
-	m[2][2] = 1.0f;
-	m[3][3] = 1.0f;
-
-}
-
-//////////////////////////////////////////////////////////////////////////
-void Matrix4::rotationZ(float angle) {
-	identity();
-
-	m[0][0] = cos(angle);
-	m[1][1] = cos(angle);
-	m[0][1] = sin(angle);
-	m[1][0] = -sin(angle);
-}
-
-//////////////////////////////////////////////////////////////////////////
-void Matrix4::transformVector2(Vector2 &vec) {
-	float norm;
-
-	norm = m[0][3] * vec.x + m[1][3] * vec.y + m[3][3];
-
-	float x = (m[0][0] * vec.x + m[1][0] * vec.y + m[3][0]) / norm;
-	float y = (m[0][1] * vec.x + m[1][1] * vec.y + m[3][1]) / norm;
-
-	vec.x = x;
-	vec.y = y;
-}
-
-} // End of namespace Wintermute
diff --git a/engines/wintermute/math/matrix4.h b/engines/wintermute/math/matrix4.h
deleted file mode 100644
index b0aad786252..00000000000
--- a/engines/wintermute/math/matrix4.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-/*
- * This file is based on WME Lite.
- * http://dead-code.org/redir.php?target=wmelite
- * Copyright (c) 2011 Jan Nedoma
- */
-
-#ifndef WINTERMUTE_MATRIX4_H
-#define WINTERMUTE_MATRIX4_H
-
-namespace Wintermute {
-
-class Vector2;
-
-class Matrix4 {
-public:
-	Matrix4();
-	~Matrix4();
-
-	void identity();
-	void rotationZ(float angle);
-	void transformVector2(Vector2 &vec);
-
-	float m[4][4];
-};
-
-} // End of namespace Wintermute
-
-#endif
diff --git a/engines/wintermute/math/vector2.cpp b/engines/wintermute/math/vector2.cpp
deleted file mode 100644
index 83eed98da88..00000000000
--- a/engines/wintermute/math/vector2.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-/*
- * This file is based on WME Lite.
- * http://dead-code.org/redir.php?target=wmelite
- * Copyright (c) 2011 Jan Nedoma
- */
-
-#include "engines/wintermute/math/vector2.h"
-#include "common/scummsys.h"
-
-namespace Wintermute {
-
-//////////////////////////////////////////////////////////////////////////
-Vector2::Vector2() {
-	x = y = 0.0f;
-}
-
-//////////////////////////////////////////////////////////////////////////
-Vector2::Vector2(float xVal, float yVal) {
-	this->x = xVal;
-	this->y = yVal;
-}
-
-//////////////////////////////////////////////////////////////////////////
-Vector2::~Vector2() {
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-float Vector2::length() const {
-	return (float)sqrt(x * x + y * y);
-}
-
-} // End of namespace Wintermute
diff --git a/engines/wintermute/math/vector2.h b/engines/wintermute/math/vector2.h
deleted file mode 100644
index b5f9e4ad42c..00000000000
--- a/engines/wintermute/math/vector2.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-/*
- * This file is based on WME Lite.
- * http://dead-code.org/redir.php?target=wmelite
- * Copyright (c) 2011 Jan Nedoma
- */
-
-#ifndef WINTERMUTE_VECTOR2_H
-#define WINTERMUTE_VECTOR2_H
-
-namespace Wintermute {
-
-class Vector2 {
-public:
-	Vector2();
-	Vector2(float x, float y);
-	~Vector2();
-
-	float length() const;
-
-	inline Vector2 &operator= (const Vector2 &other) {
-		x = other.x;
-		y = other.y;
-
-		return *this;
-	}
-
-	inline Vector2 operator+ (const Vector2 &other) const {
-		return Vector2(x + other.x, y + other.y);
-	}
-
-	inline Vector2 operator- (const Vector2 &other) const {
-		return Vector2(x - other.x, y - other.y);
-	}
-
-	inline Vector2 operator* (const float scalar) const {
-		return Vector2(x * scalar, y * scalar);
-	}
-
-	inline Vector2 &operator+= (const Vector2 &other) {
-		x += other.x;
-		y += other.y;
-
-		return *this;
-	}
-
-
-	float x;
-	float y;
-};
-
-} // End of namespace Wintermute
-
-#endif
diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk
index 22f51ef08b3..38f64e73b77 100644
--- a/engines/wintermute/module.mk
+++ b/engines/wintermute/module.mk
@@ -119,8 +119,6 @@ MODULE_OBJS := \
 	debugger/watch.o \
 	debugger/watch_instance.o \
 	math/math_util.o \
-	math/matrix4.o \
-	math/vector2.o \
 	metaengine.o \
 	platform_osystem.o \
 	system/sys_class.o \




More information about the Scummvm-git-logs mailing list