[Scummvm-git-logs] scummvm master -> 81f78d4ddf2bee6164dd9cb90657d0666688603d

bluegr bluegr at gmail.com
Sun Aug 26 14:33:48 CEST 2018


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:
6af0c77b5a SWORD25: Remove use of C99 sqrtf
81f78d4ddf BLADERUNNER: Remove use of C99 math


Commit: 6af0c77b5a8fb9176870b287e0eb18c99c82c102
    https://github.com/scummvm/scummvm/commit/6af0c77b5a8fb9176870b287e0eb18c99c82c102
Author: Colin Snover (github.com at zetafleet.com)
Date: 2018-08-26T15:33:44+03:00

Commit Message:
SWORD25: Remove use of C99 sqrtf

C++ sqrt is overloaded so operates using single-precision when
receiving a float input. The C standard library on FreeMiNT does
not fully support C99 math so use of sqrtf instead of sqrt(float)
does not work.

Changed paths:
    engines/sword25/math/vertex.h


diff --git a/engines/sword25/math/vertex.h b/engines/sword25/math/vertex.h
index 574ce39..537742b 100644
--- a/engines/sword25/math/vertex.h
+++ b/engines/sword25/math/vertex.h
@@ -45,10 +45,6 @@
 
 struct lua_State;
 
-#if defined(MACOSX) || defined(SOLARIS) || defined(__MINGW32__)
-#define sqrtf(x)	((float)sqrt(x))
-#endif
-
 namespace Sword25 {
 
 /**
@@ -67,7 +63,7 @@ public:
 	 * @remark              If only distances should be compared, sqrDist() should be used, since it is faster.
 	 */
 	inline int distance(const Vertex &vertex) const {
-		return (int)(sqrtf(static_cast<float>(sqrDist(vertex))) + 0.5);
+		return (int)(sqrt(static_cast<float>(sqrDist(vertex))) + 0.5);
 	}
 
 	static Vertex &luaVertexToVertex(lua_State *L, int StackIndex, Vertex &vertex);


Commit: 81f78d4ddf2bee6164dd9cb90657d0666688603d
    https://github.com/scummvm/scummvm/commit/81f78d4ddf2bee6164dd9cb90657d0666688603d
Author: Colin Snover (github.com at zetafleet.com)
Date: 2018-08-26T15:33:44+03:00

Commit Message:
BLADERUNNER: Remove use of C99 math

C++ math functions are overloaded so operate using single-precision
when receiving a float input. The C standard library on FreeMiNT
does not fully support C99 math so use of sqrtf, sinf, etc.
instead of the C++ API does not work.

Changed paths:
    engines/bladerunner/script/ai/leon.cpp
    engines/bladerunner/script/ai/maggie.cpp
    engines/bladerunner/script/script.cpp
    engines/bladerunner/slice_renderer.cpp
    engines/bladerunner/vector.h
    engines/bladerunner/view.cpp
    engines/sword25/math/region.cpp


diff --git a/engines/bladerunner/script/ai/leon.cpp b/engines/bladerunner/script/ai/leon.cpp
index fdcb538..1a42123 100644
--- a/engines/bladerunner/script/ai/leon.cpp
+++ b/engines/bladerunner/script/ai/leon.cpp
@@ -455,7 +455,7 @@ void AIScriptLeon::FledCombat() {}
 float AIScriptLeon::sub_446700(int actorId, float x, float y, float z) {
 	float actorX, actorY, actorZ;
 	Actor_Query_XYZ(actorId, &actorX, &actorY, &actorZ);
-	return sqrtf((z - actorZ) * (z - actorZ) + (y - actorY) * (y - actorY) + (x - actorX) * (x - actorX));
+	return sqrt(static_cast<float>((z - actorZ) * (z - actorZ) + (y - actorY) * (y - actorY) + (x - actorX) * (x - actorX)));
 }
 
 } // End of namespace BladeRunner
diff --git a/engines/bladerunner/script/ai/maggie.cpp b/engines/bladerunner/script/ai/maggie.cpp
index 09631d4..7d56e12 100644
--- a/engines/bladerunner/script/ai/maggie.cpp
+++ b/engines/bladerunner/script/ai/maggie.cpp
@@ -658,7 +658,7 @@ int AIScriptMaggie::sub_44B260() {
 float AIScriptMaggie::sub_44B200(int actorId, float x, float y, float z) {
 	float actorX, actorY, actorZ;
 	Actor_Query_XYZ(actorId, &actorX, &actorY, &actorZ);
-	return sqrtf((z - actorZ) * (z - actorZ) + (y - actorY) * (y - actorY) + (x - actorX) * (x - actorX));
+	return sqrt(static_cast<float>((z - actorZ) * (z - actorZ) + (y - actorY) * (y - actorY) + (x - actorX) * (x - actorX)));
 }
 
 } // End of namespace BladeRunner
diff --git a/engines/bladerunner/script/script.cpp b/engines/bladerunner/script/script.cpp
index 3c68717..92fbc2b 100644
--- a/engines/bladerunner/script/script.cpp
+++ b/engines/bladerunner/script/script.cpp
@@ -358,7 +358,7 @@ int ScriptBase::Actor_Query_Inch_Distance_From_Waypoint(int actorId, int waypoin
 	float distX = actorX - waypointX;
 	float distZ = actorZ - waypointZ;
 
-	return sqrtf(distX * distX + distZ * distZ);
+	return sqrt(distX * distX + distZ * distZ);
 }
 
 bool ScriptBase::Actor_Query_In_Between_Two_Actors(int actorId, int otherActor1Id, int otherActor2Id) {
diff --git a/engines/bladerunner/slice_renderer.cpp b/engines/bladerunner/slice_renderer.cpp
index 31da697..eca7a91 100644
--- a/engines/bladerunner/slice_renderer.cpp
+++ b/engines/bladerunner/slice_renderer.cpp
@@ -118,9 +118,9 @@ Matrix3x2 SliceRenderer::calculateFacingRotationMatrix() {
 	assert(_sliceFramePtr);
 
 	Vector3 viewPos = _view->_sliceViewMatrix * _position;
-	float dir = atan2f(viewPos.x, viewPos.z) + _facing;
-	float s = sinf(dir);
-	float c = cosf(dir);
+	float dir = atan2(viewPos.x, viewPos.z) + _facing;
+	float s = sin(dir);
+	float c = cos(dir);
 
 	Matrix3x2 mRotation(c, -s, 0.0f,
 	                    s,  c, 0.0f);
@@ -488,11 +488,11 @@ void SliceRenderer::drawOnScreen(int animationId, int animationFrame, int screen
 	loadFrame(animationId, animationFrame);
 
 	float frameHeight = _frameSliceHeight * _frameSliceCount;
-	float frameSize = sqrtf(_frameScale.x * 255.0f * _frameScale.x * 255.0f + _frameScale.y * 255.0f * _frameScale.y * 255.0f);
+	float frameSize = sqrt(_frameScale.x * 255.0f * _frameScale.x * 255.0f + _frameScale.y * 255.0f * _frameScale.y * 255.0f);
 	float size = scale / MAX(frameSize, frameHeight);
 
-	float s = sinf(_facing);
-	float c = cosf(_facing);
+	float s = sin(_facing);
+	float c = cos(_facing);
 
 	Matrix3x2 m_rotation(c, -s, 0.0f,
 	                     s,  c, 0.0f);
diff --git a/engines/bladerunner/vector.h b/engines/bladerunner/vector.h
index 706d81f..f6670c2 100644
--- a/engines/bladerunner/vector.h
+++ b/engines/bladerunner/vector.h
@@ -55,7 +55,7 @@ public:
 
 	Vector3(float ax, float ay, float az) : x(ax), y(ay), z(az) {}
 
-	float length() { return sqrtf(x * x + y * y + z * z); }
+	float length() { return sqrt(x * x + y * y + z * z); }
 	Vector3 normalize() {
 		float len = length();
 		if (len == 0) {
diff --git a/engines/bladerunner/view.cpp b/engines/bladerunner/view.cpp
index 72c070e..cb14f51 100644
--- a/engines/bladerunner/view.cpp
+++ b/engines/bladerunner/view.cpp
@@ -51,7 +51,7 @@ void View::setFovX(float fovX) {
 
 	_viewportPosition.x = 320.0f;
 	_viewportPosition.y = 240.0f;
-	_viewportPosition.z = 320.0f / tanf(_fovX / 2.0f);
+	_viewportPosition.z = 320.0f / tan(_fovX / 2.0f);
 }
 
 void View::calculateSliceViewMatrix() {
diff --git a/engines/sword25/math/region.cpp b/engines/sword25/math/region.cpp
index cf422af..788b584 100644
--- a/engines/sword25/math/region.cpp
+++ b/engines/sword25/math/region.cpp
@@ -266,10 +266,10 @@ Vertex Region::findClosestPointOnLine(const Vertex &lineStart, const Vertex &lin
 	float vector1Y = static_cast<float>(point.y - lineStart.y);
 	float vector2X = static_cast<float>(lineEnd.x - lineStart.x);
 	float vector2Y = static_cast<float>(lineEnd.y - lineStart.y);
-	float vector2Length = sqrtf(vector2X * vector2X + vector2Y * vector2Y);
+	float vector2Length = sqrt(vector2X * vector2X + vector2Y * vector2Y);
 	vector2X /= vector2Length;
 	vector2Y /= vector2Length;
-	float distance = sqrtf(static_cast<float>((lineStart.x - lineEnd.x) * (lineStart.x - lineEnd.x) +
+	float distance = sqrt(static_cast<float>((lineStart.x - lineEnd.x) * (lineStart.x - lineEnd.x) +
 	                       (lineStart.y - lineEnd.y) * (lineStart.y - lineEnd.y)));
 	float dot = vector1X * vector2X + vector1Y * vector2Y;
 





More information about the Scummvm-git-logs mailing list