[Scummvm-git-logs] scummvm master -> 421cb1f08728f45e67cc001f2acfccd8deafb1ee
bluegr
noreply at scummvm.org
Sat Jul 27 11:00:52 UTC 2024
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
89c57d29ef COMMON: Move more maths functions into the Math namespace
421cb1f087 COMMON: Rename common/math.h to common/intrinsics.h
Commit: 89c57d29ef2c36c2abe39112eaf60357f0fa9f30
https://github.com/scummvm/scummvm/commit/89c57d29ef2c36c2abe39112eaf60357f0fa9f30
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2024-07-27T14:00:48+03:00
Commit Message:
COMMON: Move more maths functions into the Math namespace
Changed paths:
A test/math/utils.h
common/math.h
engines/adl/display_a2.cpp
engines/avalanche/avalot.cpp
engines/avalanche/graphics.cpp
engines/bladerunner/rect_float.h
engines/freescape/freescape.cpp
engines/freescape/gfx_opengl.cpp
engines/freescape/gfx_opengl_shaders.cpp
engines/freescape/gfx_tinygl.cpp
engines/icb/common/px_2drealline.cpp
engines/icb/game_volume.h
engines/icb/prim_route_builder.cpp
engines/mads/nebular/nebular_scenes1.cpp
engines/mads/nebular/nebular_scenes4.cpp
engines/mohawk/myst_stacks/myst.cpp
engines/myst3/hotspot.cpp
engines/myst3/scene.cpp
engines/ngi/fullpipe/scene18and19.cpp
engines/petka/walk.cpp
engines/pink/objects/walk/walk_mgr.cpp
engines/sci/engine/kpathing.cpp
engines/scumm/he/gfx_comp/aux_comp.cpp
engines/scumm/he/gfx_comp/mrle_comp.cpp
engines/scumm/he/gfx_comp/trle_comp.cpp
engines/scumm/he/gfx_primitives_he.cpp
engines/scumm/he/polygon_he.cpp
engines/scumm/he/wizwarp_he.cpp
engines/stark/resources/floor.cpp
engines/sword25/gfx/image/art.cpp
engines/tetraedge/game/amerzone_game.cpp
engines/tetraedge/te/micropather.h
engines/tetraedge/te/te_button_layout.cpp
engines/tetraedge/te/te_camera.cpp
engines/tetraedge/te/te_frame_anim.cpp
engines/tetraedge/te/te_light.cpp
engines/tetraedge/te/te_light_opengl.cpp
engines/tetraedge/te/te_light_opengl.h
engines/tetraedge/te/te_light_tinygl.cpp
engines/tetraedge/te/te_light_tinygl.h
engines/tetraedge/te/te_lua_gui_lua_callbacks.cpp
engines/tetraedge/te/te_model_vertex_animation.cpp
engines/tetraedge/te/te_pick_mesh.cpp
engines/tetraedge/te/te_pick_mesh2.cpp
engines/tetraedge/te/te_scrolling_layout.cpp
engines/tetraedge/te/te_warp.cpp
engines/titanic/star_control/const_boundaries.cpp
engines/titanic/star_control/constellations.cpp
engines/titanic/star_control/fpose.cpp
engines/titanic/star_control/fvector.cpp
engines/titanic/star_control/star_closeup.cpp
engines/titanic/star_control/viewport.cpp
engines/tsage/ringworld2/ringworld2_scenes1.cpp
engines/twp/lighting.cpp
engines/ultima/ultima8/misc/direction_util.h
engines/ultima/ultima8/world/crosshair_process.cpp
engines/vcruise/runtime.cpp
engines/wintermute/ad/ad_actor_3dx.cpp
engines/wintermute/ad/ad_scene_geometry.cpp
engines/wintermute/base/particles/part_emitter.cpp
engines/wintermute/base/scriptables/script_ext_math.cpp
engines/zvision/graphics/render_table.cpp
graphics/blit/blit-scale.cpp
graphics/tinygl/zdirtyrect.cpp
graphics/transform_tools.cpp
math/angle.cpp
math/quat.cpp
math/utils.h
test/common/math.h
test/image/blending.h
video/mkv/mkvparser.cpp
diff --git a/common/math.h b/common/math.h
index ef2ce4f95b2..f9b7e9156b0 100644
--- a/common/math.h
+++ b/common/math.h
@@ -51,14 +51,6 @@
#endif
#endif
-#ifndef FLT_MIN
- #define FLT_MIN 1E-37f
-#endif
-
-#ifndef FLT_MAX
- #define FLT_MAX 1E+37f
-#endif
-
namespace Common {
#if defined(__GNUC__)
@@ -102,67 +94,6 @@ inline int intLog2(uint32 v) {
}
#endif
-// Round a number towards zero
-// Input and Output type can be different
-template<class InputT, class OutputT>
-inline OutputT trunc(InputT x) {
- return (x > 0) ? floor(x) : ceil(x);
-}
-
-// Round a number towards zero
-// Input and Output type are the same
-template<class T>
-inline T trunc(T x) {
- return trunc<T,T>(x);
-}
-
-// Convert radians to degrees
-// Input and Output type can be different
-// Upconvert everything to floats
-template<class InputT, class OutputT>
-inline OutputT rad2deg(InputT rad) {
- return (OutputT)( (float)rad * (float)57.2957795130823); // 180.0/M_PI = 57.2957795130823
-}
-
-// Handle the case differently when the input type is double
-template<class OutputT>
-inline OutputT rad2deg(double rad) {
- return (OutputT)( rad * 57.2957795130823);
-}
-
-// Convert radians to degrees
-// Input and Output type are the same
-template<class T>
-inline T rad2deg(T rad) {
- return rad2deg<T,T>(rad);
-}
-
-// Convert degrees to radians
-// Input and Output type can be different
-// Upconvert everything to floats
-template<class InputT, class OutputT>
-inline OutputT deg2rad(InputT deg) {
- return (OutputT)( (float)deg * (float)0.0174532925199433); // M_PI/180.0 = 0.0174532925199433
-}
-
-// Handle the case differently when the input type is double
-template<class OutputT>
-inline OutputT deg2rad(double deg) {
- return (OutputT)( deg * 0.0174532925199433);
-}
-
-// Convert degrees to radians
-// Input and Output type are the same
-template<class T>
-inline T deg2rad(T deg) {
- return deg2rad<T,T>(deg);
-}
-
-template<class T>
-inline T hypotenuse(T xv, T yv) {
- return (T)sqrt((double)(xv * xv + yv * yv));
-}
-
} // End of namespace Common
#endif // COMMON_MATH_H
diff --git a/engines/adl/display_a2.cpp b/engines/adl/display_a2.cpp
index 31596a79fb2..a5cccfc4248 100644
--- a/engines/adl/display_a2.cpp
+++ b/engines/adl/display_a2.cpp
@@ -29,12 +29,13 @@
#include "common/system.h"
#include "common/str.h"
#include "common/config-manager.h"
-#include "common/math.h"
#include "common/memstream.h"
#include "graphics/surface.h"
#include "graphics/thumbnail.h"
+#include "math/utils.h"
+
#include "engines/util.h"
#include "adl/display_a2.h"
@@ -246,7 +247,7 @@ public:
PixelWriterColorNTSC() {
for (uint phase = 0; phase < kColorPhases; ++phase) {
- double phi = Common::deg2rad(phase * 90.0 + 45.0);
+ double phi = Math::deg2rad(phase * 90.0 + 45.0);
for (uint s = 0; s < kColors; ++s) {
uint t = s;
double y;
@@ -266,7 +267,7 @@ public:
i = i + (c * cos(phi) - i) / 8.0;
q = q + (c * sin(phi) - q) / 8.0;
- phi += Common::deg2rad(45.0);
+ phi += Math::deg2rad(45.0);
}
}
diff --git a/engines/avalanche/avalot.cpp b/engines/avalanche/avalot.cpp
index cb29cc8f148..729ace16db5 100644
--- a/engines/avalanche/avalot.cpp
+++ b/engines/avalanche/avalot.cpp
@@ -28,11 +28,11 @@
#include "avalanche/avalanche.h"
-#include "common/math.h"
#include "common/random.h"
#include "common/system.h"
#include "common/config-manager.h"
#include "graphics/paletteman.h"
+#include "math/utils.h"
namespace Avalanche {
@@ -1308,7 +1308,7 @@ uint16 AvalancheEngine::bearing(byte whichPed) {
int16 deltaX = avvy->_x - curPed->_x;
int16 deltaY = avvy->_y - curPed->_y;
- uint16 result = Common::rad2deg<float,uint16>(atan((float)deltaY / (float)deltaX)); // TODO: Would atan2 be preferable?
+ uint16 result = Math::rad2deg<float,uint16>(atan((float)deltaY / (float)deltaX)); // TODO: Would atan2 be preferable?
if (avvy->_x < curPed->_x) {
return result + 90;
} else {
diff --git a/engines/avalanche/graphics.cpp b/engines/avalanche/graphics.cpp
index 68c46d12c9b..f9f3e54ccf2 100644
--- a/engines/avalanche/graphics.cpp
+++ b/engines/avalanche/graphics.cpp
@@ -27,10 +27,10 @@
#include "avalanche/avalanche.h"
#include "avalanche/graphics.h"
-#include "common/math.h"
#include "common/system.h"
#include "engines/util.h"
#include "graphics/paletteman.h"
+#include "math/utils.h"
namespace Avalanche {
@@ -242,7 +242,7 @@ Common::Point GraphicManager::drawArc(Graphics::Surface &surface, int16 x, int16
uint16 deltaEnd = 91;
// Set the end point.
- float tempTerm = Common::deg2rad<float>(endAngle);
+ float tempTerm = Math::deg2rad<float>(endAngle);
endPoint.x = (int16)floor(xRadius * cos(tempTerm) + 0.5) + x;
endPoint.y = (int16)floor(yRadius * sin(tempTerm + M_PI) + 0.5) + y;
@@ -253,7 +253,7 @@ Common::Point GraphicManager::drawArc(Graphics::Surface &surface, int16 x, int16
int16 xTemp = xNext;
int16 yTemp = yNext;
// This is used by both sin and cos.
- tempTerm = Common::deg2rad<float>(j + delta);
+ tempTerm = Math::deg2rad<float>(j + delta);
xNext = (int16)floor(xRadius * cos(tempTerm) + 0.5);
yNext = (int16)floor(yRadius * sin(tempTerm + M_PI) + 0.5);
diff --git a/engines/bladerunner/rect_float.h b/engines/bladerunner/rect_float.h
index 14a8207288e..ff2581402c8 100644
--- a/engines/bladerunner/rect_float.h
+++ b/engines/bladerunner/rect_float.h
@@ -23,9 +23,9 @@
#define BLADERUNNER_RECT_FLOAT_H
#include "common/debug.h"
-#include "common/math.h"
#include "common/types.h"
#include "common/util.h"
+#include "math/utils.h"
namespace BladeRunner {
@@ -50,10 +50,10 @@ struct RectFloat {
}
void trunc_2_decimals() {
- x0 = Common::trunc(x0 * 100.0f) / 100.0f;
- y0 = Common::trunc(y0 * 100.0f) / 100.0f;
- x1 = Common::trunc(x1 * 100.0f) / 100.0f;
- y1 = Common::trunc(y1 * 100.0f) / 100.0f;
+ x0 = Math::trunc(x0 * 100.0f) / 100.0f;
+ y0 = Math::trunc(y0 * 100.0f) / 100.0f;
+ x1 = Math::trunc(x1 * 100.0f) / 100.0f;
+ y1 = Math::trunc(y1 * 100.0f) / 100.0f;
}
};
diff --git a/engines/freescape/freescape.cpp b/engines/freescape/freescape.cpp
index 1c92c727f9a..1c761e57dc2 100644
--- a/engines/freescape/freescape.cpp
+++ b/engines/freescape/freescape.cpp
@@ -21,12 +21,12 @@
#include "common/config-manager.h"
#include "common/events.h"
-#include "common/math.h"
#include "common/random.h"
#include "common/timer.h"
#include "graphics/cursorman.h"
#include "image/neo.h"
#include "image/scr.h"
+#include "math/utils.h"
#include "freescape/freescape.h"
#include "freescape/language/8bitDetokeniser.h"
@@ -312,8 +312,8 @@ Math::Vector3d FreescapeEngine::directionToVector(float pitch, float heading, bo
v.setValue(1, (int8)kCosineSineTable[pitchIndex][1] / 64.0);
v.setValue(2, ((int8)kCosineSineTable[pitchIndex][0] / 64.0) * (int8)kCosineSineTable[headingIndex][1] / 64.0);
} else {
- float radHeading = Common::deg2rad(heading);
- float radPitch = Common::deg2rad(pitch);
+ float radHeading = Math::deg2rad(heading);
+ float radPitch = Math::deg2rad(pitch);
v.setValue(0, cos(radPitch) * cos(radHeading));
v.setValue(1, sin(radPitch));
diff --git a/engines/freescape/gfx_opengl.cpp b/engines/freescape/gfx_opengl.cpp
index 98534485b72..97d285db066 100644
--- a/engines/freescape/gfx_opengl.cpp
+++ b/engines/freescape/gfx_opengl.cpp
@@ -23,7 +23,6 @@
// available at https://github.com/TomHarte/Phantasma/ (MIT)
#include "common/config-manager.h"
-#include "common/math.h"
#include "common/system.h"
#include "math/glmath.h"
diff --git a/engines/freescape/gfx_opengl_shaders.cpp b/engines/freescape/gfx_opengl_shaders.cpp
index 8e9da82aeec..c33353f4258 100644
--- a/engines/freescape/gfx_opengl_shaders.cpp
+++ b/engines/freescape/gfx_opengl_shaders.cpp
@@ -23,7 +23,6 @@
// available at https://github.com/TomHarte/Phantasma/ (MIT)
#include "common/config-manager.h"
-#include "common/math.h"
#include "common/system.h"
#include "math/glmath.h"
diff --git a/engines/freescape/gfx_tinygl.cpp b/engines/freescape/gfx_tinygl.cpp
index 84d27d31e1b..856ac2be840 100644
--- a/engines/freescape/gfx_tinygl.cpp
+++ b/engines/freescape/gfx_tinygl.cpp
@@ -23,7 +23,6 @@
// available at https://github.com/TomHarte/Phantasma/ (MIT)
#include "common/config-manager.h"
-#include "common/math.h"
#include "common/system.h"
#include "graphics/tinygl/tinygl.h"
#include "math/glmath.h"
diff --git a/engines/icb/common/px_2drealline.cpp b/engines/icb/common/px_2drealline.cpp
index c08a9ce5429..0077b6dbbc7 100644
--- a/engines/icb/common/px_2drealline.cpp
+++ b/engines/icb/common/px_2drealline.cpp
@@ -26,7 +26,7 @@
#include "engines/icb/common/px_2drealline.h"
-#include "common/math.h"
+#include "math/utils.h"
namespace ICB {
diff --git a/engines/icb/game_volume.h b/engines/icb/game_volume.h
index 8c2bd829b17..0a119f844b8 100644
--- a/engines/icb/game_volume.h
+++ b/engines/icb/game_volume.h
@@ -33,7 +33,7 @@
#include "engines/icb/common/px_linkeddatafile.h"
#include "engines/icb/common/px_route_barriers.h"
-#include "common/math.h"
+#include "math/utils.h"
namespace ICB {
diff --git a/engines/icb/prim_route_builder.cpp b/engines/icb/prim_route_builder.cpp
index 54f1d362bfb..3ebbedf89f5 100644
--- a/engines/icb/prim_route_builder.cpp
+++ b/engines/icb/prim_route_builder.cpp
@@ -37,7 +37,7 @@
#include "engines/icb/global_objects.h"
#include "common/system.h"
-#include "common/math.h"
+#include "math/utils.h"
namespace ICB {
diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index c884feb861e..eaba6928a34 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -20,7 +20,7 @@
*/
#include "common/scummsys.h"
-#include "common/math.h"
+#include "math/utils.h"
#include "mads/mads.h"
#include "mads/scene.h"
#include "mads/nebular/nebular_scenes.h"
@@ -1375,14 +1375,14 @@ void Scene103::step() {
case 72: {
Common::Point pt = _vm->_game->_player._playerPos;
- int dist = Common::hypotenuse(pt.x - 58, pt.y - 93);
+ int dist = Math::hypotenuse(pt.x - 58, pt.y - 93);
_vm->_sound->command(27, (dist * -128 / 378) + 127);
}
break;
case 73: {
Common::Point pt = _vm->_game->_player._playerPos;
- int dist = Common::hypotenuse(pt.x - 266, pt.y - 81);
+ int dist = Math::hypotenuse(pt.x - 266, pt.y - 81);
_vm->_sound->command(27, (dist * -127 / 378) + 127);
}
break;
@@ -1393,15 +1393,15 @@ void Scene103::step() {
if (_scene->_frameStartTime >= _updateClock) {
Common::Point pt = _vm->_game->_player._playerPos;
- int dist = Common::hypotenuse(pt.x - 79, pt.y - 137);
+ int dist = Math::hypotenuse(pt.x - 79, pt.y - 137);
_vm->_sound->command(29, (dist * -127 / 378) + 127);
pt = _vm->_game->_player._playerPos;
- dist = Common::hypotenuse(pt.x - 69, pt.y - 80);
+ dist = Math::hypotenuse(pt.x - 69, pt.y - 80);
_vm->_sound->command(30, (dist * -127 / 378) + 127);
pt = _vm->_game->_player._playerPos;
- dist = Common::hypotenuse(pt.x - 266, pt.y - 138);
+ dist = Math::hypotenuse(pt.x - 266, pt.y - 138);
_vm->_sound->command(32, (dist * -127 / 378) + 127);
_updateClock = _scene->_frameStartTime + _vm->_game->_player._ticksAmount;
diff --git a/engines/mads/nebular/nebular_scenes4.cpp b/engines/mads/nebular/nebular_scenes4.cpp
index 5b30e6f7b2a..16c2843ed23 100644
--- a/engines/mads/nebular/nebular_scenes4.cpp
+++ b/engines/mads/nebular/nebular_scenes4.cpp
@@ -20,7 +20,7 @@
*/
#include "common/scummsys.h"
-#include "common/math.h"
+#include "math/utils.h"
#include "mads/mads.h"
#include "mads/scene.h"
#include "mads/nebular/nebular_scenes.h"
@@ -149,7 +149,7 @@ void Scene401::step() {
}
if (_scene->_frameStartTime >= _timer) {
- int dist = 64 - ((Common::hypotenuse(_game._player._playerPos.x - 219, _game._player._playerPos.y - 115) * 64) / 120);
+ int dist = 64 - ((Math::hypotenuse(_game._player._playerPos.x - 219, _game._player._playerPos.y - 115) * 64) / 120);
if (dist > 64)
dist = 64;
diff --git a/engines/mohawk/myst_stacks/myst.cpp b/engines/mohawk/myst_stacks/myst.cpp
index f3330ef861a..1440dcdaf85 100644
--- a/engines/mohawk/myst_stacks/myst.cpp
+++ b/engines/mohawk/myst_stacks/myst.cpp
@@ -31,9 +31,9 @@
#include "common/config-manager.h"
#include "common/events.h"
-#include "common/math.h"
#include "common/system.h"
#include "common/textconsole.h"
+#include "math/utils.h"
namespace Mohawk {
namespace MystStacks {
@@ -3279,7 +3279,7 @@ Common::Point Myst::towerRotationMapComputeCoords(uint16 angle) {
Common::Point end;
// Polar to rect coords
- float radians = Common::deg2rad<uint16,float>(angle);
+ float radians = Math::deg2rad<uint16,float>(angle);
end.x = (int16)(_towerRotationCenter.x + cos(radians) * 310.0f);
end.y = (int16)(_towerRotationCenter.y + sin(radians) * 310.0f);
diff --git a/engines/myst3/hotspot.cpp b/engines/myst3/hotspot.cpp
index 15e1e4ec880..db20956caa3 100644
--- a/engines/myst3/hotspot.cpp
+++ b/engines/myst3/hotspot.cpp
@@ -24,7 +24,6 @@
#include "engines/myst3/state.h"
#include "common/config-manager.h"
-#include "common/math.h"
#include "math/ray.h"
diff --git a/engines/myst3/scene.cpp b/engines/myst3/scene.cpp
index c354f4a2ded..26d869bae14 100644
--- a/engines/myst3/scene.cpp
+++ b/engines/myst3/scene.cpp
@@ -19,7 +19,6 @@
*
*/
-#include "common/math.h"
#include "common/config-manager.h"
#include "engines/myst3/scene.h"
@@ -29,6 +28,7 @@
#include "engines/myst3/state.h"
#include "math/vector2d.h"
+#include "math/utils.h"
namespace Myst3 {
@@ -115,8 +115,8 @@ void Scene::drawSunspotFlare(const SunSpot &s) {
Math::Vector3d Scene::directionToVector(float pitch, float heading) {
Math::Vector3d v;
- float radHeading = Common::deg2rad(heading);
- float radPitch = Common::deg2rad(pitch);
+ float radHeading = Math::deg2rad(heading);
+ float radPitch = Math::deg2rad(pitch);
v.setValue(0, cos(radPitch) * cos(radHeading));
v.setValue(1, sin(radPitch));
diff --git a/engines/ngi/fullpipe/scene18and19.cpp b/engines/ngi/fullpipe/scene18and19.cpp
index fb8ceb36980..76708a4cf03 100644
--- a/engines/ngi/fullpipe/scene18and19.cpp
+++ b/engines/ngi/fullpipe/scene18and19.cpp
@@ -32,7 +32,7 @@
#include "ngi/interaction.h"
#include "ngi/behavior.h"
-#include "common/math.h"
+#include "math/utils.h"
namespace NGI {
@@ -147,7 +147,7 @@ void scene18_setupSwingers(StaticANIObject *ani, Scene *sc) {
for (int i = 0; i < 8; i++) {
swinger = new Swinger;
- swinger->angle = (double)i * Common::deg2rad<double>(45.0);
+ swinger->angle = (double)i * Math::deg2rad<double>(45.0);
swinger->sx = g_vars->scene18_wheelCenterX - (int)(cos(swinger->angle) * -575.0);
swinger->sy = g_vars->scene18_wheelCenterY - (int)(sin(swinger->angle) * -575.0) + 87;
swinger->ix = swinger->sx;
@@ -553,11 +553,11 @@ void sceneHandler18and19_drawRiders() {
double oldangle = swinger->angle;
- swinger->angle += Common::deg2rad<double>(1.0);
+ swinger->angle += Math::deg2rad<double>(1.0);
- if (swinger->angle > Common::deg2rad<double>(360.0)) {
- swinger->angle -= Common::deg2rad<double>(360.0);
- oldangle -= Common::deg2rad<double>(360.0);
+ if (swinger->angle > Math::deg2rad<double>(360.0)) {
+ swinger->angle -= Math::deg2rad<double>(360.0);
+ oldangle -= Math::deg2rad<double>(360.0);
}
int ix = g_vars->scene18_wheelCenterX - (int)(cos(swinger->angle) * -575.0);
@@ -566,7 +566,7 @@ void sceneHandler18and19_drawRiders() {
if (!g_vars->scene18_rotationCounter) {
ix = swinger->sx;
iy = swinger->sy;
- swinger->angle = (double)i * Common::deg2rad<double>(45.0);
+ swinger->angle = (double)i * Math::deg2rad<double>(45.0);
}
if (swinger->ani->_movement)
@@ -598,27 +598,27 @@ void sceneHandler18and19_drawRiders() {
}
if (g_vars->scene18_wheelIsTurning) {
- if ((swinger->sflags & 2) && swinger->angle >= Common::deg2rad<double>(160.0) && oldangle < Common::deg2rad<double>(160.0)) {
+ if ((swinger->sflags & 2) && swinger->angle >= Math::deg2rad<double>(160.0) && oldangle < Math::deg2rad<double>(160.0)) {
swinger->sflags = 8;
swinger->ani->changeStatics2(ST_KSL_BOY);
swinger->ani->startAnim(MV_KSL_JUMPBOY, 0, -1);
g_vars->scene18_kidWheelPos = i;
- } else if ((swinger->sflags & 4) && swinger->angle >= Common::deg2rad<double>(162.0) && oldangle < Common::deg2rad<double>(162.0)) {
+ } else if ((swinger->sflags & 4) && swinger->angle >= Math::deg2rad<double>(162.0) && oldangle < Math::deg2rad<double>(162.0)) {
swinger->sflags = 16;
swinger->ani->changeStatics2(ST_KSL_GIRL);
swinger->ani->startAnim(MV_KSL_JUMPGIRL, 0, -1);
g_vars->scene18_kidWheelPos = i;
} else if (g_vars->scene18_kidIsOnWheel) {
- if (g_vars->scene18_boyIsOnWheel > 0 && (swinger->sflags & 1) && swinger->angle >= Common::deg2rad<double>(185.0) && oldangle < Common::deg2rad<double>(185.0)) {
+ if (g_vars->scene18_boyIsOnWheel > 0 && (swinger->sflags & 1) && swinger->angle >= Math::deg2rad<double>(185.0) && oldangle < Math::deg2rad<double>(185.0)) {
g_vars->scene18_kidWheelPosTo = i;
sceneHandler18and19_boyJumpTo();
}
- } else if (g_vars->scene18_girlIsOnWheel > 0 && (swinger->sflags & 1) && swinger->angle >= Common::deg2rad<double>(187.0) && oldangle < Common::deg2rad<double>(187.0)) {
+ } else if (g_vars->scene18_girlIsOnWheel > 0 && (swinger->sflags & 1) && swinger->angle >= Math::deg2rad<double>(187.0) && oldangle < Math::deg2rad<double>(187.0)) {
g_vars->scene18_kidWheelPosTo = i;
sceneHandler18and19_girlJumpTo();
}
- if (swinger->angle >= Common::deg2rad<double>(200.0) && oldangle < Common::deg2rad<double>(200.0)) {
+ if (swinger->angle >= Math::deg2rad<double>(200.0) && oldangle < Math::deg2rad<double>(200.0)) {
if (g_vars->scene18_boyJumpedOff)
g_vars->scene18_boyIsOnWheel++;
@@ -626,7 +626,7 @@ void sceneHandler18and19_drawRiders() {
}
}
- if (g_vars->scene18_manIsReady && (swinger->sflags & 1) && swinger->angle >= Common::deg2rad<double>(83.0) && oldangle < Common::deg2rad<double>(83.0)) {
+ if (g_vars->scene18_manIsReady && (swinger->sflags & 1) && swinger->angle >= Math::deg2rad<double>(83.0) && oldangle < Math::deg2rad<double>(83.0)) {
g_vars->scene18_manWheelPosTo = i;
sceneHandler18and19_manStandArmchair();
}
@@ -635,18 +635,18 @@ void sceneHandler18and19_drawRiders() {
continue;
if ((int)i == g_vars->scene18_manWheelPosTo) {
- if (swinger->angle >= Common::deg2rad<double>(170.0) && oldangle < Common::deg2rad<double>(170.0)) {
+ if (swinger->angle >= Math::deg2rad<double>(170.0) && oldangle < Math::deg2rad<double>(170.0)) {
g_nmi->_gameLoader->preloadScene(SC_18, TrubaRight);
- } else if (swinger->angle >= Common::deg2rad<double>(25.0) && oldangle < Common::deg2rad<double>(25.0)) {
+ } else if (swinger->angle >= Math::deg2rad<double>(25.0) && oldangle < Math::deg2rad<double>(25.0)) {
g_nmi->_gameLoader->preloadScene(SC_19, TrubaRight);
- } else if (swinger->angle >= Common::deg2rad<double>(270.0) && oldangle < Common::deg2rad<double>(270.0)) {
+ } else if (swinger->angle >= Math::deg2rad<double>(270.0) && oldangle < Math::deg2rad<double>(270.0)) {
g_nmi->_sceneRect.translate(1200, 0);
}
}
if (g_vars->scene18_jumpDistance > 0) {
if (swinger->sflags & 0x20) {
- double newa = (double)g_vars->scene18_jumpAngle * Common::deg2rad<double>(1.0);
+ double newa = (double)g_vars->scene18_jumpAngle * Math::deg2rad<double>(1.0);
if (newa <= swinger->angle && oldangle < newa) {
swinger->ani->changeStatics2(ST_KSL_MAN);
diff --git a/engines/petka/walk.cpp b/engines/petka/walk.cpp
index 34b8dabed7a..2994451b11c 100644
--- a/engines/petka/walk.cpp
+++ b/engines/petka/walk.cpp
@@ -19,7 +19,7 @@
*
*/
-#include "common/math.h"
+#include "math/utils.h"
#include "petka/walk.h"
#include "petka/petka.h"
@@ -365,7 +365,7 @@ int Walk::sub_422EA0(Point p1, Point p2) {
double v28 = p2.x - p1.x;
double v26 = p2.y - p1.y;
- double v12 = Common::hypotenuse(p2.x - p1.x, p2.y - p1.y);
+ double v12 = Math::hypotenuse(p2.x - p1.x, p2.y - p1.y);
double v39 = 1.0 / sqrt(field_D0[resId] * field_D0[resId] - -1.0);
if (v39 == 0.0)
@@ -610,8 +610,8 @@ double Walk::angle(DBLPoint p1, DBLPoint p2, DBLPoint p3) { // CHECKED
double yv1 = p2.y - p1.y;
double yv2 = p3.y - p1.y;
- double mv1 = Common::hypotenuse(xv1, yv1);
- double mv2 = Common::hypotenuse(xv2, yv2);
+ double mv1 = Math::hypotenuse(xv1, yv1);
+ double mv2 = Math::hypotenuse(xv2, yv2);
double v13 = (xv1 * xv2 + yv1 * yv2) / (mv1 * mv2);
if ((xv2 / mv2 * (yv1 / mv1) - yv2 / mv2 * (xv1 / mv1)) < 0.0) // Not sure
return -acos(v13);
diff --git a/engines/pink/objects/walk/walk_mgr.cpp b/engines/pink/objects/walk/walk_mgr.cpp
index afb88bf1435..96d63f7f7db 100644
--- a/engines/pink/objects/walk/walk_mgr.cpp
+++ b/engines/pink/objects/walk/walk_mgr.cpp
@@ -19,7 +19,7 @@
*
*/
-#include "common/math.h"
+#include "math/utils.h"
#include "pink/archive.h"
#include "pink/cel_decoder.h"
@@ -111,7 +111,7 @@ WalkAction *WalkMgr::getWalkAction() {
double WalkMgr::getLengthBetweenLocations(WalkLocation *first, WalkLocation *second) {
Coordinates firstCoord = getLocationCoordinates(first->getName());
Coordinates secondCoord = getLocationCoordinates(second->getName());
- return Common::hypotenuse(secondCoord.point.x - firstCoord.point.x, secondCoord.point.y - firstCoord.point.y);
+ return Math::hypotenuse(secondCoord.point.x - firstCoord.point.x, secondCoord.point.y - firstCoord.point.y);
}
Coordinates WalkMgr::getLocationCoordinates(const Common::String &locationName) {
diff --git a/engines/sci/engine/kpathing.cpp b/engines/sci/engine/kpathing.cpp
index 8f30b15bd75..243fc031bdd 100644
--- a/engines/sci/engine/kpathing.cpp
+++ b/engines/sci/engine/kpathing.cpp
@@ -36,7 +36,7 @@
#include "common/debug-channels.h"
#include "common/list.h"
#include "common/system.h"
-#include "common/math.h"
+#include "math/utils.h"
//#define DEBUG_MERGEPOLY
@@ -1986,7 +1986,7 @@ static int intersectDir(const Vertex *v1, const Vertex *v2) {
// Direction of edge in degrees from pos. x-axis, between -180 and 180
static int edgeDir(const Vertex *v) {
Common::Point p = v->_next->v - v->v;
- int deg = Common::rad2deg<float,int>((float)atan2((double)p.y, (double)p.x));
+ int deg = Math::rad2deg<float,int>((float)atan2((double)p.y, (double)p.x));
if (deg < -180) deg += 360;
if (deg > 180) deg -= 360;
return deg;
diff --git a/engines/scumm/he/gfx_comp/aux_comp.cpp b/engines/scumm/he/gfx_comp/aux_comp.cpp
index e4fb5c4ce75..1052e7fb950 100644
--- a/engines/scumm/he/gfx_comp/aux_comp.cpp
+++ b/engines/scumm/he/gfx_comp/aux_comp.cpp
@@ -21,7 +21,6 @@
#ifdef ENABLE_HE
-#include "common/math.h"
#include "common/system.h"
#include "scumm/he/intern_he.h"
#include "scumm/he/wiz_he.h"
diff --git a/engines/scumm/he/gfx_comp/mrle_comp.cpp b/engines/scumm/he/gfx_comp/mrle_comp.cpp
index 0f1e738f573..3c3d74424fd 100644
--- a/engines/scumm/he/gfx_comp/mrle_comp.cpp
+++ b/engines/scumm/he/gfx_comp/mrle_comp.cpp
@@ -21,7 +21,6 @@
#ifdef ENABLE_HE
-#include "common/math.h"
#include "common/system.h"
#include "scumm/he/intern_he.h"
#include "scumm/he/wiz_he.h"
diff --git a/engines/scumm/he/gfx_comp/trle_comp.cpp b/engines/scumm/he/gfx_comp/trle_comp.cpp
index 29fbd6b4216..42d470783a4 100644
--- a/engines/scumm/he/gfx_comp/trle_comp.cpp
+++ b/engines/scumm/he/gfx_comp/trle_comp.cpp
@@ -21,7 +21,6 @@
#ifdef ENABLE_HE
-#include "common/math.h"
#include "common/system.h"
#include "scumm/he/intern_he.h"
#include "scumm/he/wiz_he.h"
diff --git a/engines/scumm/he/gfx_primitives_he.cpp b/engines/scumm/he/gfx_primitives_he.cpp
index 53a7d406805..81a82a4a039 100644
--- a/engines/scumm/he/gfx_primitives_he.cpp
+++ b/engines/scumm/he/gfx_primitives_he.cpp
@@ -22,7 +22,6 @@
#ifdef ENABLE_HE
#include "common/system.h"
-#include "common/math.h"
#include "scumm/he/intern_he.h"
#include "scumm/he/wiz_he.h"
diff --git a/engines/scumm/he/polygon_he.cpp b/engines/scumm/he/polygon_he.cpp
index ecac2ffa5cb..4def4704dcf 100644
--- a/engines/scumm/he/polygon_he.cpp
+++ b/engines/scumm/he/polygon_he.cpp
@@ -21,7 +21,6 @@
#ifdef ENABLE_HE
-#include "common/math.h"
#include "common/system.h"
#include "scumm/he/intern_he.h"
#include "scumm/he/wiz_he.h"
diff --git a/engines/scumm/he/wizwarp_he.cpp b/engines/scumm/he/wizwarp_he.cpp
index 08789d410e2..0c3e63279e1 100644
--- a/engines/scumm/he/wizwarp_he.cpp
+++ b/engines/scumm/he/wizwarp_he.cpp
@@ -21,7 +21,6 @@
#ifdef ENABLE_HE
-#include "common/math.h"
#include "common/system.h"
#include "scumm/he/intern_he.h"
#include "scumm/he/wiz_he.h"
diff --git a/engines/stark/resources/floor.cpp b/engines/stark/resources/floor.cpp
index 3976bca00fe..fdca4240911 100644
--- a/engines/stark/resources/floor.cpp
+++ b/engines/stark/resources/floor.cpp
@@ -28,8 +28,6 @@
#include "engines/stark/services/stateprovider.h"
-#include "common/math.h"
-
namespace Stark {
namespace Resources {
diff --git a/engines/sword25/gfx/image/art.cpp b/engines/sword25/gfx/image/art.cpp
index 0ec07d3b0ae..66abff06734 100644
--- a/engines/sword25/gfx/image/art.cpp
+++ b/engines/sword25/gfx/image/art.cpp
@@ -30,8 +30,8 @@
/* Various utility functions RLL finds useful. */
-#include "common/math.h"
#include "common/textconsole.h"
+#include "math/utils.h"
#include "sword25/gfx/image/art.h"
@@ -365,8 +365,8 @@ static void art_vpath_render_bez(ArtVpath **p_vpath, int *pn, int *pn_max,
* the other two control points are the same as the start point,
* too.
*/
- if (!(Common::hypotenuse(x1 - x0, y1 - y0) < 0.001
- && Common::hypotenuse(x2 - x0, y2 - y0) < 0.001))
+ if (!(Math::hypotenuse(x1 - x0, y1 - y0) < 0.001
+ && Math::hypotenuse(x2 - x0, y2 - y0) < 0.001))
subDivide = true;
} else {
/* we can avoid subdivision if:
diff --git a/engines/tetraedge/game/amerzone_game.cpp b/engines/tetraedge/game/amerzone_game.cpp
index dc44e8ec3f1..6417dbf7fb5 100644
--- a/engines/tetraedge/game/amerzone_game.cpp
+++ b/engines/tetraedge/game/amerzone_game.cpp
@@ -19,7 +19,6 @@
*
*/
-#include "common/math.h"
#include "common/savefile.h"
#include "tetraedge/tetraedge.h"
diff --git a/engines/tetraedge/te/micropather.h b/engines/tetraedge/te/micropather.h
index b1267157beb..50d5cfce046 100644
--- a/engines/tetraedge/te/micropather.h
+++ b/engines/tetraedge/te/micropather.h
@@ -58,8 +58,8 @@ distribution.
#include "common/array.h"
#include "common/util.h"
-#include "common/math.h"
#include "common/types.h"
+#include "math/utils.h"
/** @mainpage MicroPather
diff --git a/engines/tetraedge/te/te_button_layout.cpp b/engines/tetraedge/te/te_button_layout.cpp
index a7dc0d433a1..41f9c99f44e 100644
--- a/engines/tetraedge/te/te_button_layout.cpp
+++ b/engines/tetraedge/te/te_button_layout.cpp
@@ -19,8 +19,6 @@
*
*/
-#include "common/math.h"
-
#include "tetraedge/tetraedge.h"
#include "tetraedge/te/te_button_layout.h"
diff --git a/engines/tetraedge/te/te_camera.cpp b/engines/tetraedge/te/te_camera.cpp
index 5bee6b2235e..80a487fbba7 100644
--- a/engines/tetraedge/te/te_camera.cpp
+++ b/engines/tetraedge/te/te_camera.cpp
@@ -19,7 +19,6 @@
*
*/
-#include "common/math.h"
#include "math/ray.h"
#include "tetraedge/tetraedge.h"
diff --git a/engines/tetraedge/te/te_frame_anim.cpp b/engines/tetraedge/te/te_frame_anim.cpp
index 40a9bc3282b..43cd80503ec 100644
--- a/engines/tetraedge/te/te_frame_anim.cpp
+++ b/engines/tetraedge/te/te_frame_anim.cpp
@@ -20,7 +20,7 @@
*/
#include "common/util.h"
-#include "common/math.h"
+#include "math/utils.h"
#include "tetraedge/te/te_frame_anim.h"
namespace Tetraedge {
diff --git a/engines/tetraedge/te/te_light.cpp b/engines/tetraedge/te/te_light.cpp
index 915a7b16f87..5f0dac5c3ff 100644
--- a/engines/tetraedge/te/te_light.cpp
+++ b/engines/tetraedge/te/te_light.cpp
@@ -19,7 +19,6 @@
*
*/
-#include "common/math.h"
#include "graphics/renderer.h"
#include "tetraedge/tetraedge.h"
diff --git a/engines/tetraedge/te/te_light_opengl.cpp b/engines/tetraedge/te/te_light_opengl.cpp
index 8dfe56fe5fe..01de8f396e5 100644
--- a/engines/tetraedge/te/te_light_opengl.cpp
+++ b/engines/tetraedge/te/te_light_opengl.cpp
@@ -19,8 +19,6 @@
*
*/
-#include "common/math.h"
-
#include "tetraedge/te/te_light_opengl.h"
#include "tetraedge/tetraedge.h"
#include "tetraedge/te/te_color.h"
diff --git a/engines/tetraedge/te/te_light_opengl.h b/engines/tetraedge/te/te_light_opengl.h
index 1cd4085ec64..7e650d0e799 100644
--- a/engines/tetraedge/te/te_light_opengl.h
+++ b/engines/tetraedge/te/te_light_opengl.h
@@ -22,6 +22,8 @@
#ifndef TETRAEDGE_TE_TE_LIGHT_OPENGL_H
#define TETRAEDGE_TE_TE_LIGHT_OPENGL_H
+#include "common/scummsys.h"
+
#if defined(USE_OPENGL_GAME)
#include "tetraedge/te/te_light.h"
diff --git a/engines/tetraedge/te/te_light_tinygl.cpp b/engines/tetraedge/te/te_light_tinygl.cpp
index 3d6c3d04210..ec54ee0dc03 100644
--- a/engines/tetraedge/te/te_light_tinygl.cpp
+++ b/engines/tetraedge/te/te_light_tinygl.cpp
@@ -19,8 +19,6 @@
*
*/
-#include "common/math.h"
-
#include "graphics/tinygl/tinygl.h"
#include "tetraedge/te/te_light_tinygl.h"
diff --git a/engines/tetraedge/te/te_light_tinygl.h b/engines/tetraedge/te/te_light_tinygl.h
index a05470f86e9..fd3c1cfd5cc 100644
--- a/engines/tetraedge/te/te_light_tinygl.h
+++ b/engines/tetraedge/te/te_light_tinygl.h
@@ -22,6 +22,8 @@
#ifndef TETRAEDGE_TE_TE_LIGHT_TINYGL_H
#define TETRAEDGE_TE_TE_LIGHT_TINYGL_H
+#include "common/scummsys.h"
+
#if defined(USE_TINYGL)
#include "tetraedge/te/te_light.h"
diff --git a/engines/tetraedge/te/te_lua_gui_lua_callbacks.cpp b/engines/tetraedge/te/te_lua_gui_lua_callbacks.cpp
index e1fb38c5cfa..d66f27372e9 100644
--- a/engines/tetraedge/te/te_lua_gui_lua_callbacks.cpp
+++ b/engines/tetraedge/te/te_lua_gui_lua_callbacks.cpp
@@ -20,7 +20,6 @@
*/
#include "common/lua/lua.h"
-#include "common/math.h"
#include "common/textconsole.h"
#include "tetraedge/te/te_lua_gui_lua_callbacks.h"
#include "tetraedge/te/te_layout.h"
diff --git a/engines/tetraedge/te/te_model_vertex_animation.cpp b/engines/tetraedge/te/te_model_vertex_animation.cpp
index f194279076f..f1777f4f7a3 100644
--- a/engines/tetraedge/te/te_model_vertex_animation.cpp
+++ b/engines/tetraedge/te/te_model_vertex_animation.cpp
@@ -20,7 +20,6 @@
*/
#include "tetraedge/te/te_model_vertex_animation.h"
-#include "common/math.h"
namespace Tetraedge {
diff --git a/engines/tetraedge/te/te_pick_mesh.cpp b/engines/tetraedge/te/te_pick_mesh.cpp
index 2f30a52a246..c823963416d 100644
--- a/engines/tetraedge/te/te_pick_mesh.cpp
+++ b/engines/tetraedge/te/te_pick_mesh.cpp
@@ -19,8 +19,6 @@
*
*/
-#include "common/math.h"
-
#include "math/ray.h"
#include "tetraedge/te/te_pick_mesh.h"
diff --git a/engines/tetraedge/te/te_pick_mesh2.cpp b/engines/tetraedge/te/te_pick_mesh2.cpp
index f73c774885b..f73e7484b98 100644
--- a/engines/tetraedge/te/te_pick_mesh2.cpp
+++ b/engines/tetraedge/te/te_pick_mesh2.cpp
@@ -20,7 +20,6 @@
*/
#include "common/util.h"
-#include "common/math.h"
#include "tetraedge/tetraedge.h"
diff --git a/engines/tetraedge/te/te_scrolling_layout.cpp b/engines/tetraedge/te/te_scrolling_layout.cpp
index 70c867878af..3e33b448e7e 100644
--- a/engines/tetraedge/te/te_scrolling_layout.cpp
+++ b/engines/tetraedge/te/te_scrolling_layout.cpp
@@ -24,8 +24,6 @@
#include "tetraedge/tetraedge.h"
#include "tetraedge/te/te_input_mgr.h"
-#include "common/math.h"
-
namespace Tetraedge {
TeScrollingLayout::TeScrollingLayout() : _contentLayout(nullptr),
diff --git a/engines/tetraedge/te/te_warp.cpp b/engines/tetraedge/te/te_warp.cpp
index ff02d88d25d..57fc5f26b21 100644
--- a/engines/tetraedge/te/te_warp.cpp
+++ b/engines/tetraedge/te/te_warp.cpp
@@ -19,8 +19,6 @@
*
*/
-#include "common/math.h"
-
#include "tetraedge/tetraedge.h"
#include "tetraedge/game/application.h"
#include "tetraedge/te/te_warp.h"
diff --git a/engines/titanic/star_control/const_boundaries.cpp b/engines/titanic/star_control/const_boundaries.cpp
index 24968ed3340..d5d5f8948d2 100644
--- a/engines/titanic/star_control/const_boundaries.cpp
+++ b/engines/titanic/star_control/const_boundaries.cpp
@@ -26,7 +26,7 @@
#include "titanic/support/files_manager.h"
#include "titanic/titanic.h"
-#include "common/math.h"
+#include "math/utils.h"
namespace Titanic {
@@ -55,8 +55,8 @@ bool CConstBoundaries::initialize() {
dec = z / 100.0F;
// Work the polar coordinates
- phi = Common::deg2rad<double>(ra);
- theta = Common::deg2rad<double>(dec);
+ phi = Math::deg2rad<double>(ra);
+ theta = Math::deg2rad<double>(dec);
entry._x = UNIVERSE_SCALE * cos(theta) * cos(phi);
entry._y = UNIVERSE_SCALE * cos(theta) * sin(phi);
diff --git a/engines/titanic/star_control/constellations.cpp b/engines/titanic/star_control/constellations.cpp
index a61caf8e4f4..50a70fc29f2 100644
--- a/engines/titanic/star_control/constellations.cpp
+++ b/engines/titanic/star_control/constellations.cpp
@@ -26,7 +26,7 @@
#include "titanic/support/files_manager.h"
#include "titanic/titanic.h"
-#include "common/math.h"
+#include "math/utils.h"
namespace Titanic {
@@ -55,8 +55,8 @@ bool CConstellations::initialize() {
dec = (double)stream->readSint32LE() / 100.0f;
// Work the polar coordinates
- phi = Common::deg2rad<double>(ra);
- theta = Common::deg2rad<double>(dec);
+ phi = Math::deg2rad<double>(ra);
+ theta = Math::deg2rad<double>(dec);
vectors[fctr]->_x = UNIVERSE_SCALE * cos(theta) * cos(phi);
vectors[fctr]->_y = UNIVERSE_SCALE * cos(theta) * sin(phi);
diff --git a/engines/titanic/star_control/fpose.cpp b/engines/titanic/star_control/fpose.cpp
index 6e7f281f16a..775e3ef9119 100644
--- a/engines/titanic/star_control/fpose.cpp
+++ b/engines/titanic/star_control/fpose.cpp
@@ -23,7 +23,7 @@
#include "titanic/star_control/matrix_transform.h"
#include "titanic/star_control/matrix_inv.h"
-#include "common/math.h"
+#include "math/utils.h"
namespace Titanic {
@@ -88,8 +88,8 @@ void FPose::identity() {
// Source: https://en.wikipedia.org/wiki/Rotation_matrix
void FPose::setRotationMatrix(Axis axis, float amount) {
- float sinVal = sin(Common::deg2rad<float>(amount));
- float cosVal = cos(Common::deg2rad<float>(amount));
+ float sinVal = sin(Math::deg2rad<float>(amount));
+ float cosVal = cos(Math::deg2rad<float>(amount));
switch (axis) {
case X_AXIS:
diff --git a/engines/titanic/star_control/fvector.cpp b/engines/titanic/star_control/fvector.cpp
index 1a5cc4fa60d..abd1dd08a2e 100644
--- a/engines/titanic/star_control/fvector.cpp
+++ b/engines/titanic/star_control/fvector.cpp
@@ -23,7 +23,7 @@
#include "titanic/star_control/fpose.h"
#include "common/str.h"
-#include "common/math.h"
+#include "math/utils.h"
namespace Titanic {
@@ -45,8 +45,8 @@ FVector FVector::crossProduct(const FVector &src) const {
}
void FVector::rotVectAxisY(float angleDeg) {
- float sinVal = sin(Common::deg2rad<double>(angleDeg));
- float cosVal = cos(Common::deg2rad<double>(angleDeg));
+ float sinVal = sin(Math::deg2rad<double>(angleDeg));
+ float cosVal = cos(Math::deg2rad<double>(angleDeg));
float x = cosVal * _x - sinVal * _z;
float z = cosVal * _z + sinVal * _x;
@@ -109,14 +109,14 @@ FPose FVector::getFrameTransform(const FVector &v) {
FPose matrix1, matrix2, matrix3, matrix4;
FVector vector1 = getPolarCoord();
- matrix1.setRotationMatrix(X_AXIS, Common::rad2deg<double>(vector1._y));
- matrix2.setRotationMatrix(Y_AXIS, Common::rad2deg<double>(vector1._z));
+ matrix1.setRotationMatrix(X_AXIS, Math::rad2deg<double>(vector1._y));
+ matrix2.setRotationMatrix(Y_AXIS, Math::rad2deg<double>(vector1._z));
fposeProd(matrix1, matrix2, matrix3);
matrix4 = matrix3.inverseTransform();
vector1 = v.getPolarCoord();
- matrix1.setRotationMatrix(X_AXIS, Common::rad2deg<double>(vector1._y));
- matrix2.setRotationMatrix(Y_AXIS, Common::rad2deg<double>(vector1._z));
+ matrix1.setRotationMatrix(X_AXIS, Math::rad2deg<double>(vector1._y));
+ matrix2.setRotationMatrix(Y_AXIS, Math::rad2deg<double>(vector1._z));
fposeProd(matrix1, matrix2, matrix3);
fposeProd(matrix4, matrix3, matrix1);
@@ -126,8 +126,8 @@ FPose FVector::getFrameTransform(const FVector &v) {
FPose FVector::formRotXY() const {
FVector v1 = getPolarCoord();
FPose m1, m2;
- m1.setRotationMatrix(X_AXIS, Common::rad2deg<double>(v1._y));
- m2.setRotationMatrix(Y_AXIS, Common::rad2deg<double>(v1._z));
+ m1.setRotationMatrix(X_AXIS, Math::rad2deg<double>(v1._y));
+ m2.setRotationMatrix(Y_AXIS, Math::rad2deg<double>(v1._z));
FPose m3;
fposeProd(m1, m2, m3);
return m3;
diff --git a/engines/titanic/star_control/star_closeup.cpp b/engines/titanic/star_control/star_closeup.cpp
index a900384b392..8c97819e26f 100644
--- a/engines/titanic/star_control/star_closeup.cpp
+++ b/engines/titanic/star_control/star_closeup.cpp
@@ -25,7 +25,7 @@
#include "titanic/star_control/surface_area.h"
#include "titanic/titanic.h"
-#include "common/math.h"
+#include "math/utils.h"
namespace Titanic {
@@ -83,7 +83,7 @@ bool CStarCloseup::setup2(int val1, int val2) {
e->_pixel3 = 0x40;
e->_field8 = g_vm->getRandomNumber(3) + 3;
e->_fieldC = g_vm->getRandomNumber(255);
- e->_field10 = Common::deg2rad<double>(7.0);
+ e->_field10 = Math::deg2rad<double>(7.0);
e->_field14 = 0.0084687499;
++e;
@@ -93,7 +93,7 @@ bool CStarCloseup::setup2(int val1, int val2) {
e->_pixel3 = 0;
e->_field8 = g_vm->getRandomNumber(3) + 3;
e->_fieldC = g_vm->getRandomNumber(255);
- e->_field10 = Common::deg2rad<double>(3.0);
+ e->_field10 = Math::deg2rad<double>(3.0);
e->_field14 = 0.021011719;
++e;
@@ -113,7 +113,7 @@ bool CStarCloseup::setup2(int val1, int val2) {
e->_pixel3 = 0;
e->_field8 = g_vm->getRandomNumber(3) + 3;
e->_fieldC = g_vm->getRandomNumber(255);
- e->_field10 = Common::deg2rad<double>(2.0);
+ e->_field10 = Math::deg2rad<double>(2.0);
e->_field14 = 0.01178125;
++e;
@@ -123,7 +123,7 @@ bool CStarCloseup::setup2(int val1, int val2) {
e->_pixel3 = 0;
e->_field8 = g_vm->getRandomNumber(3) + 3;
e->_fieldC = g_vm->getRandomNumber(255);
- e->_field10 = Common::deg2rad<double>(1.0);
+ e->_field10 = Math::deg2rad<double>(1.0);
e->_field14 = 0.24791406;
++e;
@@ -133,7 +133,7 @@ bool CStarCloseup::setup2(int val1, int val2) {
e->_pixel3 = 0xe6;
e->_field8 = g_vm->getRandomNumber(3) + 3;
e->_fieldC = g_vm->getRandomNumber(255);
- e->_field10 = Common::deg2rad<double>(3.0);
+ e->_field10 = Math::deg2rad<double>(3.0);
e->_field14 = 0.20832032;
++e;
@@ -143,7 +143,7 @@ bool CStarCloseup::setup2(int val1, int val2) {
e->_pixel3 = 0x28;
e->_field8 = g_vm->getRandomNumber(3) + 3;
e->_fieldC = g_vm->getRandomNumber(255);
- e->_field10 = Common::deg2rad<double>(1.0);
+ e->_field10 = Math::deg2rad<double>(1.0);
e->_field14 = 0.088164061;
++e;
@@ -153,7 +153,7 @@ bool CStarCloseup::setup2(int val1, int val2) {
e->_pixel3 = 0xf0;
e->_field8 = g_vm->getRandomNumber(3) + 3;
e->_fieldC = g_vm->getRandomNumber(255);
- e->_field10 = Common::deg2rad<double>(2.0);
+ e->_field10 = Math::deg2rad<double>(2.0);
e->_field14 = 0.084375001;
++e;
@@ -163,7 +163,7 @@ bool CStarCloseup::setup2(int val1, int val2) {
e->_pixel3 = 0x20;
e->_field8 = g_vm->getRandomNumber(3) + 3;
e->_fieldC = g_vm->getRandomNumber(255);
- e->_field10 = Common::deg2rad<double>(17.0);
+ e->_field10 = Math::deg2rad<double>(17.0);
e->_field14 = 1 / 256.0;
} else {
for (int ctr = 0; ctr < 5; ++ctr) {
@@ -175,7 +175,7 @@ bool CStarCloseup::setup2(int val1, int val2) {
e->_pixel3 = (val >> 16) & 0xff;
e->_field8 = g_vm->getRandomNumber(3) + 3;
e->_fieldC = g_vm->getRandomNumber(255);
- e->_field10 = Common::deg2rad<double>((double)g_vm->getRandomNumber(15));
+ e->_field10 = Math::deg2rad<double>((double)g_vm->getRandomNumber(15));
e->_field14 = ((float)g_vm->getRandomNumber(0xfffffffe)
* 50.0 / 65536.0) / 256.0;
}
@@ -509,12 +509,12 @@ bool CStarCloseup::setupEntry(int width, int height, int index, float val) {
for (ctr = height - 2, idx = 1, yVal = vy; ctr > 0; --ctr, yVal += vy) {
degrees = 0.0;
- cosVal = cos(Common::deg2rad<float>(yVal));
- sinVal = sin(Common::deg2rad<float>(yVal));
+ cosVal = cos(Math::deg2rad<float>(yVal));
+ sinVal = sin(Math::deg2rad<float>(yVal));
if (width > 0) {
for (int xCtr = 0; xCtr < width; ++xCtr, ++idx, degrees += vx) {
- angle = Common::deg2rad<float>(degrees);
+ angle = Math::deg2rad<float>(degrees);
FVector &tempV = entry._data2[idx];
tempV._x = sin(angle) * sinVal * val;
diff --git a/engines/titanic/star_control/viewport.cpp b/engines/titanic/star_control/viewport.cpp
index 126b3db8e1d..3cceb085b9a 100644
--- a/engines/titanic/star_control/viewport.cpp
+++ b/engines/titanic/star_control/viewport.cpp
@@ -25,7 +25,7 @@
#include "titanic/support/simple_file.h"
#include "titanic/titanic.h"
-#include "common/math.h"
+#include "math/utils.h"
namespace Titanic {
@@ -297,8 +297,8 @@ void CViewport::reset() {
_center = FPoint((double)_width * 0.5, (double)_height * 0.5);
_centerVector._x = MIN(_center._x, _center._y);
- _centerVector._y = tan(Common::deg2rad<double>(_centerYAngleDegrees));
- _centerVector._z = tan(Common::deg2rad<double>(_centerZAngleDegrees));
+ _centerVector._y = tan(Math::deg2rad<double>(_centerYAngleDegrees));
+ _centerVector._z = tan(Math::deg2rad<double>(_centerZAngleDegrees));
}
const FMatrix &CViewport::getOrientation() const {
diff --git a/engines/tsage/ringworld2/ringworld2_scenes1.cpp b/engines/tsage/ringworld2/ringworld2_scenes1.cpp
index d361eaa38ea..037186bdf32 100644
--- a/engines/tsage/ringworld2/ringworld2_scenes1.cpp
+++ b/engines/tsage/ringworld2/ringworld2_scenes1.cpp
@@ -19,8 +19,8 @@
*
*/
-#include "common/math.h"
#include "graphics/cursorman.h"
+#include "math/utils.h"
#include "tsage/scenes.h"
#include "tsage/dialogs.h"
@@ -3910,8 +3910,8 @@ void Scene1575::postInit(SceneObjectList *OwnerList) {
_arrActor[i].postInit();
_arrActor[i].setup(1575, 2, k5A7F6[3 * i + 2]);
- double v1 = Common::hypotenuse<double>(2.0, 3 - k5A7F6[3 * i]);
- v1 += Common::hypotenuse<double>(2.0, 3 - k5A7F6[3 * i + 1]);
+ double v1 = Math::hypotenuse<double>(2.0, 3 - k5A7F6[3 * i]);
+ v1 += Math::hypotenuse<double>(2.0, 3 - k5A7F6[3 * i + 1]);
int yp = (int)(sqrt(v1) * 75.0 / 17.0 - 161.0);
int angle = R2_GLOBALS._gfxManagerInstance.getAngle(
diff --git a/engines/twp/lighting.cpp b/engines/twp/lighting.cpp
index 59f700d5c72..691700ddd57 100644
--- a/engines/twp/lighting.cpp
+++ b/engines/twp/lighting.cpp
@@ -19,7 +19,7 @@
*
*/
-#include "common/math.h"
+#include "math/utils.h"
#include "twp/lighting.h"
#include "twp/room.h"
#include "twp/twp.h"
@@ -208,9 +208,9 @@ void Lighting::update(const Lights &lights) {
u_lightPos[u_numberLights * 3 + 0] = light.pos.getX();
u_lightPos[u_numberLights * 3 + 1] = light.pos.getY();
u_lightPos[u_numberLights * 3 + 2] = 1.f;
- u_coneDirection[u_numberLights * 2 + 0] = cos(Common::deg2rad(direction));
- u_coneDirection[u_numberLights * 2 + 1] = sin(Common::deg2rad(direction));
- u_coneCosineHalfConeAngle[u_numberLights] = cos(Common::deg2rad(light.coneAngle / 2.f));
+ u_coneDirection[u_numberLights * 2 + 0] = cos(Math::deg2rad(direction));
+ u_coneDirection[u_numberLights * 2 + 1] = sin(Math::deg2rad(direction));
+ u_coneCosineHalfConeAngle[u_numberLights] = cos(Math::deg2rad(light.coneAngle / 2.f));
u_coneFalloff[u_numberLights] = light.coneFalloff;
u_lightColor[u_numberLights * 3 + 0] = light.color.rgba.r;
u_lightColor[u_numberLights * 3 + 1] = light.color.rgba.g;
diff --git a/engines/ultima/ultima8/misc/direction_util.h b/engines/ultima/ultima8/misc/direction_util.h
index ec230a3cb8d..90c2aeeee69 100644
--- a/engines/ultima/ultima8/misc/direction_util.h
+++ b/engines/ultima/ultima8/misc/direction_util.h
@@ -24,7 +24,7 @@
#include "ultima/ultima8/misc/direction.h"
#include "ultima/ultima8/ultima8.h"
-#include "common/math.h"
+#include "math/utils.h"
namespace Ultima {
namespace Ultima8 {
@@ -97,7 +97,7 @@ inline Direction Direction_Get(int deltay, int deltax, DirectionMode dirmode) {
return dydx >= -424 ? dir_southwest : dydx >= -2472 ? dir_west
: dir_northwest;
} else {
- double angle = Common::rad2deg(atan2(deltay, deltax));
+ double angle = Math::rad2deg(atan2(deltay, deltax));
if (angle < -168.75) return dir_southwest;
else if (angle < -146.25) return dir_ssw;
else if (angle < -123.75) return dir_south;
@@ -138,7 +138,7 @@ inline Direction Direction_GetWorldDir(int deltay, int deltax, DirectionMode dir
else // south-west
return dydx >= -424 ? dir_west : dydx >= -2472 ? dir_southwest : dir_south;
} else {
- double angle = Common::rad2deg(atan2(deltay, deltax));
+ double angle = Math::rad2deg(atan2(deltay, deltax));
if (angle < -168.75) return dir_west;
else if (angle < -146.25) return dir_wnw;
else if (angle < -123.75) return dir_northwest;
diff --git a/engines/ultima/ultima8/world/crosshair_process.cpp b/engines/ultima/ultima8/world/crosshair_process.cpp
index a2f292188cf..29632919062 100644
--- a/engines/ultima/ultima8/world/crosshair_process.cpp
+++ b/engines/ultima/ultima8/world/crosshair_process.cpp
@@ -29,7 +29,7 @@
#include "ultima/ultima8/world/get_object.h"
#include "ultima/ultima8/ultima8.h"
-#include "common/math.h"
+#include "math/utils.h"
namespace Ultima {
namespace Ultima8 {
@@ -73,7 +73,7 @@ void CrosshairProcess::run() {
return;
}
// Convert angle to 0~2pi
- double rads = Common::deg2rad(angle);
+ double rads = Math::deg2rad(angle);
float xoff = CROSSHAIR_DIST * cos(rads);
float yoff = CROSSHAIR_DIST * sin(rads);
pt.x -= static_cast<int32>(xoff);
diff --git a/engines/vcruise/runtime.cpp b/engines/vcruise/runtime.cpp
index f1fad9b84c1..846fb04a06e 100644
--- a/engines/vcruise/runtime.cpp
+++ b/engines/vcruise/runtime.cpp
@@ -25,7 +25,6 @@
#include "common/endian.h"
#include "common/events.h"
#include "common/file.h"
-#include "common/math.h"
#include "common/ptr.h"
#include "common/random.h"
#include "common/savefile.h"
@@ -44,6 +43,8 @@
#include "image/bmp.h"
#include "image/icocur.h"
+#include "math/utils.h"
+
#include "audio/decoders/wave.h"
#include "audio/decoders/vorbis.h"
@@ -5131,7 +5132,7 @@ bool Runtime::computeEffectiveVolumeAndBalance(SoundInstance &snd) {
uint effectiveVolume = applyVolumeScale(snd.volume);
int32 effectiveBalance = applyBalanceScale(snd.balance);
- double radians = Common::deg2rad<double>(_listenerAngle);
+ double radians = Math::deg2rad<double>(_listenerAngle);
int32 cosAngle = static_cast<int32>(cos(radians) * (1 << 15));
int32 sinAngle = static_cast<int32>(sin(radians) * (1 << 15));
diff --git a/engines/wintermute/ad/ad_actor_3dx.cpp b/engines/wintermute/ad/ad_actor_3dx.cpp
index 32d900c8c2e..45000826419 100644
--- a/engines/wintermute/ad/ad_actor_3dx.cpp
+++ b/engines/wintermute/ad/ad_actor_3dx.cpp
@@ -25,8 +25,8 @@
* Copyright (c) 2003-2013 Jan Nedoma and contributors
*/
-#include "common/math.h"
#include "common/util.h"
+#include "math/utils.h"
#include "engines/wintermute/ad/ad_actor_3dx.h"
#include "engines/wintermute/ad/ad_attach_3dx.h"
@@ -665,9 +665,9 @@ void AdActor3DX::initLine3D(Math::Vector3d startPt, Math::Vector3d endPt, bool f
// wme subtracted 90 dregrees from the angle, so that the angle zero points downwards
// and the angle 90 goes left
// now we have a right handed coordinate system, so we add 90 degrees instead
- turnTo(Common::rad2deg(-atan2(endPt.z() - startPt.z(), endPt.x() - startPt.x())) + 90);
+ turnTo(Math::rad2deg(-atan2(endPt.z() - startPt.z(), endPt.x() - startPt.x())) + 90);
} else {
- _turningLeft = prepareTurn(Common::rad2deg(-atan2(endPt.z() - startPt.z(), endPt.x() - startPt.x())) + 90);
+ _turningLeft = prepareTurn(Math::rad2deg(-atan2(endPt.z() - startPt.z(), endPt.x() - startPt.x())) + 90);
}
}
@@ -1647,7 +1647,7 @@ bool AdActor3DX::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta
BaseObject *obj = (BaseObject *)val->getNative();
Math::Vector3d objPos;
((AdGame *)_gameRef)->_scene->_sceneGeometry->convert2Dto3D(obj->_posX, obj->_posY, &objPos);
- angle = Common::rad2deg(-atan2(objPos.z() - _posVector.z(), objPos.x() - _posVector.x())) + 90;
+ angle = Math::rad2deg(-atan2(objPos.z() - _posVector.z(), objPos.x() - _posVector.x())) + 90;
} else {
// otherwise turn to direction
dir = val->getInt();
diff --git a/engines/wintermute/ad/ad_scene_geometry.cpp b/engines/wintermute/ad/ad_scene_geometry.cpp
index 92f45ff7e8e..14834d359d4 100644
--- a/engines/wintermute/ad/ad_scene_geometry.cpp
+++ b/engines/wintermute/ad/ad_scene_geometry.cpp
@@ -25,7 +25,6 @@
* Copyright (c) 2003-2013 Jan Nedoma and contributors
*/
-#include "common/math.h"
#include "common/util.h"
#include "engines/wintermute/ad/ad_block.h"
diff --git a/engines/wintermute/base/particles/part_emitter.cpp b/engines/wintermute/base/particles/part_emitter.cpp
index a82b1e4ca27..dde9ebc6bd7 100644
--- a/engines/wintermute/base/particles/part_emitter.cpp
+++ b/engines/wintermute/base/particles/part_emitter.cpp
@@ -38,7 +38,7 @@
#include "engines/wintermute/base/gfx/base_renderer.h"
#include "engines/wintermute/utils/utils.h"
#include "common/str.h"
-#include "common/math.h"
+#include "math/utils.h"
namespace Wintermute {
@@ -214,7 +214,7 @@ bool PartEmitter::initParticle(PartParticle *particle, uint32 currentTime, uint3
Vector2 vecVel(0, velocity);
Matrix4 matRot;
- float radZrot = Common::deg2rad<float>(BaseUtils::normalizeAngle(angle - 180.0));
+ float radZrot = Math::deg2rad<float>(BaseUtils::normalizeAngle(angle - 180.0));
matRot.rotationZ(radZrot);
matRot.transformVector2(vecVel);
@@ -432,7 +432,7 @@ bool PartEmitter::addForce(const Common::String &name, PartForce::TForceType typ
force->_direction = Vector2(0, strength);
Matrix4 matRot;
- float radZrot = Common::deg2rad<float>(BaseUtils::normalizeAngle(angle - 180.0));
+ float radZrot = Math::deg2rad<float>(BaseUtils::normalizeAngle(angle - 180.0));
matRot.rotationZ(radZrot);
matRot.transformVector2(force->_direction);
diff --git a/engines/wintermute/base/scriptables/script_ext_math.cpp b/engines/wintermute/base/scriptables/script_ext_math.cpp
index 1be98d1d267..afbed34bdd5 100644
--- a/engines/wintermute/base/scriptables/script_ext_math.cpp
+++ b/engines/wintermute/base/scriptables/script_ext_math.cpp
@@ -29,7 +29,7 @@
#include "engines/wintermute/base/scriptables/script_stack.h"
#include "engines/wintermute/base/scriptables/script_value.h"
#include "engines/wintermute/persistent.h"
-#include "common/math.h"
+#include "math/utils.h"
namespace Wintermute {
@@ -119,7 +119,7 @@ bool SXMath::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "Cos") == 0) {
stack->correctParams(1);
- stack->pushFloat(cos(Common::deg2rad<double>(stack->pop()->getFloat())));
+ stack->pushFloat(cos(Math::deg2rad<double>(stack->pop()->getFloat())));
return STATUS_OK;
}
@@ -128,7 +128,7 @@ bool SXMath::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "Cosh") == 0) {
stack->correctParams(1);
- stack->pushFloat(cosh(Common::deg2rad<double>(stack->pop()->getFloat())));
+ stack->pushFloat(cosh(Math::deg2rad<double>(stack->pop()->getFloat())));
return STATUS_OK;
}
@@ -185,7 +185,7 @@ bool SXMath::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "Sin") == 0) {
stack->correctParams(1);
- stack->pushFloat(sin(Common::deg2rad<double>(stack->pop()->getFloat())));
+ stack->pushFloat(sin(Math::deg2rad<double>(stack->pop()->getFloat())));
return STATUS_OK;
}
@@ -194,7 +194,7 @@ bool SXMath::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "Sinh") == 0) {
stack->correctParams(1);
- stack->pushFloat(sinh(Common::deg2rad<double>(stack->pop()->getFloat())));
+ stack->pushFloat(sinh(Math::deg2rad<double>(stack->pop()->getFloat())));
return STATUS_OK;
}
@@ -203,7 +203,7 @@ bool SXMath::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "Tan") == 0) {
stack->correctParams(1);
- stack->pushFloat(tan(Common::deg2rad<double>(stack->pop()->getFloat())));
+ stack->pushFloat(tan(Math::deg2rad<double>(stack->pop()->getFloat())));
return STATUS_OK;
}
@@ -212,7 +212,7 @@ bool SXMath::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "Tanh") == 0) {
stack->correctParams(1);
- stack->pushFloat(tanh(Common::deg2rad<double>(stack->pop()->getFloat())));
+ stack->pushFloat(tanh(Math::deg2rad<double>(stack->pop()->getFloat())));
return STATUS_OK;
}
@@ -230,7 +230,7 @@ bool SXMath::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "DegToRad") == 0) {
stack->correctParams(1);
- stack->pushFloat(Common::deg2rad<double>(stack->pop()->getFloat()));
+ stack->pushFloat(Math::deg2rad<double>(stack->pop()->getFloat()));
return STATUS_OK;
}
@@ -239,7 +239,7 @@ bool SXMath::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "RadToDeg") == 0) {
stack->correctParams(1);
- stack->pushFloat(Common::rad2deg<double>(stack->pop()->getFloat()));
+ stack->pushFloat(Math::rad2deg<double>(stack->pop()->getFloat()));
return STATUS_OK;
} else {
return STATUS_FAILED;
diff --git a/engines/zvision/graphics/render_table.cpp b/engines/zvision/graphics/render_table.cpp
index ffe5c2451db..93cef5f7e9a 100644
--- a/engines/zvision/graphics/render_table.cpp
+++ b/engines/zvision/graphics/render_table.cpp
@@ -21,9 +21,9 @@
#include "zvision/graphics/render_table.h"
-#include "common/math.h"
#include "common/rect.h"
#include "common/scummsys.h"
+#include "math/utils.h"
namespace ZVision {
@@ -154,7 +154,7 @@ void RenderTable::generatePanoramaLookupTable() {
float halfWidth = (float)_numColumns / 2.0f;
float halfHeight = (float)_numRows / 2.0f;
- float fovInRadians = Common::deg2rad<float>(_panoramaOptions.fieldOfView);
+ float fovInRadians = Math::deg2rad<float>(_panoramaOptions.fieldOfView);
float cylinderRadius = halfHeight / tan(fovInRadians);
for (uint x = 0; x < _numColumns; ++x) {
@@ -186,7 +186,7 @@ void RenderTable::generateTiltLookupTable() {
float halfWidth = (float)_numColumns / 2.0f;
float halfHeight = (float)_numRows / 2.0f;
- float fovInRadians = Common::deg2rad<float>(_tiltOptions.fieldOfView);
+ float fovInRadians = Math::deg2rad<float>(_tiltOptions.fieldOfView);
float cylinderRadius = halfWidth / tan(fovInRadians);
_tiltOptions.gap = cylinderRadius * atan2((float)(halfHeight / cylinderRadius), 1.0f) * _tiltOptions.linearScale;
diff --git a/graphics/blit/blit-scale.cpp b/graphics/blit/blit-scale.cpp
index 45e7223d2f9..cb2d66f0fb4 100644
--- a/graphics/blit/blit-scale.cpp
+++ b/graphics/blit/blit-scale.cpp
@@ -28,8 +28,8 @@
#include "graphics/pixelformat.h"
#include "graphics/transform_struct.h"
-#include "common/math.h"
#include "common/rect.h"
+#include "math/utils.h"
namespace Graphics {
@@ -306,7 +306,7 @@ void rotoscaleBlitLogic(byte *dst, const byte *src,
}
uint32 invAngle = 360 - (transform._angle % 360);
- float invAngleRad = Common::deg2rad<uint32,float>(invAngle);
+ float invAngleRad = Math::deg2rad<uint32,float>(invAngle);
float invCos = cos(invAngleRad);
float invSin = sin(invAngleRad);
diff --git a/graphics/tinygl/zdirtyrect.cpp b/graphics/tinygl/zdirtyrect.cpp
index 145c1b704af..89b48dc21c4 100644
--- a/graphics/tinygl/zdirtyrect.cpp
+++ b/graphics/tinygl/zdirtyrect.cpp
@@ -24,7 +24,6 @@
#include "graphics/tinygl/gl.h"
#include "common/debug.h"
-#include "common/math.h"
namespace TinyGL {
diff --git a/graphics/transform_tools.cpp b/graphics/transform_tools.cpp
index aedb0b72103..34a58528249 100644
--- a/graphics/transform_tools.cpp
+++ b/graphics/transform_tools.cpp
@@ -21,13 +21,13 @@
#include "graphics/transform_tools.h"
-#include "common/math.h"
+#include "math/utils.h"
#include <math.h>
namespace Graphics {
FloatPoint TransformTools::transformPoint(FloatPoint point, const float rotate, const Common::Point &zoom, const bool mirrorX, const bool mirrorY) {
- float rotateRad = Common::deg2rad<float>(rotate);
+ float rotateRad = Math::deg2rad<float>(rotate);
float x = point.x;
float y = point.y;
x = (x * zoom.x) / kDefaultZoomX;
diff --git a/math/angle.cpp b/math/angle.cpp
index d2eff046f56..60cc7e370f5 100644
--- a/math/angle.cpp
+++ b/math/angle.cpp
@@ -20,9 +20,9 @@
*/
#include "common/streamdebug.h"
-#include "common/math.h"
#include "math/angle.h"
+#include "math/utils.h"
namespace Math {
@@ -65,7 +65,7 @@ void Angle::setDegrees(float degrees) {
}
void Angle::setRadians(float radians) {
- _degrees = Common::rad2deg(radians);
+ _degrees = rad2deg(radians);
}
float Angle::getDegrees() const {
@@ -73,7 +73,7 @@ float Angle::getDegrees() const {
}
float Angle::getRadians() const {
- return Common::deg2rad(getDegrees());
+ return deg2rad(getDegrees());
}
float Angle::getDegrees(float low) const {
@@ -90,7 +90,7 @@ float Angle::getDegrees(float low) const {
float Angle::getRadians(float low) const {
float d = getDegrees(low);
- return Common::deg2rad(d);
+ return deg2rad(d);
}
float Angle::getCosine() const {
@@ -142,7 +142,7 @@ Angle &Angle::operator-=(float degrees) {
}
Angle Angle::fromRadians(float radians) {
- return Angle(Common::rad2deg(radians));
+ return Angle(rad2deg(radians));
}
Angle Angle::arcCosine(float x) {
diff --git a/math/quat.cpp b/math/quat.cpp
index 96fa3733f9e..17d27cc5467 100644
--- a/math/quat.cpp
+++ b/math/quat.cpp
@@ -37,8 +37,8 @@
#include "common/streamdebug.h"
-#include "common/math.h"
#include "math/quat.h"
+#include "math/utils.h"
namespace Math {
@@ -208,7 +208,7 @@ Vector3d Quaternion::directionVector(const int col) const {
Angle Quaternion::getAngleBetween(const Quaternion &to) {
Quaternion q = this->inverse() * to;
- Angle diff(Common::rad2deg(2 * acos(q.w())));
+ Angle diff(Math::rad2deg(2 * acos(q.w())));
return diff;
}
diff --git a/math/utils.h b/math/utils.h
index 28d8728c087..9ed89d86a6c 100644
--- a/math/utils.h
+++ b/math/utils.h
@@ -24,6 +24,14 @@
#include "common/scummsys.h"
+#ifndef FLT_MIN
+ #define FLT_MIN 1E-37f
+#endif
+
+#ifndef FLT_MAX
+ #define FLT_MAX 1E+37f
+#endif
+
namespace Math {
/** A complex number. */
@@ -40,6 +48,67 @@ struct Complex {
*/
static const float epsilon = 0.0001f;
+// Round a number towards zero
+// Input and Output type can be different
+template<class InputT, class OutputT>
+inline OutputT trunc(InputT x) {
+ return (x > 0) ? floor(x) : ceil(x);
+}
+
+// Round a number towards zero
+// Input and Output type are the same
+template<class T>
+inline T trunc(T x) {
+ return trunc<T,T>(x);
+}
+
+// Convert radians to degrees
+// Input and Output type can be different
+// Upconvert everything to floats
+template<class InputT, class OutputT>
+inline OutputT rad2deg(InputT rad) {
+ return (OutputT)( (float)rad * (float)57.2957795130823); // 180.0/M_PI = 57.2957795130823
+}
+
+// Handle the case differently when the input type is double
+template<class OutputT>
+inline OutputT rad2deg(double rad) {
+ return (OutputT)( rad * 57.2957795130823);
+}
+
+// Convert radians to degrees
+// Input and Output type are the same
+template<class T>
+inline T rad2deg(T rad) {
+ return rad2deg<T,T>(rad);
+}
+
+// Convert degrees to radians
+// Input and Output type can be different
+// Upconvert everything to floats
+template<class InputT, class OutputT>
+inline OutputT deg2rad(InputT deg) {
+ return (OutputT)( (float)deg * (float)0.0174532925199433); // M_PI/180.0 = 0.0174532925199433
+}
+
+// Handle the case differently when the input type is double
+template<class OutputT>
+inline OutputT deg2rad(double deg) {
+ return (OutputT)( deg * 0.0174532925199433);
+}
+
+// Convert degrees to radians
+// Input and Output type are the same
+template<class T>
+inline T deg2rad(T deg) {
+ return deg2rad<T,T>(deg);
+}
+
+template<class T>
+inline T hypotenuse(T xv, T yv) {
+ return (T)sqrt((double)(xv * xv + yv * yv));
+}
+
inline float square(float x) {
return x * x;
}
diff --git a/test/common/math.h b/test/common/math.h
index 010c6d71aa9..5da0410e8ea 100644
--- a/test/common/math.h
+++ b/test/common/math.h
@@ -2,8 +2,6 @@
#include "common/math.h"
-const float MAX_ERROR_FLT = 1e-7f;
-const double MAX_ERROR_DBL = 1e-15;
class MathTestSuite : public CxxTest::TestSuite
{
public:
@@ -17,30 +15,4 @@ class MathTestSuite : public CxxTest::TestSuite
// Some simple test for 2^10
TS_ASSERT_EQUALS(Common::intLog2(1024), 10);
}
-
- void test_rad2deg() {
- //float verion
- TS_ASSERT_DELTA(Common::rad2deg(0), 0, MAX_ERROR_FLT);
- TS_ASSERT_DELTA(Common::rad2deg(M_PI), 180.0, 180.0 * MAX_ERROR_FLT);
- TS_ASSERT_DELTA(Common::rad2deg(2.0 * M_PI), 360.0, 360.0 * MAX_ERROR_FLT);
- TS_ASSERT_DELTA(Common::rad2deg(M_PI / 2.0), 90.0, 90.0 * MAX_ERROR_FLT);
- //double version
- TS_ASSERT_DELTA(Common::rad2deg<double>(0), 0, MAX_ERROR_DBL);
- TS_ASSERT_DELTA(Common::rad2deg<double>(M_PI), 180.0, 180.0 * MAX_ERROR_DBL);
- TS_ASSERT_DELTA(Common::rad2deg<double>(2.0 * M_PI), 360.0, 360.0 * MAX_ERROR_DBL);
- TS_ASSERT_DELTA(Common::rad2deg<double>(M_PI / 2.0), 90.0, 90.0 * MAX_ERROR_DBL);
- }
-
- void test_deg2rad() {
- //float verion
- TS_ASSERT_DELTA(Common::deg2rad(0), 0, MAX_ERROR_FLT);
- TS_ASSERT_DELTA(Common::deg2rad(180.0), M_PI, M_PI * MAX_ERROR_FLT);
- TS_ASSERT_DELTA(Common::deg2rad(360.0), 2.0 * M_PI, 2.0 * M_PI * MAX_ERROR_FLT);
- TS_ASSERT_DELTA(Common::deg2rad(90.0), M_PI / 2.0, M_PI / 2.0 * MAX_ERROR_FLT);
- //double version
- TS_ASSERT_DELTA(Common::deg2rad<double>(0), 0, MAX_ERROR_DBL);
- TS_ASSERT_DELTA(Common::deg2rad<double>(180.0), M_PI, M_PI * MAX_ERROR_DBL);
- TS_ASSERT_DELTA(Common::deg2rad<double>(360.0), 2.0 * M_PI, 2.0 * M_PI * MAX_ERROR_DBL);
- TS_ASSERT_DELTA(Common::deg2rad<double>(90.0), M_PI / 2.0, M_PI / 2.0 * MAX_ERROR_DBL);
- }
};
diff --git a/test/image/blending.h b/test/image/blending.h
index 0ecc753d3eb..d898223f1d4 100644
--- a/test/image/blending.h
+++ b/test/image/blending.h
@@ -37,7 +37,6 @@
#include "common/endian.h"
#include "common/util.h"
#include "common/rect.h"
-#include "common/math.h"
#include "common/textconsole.h"
#include "graphics/blit.h"
#include "graphics/primitives.h"
diff --git a/test/math/utils.h b/test/math/utils.h
new file mode 100644
index 00000000000..0882d8a1db9
--- /dev/null
+++ b/test/math/utils.h
@@ -0,0 +1,35 @@
+#include <cxxtest/TestSuite.h>
+
+#include "math/utils.h"
+
+const float MAX_ERROR_FLT = 1e-7f;
+const double MAX_ERROR_DBL = 1e-15;
+class MathUtilsTestSuite : public CxxTest::TestSuite
+{
+ public:
+ void test_rad2deg() {
+ //float verion
+ TS_ASSERT_DELTA(Math::rad2deg(0), 0, MAX_ERROR_FLT);
+ TS_ASSERT_DELTA(Math::rad2deg(M_PI), 180.0, 180.0 * MAX_ERROR_FLT);
+ TS_ASSERT_DELTA(Math::rad2deg(2.0 * M_PI), 360.0, 360.0 * MAX_ERROR_FLT);
+ TS_ASSERT_DELTA(Math::rad2deg(M_PI / 2.0), 90.0, 90.0 * MAX_ERROR_FLT);
+ //double version
+ TS_ASSERT_DELTA(Math::rad2deg<double>(0), 0, MAX_ERROR_DBL);
+ TS_ASSERT_DELTA(Math::rad2deg<double>(M_PI), 180.0, 180.0 * MAX_ERROR_DBL);
+ TS_ASSERT_DELTA(Math::rad2deg<double>(2.0 * M_PI), 360.0, 360.0 * MAX_ERROR_DBL);
+ TS_ASSERT_DELTA(Math::rad2deg<double>(M_PI / 2.0), 90.0, 90.0 * MAX_ERROR_DBL);
+ }
+
+ void test_deg2rad() {
+ //float verion
+ TS_ASSERT_DELTA(Math::deg2rad(0), 0, MAX_ERROR_FLT);
+ TS_ASSERT_DELTA(Math::deg2rad(180.0), M_PI, M_PI * MAX_ERROR_FLT);
+ TS_ASSERT_DELTA(Math::deg2rad(360.0), 2.0 * M_PI, 2.0 * M_PI * MAX_ERROR_FLT);
+ TS_ASSERT_DELTA(Math::deg2rad(90.0), M_PI / 2.0, M_PI / 2.0 * MAX_ERROR_FLT);
+ //double version
+ TS_ASSERT_DELTA(Math::deg2rad<double>(0), 0, MAX_ERROR_DBL);
+ TS_ASSERT_DELTA(Math::deg2rad<double>(180.0), M_PI, M_PI * MAX_ERROR_DBL);
+ TS_ASSERT_DELTA(Math::deg2rad<double>(360.0), 2.0 * M_PI, 2.0 * M_PI * MAX_ERROR_DBL);
+ TS_ASSERT_DELTA(Math::deg2rad<double>(90.0), M_PI / 2.0, M_PI / 2.0 * MAX_ERROR_DBL);
+ }
+};
diff --git a/video/mkv/mkvparser.cpp b/video/mkv/mkvparser.cpp
index 71a19cd40a7..94c8fc72cd0 100644
--- a/video/mkv/mkvparser.cpp
+++ b/video/mkv/mkvparser.cpp
@@ -6,9 +6,9 @@
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
-#include "common/math.h"
#include "common/ptr.h"
#include "common/str.h"
+#include "math/utils.h"
#include "video/mkv/mkvparser.h"
#include "video/mkv/webmids.h"
Commit: 421cb1f08728f45e67cc001f2acfccd8deafb1ee
https://github.com/scummvm/scummvm/commit/421cb1f08728f45e67cc001f2acfccd8deafb1ee
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2024-07-27T14:00:48+03:00
Commit Message:
COMMON: Rename common/math.h to common/intrinsics.h
Changed paths:
A common/intrinsics.h
A test/common/intrinsics.h
R common/math.h
R test/common/math.h
audio/decoders/qdm2.cpp
audio/decoders/wma.cpp
engines/asylum/puzzles/pipes.cpp
video/bink_decoder.cpp
diff --git a/audio/decoders/qdm2.cpp b/audio/decoders/qdm2.cpp
index 84370d28737..26bdb02095e 100644
--- a/audio/decoders/qdm2.cpp
+++ b/audio/decoders/qdm2.cpp
@@ -33,7 +33,7 @@
#include "common/array.h"
#include "common/debug.h"
-#include "common/math.h"
+#include "common/intrinsics.h"
#include "common/stream.h"
#include "common/memstream.h"
#include "common/bitstream.h"
diff --git a/audio/decoders/wma.cpp b/audio/decoders/wma.cpp
index 8caa97dd09d..06f5a17e7fd 100644
--- a/audio/decoders/wma.cpp
+++ b/audio/decoders/wma.cpp
@@ -23,7 +23,7 @@
// Largely based on the WMA implementation found in FFmpeg.
#include "common/util.h"
-#include "common/math.h"
+#include "common/intrinsics.h"
#include "common/error.h"
#include "common/memstream.h"
#include "common/compression/huffman.h"
diff --git a/common/math.h b/common/intrinsics.h
similarity index 97%
rename from common/math.h
rename to common/intrinsics.h
index f9b7e9156b0..00e95358a74 100644
--- a/common/math.h
+++ b/common/intrinsics.h
@@ -21,8 +21,8 @@
// Based on eos' math code
-#ifndef COMMON_MATH_H
-#define COMMON_MATH_H
+#ifndef COMMON_INTRINSICS_H
+#define COMMON_INTRINSICS_H
#include "common/scummsys.h"
#ifdef _MSC_VER
@@ -96,4 +96,4 @@ inline int intLog2(uint32 v) {
} // End of namespace Common
-#endif // COMMON_MATH_H
+#endif // COMMON_INTRINSICS_H
diff --git a/engines/asylum/puzzles/pipes.cpp b/engines/asylum/puzzles/pipes.cpp
index 8df08830ac7..d87835835b6 100644
--- a/engines/asylum/puzzles/pipes.cpp
+++ b/engines/asylum/puzzles/pipes.cpp
@@ -19,7 +19,7 @@
*
*/
-#include "common/math.h"
+#include "common/intrinsics.h"
#include "asylum/puzzles/pipes.h"
diff --git a/test/common/math.h b/test/common/intrinsics.h
similarity index 78%
rename from test/common/math.h
rename to test/common/intrinsics.h
index 5da0410e8ea..9d79c101288 100644
--- a/test/common/math.h
+++ b/test/common/intrinsics.h
@@ -1,8 +1,8 @@
#include <cxxtest/TestSuite.h>
-#include "common/math.h"
+#include "common/intrinsics.h"
-class MathTestSuite : public CxxTest::TestSuite
+class IntrinsicsTestSuite : public CxxTest::TestSuite
{
public:
void test_intLog2() {
diff --git a/video/bink_decoder.cpp b/video/bink_decoder.cpp
index 63b761e59e7..2b426a4e810 100644
--- a/video/bink_decoder.cpp
+++ b/video/bink_decoder.cpp
@@ -28,7 +28,7 @@
#include "common/util.h"
#include "common/textconsole.h"
-#include "common/math.h"
+#include "common/intrinsics.h"
#include "common/stream.h"
#include "common/substream.h"
#include "common/file.h"
More information about the Scummvm-git-logs
mailing list