[ioquake3] 08/59: [botlib] Use floating point absolute value rather than truncate to integer

Simon McVittie smcv at debian.org
Wed Sep 21 19:56:58 UTC 2016


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to branch debian/master
in repository ioquake3.

commit 18d6c8fda279907e2d140e03c8f322bc8d1a4762
Author: Thomas Köppe <tkoeppe at google.com>
Date:   Mon Jul 25 18:30:48 2016 +0100

    [botlib] Use floating point absolute value rather than truncate to integer
---
 code/botlib/be_aas_entity.c | 4 ++--
 code/botlib/be_aas_move.c   | 2 +-
 code/botlib/be_aas_reach.c  | 8 ++++----
 code/botlib/be_ai_move.c    | 2 +-
 code/tools/asm/q3asm.c      | 1 +
 5 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/code/botlib/be_aas_entity.c b/code/botlib/be_aas_entity.c
index 02699bd..c78f9e7 100644
--- a/code/botlib/be_aas_entity.c
+++ b/code/botlib/be_aas_entity.c
@@ -390,9 +390,9 @@ int AAS_NearestEntity(vec3_t origin, int modelindex)
 		ent = &aasworld.entities[i];
 		if (ent->i.modelindex != modelindex) continue;
 		VectorSubtract(ent->i.origin, origin, dir);
-		if (abs(dir[0]) < 40)
+		if (fabsf(dir[0]) < 40)
 		{
-			if (abs(dir[1]) < 40)
+			if (fabsf(dir[1]) < 40)
 			{
 				dist = VectorLength(dir);
 				if (dist < bestdist)
diff --git a/code/botlib/be_aas_move.c b/code/botlib/be_aas_move.c
index c42b6cc..9ce95c6 100644
--- a/code/botlib/be_aas_move.c
+++ b/code/botlib/be_aas_move.c
@@ -168,7 +168,7 @@ int AAS_AgainstLadder(vec3_t origin)
 		//get the plane the face is in
 		plane = &aasworld.planes[face->planenum ^ side];
 		//if the origin is pretty close to the plane
-		if (abs(DotProduct(plane->normal, origin) - plane->dist) < 3)
+		if (fabsf(DotProduct(plane->normal, origin) - plane->dist) < 3)
 		{
 			if (AAS_PointInsideFace(abs(facenum), origin, 0.1f)) return qtrue;
 		} //end if
diff --git a/code/botlib/be_aas_reach.c b/code/botlib/be_aas_reach.c
index 379948a..62acd47 100644
--- a/code/botlib/be_aas_reach.c
+++ b/code/botlib/be_aas_reach.c
@@ -2465,8 +2465,8 @@ int AAS_Reachability_Ladder(int area1num, int area2num)
 		VectorMA(area1point, -32, dir, area1point);
 		VectorMA(area2point, 32, dir, area2point);
 		//
-		ladderface1vertical = abs(DotProduct(plane1->normal, up)) < 0.1;
-		ladderface2vertical = abs(DotProduct(plane2->normal, up)) < 0.1;
+		ladderface1vertical = fabsf(DotProduct(plane1->normal, up)) < 0.1;
+		ladderface2vertical = fabsf(DotProduct(plane2->normal, up)) < 0.1;
 		//there's only reachability between vertical ladder faces
 		if (!ladderface1vertical && !ladderface2vertical) return qfalse;
 		//if both vertical ladder faces
@@ -2474,7 +2474,7 @@ int AAS_Reachability_Ladder(int area1num, int area2num)
 					//and the ladder faces do not make a sharp corner
 					&& DotProduct(plane1->normal, plane2->normal) > 0.7
 					//and the shared edge is not too vertical
-					&& abs(DotProduct(sharededgevec, up)) < 0.7)
+					&& fabsf(DotProduct(sharededgevec, up)) < 0.7)
 		{
 			//create a new reachability link
 			lreach = AAS_AllocReachability();
@@ -2599,7 +2599,7 @@ int AAS_Reachability_Ladder(int area1num, int area2num)
 				if (face2->faceflags & FACE_LADDER)
 				{
 					plane2 = &aasworld.planes[face2->planenum];
-					if (abs(DotProduct(plane2->normal, up)) < 0.1) break;
+					if (fabsf(DotProduct(plane2->normal, up)) < 0.1) break;
 				} //end if
 			} //end for
 			//if from another area without vertical ladder faces
diff --git a/code/botlib/be_ai_move.c b/code/botlib/be_ai_move.c
index 0c4de34..42232d6 100644
--- a/code/botlib/be_ai_move.c
+++ b/code/botlib/be_ai_move.c
@@ -2054,7 +2054,7 @@ bot_moveresult_t BotTravel_Elevator(bot_movestate_t *ms, aas_reachability_t *rea
 		botimport.Print(PRT_MESSAGE, "bot on elevator\n");
 #endif //DEBUG_ELEVATOR
 		//if vertically not too far from the end point
-		if (abs(ms->origin[2] - reach->end[2]) < sv_maxbarrier->value)
+		if (fabsf(ms->origin[2] - reach->end[2]) < sv_maxbarrier->value)
 		{
 #ifdef DEBUG_ELEVATOR
 			botimport.Print(PRT_MESSAGE, "bot moving to end\n");
diff --git a/code/tools/asm/q3asm.c b/code/tools/asm/q3asm.c
index 54c6ab1..8be0124 100644
--- a/code/tools/asm/q3asm.c
+++ b/code/tools/asm/q3asm.c
@@ -1644,3 +1644,4 @@ Motivation: not wanting to scrollback for pages to find asm error.
 
 	return errorCount;
 }
+

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/ioquake3.git



More information about the Pkg-games-commits mailing list