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

sev- sev at scummvm.org
Sat Jun 6 13:09:14 UTC 2020


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

Summary:
83c8035fbc MATH: Added hypotenuse() call
b1c5e63de0 JANITORIAL: Whitespace fixes
b53a7db0da ALL: Switch to Common::hypotenuse()


Commit: 83c8035fbcb21aa594f5ec61a7a32e9eec0d3153
    https://github.com/scummvm/scummvm/commit/83c8035fbcb21aa594f5ec61a7a32e9eec0d3153
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-06-06T15:08:17+02:00

Commit Message:
MATH: Added hypotenuse() call

Changed paths:
    common/math.h


diff --git a/common/math.h b/common/math.h
index 2c62fce6d5..d0b4ee60e5 100644
--- a/common/math.h
+++ b/common/math.h
@@ -163,6 +163,11 @@ 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


Commit: b1c5e63de04781b771e4469ccee8ff9c820851fc
    https://github.com/scummvm/scummvm/commit/b1c5e63de04781b771e4469ccee8ff9c820851fc
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-06-06T15:08:33+02:00

Commit Message:
JANITORIAL: Whitespace fixes

Changed paths:
    common/math.h


diff --git a/common/math.h b/common/math.h
index d0b4ee60e5..5c8b82372a 100644
--- a/common/math.h
+++ b/common/math.h
@@ -124,20 +124,20 @@ inline T trunc(T x) {
 // Convert radians to degrees
 // Input and Output type can be different
 // Upconvert everything to floats
-template<class InputT, class OutputT> 
+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> 
+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> 
+template<class T>
 inline T rad2deg(T rad) {
 	return rad2deg<T,T>(rad);
 }
@@ -145,20 +145,20 @@ inline T rad2deg(T rad) {
 // Convert degrees to radians
 // Input and Output type can be different
 // Upconvert everything to floats
-template<class InputT, class OutputT> 
+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> 
+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> 
+template<class T>
 inline T deg2rad(T deg) {
 	return deg2rad<T,T>(deg);
 }


Commit: b53a7db0da0ed4eadbc11077277c931d4ba972fb
    https://github.com/scummvm/scummvm/commit/b53a7db0da0ed4eadbc11077277c931d4ba972fb
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-06-06T15:08:52+02:00

Commit Message:
ALL: Switch to Common::hypotenuse()

Changed paths:
    engines/mads/mads.cpp
    engines/mads/mads.h
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes4.cpp
    engines/pink/objects/walk/walk_mgr.cpp
    engines/sword25/gfx/image/art.cpp
    engines/tsage/ringworld2/ringworld2_scenes1.cpp


diff --git a/engines/mads/mads.cpp b/engines/mads/mads.cpp
index 9b9be0da72..6d1c775a81 100644
--- a/engines/mads/mads.cpp
+++ b/engines/mads/mads.cpp
@@ -178,10 +178,6 @@ int MADSEngine::getRandomNumber(int minNumber, int maxNumber) {
 	return minNumber + _randomSource.getRandomNumber(range);
 }
 
-int MADSEngine::hypotenuse(int xv, int yv) {
-	return (int)sqrt((double)(xv * xv + yv * yv));
-}
-
 bool MADSEngine::canLoadGameStateCurrently() {
 	return !_game->_winStatus && !_game->globals()[5]
 		&& _dialogs->_pendingDialog == DIALOG_NONE
diff --git a/engines/mads/mads.h b/engines/mads/mads.h
index c6eb59f2bd..4b98af1836 100644
--- a/engines/mads/mads.h
+++ b/engines/mads/mads.h
@@ -124,7 +124,6 @@ public:
 
 	int getRandomNumber(int maxNumber);
 	int getRandomNumber(int minNumber, int maxNumber);
-	int hypotenuse(int xv, int yv);
 
 	/**
 	* Returns true if it is currently okay to restore a game
diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index afa9533981..1c0bb48357 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "common/scummsys.h"
+#include "common/math.h"
 #include "mads/mads.h"
 #include "mads/scene.h"
 #include "mads/nebular/nebular_scenes.h"
@@ -1375,14 +1376,14 @@ void Scene103::step() {
 
 	case 72: {
 		Common::Point pt = _vm->_game->_player._playerPos;
-		int dist = _vm->hypotenuse(pt.x - 58, pt.y - 93);
+		int dist = Common::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 = _vm->hypotenuse(pt.x - 266, pt.y - 81);
+		int dist = Common::hypotenuse(pt.x - 266, pt.y - 81);
 		_vm->_sound->command(27, (dist * -127 / 378) + 127);
 		}
 		break;
@@ -1393,15 +1394,15 @@ void Scene103::step() {
 
 	if (_scene->_frameStartTime >= _updateClock) {
 		Common::Point pt = _vm->_game->_player._playerPos;
-		int dist = _vm->hypotenuse(pt.x - 79, pt.y - 137);
+		int dist = Common::hypotenuse(pt.x - 79, pt.y - 137);
 		_vm->_sound->command(29, (dist * -127 / 378) + 127);
 
 		pt = _vm->_game->_player._playerPos;
-		dist = _vm->hypotenuse(pt.x - 69, pt.y - 80);
+		dist = Common::hypotenuse(pt.x - 69, pt.y - 80);
 		_vm->_sound->command(30, (dist * -127 / 378) + 127);
 
 		pt = _vm->_game->_player._playerPos;
-		dist = _vm->hypotenuse(pt.x - 266, pt.y - 138);
+		dist = Common::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 7fdb3302cb..b6ac5a901a 100644
--- a/engines/mads/nebular/nebular_scenes4.cpp
+++ b/engines/mads/nebular/nebular_scenes4.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "common/scummsys.h"
+#include "common/math.h"
 #include "mads/mads.h"
 #include "mads/scene.h"
 #include "mads/nebular/nebular_scenes.h"
@@ -149,7 +150,7 @@ void Scene401::step() {
 	}
 
 	if (_scene->_frameStartTime >= _timer) {
-		int dist = 64 - ((_vm->hypotenuse(_game._player._playerPos.x - 219, _game._player._playerPos.y - 115) * 64) / 120);
+		int dist = 64 - ((Common::hypotenuse(_game._player._playerPos.x - 219, _game._player._playerPos.y - 115) * 64) / 120);
 
 		if (dist > 64)
 			dist = 64;
diff --git a/engines/pink/objects/walk/walk_mgr.cpp b/engines/pink/objects/walk/walk_mgr.cpp
index 6aa1fddbb8..5f0b487f16 100644
--- a/engines/pink/objects/walk/walk_mgr.cpp
+++ b/engines/pink/objects/walk/walk_mgr.cpp
@@ -20,6 +20,8 @@
  *
  */
 
+#include "common/math.h"
+
 #include "pink/archive.h"
 #include "pink/cel_decoder.h"
 #include "pink/pink.h"
@@ -110,7 +112,7 @@ WalkAction *WalkMgr::getWalkAction() {
 double WalkMgr::getLengthBetweenLocations(WalkLocation *first, WalkLocation *second) {
 	Coordinates firstCoord = getLocationCoordinates(first->getName());
 	Coordinates secondCoord = getLocationCoordinates(second->getName());
-	return hypot(secondCoord.point.x - firstCoord.point.x, secondCoord.point.y - firstCoord.point.y);
+	return Common::hypotenuse(secondCoord.point.x - firstCoord.point.x, secondCoord.point.y - firstCoord.point.y);
 }
 
 Coordinates WalkMgr::getLocationCoordinates(const Common::String &locationName) {
diff --git a/engines/sword25/gfx/image/art.cpp b/engines/sword25/gfx/image/art.cpp
index 4296ec6fdb..3299e363a3 100644
--- a/engines/sword25/gfx/image/art.cpp
+++ b/engines/sword25/gfx/image/art.cpp
@@ -31,6 +31,7 @@
 
 /* Various utility functions RLL finds useful. */
 
+#include "common/math.h"
 #include "common/textconsole.h"
 
 #include "sword25/gfx/image/art.h"
@@ -365,8 +366,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 (!(hypot(x1 - x0, y1 - y0) < 0.001
-		        && hypot(x2 - x0, y2 - y0) < 0.001))
+		if (!(Common::hypotenuse(x1 - x0, y1 - y0) < 0.001
+		        && Common::hypotenuse(x2 - x0, y2 - y0) < 0.001))
 			subDivide = true;
 	} else {
 		/* we can avoid subdivision if:
diff --git a/engines/tsage/ringworld2/ringworld2_scenes1.cpp b/engines/tsage/ringworld2/ringworld2_scenes1.cpp
index 8b6e413ab0..832c375c43 100644
--- a/engines/tsage/ringworld2/ringworld2_scenes1.cpp
+++ b/engines/tsage/ringworld2/ringworld2_scenes1.cpp
@@ -20,6 +20,7 @@
  *
  */
 
+#include "common/math.h"
 #include "graphics/cursorman.h"
 
 #include "tsage/scenes.h"
@@ -3885,10 +3886,6 @@ void Scene1575::synchronize(Serializer &s) {
 	s.syncAsSint16LE(_field41A);
 }
 
-double hypotenuse(double v1, double v2) {
-	return sqrt(v1 * v1 + v2 * v2);
-}
-
 void Scene1575::postInit(SceneObjectList *OwnerList) {
 	loadScene(1575);
 	R2_GLOBALS._uiElements._active = false;
@@ -3914,8 +3911,8 @@ void Scene1575::postInit(SceneObjectList *OwnerList) {
 		_arrActor[i].postInit();
 		_arrActor[i].setup(1575, 2, k5A7F6[3 * i + 2]);
 
-		double v1 = hypotenuse(2.0, 3 - k5A7F6[3 * i]);
-		v1 += hypotenuse(2.0, 3 - k5A7F6[3 * i + 1]);
+		double v1 = Common::hypotenuse<double>(2.0, 3 - k5A7F6[3 * i]);
+		v1 += Common::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(




More information about the Scummvm-git-logs mailing list