summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/audio/AudioManager.cpp2
-rw-r--r--src/control/PathFind.cpp14
-rw-r--r--src/control/Replay.cpp6
-rw-r--r--src/core/Camera.cpp56
-rw-r--r--src/core/Collision.cpp20
-rw-r--r--src/core/FileLoader.cpp6
-rw-r--r--src/core/General.h24
-rw-r--r--src/core/Pad.cpp22
-rw-r--r--src/core/Radar.cpp20
-rw-r--r--src/core/Streaming.cpp10
-rw-r--r--src/core/common.h1
-rw-r--r--src/entities/Entity.cpp6
-rw-r--r--src/entities/Physical.cpp32
-rw-r--r--src/math/Matrix.h24
-rw-r--r--src/math/Quaternion.h2
-rw-r--r--src/math/Vector.h6
-rw-r--r--src/math/Vector2D.h2
-rw-r--r--src/math/math.cpp6
-rw-r--r--src/math/maths.h12
-rw-r--r--src/peds/Ped.cpp18
-rw-r--r--src/peds/PedIK.cpp4
-rw-r--r--src/render/Clouds.cpp14
-rw-r--r--src/render/Coronas.cpp4
-rw-r--r--src/render/Hud.cpp2
-rw-r--r--src/render/Particle.cpp8
-rw-r--r--src/render/PointLights.cpp14
-rw-r--r--src/render/Sprite.cpp20
-rw-r--r--src/render/Timecycle.cpp4
-rw-r--r--src/skel/win/win.cpp10
-rw-r--r--src/vehicles/Door.cpp8
-rw-r--r--src/vehicles/Vehicle.cpp18
31 files changed, 204 insertions, 191 deletions
diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp
index 9e86aef0..51f45e16 100644
--- a/src/audio/AudioManager.cpp
+++ b/src/audio/AudioManager.cpp
@@ -445,7 +445,7 @@ void
cAudioManager::CalculateDistance(bool *ptr, float dist)
{
if(*ptr == false) {
- m_sQueueSample.m_fDistance = sqrt(dist);
+ m_sQueueSample.m_fDistance = Sqrt(dist);
*ptr = true;
}
}
diff --git a/src/control/PathFind.cpp b/src/control/PathFind.cpp
index f9ce7f35..a92882db 100644
--- a/src/control/PathFind.cpp
+++ b/src/control/PathFind.cpp
@@ -146,8 +146,8 @@ CPathFind::PreparePathData(void)
numExtern++;
if(InfoForTileCars[k].numLeftLanes + InfoForTileCars[k].numRightLanes > numLanes)
numLanes = InfoForTileCars[k].numLeftLanes + InfoForTileCars[k].numRightLanes;
- maxX = max(maxX, fabs(InfoForTileCars[k].x));
- maxY = max(maxY, fabs(InfoForTileCars[k].y));
+ maxX = max(maxX, Abs(InfoForTileCars[k].x));
+ maxY = max(maxY, Abs(InfoForTileCars[k].y));
}else if(InfoForTileCars[k].type == NodeTypeIntern)
numIntern++;
}
@@ -327,10 +327,10 @@ CPathFind::PreparePathDataForType(uint8 type, CTempNode *tempnodes, CPathInfoFor
if(tempnodes[k].linkState != 1)
continue;
dx = tempnodes[k].pos.x - CoorsXFormed.x;
- if(fabs(dx) < nearestDist){
+ if(Abs(dx) < nearestDist){
dy = tempnodes[k].pos.y - CoorsXFormed.y;
- if(fabs(dy) < nearestDist){
- nearestDist = max(fabs(dx), fabs(dy));
+ if(Abs(dy) < nearestDist){
+ nearestDist = max(Abs(dx), Abs(dy));
nearestId = k;
}
}
@@ -369,7 +369,7 @@ CPathFind::PreparePathDataForType(uint8 type, CTempNode *tempnodes, CPathInfoFor
dx = m_pathNodes[tempnodes[nearestId].link1].pos.x - m_pathNodes[tempnodes[nearestId].link2].pos.x;
dy = m_pathNodes[tempnodes[nearestId].link1].pos.y - m_pathNodes[tempnodes[nearestId].link2].pos.y;
tempnodes[nearestId].pos = (tempnodes[nearestId].pos + CoorsXFormed)*0.5f;
- mag = sqrt(dx*dx + dy*dy);
+ mag = Sqrt(dx*dx + dy*dy);
tempnodes[nearestId].dirX = dx/mag;
tempnodes[nearestId].dirY = dy/mag;
// do something when number of lanes doesn't agree
@@ -464,7 +464,7 @@ CPathFind::PreparePathDataForType(uint8 type, CTempNode *tempnodes, CPathInfoFor
posy = (m_pathNodes[i].pos.y + m_pathNodes[j].pos.y)*0.5f;
dx = m_pathNodes[j].pos.x - m_pathNodes[i].pos.x;
dy = m_pathNodes[j].pos.y - m_pathNodes[i].pos.y;
- mag = sqrt(dx*dx + dy*dy);
+ mag = Sqrt(dx*dx + dy*dy);
dx /= mag;
dy /= mag;
if(i < j){
diff --git a/src/control/Replay.cpp b/src/control/Replay.cpp
index 2bdb9dfe..3ce9085f 100644
--- a/src/control/Replay.cpp
+++ b/src/control/Replay.cpp
@@ -1505,9 +1505,9 @@ void CReplay::ProcessLookAroundCam(void)
else
fAlphaAngleLookAroundCam = max(0.1f, min(1.5f, fAlphaAngleLookAroundCam + y_moved));
CVector camera_pt(
- fDistanceLookAroundCam * sin(fBetaAngleLookAroundCam) * cos(fAlphaAngleLookAroundCam),
- fDistanceLookAroundCam * cos(fBetaAngleLookAroundCam) * cos(fAlphaAngleLookAroundCam),
- fDistanceLookAroundCam * sin(fAlphaAngleLookAroundCam)
+ fDistanceLookAroundCam * Sin(fBetaAngleLookAroundCam) * Cos(fAlphaAngleLookAroundCam),
+ fDistanceLookAroundCam * Cos(fBetaAngleLookAroundCam) * Cos(fAlphaAngleLookAroundCam),
+ fDistanceLookAroundCam * Sin(fAlphaAngleLookAroundCam)
);
CVector focus = CVector(CameraFocusX, CameraFocusY, CameraFocusZ);
camera_pt += focus;
diff --git a/src/core/Camera.cpp b/src/core/Camera.cpp
index 4f565897..4e988c15 100644
--- a/src/core/Camera.cpp
+++ b/src/core/Camera.cpp
@@ -170,9 +170,9 @@ WellBufferMe(float Target, float *CurrentValue, float *CurrentSpeed, float MaxSp
float TargetSpeed = Delta * MaxSpeed;
// Add or subtract absolute depending on sign, genius!
// if(TargetSpeed - *CurrentSpeed > 0.0f)
-// *CurrentSpeed += Acceleration * fabs(TargetSpeed - *CurrentSpeed) * CTimer::GetTimeStep();
+// *CurrentSpeed += Acceleration * Abs(TargetSpeed - *CurrentSpeed) * CTimer::GetTimeStep();
// else
-// *CurrentSpeed -= Acceleration * fabs(TargetSpeed - *CurrentSpeed) * CTimer::GetTimeStep();
+// *CurrentSpeed -= Acceleration * Abs(TargetSpeed - *CurrentSpeed) * CTimer::GetTimeStep();
// this is simpler:
*CurrentSpeed += Acceleration * (TargetSpeed - *CurrentSpeed) * CTimer::GetTimeStep();
@@ -249,14 +249,14 @@ CCam::GetPedBetaAngleForClearView(const CVector &Target, float Dist, float BetaO
for(a = 0.0f; a <= PI; a += DEGTORAD(5.0f)){
if(BetaOffset <= 0.0f){
- ToSource = CVector(cos(Beta + BetaOffset + a), sin(Beta + BetaOffset + a), 0.0f)*Dist;
+ ToSource = CVector(Cos(Beta + BetaOffset + a), Sin(Beta + BetaOffset + a), 0.0f)*Dist;
if(!CWorld::ProcessLineOfSight(Target, Target + ToSource,
point, ent, checkBuildings, checkVehicles, checkPeds,
checkObjects, checkDummies, true, true))
return a;
}
if(BetaOffset >= 0.0f){
- ToSource = CVector(cos(Beta + BetaOffset - a), sin(Beta + BetaOffset - a), 0.0f)*Dist;
+ ToSource = CVector(Cos(Beta + BetaOffset - a), Sin(Beta + BetaOffset - a), 0.0f)*Dist;
if(!CWorld::ProcessLineOfSight(Target, Target + ToSource,
point, ent, checkBuildings, checkVehicles, checkPeds,
checkObjects, checkDummies, true, true))
@@ -500,7 +500,7 @@ CCam::Process_FollowPed(const CVector &CameraTarget, float TargetOrientation, fl
CVector PlayerPos = FindPlayerPed()->GetPosition();
float RotationDist = (AngleToGoTo == Center ? CenterDist : LateralDist) * RealGroundDist;
// What's going on here? - AngleToGoTo?
- CVector RotatedSource = PlayerPos + CVector(cos(Beta - AngleToGoTo), sin(Beta - AngleToGoTo), 0.0f) * RotationDist;
+ CVector RotatedSource = PlayerPos + CVector(Cos(Beta - AngleToGoTo), Sin(Beta - AngleToGoTo), 0.0f) * RotationDist;
CColPoint colpoint;
CEntity *entity;
@@ -584,9 +584,9 @@ CCam::Process_FollowPed(const CVector &CameraTarget, float TargetOrientation, fl
float ReqSpeed = DeltaBeta * MaxSpeed;
// Add or subtract absolute depending on sign, genius!
if(ReqSpeed - BetaSpeed > 0.0f)
- BetaSpeed += SpeedStep * fabs(ReqSpeed - BetaSpeed) * CTimer::GetTimeStep();
+ BetaSpeed += SpeedStep * Abs(ReqSpeed - BetaSpeed) * CTimer::GetTimeStep();
else
- BetaSpeed -= SpeedStep * fabs(ReqSpeed - BetaSpeed) * CTimer::GetTimeStep();
+ BetaSpeed -= SpeedStep * Abs(ReqSpeed - BetaSpeed) * CTimer::GetTimeStep();
// this would be simpler:
// BetaSpeed += SpeedStep * (ReqSpeed - BetaSpeed) * CTimer::ms_fTimeStep;
@@ -604,14 +604,14 @@ CCam::Process_FollowPed(const CVector &CameraTarget, float TargetOrientation, fl
BetaSpeed = 0.0f;
}
- Source.x = TargetCoors.x + Distance * cos(Beta);
- Source.y = TargetCoors.y + Distance * sin(Beta);
+ Source.x = TargetCoors.x + Distance * Cos(Beta);
+ Source.y = TargetCoors.y + Distance * Sin(Beta);
// Check if we can stop rotating
DeltaBeta = FixedTargetOrientation - Beta;
while(DeltaBeta >= PI) DeltaBeta -= 2*PI;
while(DeltaBeta < -PI) DeltaBeta += 2*PI;
- if(fabs(DeltaBeta) < DEGTORAD(1.0f) && !bBehindPlayerDesired){
+ if(Abs(DeltaBeta) < DEGTORAD(1.0f) && !bBehindPlayerDesired){
// Stop rotation
PickedASide = false;
Rotating = false;
@@ -624,18 +624,18 @@ CCam::Process_FollowPed(const CVector &CameraTarget, float TargetOrientation, fl
HackPlayerOnStoppingTrain || Rotating){
if(TheCamera.m_bCamDirectlyBehind){
Beta = TargetOrientation + PI;
- Source.x = TargetCoors.x + Distance * cos(Beta);
- Source.y = TargetCoors.y + Distance * sin(Beta);
+ Source.x = TargetCoors.x + Distance * Cos(Beta);
+ Source.y = TargetCoors.y + Distance * Sin(Beta);
}
if(TheCamera.m_bCamDirectlyInFront){
Beta = TargetOrientation;
- Source.x = TargetCoors.x + Distance * cos(Beta);
- Source.y = TargetCoors.y + Distance * sin(Beta);
+ Source.x = TargetCoors.x + Distance * Cos(Beta);
+ Source.y = TargetCoors.y + Distance * Sin(Beta);
}
if(HackPlayerOnStoppingTrain){
Beta = TargetOrientation + PI;
- Source.x = TargetCoors.x + Distance * cos(Beta);
- Source.y = TargetCoors.y + Distance * sin(Beta);
+ Source.x = TargetCoors.x + Distance * Cos(Beta);
+ Source.y = TargetCoors.y + Distance * Sin(Beta);
m_fDimensionOfHighestNearCar = 0.0f;
m_fCamBufferedHeight = 0.0f;
m_fCamBufferedHeightSpeed = 0.0f;
@@ -904,7 +904,7 @@ CCam::WorkOutCamHeight(const CVector &TargetCoors, float TargetOrientation, floa
while(deltaBeta >= PI) deltaBeta -= 2*PI;
while(deltaBeta < -PI) deltaBeta += 2*PI;
- float BehindCarNess = cos(deltaBeta); // 1 if behind car, 0 if side, -1 if in front
+ float BehindCarNess = Cos(deltaBeta); // 1 if behind car, 0 if side, -1 if in front
CarAlpha = -CarAlpha * BehindCarNess;
if(CarAlpha < -0.01f)
CarAlpha = -0.01f;
@@ -939,8 +939,8 @@ CCam::WorkOutCamHeight(const CVector &TargetCoors, float TargetOrientation, floa
Forward = CamTargetEntity->GetForward(); // we actually still have that...
Forward.Normalise(); // shouldn't be necessary
float CarSideAngle = CGeneral::GetATanOfXY(Forward.x, Forward.y) + PI/2.0f;
- float SideX = 2.5f * cos(CarSideAngle);
- float SideY = 2.5f * sin(CarSideAngle);
+ float SideX = 2.5f * Cos(CarSideAngle);
+ float SideY = 2.5f * Sin(CarSideAngle);
CWorld::FindRoofZFor3DCoord(TargetCoors.x + SideX, TargetCoors.y + SideY, CarBottom, &FoundRoofSide1);
CWorld::FindRoofZFor3DCoord(TargetCoors.x - SideX, TargetCoors.y - SideY, CarBottom, &FoundRoofSide2);
@@ -1042,7 +1042,7 @@ CCam::WorkOutCamHeight(const CVector &TargetCoors, float TargetOrientation, floa
WellBufferMe(LastTargetAlphaWithCollisionOn, &Alpha, &AlphaSpeed, LastTopAlphaSpeed, LastAlphaSpeedStep, true);
- Source.z = TargetCoors.z + sin(Alpha + ModeAlpha)*Length + m_fCloseInCarHeightOffset;
+ Source.z = TargetCoors.z + Sin(Alpha + ModeAlpha)*Length + m_fCloseInCarHeightOffset;
}
// Rotate cam behind the car when the car is moving forward
@@ -1062,7 +1062,7 @@ CCam::RotCamIfInFrontCar(CVector &TargetCoors, float TargetOrientation)
while(DeltaBeta >= PI) DeltaBeta -= 2*PI;
while(DeltaBeta < -PI) DeltaBeta += 2*PI;
- if(fabs(DeltaBeta) > DEGTORAD(20.0f) && MovingForward && TheCamera.m_uiTransitionState == 0)
+ if(Abs(DeltaBeta) > DEGTORAD(20.0f) && MovingForward && TheCamera.m_uiTransitionState == 0)
m_bFixingBeta = true;
CPad *pad = CPad::GetPad(0);
@@ -1088,14 +1088,14 @@ CCam::RotCamIfInFrontCar(CVector &TargetCoors, float TargetOrientation)
if(TheCamera.m_bUseTransitionBeta && &TheCamera.Cams[TheCamera.ActiveCam] == this)
Beta = m_fTransitionBeta;
- Source.x = TargetCoors.x - cos(Beta)*Dist;
- Source.y = TargetCoors.y - sin(Beta)*Dist;
+ Source.x = TargetCoors.x - Cos(Beta)*Dist;
+ Source.y = TargetCoors.y - Sin(Beta)*Dist;
// Check if we're done
DeltaBeta = TargetOrientation - Beta;
while(DeltaBeta >= PI) DeltaBeta -= 2*PI;
while(DeltaBeta < -PI) DeltaBeta += 2*PI;
- if(fabs(DeltaBeta) < DEGTORAD(2.0f))
+ if(Abs(DeltaBeta) < DEGTORAD(2.0f))
m_bFixingBeta = false;
}
TheCamera.m_bCamDirectlyBehind = false;
@@ -1157,14 +1157,14 @@ CCam::FixCamIfObscured(CVector &TargetCoors, float TargetHeight, float TargetOri
return false;
if(Fix1){
- Source.x = Target.x - cos(Beta)*Dist1;
- Source.y = Target.y - sin(Beta)*Dist1;
+ Source.x = Target.x - Cos(Beta)*Dist1;
+ Source.y = Target.y - Sin(Beta)*Dist1;
if(Mode == MODE_BEHINDCAR)
Source = colPoint.point;
}else{
WellBufferMe(Dist2, &m_fDistanceBeforeChanges, &DistanceSpeed, 0.2f, 0.025f, false);
- Source.x = Target.x - cos(Beta)*m_fDistanceBeforeChanges;
- Source.y = Target.y - sin(Beta)*m_fDistanceBeforeChanges;
+ Source.x = Target.x - Cos(Beta)*m_fDistanceBeforeChanges;
+ Source.y = Target.y - Sin(Beta)*m_fDistanceBeforeChanges;
}
if(ResetStatics){
diff --git a/src/core/Collision.cpp b/src/core/Collision.cpp
index 94da1338..6241b79a 100644
--- a/src/core/Collision.cpp
+++ b/src/core/Collision.cpp
@@ -457,7 +457,7 @@ CCollision::TestLineSphere(const CColLine &line, const CColSphere &sph)
// I leave in the strange -2 factors even though they serve no real purpose
float projline = -2.0f * DotProduct(v01, v0c); // project v0c onto line
// Square of tangent from p0 multiplied by line length so we can compare with projline.
- // The length of the tangent would be this: sqrt((c-p0)^2 - r^2).
+ // The length of the tangent would be this: Sqrt((c-p0)^2 - r^2).
// Negative if p0 is inside the sphere! This breaks the test!
float tansq = 4.0f * linesq *
(sph.center.MagnitudeSqr() - 2.0f*DotProduct(sph.center, line.p0) + line.p0.MagnitudeSqr() - sph.radius*sph.radius);
@@ -467,10 +467,10 @@ CCollision::TestLineSphere(const CColLine &line, const CColSphere &sph)
return false;
// projline (negative in GTA for some reason) is the point on the line
// in the middle of the two intersection points (startin from p0).
- // sqrt(diffsq) somehow works out to be the distance from that
+ // Sqrt(diffsq) somehow works out to be the distance from that
// midpoint to the intersection points.
// So subtract that and get rid of the awkward scaling:
- float f = (-projline - sqrt(diffsq)) / (2.0f*linesq);
+ float f = (-projline - Sqrt(diffsq)) / (2.0f*linesq);
// f should now be in range [0, 1] for [p0, p1]
return f >= 0.0f && f <= 1.0f;
}
@@ -480,7 +480,7 @@ CCollision::TestSphereTriangle(const CColSphere &sphere,
const CVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane)
{
// If sphere and plane don't intersect, no collision
- if(fabs(plane.CalcPoint(sphere.center)) > sphere.radius)
+ if(Abs(plane.CalcPoint(sphere.center)) > sphere.radius)
return false;
const CVector &va = verts[tri.a];
@@ -669,7 +669,7 @@ CCollision::ProcessSphereBox(const CColSphere &sph, const CColBox &box, CColPoin
dist = sph.center - p;
float lensq = dist.MagnitudeSqr();
if(lensq < mindistsq){
- float len = sqrt(lensq);
+ float len = Sqrt(lensq);
point.point = p;
point.normal = dist * (1.0f/len);
point.surfaceA = sph.surface;
@@ -816,7 +816,7 @@ CCollision::ProcessLineSphere(const CColLine &line, const CColSphere &sphere, CC
if(diffsq < 0.0f)
return false;
// point of first intersection, in range [0,1] between p0 and p1
- float t = (projline - sqrt(diffsq)) / linesq;
+ float t = (projline - Sqrt(diffsq)) / linesq;
// if not on line or beyond mindist, no intersection
if(t < 0.0f || t > 1.0f || t >= mindist)
return false;
@@ -1010,7 +1010,7 @@ CCollision::ProcessSphereTriangle(const CColSphere &sphere,
// If sphere and plane don't intersect, no collision
float planedist = plane.CalcPoint(sphere.center);
float distsq = planedist*planedist;
- if(fabs(planedist) > sphere.radius || distsq > mindistsq)
+ if(Abs(planedist) > sphere.radius || distsq > mindistsq)
return false;
const CVector &va = verts[tri.a];
@@ -1057,7 +1057,7 @@ CCollision::ProcessSphereTriangle(const CColSphere &sphere,
else assert(0);
}else if(testcase == 3){
// center is in triangle
- dist = fabs(planedist);
+ dist = Abs(planedist);
p = sphere.center - normal*planedist;
}else
assert(0); // front fell off
@@ -1333,7 +1333,7 @@ CCollision::DistToLine(const CVector *l0, const CVector *l1, const CVector *poin
if(dot >= lensq)
return (*point - *l1).Magnitude();
// distance to line
- return sqrt((*point - *l0).MagnitudeSqr() - dot*dot/lensq);
+ return Sqrt((*point - *l0).MagnitudeSqr() - dot*dot/lensq);
}
// same as above but also return the point on the line
@@ -1641,7 +1641,7 @@ CColTrianglePlane::Set(const CVector *v, CColTriangle &tri)
normal = CrossProduct(vc-va, vb-va);
normal.Normalise();
dist = DotProduct(normal, va);
- CVector an(fabs(normal.x), fabs(normal.y), fabs(normal.z));
+ CVector an(Abs(normal.x), Abs(normal.y), Abs(normal.z));
// find out largest component and its direction
if(an.x > an.y && an.x > an.z)
dir = normal.x < 0.0f ? DIR_X_NEG : DIR_X_POS;
diff --git a/src/core/FileLoader.cpp b/src/core/FileLoader.cpp
index b949eb98..0c53ae66 100644
--- a/src/core/FileLoader.cpp
+++ b/src/core/FileLoader.cpp
@@ -262,9 +262,9 @@ CFileLoader::LoadCollisionModel(uint8 *buf, CColModel &model, char *modelname)
model.vertices = (CVector*)RwMalloc(numVertices*sizeof(CVector));
for(i = 0; i < numVertices; i++){
model.vertices[i] = *(CVector*)buf;
- if(fabs(model.vertices[i].x) >= 256.0f ||
- fabs(model.vertices[i].y) >= 256.0f ||
- fabs(model.vertices[i].z) >= 256.0f)
+ if(Abs(model.vertices[i].x) >= 256.0f ||
+ Abs(model.vertices[i].y) >= 256.0f ||
+ Abs(model.vertices[i].z) >= 256.0f)
printf("%s:Collision volume too big\n", modelname);
buf += 12;
}
diff --git a/src/core/General.h b/src/core/General.h
index cae1caa0..a08b622b 100644
--- a/src/core/General.h
+++ b/src/core/General.h
@@ -6,32 +6,32 @@ public:
static float GetATanOfXY(float x, float y){
if(x == 0.0f && y == 0.0f)
return 0.0f;
- float xabs = fabs(x);
- float yabs = fabs(y);
+ float xabs = Abs(x);
+ float yabs = Abs(y);
if(xabs < yabs){
if(y > 0.0f){
if(x > 0.0f)
- return 0.5f*PI - atan2(x / y, 1.0f);
+ return 0.5f*PI - Atan2(x / y, 1.0f);
else
- return 0.5f*PI + atan2(-x / y, 1.0f);
+ return 0.5f*PI + Atan2(-x / y, 1.0f);
}else{
if(x > 0.0f)
- return 1.5f*PI + atan2(x / -y, 1.0f);
+ return 1.5f*PI + Atan2(x / -y, 1.0f);
else
- return 1.5f*PI - atan2(-x / -y, 1.0f);
+ return 1.5f*PI - Atan2(-x / -y, 1.0f);
}
}else{
if(y > 0.0f){
if(x > 0.0f)
- return atan2(y / x, 1.0f);
+ return Atan2(y / x, 1.0f);
else
- return PI - atan2(y / -x, 1.0f);
+ return PI - Atan2(y / -x, 1.0f);
}else{
if(x > 0.0f)
- return 2.0f*PI - atan2(-y / x, 1.0f);
+ return 2.0f*PI - Atan2(-y / x, 1.0f);
else
- return PI + atan2(-y / -x, 1.0f);
+ return PI + Atan2(-y / -x, 1.0f);
}
}
}
@@ -68,12 +68,12 @@ public:
if (x > 0.0f) {
if (y > 0.0f)
- return PI - atan2(x / y, 1.0f);
+ return PI - Atan2(x / y, 1.0f);
else
return -atan2(x / y, 1.0f);
} else {
if (y > 0.0f)
- return -(PI + atan2(x / y, 1.0f));
+ return -(PI + Atan2(x / y, 1.0f));
else
return -atan2(x / y, 1.0f);
}
diff --git a/src/core/Pad.cpp b/src/core/Pad.cpp
index 002e7180..9c5e1c8a 100644
--- a/src/core/Pad.cpp
+++ b/src/core/Pad.cpp
@@ -670,7 +670,7 @@ int16 CPad::GetSteeringLeftRight(void)
int16 axis = NewState.LeftStickX;
int16 dpad = (NewState.DPadRight - NewState.DPadLeft) / 2;
- if ( abs(axis) > abs(dpad) )
+ if ( Abs(axis) > Abs(dpad) )
return axis;
else
return dpad;
@@ -703,7 +703,7 @@ int16 CPad::GetSteeringUpDown(void)
int16 axis = NewState.LeftStickY;
int16 dpad = (NewState.DPadUp - NewState.DPadDown) / 2;
- if ( abs(axis) > abs(dpad) )
+ if ( Abs(axis) > Abs(dpad) )
return axis;
else
return dpad;
@@ -790,7 +790,7 @@ int16 CPad::GetPedWalkLeftRight(void)
int16 axis = NewState.LeftStickX;
int16 dpad = (NewState.DPadRight - NewState.DPadLeft) / 2;
- if ( abs(axis) > abs(dpad) )
+ if ( Abs(axis) > Abs(dpad) )
return axis;
else
return dpad;
@@ -824,7 +824,7 @@ int16 CPad::GetPedWalkUpDown(void)
int16 axis = NewState.LeftStickY;
int16 dpad = (NewState.DPadDown - NewState.DPadUp) / 2;
- if ( abs(axis) > abs(dpad) )
+ if ( Abs(axis) > Abs(dpad) )
return axis;
else
return dpad;
@@ -854,7 +854,7 @@ int16 CPad::GetAnalogueUpDown(void)
int16 axis = NewState.LeftStickY;
int16 dpad = (NewState.DPadDown - NewState.DPadUp) / 2;
- if ( abs(axis) > abs(dpad) )
+ if ( Abs(axis) > Abs(dpad) )
return axis;
else
return dpad;
@@ -1683,7 +1683,7 @@ int16 CPad::SniperModeLookLeftRight(void)
int16 axis = NewState.LeftStickX;
int16 dpad = (NewState.DPadRight - NewState.DPadLeft) / 2;
- if ( abs(axis) > abs(dpad) )
+ if ( Abs(axis) > Abs(dpad) )
return axis;
else
return dpad;
@@ -1694,7 +1694,7 @@ int16 CPad::SniperModeLookUpDown(void)
int16 axis = NewState.LeftStickY;
int16 dpad = (NewState.DPadUp - NewState.DPadDown) / 2;
- if ( abs(axis) > abs(dpad) )
+ if ( Abs(axis) > Abs(dpad) )
return axis;
else
return dpad;
@@ -1704,11 +1704,11 @@ int16 CPad::LookAroundLeftRight(void)
{
float axis = GetPad(0)->NewState.RightStickX;
- if ( fabs(axis) > 85 && !GetLookBehindForPed() )
+ if ( Abs(axis) > 85 && !GetLookBehindForPed() )
return (int16) ( (axis + ( ( axis > 0 ) ? -85 : 85) )
* (127.0f / 32.0f) ); // 3.96875f
- else if ( TheCamera.Cams[0].Using3rdPersonMouseCam() && fabs(axis) > 10 )
+ else if ( TheCamera.Cams[0].Using3rdPersonMouseCam() && Abs(axis) > 10 )
return (int16) ( (axis + ( ( axis > 0 ) ? -10 : 10) )
* (127.0f / 64.0f) ); // 1.984375f
@@ -1719,11 +1719,11 @@ int16 CPad::LookAroundUpDown(void)
{
int16 axis = GetPad(0)->NewState.RightStickY;
- if ( abs(axis) > 85 && !GetLookBehindForPed() )
+ if ( Abs(axis) > 85 && !GetLookBehindForPed() )
return (int16) ( (axis + ( ( axis > 0 ) ? -85 : 85) )
* (127.0f / 32.0f) ); // 3.96875f
- else if ( TheCamera.Cams[0].Using3rdPersonMouseCam() && abs(axis) > 40 )
+ else if ( TheCamera.Cams[0].Using3rdPersonMouseCam() && Abs(axis) > 40 )
return (int16) ( (axis + ( ( axis > 0 ) ? -40 : 40) )
* (127.0f / 64.0f) ); // 1.984375f
diff --git a/src/core/Radar.cpp b/src/core/Radar.cpp
index a071b96b..b634e4f5 100644
--- a/src/core/Radar.cpp
+++ b/src/core/Radar.cpp
@@ -469,8 +469,8 @@ void CRadar::DrawRadarMask()
// Then generate a quarter of the circle
for (int j = 0; j < 7; j++) {
- in.x = corners[i].x * cos(j * (PI / 2.0f / 6.0f));
- in.y = corners[i].y * sin(j * (PI / 2.0f / 6.0f));
+ in.x = corners[i].x * Cos(j * (PI / 2.0f / 6.0f));
+ in.y = corners[i].y * Sin(j * (PI / 2.0f / 6.0f));
TransformRadarPointToScreenSpace(out[j + 1], in);
};
@@ -562,8 +562,8 @@ void CRadar::DrawRotatingRadarSprite(CSprite2d* sprite, float x, float y, float
for (uint32 i = 0; i < 4; i++) {
oldPosn[i] = curPosn[i];
- curPosn[i].x = x + (oldPosn[i].x - x) * cosf(angle) + (oldPosn[i].y - y) * sinf(angle);
- curPosn[i].y = y - (oldPosn[i].x - x) * sinf(angle) + (oldPosn[i].y - y) * cosf(angle);
+ curPosn[i].x = x + (oldPosn[i].x - x) * Cos(angle) + (oldPosn[i].y - y) * Sin(angle);
+ curPosn[i].y = y - (oldPosn[i].x - x) * Sin(angle) + (oldPosn[i].y - y) * Cos(angle);
}
sprite->Draw(curPosn[2].x, curPosn[2].y, curPosn[3].x, curPosn[3].y, curPosn[0].x, curPosn[0].y, curPosn[1].x, curPosn[1].y, CRGBA(255, 255, 255, alpha));
@@ -869,7 +869,7 @@ void CRadar::TransformRadarPointToRealWorldSpace(CVector2D &out, const CVector2D
float s, c;
s = -sin(TheCamera.GetForward().Heading());
- c = cos(TheCamera.GetForward().Heading());
+ c = Cos(TheCamera.GetForward().Heading());
if (TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_TOPDOWN1 || TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_TOPDOWNPED) {
s = 0.0f;
@@ -886,7 +886,7 @@ void CRadar::TransformRadarPointToRealWorldSpace(CVector2D &out, const CVector2D
forward = TheCamera.Cams[TheCamera.ActiveCam].CamTargetEntity->GetPosition() - TheCamera.Cams[TheCamera.ActiveCam].SourceBeforeLookBehind;
s = -sin(forward.Heading());
- c = cos(forward.Heading());
+ c = Cos(forward.Heading());
}
out.x = s * in.y + c * in.x;
@@ -915,8 +915,8 @@ void CRadar::TransformRealWorldPointToRadarSpace(CVector2D &out, const CVector2D
c = 1.0f;
}
else if (TheCamera.GetLookDirection() == LOOKING_FORWARD) {
- s = sin(TheCamera.GetForward().Heading());
- c = cos(TheCamera.GetForward().Heading());
+ s = Sin(TheCamera.GetForward().Heading());
+ c = Cos(TheCamera.GetForward().Heading());
}
else {
CVector forward;
@@ -928,8 +928,8 @@ void CRadar::TransformRealWorldPointToRadarSpace(CVector2D &out, const CVector2D
else
forward = TheCamera.Cams[TheCamera.ActiveCam].CamTargetEntity->GetPosition() - TheCamera.Cams[TheCamera.ActiveCam].SourceBeforeLookBehind;
- s = sin(forward.Heading());
- c = cos(forward.Heading());
+ s = Sin(forward.Heading());
+ c = Cos(forward.Heading());
}
float x = (in.x - vec2DRadarOrigin.x) * (1.0f / m_RadarRange);
diff --git a/src/core/Streaming.cpp b/src/core/Streaming.cpp
index f8ab19d4..a23e35be 100644
--- a/src/core/Streaming.cpp
+++ b/src/core/Streaming.cpp
@@ -2131,8 +2131,8 @@ CStreaming::DeleteRwObjectsAfterDeath(const CVector &pos)
for(x = 0; x < NUMSECTORS_X; x++)
for(y = 0; y < NUMSECTORS_Y; y++)
- if(fabs(ix - x) > 3.0f &&
- fabs(iy - y) > 3.0f){
+ if(Abs(ix - x) > 3.0f &&
+ Abs(iy - y) > 3.0f){
sect = CWorld::GetSector(x, y);
DeleteRwObjectsInSectorList(sect->m_lists[ENTITYLIST_BUILDINGS]);
DeleteRwObjectsInSectorList(sect->m_lists[ENTITYLIST_BUILDINGS_OVERLAP]);
@@ -2158,7 +2158,7 @@ CStreaming::DeleteRwObjectsBehindCamera(int32 mem)
ix = CWorld::GetSectorIndexX(TheCamera.GetPosition().x);
iy = CWorld::GetSectorIndexX(TheCamera.GetPosition().y);
- if(fabs(TheCamera.GetForward().x) > fabs(TheCamera.GetForward().y)){
+ if(Abs(TheCamera.GetForward().x) > Abs(TheCamera.GetForward().y)){
// looking west/east
ymin = max(iy - 10, 0);
@@ -2312,13 +2312,13 @@ CStreaming::DeleteRwObjectsInOverlapSectorList(CPtrList &list, int32 x, int32 y)
e = (CEntity*)node->item;
if(e->m_rwObject && !e->bStreamingDontDelete && !e->bImBeingRendered){
// Now this is pretty weird...
- if(fabs(CWorld::GetSectorIndexX(e->GetPosition().x) - x) >= 2.0f)
+ if(Abs(CWorld::GetSectorIndexX(e->GetPosition().x) - x) >= 2.0f)
// {
e->DeleteRwObject();
// return; // BUG?
// }
else // FIX?
- if(fabs(CWorld::GetSectorIndexY(e->GetPosition().y) - y) >= 2.0f)
+ if(Abs(CWorld::GetSectorIndexY(e->GetPosition().y) - y) >= 2.0f)
e->DeleteRwObject();
}
}
diff --git a/src/core/common.h b/src/core/common.h
index 79626acb..e5702a2f 100644
--- a/src/core/common.h
+++ b/src/core/common.h
@@ -97,6 +97,7 @@ extern void **rwengine;
#define SCREEN_SCALE_AR(a) (a)
#endif
+#include "math/maths.h"
#include "math/Vector.h"
#include "math/Vector2D.h"
#include "math/Matrix.h"
diff --git a/src/entities/Entity.cpp b/src/entities/Entity.cpp
index d562ced5..10677bdf 100644
--- a/src/entities/Entity.cpp
+++ b/src/entities/Entity.cpp
@@ -806,12 +806,12 @@ CEntity::ModifyMatrixForTreeInWind(void)
}else if(CWeather::Wind >= 0.2){
t = (uintptr)this + CTimer::GetTimeInMilliseconds();
f = (t & 0xFFF)/(float)0x1000;
- flutter = sin(f * 6.28f);
+ flutter = Sin(f * 6.28f);
strength = 0.008f;
}else{
t = (uintptr)this + CTimer::GetTimeInMilliseconds();
f = (t & 0xFFF)/(float)0x1000;
- flutter = sin(f * 6.28f);
+ flutter = Sin(f * 6.28f);
strength = 0.005f;
}
@@ -857,7 +857,7 @@ CEntity::ModifyMatrixForBannerInWind(void)
right.z = 0.0f;
right.Normalise();
up = right * flutter;
- up.z = sqrt(sq(1.0f) - sq(flutter));
+ up.z = Sqrt(sq(1.0f) - sq(flutter));
GetRight() = CrossProduct(GetForward(), up);
GetUp() = up;
diff --git a/src/entities/Physical.cpp b/src/entities/Physical.cpp
index 9cabb28b..55ed5380 100644
--- a/src/entities/Physical.cpp
+++ b/src/entities/Physical.cpp
@@ -476,7 +476,7 @@ CPhysical::ApplySpringDampening(float damping, CVector &springDir, CVector &poin
// what is this?
float a = m_fTurnMass / ((point.MagnitudeSqr() + 1.0f) * 2.0f * m_fMass);
a = min(a, 1.0f);
- float b = fabs(impulse / (speedB * m_fMass));
+ float b = Abs(impulse / (speedB * m_fMass));
if(a < b)
impulse *= a/b;
@@ -505,11 +505,11 @@ void
CPhysical::ApplyAirResistance(void)
{
if(m_fAirResistance > 0.1f){
- float f = powf(m_fAirResistance, CTimer::GetTimeStep());
+ float f = Pow(m_fAirResistance, CTimer::GetTimeStep());
m_vecMoveSpeed *= f;
m_vecTurnSpeed *= f;
}else{
- float f = powf(1.0f/(m_fAirResistance*0.5f*m_vecMoveSpeed.MagnitudeSqr() + 1.0f), CTimer::GetTimeStep());
+ float f = Pow(1.0f/(m_fAirResistance*0.5f*m_vecMoveSpeed.MagnitudeSqr() + 1.0f), CTimer::GetTimeStep());
m_vecMoveSpeed *= f;
m_vecTurnSpeed *= 0.99f;
}
@@ -719,7 +719,7 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
if(!B->bInfiniteMass){
if(fB.z < 0.0f){
fB.z = 0.0f;
- if(fabs(speedA) < 0.01f)
+ if(Abs(speedA) < 0.01f)
fB *= 0.5f;
}
if(ispedcontactA){
@@ -815,9 +815,9 @@ CPhysical::ApplyCollisionAlt(CEntity *B, CColPoint &colpoint, float &impulse, CV
float minspeed = 0.0104f * CTimer::GetTimeStep();
if((IsObject() || IsVehicle() && GetUp().z < -0.3f) &&
!bHasContacted &&
- fabs(m_vecMoveSpeed.x) < minspeed &&
- fabs(m_vecMoveSpeed.y) < minspeed &&
- fabs(m_vecMoveSpeed.z) < minspeed*2.0f)
+ Abs(m_vecMoveSpeed.x) < minspeed &&
+ Abs(m_vecMoveSpeed.y) < minspeed &&
+ Abs(m_vecMoveSpeed.z) < minspeed*2.0f)
e = -1.0f;
else
e = -(m_fElasticity + 1.0f);
@@ -1150,14 +1150,14 @@ CPhysical::ProcessShiftSectorList(CPtrList *lists)
shift += dir * colpoints[mostColliding].depth * 0.5f;
}else if(A->IsPed() && B->IsVehicle() && ((CVehicle*)B)->IsBoat()){
CVector dir = colpoints[mostColliding].normal;
- float f = min(fabs(dir.z), 0.9f);
+ float f = min(Abs(dir.z), 0.9f);
dir.z = 0.0f;
dir.Normalise();
shift += dir * colpoints[mostColliding].depth / (1.0f - f);
boat = B;
}else if(B->IsPed() && A->IsVehicle() && ((CVehicle*)A)->IsBoat()){
CVector dir = colpoints[mostColliding].normal * -1.0f;
- float f = min(fabs(dir.z), 0.9f);
+ float f = min(Abs(dir.z), 0.9f);
dir.z = 0.0f;
dir.Normalise();
B->GetPosition() += dir * colpoints[mostColliding].depth / (1.0f - f);
@@ -1498,8 +1498,8 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
float imp = impulseA;
if(A->IsVehicle() && A->GetUp().z < -0.6f &&
- fabs(A->m_vecMoveSpeed.x) < 0.05f &&
- fabs(A->m_vecMoveSpeed.y) < 0.05f)
+ Abs(A->m_vecMoveSpeed.x) < 0.05f &&
+ Abs(A->m_vecMoveSpeed.y) < 0.05f)
imp *= 0.1f;
float turnSpeedDiff = A->m_vecTurnSpeed.MagnitudeSqr();
@@ -1519,8 +1519,8 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
float imp = impulseA;
if(A->IsVehicle() && A->GetUp().z < -0.6f &&
- fabs(A->m_vecMoveSpeed.x) < 0.05f &&
- fabs(A->m_vecMoveSpeed.y) < 0.05f)
+ Abs(A->m_vecMoveSpeed.x) < 0.05f &&
+ Abs(A->m_vecMoveSpeed.y) < 0.05f)
imp *= 0.1f;
float turnSpeedDiff = A->m_vecTurnSpeed.MagnitudeSqr();
@@ -1557,8 +1557,8 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
m_vecTurnSpeed += turnSpeed / numResponses;
if(!CWorld::bNoMoreCollisionTorque &&
A->m_status == STATUS_PLAYER && A->IsVehicle() &&
- fabs(A->m_vecMoveSpeed.x) > 0.2f &&
- fabs(A->m_vecMoveSpeed.y) > 0.2f){
+ Abs(A->m_vecMoveSpeed.x) > 0.2f &&
+ Abs(A->m_vecMoveSpeed.y) > 0.2f){
A->m_vecMoveFriction.x += moveSpeed.x * -0.3f / numCollisions;
A->m_vecMoveFriction.y += moveSpeed.y * -0.3f / numCollisions;
A->m_vecTurnFriction += turnSpeed * -0.3f / numCollisions;
@@ -1789,7 +1789,7 @@ CPhysical::ProcessShift(void)
}
// x is the number of units (m) we would like to step
-#define NUMSTEPS(x) ceil(sqrt(distSq) * (1.0f/(x)))
+#define NUMSTEPS(x) ceil(Sqrt(distSq) * (1.0f/(x)))
void
CPhysical::ProcessCollision(void)
diff --git a/src/math/Matrix.h b/src/math/Matrix.h
index b7d6c207..2c0108c1 100644
--- a/src/math/Matrix.h
+++ b/src/math/Matrix.h
@@ -127,8 +127,8 @@ public:
}
void SetRotateXOnly(float angle){
- float c = cos(angle);
- float s = sin(angle);
+ float c = Cos(angle);
+ float s = Sin(angle);
m_matrix.right.x = 1.0f;
m_matrix.right.y = 0.0f;
@@ -149,8 +149,8 @@ public:
m_matrix.pos.z = 0.0f;
}
void SetRotateYOnly(float angle){
- float c = cos(angle);
- float s = sin(angle);
+ float c = Cos(angle);
+ float s = Sin(angle);
m_matrix.right.x = c;
m_matrix.right.y = 0.0f;
@@ -171,8 +171,8 @@ public:
m_matrix.pos.z = 0.0f;
}
void SetRotateZOnly(float angle){
- float c = cos(angle);
- float s = sin(angle);
+ float c = Cos(angle);
+ float s = Sin(angle);
m_matrix.right.x = c;
m_matrix.right.y = s;
@@ -193,12 +193,12 @@ public:
m_matrix.pos.z = 0.0f;
}
void SetRotate(float xAngle, float yAngle, float zAngle) {
- float cX = cos(xAngle);
- float sX = sin(xAngle);
- float cY = cos(yAngle);
- float sY = sin(yAngle);
- float cZ = cos(zAngle);
- float sZ = sin(zAngle);
+ float cX = Cos(xAngle);
+ float sX = Sin(xAngle);
+ float cY = Cos(yAngle);
+ float sY = Sin(yAngle);
+ float cZ = Cos(zAngle);
+ float sZ = Sin(zAngle);
m_matrix.right.x = cZ * cY - (sZ * sX) * sY;
m_matrix.right.y = (cZ * sX) * sY + sZ * cY;
diff --git a/src/math/Quaternion.h b/src/math/Quaternion.h
index 702fc72f..fb37dc10 100644
--- a/src/math/Quaternion.h
+++ b/src/math/Quaternion.h
@@ -8,7 +8,7 @@ public:
CQuaternion(void) {}
CQuaternion(float x, float y, float z, float w) : x(x), y(y), z(z), w(w) {}
- float Magnitude(void) const { return sqrt(x*x + y*y + z*z + w*w); }
+ float Magnitude(void) const { return Sqrt(x*x + y*y + z*z + w*w); }
float MagnitudeSqr(void) const { return x*x + y*y + z*z + w*w; }
const CQuaternion &operator+=(CQuaternion const &right) {
diff --git a/src/math/Vector.h b/src/math/Vector.h
index b49f00f2..9a1dde7a 100644
--- a/src/math/Vector.h
+++ b/src/math/Vector.h
@@ -22,10 +22,10 @@ public:
return *((RwV3d*)this);
}
#endif
- float Heading(void) const { return atan2(-x, y); }
- float Magnitude(void) const { return sqrt(x*x + y*y + z*z); }
+ float Heading(void) const { return Atan2(-x, y); }
+ float Magnitude(void) const { return Sqrt(x*x + y*y + z*z); }
float MagnitudeSqr(void) const { return x*x + y*y + z*z; }
- float Magnitude2D(void) const { return sqrt(x*x + y*y); }
+ float Magnitude2D(void) const { return Sqrt(x*x + y*y); }
float MagnitudeSqr2D(void) const { return x*x + y*y; }
void Normalise(void) {
float sq = MagnitudeSqr();
diff --git a/src/math/Vector2D.h b/src/math/Vector2D.h
index fa32bd9b..d0580545 100644
--- a/src/math/Vector2D.h
+++ b/src/math/Vector2D.h
@@ -7,7 +7,7 @@ public:
CVector2D(void) {}
CVector2D(float x, float y) : x(x), y(y) {}
CVector2D(const CVector &v) : x(v.x), y(v.y) {}
- float Magnitude(void) const { return sqrt(x*x + y*y); }
+ float Magnitude(void) const { return Sqrt(x*x + y*y); }
float MagnitudeSqr(void) const { return x*x + y*y; }
void Normalise(void){
diff --git a/src/math/math.cpp b/src/math/math.cpp
index b76db4ae..b4ba9c98 100644
--- a/src/math/math.cpp
+++ b/src/math/math.cpp
@@ -13,11 +13,11 @@ CQuaternion::Slerp(const CQuaternion &q1, const CQuaternion &q2, float theta, fl
float w1, w2;
if(theta > PI/2){
theta = PI - theta;
- w1 = sin((1.0f - t) * theta) * invSin;
+ w1 = Sin((1.0f - t) * theta) * invSin;
w2 = -sin(t * theta) * invSin;
}else{
- w1 = sin((1.0f - t) * theta) * invSin;
- w2 = sin(t * theta) * invSin;
+ w1 = Sin((1.0f - t) * theta) * invSin;
+ w2 = Sin(t * theta) * invSin;
}
*this = w1*q1 + w2*q2;
}
diff --git a/src/math/maths.h b/src/math/maths.h
new file mode 100644
index 00000000..49e39631
--- /dev/null
+++ b/src/math/maths.h
@@ -0,0 +1,12 @@
+#pragma once
+
+// wrapper around float versions of functions
+// in gta they are in CMaths but that makes the code rather noisy
+
+inline float Sin(float x) { return sinf(x); }
+inline float Cos(float x) { return cosf(x); }
+inline float Abs(float x) { return fabs(x); }
+inline float Sqrt(float x) { return sqrtf(x); }
+inline float Atan2(float y, float x) { return atan2f(y, x); }
+inline float RecipSqrt(float x) { return 1.0f/sqrtf(x); }
+inline float Pow(float x, float y) { return powf(x, y); }
diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp
index 8ebe456f..c9a9cfb5 100644
--- a/src/peds/Ped.cpp
+++ b/src/peds/Ped.cpp
@@ -551,7 +551,7 @@ CheckForPedsOnGroundToAttack(CPlayerPed *player, CPed **pedOnGround)
angleToFace = CGeneral::LimitRadianAngle(angleToFace);
player->m_fRotationCur = CGeneral::LimitRadianAngle(player->m_fRotationCur);
- angleDiff = fabs(angleToFace - player->m_fRotationCur);
+ angleDiff = Abs(angleToFace - player->m_fRotationCur);
if (angleDiff > PI)
angleDiff = 2 * PI - angleDiff;
@@ -872,7 +872,7 @@ CPed::Avoid(void)
// If so, we want to avoid it, so we turn our body 45 degree and look to somewhere else.
// Game converts from radians to degress and back again here, doesn't make much sense
- CVector2D forward(-sin(m_fRotationCur), cos(m_fRotationCur));
+ CVector2D forward(-sin(m_fRotationCur), Cos(m_fRotationCur));
forward.Normalise(); // this is kinda pointless
// Move forward 1.25 meters
@@ -2151,10 +2151,10 @@ CPed::CalculateNewVelocity(void)
}
}
- CVector2D forward(sin(m_fRotationCur), cos(m_fRotationCur));
+ CVector2D forward(Sin(m_fRotationCur), Cos(m_fRotationCur));
- m_moved.x = CrossProduct2D(m_vecAnimMoveDelta, forward); // (m_vecAnimMoveDelta.x * cos(m_fRotationCur)) + -sin(m_fRotationCur) * m_vecAnimMoveDelta.y;
- m_moved.y = DotProduct2D(m_vecAnimMoveDelta, forward); // m_vecAnimMoveDelta.y* cos(m_fRotationCur) + (m_vecAnimMoveDelta.x * sin(m_fRotationCur));
+ m_moved.x = CrossProduct2D(m_vecAnimMoveDelta, forward); // (m_vecAnimMoveDelta.x * Cos(m_fRotationCur)) + -sin(m_fRotationCur) * m_vecAnimMoveDelta.y;
+ m_moved.y = DotProduct2D(m_vecAnimMoveDelta, forward); // m_vecAnimMoveDelta.y* Cos(m_fRotationCur) + (m_vecAnimMoveDelta.x * Sin(m_fRotationCur));
if (CTimer::GetTimeStep() >= 0.01f) {
m_moved = m_moved * (1 / CTimer::GetTimeStep());
@@ -2179,7 +2179,7 @@ CPed::CalculateNewVelocity(void)
// Interestingly this part is responsible for diagonal walking.
if (localWalkAngle > -DEGTORAD(50.0f) && localWalkAngle < DEGTORAD(50.0f)) {
TheCamera.Cams[TheCamera.ActiveCam].m_fPlayerVelocity = pedSpeed;
- m_moved = CVector2D(-sin(walkAngle), cos(walkAngle)) * pedSpeed;
+ m_moved = CVector2D(-sin(walkAngle), Cos(walkAngle)) * pedSpeed;
}
CAnimBlendAssociation *idleAssoc = RpAnimBlendClumpGetAssociation((RpClump*) m_rwObject, ANIM_IDLE_STANCE);
@@ -2239,7 +2239,7 @@ CPed::CanPedDriveOff(void)
bool
CPed::CanPedJumpThis(int32 unused)
{
- CVector2D forward(-sin(m_fRotationCur), cos(m_fRotationCur));
+ CVector2D forward(-sin(m_fRotationCur), Cos(m_fRotationCur));
CVector pos = GetPosition();
// wat?
CVector forwardPos(
@@ -2276,7 +2276,7 @@ CPed::CanSeeEntity(CEntity *entity, float threshold)
else if (ourAngle > 2 * PI)
ourAngle -= 2 * PI;
- float neededTurn = fabs(neededAngle - ourAngle);
+ float neededTurn = Abs(neededAngle - ourAngle);
return neededTurn < threshold || 2 * PI - threshold < neededTurn;
}
@@ -2811,7 +2811,7 @@ CPed::TurnBody(void)
float neededTurn = currentRot - limitedLookDir;
m_fRotationDest = limitedLookDir;
- if (fabs(neededTurn) > 0.05f) {
+ if (Abs(neededTurn) > 0.05f) {
doneSmoothly = false;
currentRot -= neededTurn * 0.2f;
}
diff --git a/src/peds/PedIK.cpp b/src/peds/PedIK.cpp
index b9baf49c..0bd49459 100644
--- a/src/peds/PedIK.cpp
+++ b/src/peds/PedIK.cpp
@@ -34,8 +34,8 @@ CPedIK::RotateTorso(AnimBlendFrameData *animBlend, LimbOrientation *limb, bool c
// rotation == 0 -> looking in y direction
// left? vector
- float c = cos(m_ped->m_fRotationCur);
- float s = sin(m_ped->m_fRotationCur);
+ float c = Cos(m_ped->m_fRotationCur);
+ float s = Sin(m_ped->m_fRotationCur);
rightVector.x = -(c*mat->right.x + s*mat->right.y);
rightVector.y = -(c*mat->up.x + s*mat->up.y);
rightVector.z = -(c*mat->at.x + s*mat->at.y);
diff --git a/src/render/Clouds.cpp b/src/render/Clouds.cpp
index d582bff8..2ead715b 100644
--- a/src/render/Clouds.cpp
+++ b/src/render/Clouds.cpp
@@ -53,7 +53,7 @@ CClouds::Shutdown(void)
void
CClouds::Update(void)
{
- float s = sin(TheCamera.Orientation - 0.85f);
+ float s = Sin(TheCamera.Orientation - 0.85f);
CloudRotation += CWeather::Wind*s*0.0025f;
IndividualRotation += (CWeather::Wind*CTimer::GetTimeStep() + 0.3f) * 60.0f;
}
@@ -81,7 +81,7 @@ CClouds::Render(void)
float coverage = CWeather::CloudCoverage <= CWeather::Foggyness ? CWeather::Foggyness : CWeather::CloudCoverage;
// Moon
- int moonfadeout = abs(minute - 180); // fully visible at 3AM
+ int moonfadeout = Abs(minute - 180); // fully visible at 3AM
if(moonfadeout < 180){ // fade in/out 3 hours
int brightness = (1.0f - coverage) * (180 - moonfadeout);
RwV3d pos = { 0.0f, -100.0f, 15.0f };
@@ -169,8 +169,8 @@ CClouds::Render(void)
}
// Fluffy clouds
- float rot_sin = sin(CloudRotation);
- float rot_cos = cos(CloudRotation);
+ float rot_sin = Sin(CloudRotation);
+ float rot_cos = Cos(CloudRotation);
int fluffyalpha = 160 * (1.0f - CWeather::Foggyness);
if(fluffyalpha != 0){
static float CoorsOffsetX[37] = {
@@ -210,7 +210,7 @@ CClouds::Render(void)
worldpos.z = pos.z;
if(CSprite::CalcScreenCoors(worldpos, &screenpos, &szx, &szy, false)){
- float sundist = sqrt(sq(screenpos.x-CCoronas::SunScreenX) + sq(screenpos.y-CCoronas::SunScreenY));
+ float sundist = Sqrt(sq(screenpos.x-CCoronas::SunScreenX) + sq(screenpos.y-CCoronas::SunScreenY));
int tr = CTimeCycle::GetFluffyCloudsTopRed();
int tg = CTimeCycle::GetFluffyCloudsTopGreen();
int tb = CTimeCycle::GetFluffyCloudsTopBlue();
@@ -302,7 +302,7 @@ CClouds::RenderBackground(int16 topred, int16 topgreen, int16 topblue,
int16 botred, int16 botgreen, int16 botblue, int16 alpha)
{
RwMatrix *mat = RwFrameGetLTM(RwCameraGetFrame(TheCamera.m_pRwCamera));
- float c = sqrt(mat->right.x * mat->right.x + mat->right.y * mat->right.y);
+ float c = Sqrt(mat->right.x * mat->right.x + mat->right.y * mat->right.y);
if(c > 1.0f)
c = 1.0f;
ms_cameraRoll = acos(c);
@@ -424,7 +424,7 @@ CClouds::RenderHorizon(void)
SCREEN_HEIGHT/300.0f * max(TheCamera.GetPosition().z, 0.0f);
float b = TheCamera.GetUp().z < 0.0f ?
SCREEN_HEIGHT :
- SCREEN_HEIGHT * fabs(TheCamera.GetRight().z);
+ SCREEN_HEIGHT * Abs(TheCamera.GetRight().z);
float z2 = z1 + (a + b)*TheCamera.LODDistMultiplier;
z2 = min(z2, SCREEN_HEIGHT);
CSprite2d::DrawRect(CRect(0, z1, SCREEN_WIDTH, z2),
diff --git a/src/render/Coronas.cpp b/src/render/Coronas.cpp
index 61fa1a5a..5ac9b149 100644
--- a/src/render/Coronas.cpp
+++ b/src/render/Coronas.cpp
@@ -286,8 +286,8 @@ CCoronas::Render(void)
// if distance too big, break streak
if(aCoronas[i].hasValue[1]){
- if(fabs(aCoronas[i].prevX[0] - aCoronas[i].prevX[1]) > 50.0f ||
- fabs(aCoronas[i].prevY[0] - aCoronas[i].prevY[1]) > 50.0f)
+ if(Abs(aCoronas[i].prevX[0] - aCoronas[i].prevX[1]) > 50.0f ||
+ Abs(aCoronas[i].prevY[0] - aCoronas[i].prevY[1]) > 50.0f)
aCoronas[i].hasValue[0] = false;
}
}
diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp
index b3264dc7..81f27153 100644
--- a/src/render/Hud.cpp
+++ b/src/render/Hud.cpp
@@ -173,7 +173,7 @@ void CHud::Draw()
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE);
- float fStep = sin((CTimer::GetTimeInMilliseconds() & 1023) * 0.0061328127);
+ float fStep = Sin((CTimer::GetTimeInMilliseconds() & 1023) * 0.0061328127);
float fMultBright = SpriteBrightness * 0.03f * (0.25f * fStep + 0.75f);
CRect rect;
#ifndef ASPECT_RATIO_SCALE
diff --git a/src/render/Particle.cpp b/src/render/Particle.cpp
index 416e5af0..63545dff 100644
--- a/src/render/Particle.cpp
+++ b/src/render/Particle.cpp
@@ -299,8 +299,8 @@ void CParticle::Initialise()
{
float angle = DEGTORAD(float(i) * float(360.0f / SIN_COS_TABLE_SIZE));
- m_SinTable[i] = sin(angle);
- m_CosTable[i] = cos(angle);
+ m_SinTable[i] = Sin(angle);
+ m_CosTable[i] = Cos(angle);
}
int32 slot = CTxdStore::FindTxdSlot("particle");
@@ -1599,7 +1599,7 @@ void CParticle::Render()
fTrailLength = fDist;
- //Float fRot = atan2( vecDist.x / fDist, sqrtf(1.0f - vecDist.x / fDist * (vecDist.x / fDist)) );
+ //Float fRot = Atan2( vecDist.x / fDist, Sqrt(1.0f - vecDist.x / fDist * (vecDist.x / fDist)) );
float fRot = asinf(vecDist.x / fDist);
fRotation = fRot;
@@ -1651,7 +1651,7 @@ void CParticle::Render()
fTrailLength = fDist;
- //Float fRot = atan2(vecDist.x / fDist, sqrt(1.0f - vecDist.x / fDist * (vecDist.x / fDist)));
+ //Float fRot = Atan2(vecDist.x / fDist, Sqrt(1.0f - vecDist.x / fDist * (vecDist.x / fDist)));
float fRot = asinf(vecDist.x / fDist);
fRotation = fRot;
diff --git a/src/render/PointLights.cpp b/src/render/PointLights.cpp
index 9e98a327..b5d4ece1 100644
--- a/src/render/PointLights.cpp
+++ b/src/render/PointLights.cpp
@@ -33,7 +33,7 @@ CPointLights::AddLight(uint8 type, CVector coors, CVector dir, float radius, flo
return;
dist = coors - TheCamera.GetPosition();
- if(fabs(dist.x) < MAX_DIST && fabs(dist.y) < MAX_DIST){
+ if(Abs(dist.x) < MAX_DIST && Abs(dist.y) < MAX_DIST){
distance = dist.Magnitude();
if(distance < MAX_DIST){
aLights[NumLights].type = type;
@@ -73,9 +73,9 @@ CPointLights::GenerateLightsAffectingObject(CVector *objCoors)
// same weird distance calculation. simplified here
dist = aLights[i].coors - *objCoors;
radius = aLights[i].radius;
- if(fabs(dist.x) < radius &&
- fabs(dist.y) < radius &&
- fabs(dist.z) < radius){
+ if(Abs(dist.x) < radius &&
+ Abs(dist.y) < radius &&
+ Abs(dist.z) < radius){
distance = dist.Magnitude();
if(distance < radius){
@@ -217,7 +217,7 @@ CPointLights::RenderFogEffect(void)
// more intensity the closer to light source
intensity *= 1.0f - sq(dot/FOG_AREA_LENGTH);
// more intensity the closer to line
- intensity *= 1.0f - sq(sqrt(linedistsq) / FOG_AREA_WIDTH);
+ intensity *= 1.0f - sq(Sqrt(linedistsq) / FOG_AREA_WIDTH);
if(CSprite::CalcScreenCoors(fogcoors, spriteCoors, &spritew, &spriteh, true)){
float rotation = (CTimer::GetTimeInMilliseconds()&0x1FFF) * 2*3.14f / 0x1FFF;
@@ -251,11 +251,11 @@ CPointLights::RenderFogEffect(void)
float dx = xi - aLights[i].coors.x;
float dy = yi - aLights[i].coors.y;
- float lightdist = sqrt(sq(dx) + sq(dy));
+ float lightdist = Sqrt(sq(dx) + sq(dy));
if(lightdist < FOG_AREA_RADIUS){
dx = xi - TheCamera.GetPosition().x;
dy = yi - TheCamera.GetPosition().y;
- float camdist = sqrt(sq(dx) + sq(dy));
+ float camdist = Sqrt(sq(dx) + sq(dy));
if(camdist < MAX_DIST){
float intensity;
// distance fade
diff --git a/src/render/Sprite.cpp b/src/render/Sprite.cpp
index d917117a..24577f41 100644
--- a/src/render/Sprite.cpp
+++ b/src/render/Sprite.cpp
@@ -135,8 +135,8 @@ CSprite::RenderOneXLUSprite(float x, float y, float z, float w, float h, uint8 r
void
CSprite::RenderOneXLUSprite_Rotate_Aspect(float x, float y, float z, float w, float h, uint8 r, uint8 g, uint8 b, int16 intens, float recipz, float rotation, uint8 a)
{
- float c = cos(DEGTORAD(rotation));
- float s = sin(DEGTORAD(rotation));
+ float c = Cos(DEGTORAD(rotation));
+ float s = Sin(DEGTORAD(rotation));
float xs[4];
float ys[4];
@@ -261,8 +261,8 @@ CSprite::RenderBufferedOneXLUSprite_Rotate_Dimension(float x, float y, float z,
{
m_bFlushSpriteBufferSwitchZTest = 0;
// TODO: replace with lookup
- float c = cos(DEGTORAD(rotation));
- float s = sin(DEGTORAD(rotation));
+ float c = Cos(DEGTORAD(rotation));
+ float s = Sin(DEGTORAD(rotation));
float xs[4];
float ys[4];
@@ -313,8 +313,8 @@ void
CSprite::RenderBufferedOneXLUSprite_Rotate_Aspect(float x, float y, float z, float w, float h, uint8 r, uint8 g, uint8 b, int16 intens, float recipz, float rotation, uint8 a)
{
m_bFlushSpriteBufferSwitchZTest = 0;
- float c = cos(DEGTORAD(rotation));
- float s = sin(DEGTORAD(rotation));
+ float c = Cos(DEGTORAD(rotation));
+ float s = Sin(DEGTORAD(rotation));
float xs[4];
float ys[4];
@@ -365,8 +365,8 @@ void
CSprite::RenderBufferedOneXLUSprite_Rotate_2Colours(float x, float y, float z, float w, float h, uint8 r1, uint8 g1, uint8 b1, uint8 r2, uint8 g2, uint8 b2, float cx, float cy, float recipz, float rotation, uint8 a)
{
m_bFlushSpriteBufferSwitchZTest = 0;
- float c = cos(DEGTORAD(rotation));
- float s = sin(DEGTORAD(rotation));
+ float c = Cos(DEGTORAD(rotation));
+ float s = Sin(DEGTORAD(rotation));
float xs[4];
float ys[4];
@@ -572,8 +572,8 @@ CSprite::RenderBufferedOneXLUSprite2D_Rotate_Dimension(float x, float y, float w
{
m_bFlushSpriteBufferSwitchZTest = 1;
CRGBA col(intens * colour.red >> 8, intens * colour.green >> 8, intens * colour.blue >> 8, alpha);
- float c = cos(DEGTORAD(rotation));
- float s = sin(DEGTORAD(rotation));
+ float c = Cos(DEGTORAD(rotation));
+ float s = Sin(DEGTORAD(rotation));
Set6Vertices2D(&SpriteBufferVerts[6 * nSpriteBufferIndex],
x + c*w - s*h,
diff --git a/src/render/Timecycle.cpp b/src/render/Timecycle.cpp
index af154716..7ab3e91e 100644
--- a/src/render/Timecycle.cpp
+++ b/src/render/Timecycle.cpp
@@ -299,9 +299,9 @@ CTimeCycle::Update(void)
float sunAngle = 2*PI*(CClock::GetMinutes() + CClock::GetHours()*60)/(24*60);
CVector &sunPos = GetSunPosition();
- sunPos.x = sinf(sunAngle);
+ sunPos.x = Sin(sunAngle);
sunPos.y = 1.0f;
- sunPos.z = 0.2f - cosf(sunAngle);
+ sunPos.z = 0.2f - Cos(sunAngle);
sunPos.Normalise();
CShadows::CalcPedShadowValues(sunPos,
diff --git a/src/skel/win/win.cpp b/src/skel/win/win.cpp
index 0481e104..9c7d0106 100644
--- a/src/skel/win/win.cpp
+++ b/src/skel/win/win.cpp
@@ -2340,7 +2340,7 @@ HRESULT CapturePad(RwInt32 padID)
{
float angle = DEGTORAD((float)js.rgdwPOV[0] / 100.0f);
- leftStickPos.x = sin(angle);
+ leftStickPos.x = Sin(angle);
leftStickPos.y = -cos(angle);
}
@@ -2365,16 +2365,16 @@ HRESULT CapturePad(RwInt32 padID)
CPad *pad = CPad::GetPad(bs.padID);
- if ( fabs(leftStickPos.x) > 0.3f )
+ if ( Abs(leftStickPos.x) > 0.3f )
pad->PCTempJoyState.LeftStickX = (int32)(leftStickPos.x * 128.0f);
- if ( fabs(leftStickPos.y) > 0.3f )
+ if ( Abs(leftStickPos.y) > 0.3f )
pad->PCTempJoyState.LeftStickY = (int32)(leftStickPos.y * 128.0f);
- if ( fabs(rightStickPos.x) > 0.3f )
+ if ( Abs(rightStickPos.x) > 0.3f )
pad->PCTempJoyState.RightStickX = (int32)(rightStickPos.x * 128.0f);
- if ( fabs(rightStickPos.y) > 0.3f )
+ if ( Abs(rightStickPos.y) > 0.3f )
pad->PCTempJoyState.RightStickY = (int32)(rightStickPos.y * 128.0f);
}
diff --git a/src/vehicles/Door.cpp b/src/vehicles/Door.cpp
index ec5eb223..25e87504 100644
--- a/src/vehicles/Door.cpp
+++ b/src/vehicles/Door.cpp
@@ -53,7 +53,7 @@ CDoor::Process(CVehicle *vehicle)
break;
}
fSpeedDiff = clamp(fSpeedDiff, -0.2f, 0.2f);
- if(fabs(fSpeedDiff) > 0.002f)
+ if(Abs(fSpeedDiff) > 0.002f)
m_fAngVel += fSpeedDiff;
m_fAngVel *= 0.945f;
m_fAngVel = clamp(m_fAngVel, -0.3f, 0.3f);
@@ -76,7 +76,7 @@ CDoor::Process(CVehicle *vehicle)
float
CDoor::RetAngleWhenClosed(void)
{
- if(fabs(m_fMaxAngle) < fabs(m_fMinAngle))
+ if(Abs(m_fMaxAngle) < Abs(m_fMinAngle))
return m_fMaxAngle;
else
return m_fMinAngle;
@@ -85,7 +85,7 @@ CDoor::RetAngleWhenClosed(void)
float
CDoor::RetAngleWhenOpen(void)
{
- if(fabs(m_fMaxAngle) < fabs(m_fMinAngle))
+ if(Abs(m_fMaxAngle) < Abs(m_fMinAngle))
return m_fMinAngle;
else
return m_fMaxAngle;
@@ -104,7 +104,7 @@ bool
CDoor::IsFullyOpen(void)
{
// why -0.5? that's around 28 deg less than fully open
- if(fabs(m_fAngle) < fabs(RetAngleWhenOpen()) - 0.5f)
+ if(Abs(m_fAngle) < Abs(RetAngleWhenOpen()) - 0.5f)
return false;
return true;
}
diff --git a/src/vehicles/Vehicle.cpp b/src/vehicles/Vehicle.cpp
index 13e02566..688496c1 100644
--- a/src/vehicles/Vehicle.cpp
+++ b/src/vehicles/Vehicle.cpp
@@ -213,7 +213,7 @@ CVehicle::FlyingControl(eFlightModel flightModel)
ApplyTurnForce(impulse*GetUp(), 2.0f*GetUp() + com);
- m_vecTurnSpeed.y *= powf(0.9f, CTimer::GetTimeStep());
+ m_vecTurnSpeed.y *= Pow(0.9f, CTimer::GetTimeStep());
moveSpeed = m_vecMoveSpeed.MagnitudeSqr();
if(moveSpeed > 2.25f)
m_vecMoveSpeed *= 1.5f/sqrt(moveSpeed);
@@ -296,7 +296,7 @@ CVehicle::ProcessWheel(CVector &wheelFwd, CVector &wheelRight, CVector &wheelCon
}
if(brake > adhesion){
- if(fabs(contactSpeedFwd) > 0.005f)
+ if(Abs(contactSpeedFwd) > 0.005f)
*wheelState = WHEEL_STATE_STATIC;
}else {
if(fwd > 0.0f){
@@ -317,7 +317,7 @@ CVehicle::ProcessWheel(CVector &wheelFwd, CVector &wheelRight, CVector &wheelCon
*wheelState = WHEEL_STATE_2;
}
- float l = sqrt(sq(right) + sq(fwd));
+ float l = Sqrt(sq(right) + sq(fwd));
float tractionLoss = bAlreadySkidding ? 1.0f : m_handling->fTractionLoss;
right *= adhesion * tractionLoss / l;
fwd *= adhesion * tractionLoss / l;
@@ -552,9 +552,9 @@ CVehicle::CanPedExitCar(void)
if(m_vecMoveSpeed.MagnitudeSqr() > 0.005f)
return false;
// if car is slow enough, check turn speed
- if(fabs(m_vecTurnSpeed.x) > 0.01f ||
- fabs(m_vecTurnSpeed.y) > 0.01f ||
- fabs(m_vecTurnSpeed.z) > 0.01f)
+ if(Abs(m_vecTurnSpeed.x) > 0.01f ||
+ Abs(m_vecTurnSpeed.y) > 0.01f ||
+ Abs(m_vecTurnSpeed.z) > 0.01f)
return false;
return true;
}else{
@@ -564,9 +564,9 @@ CVehicle::CanPedExitCar(void)
if(m_vecMoveSpeed.MagnitudeSqr() >= 0.005f)
return false;
// if car is slow enough, check turn speed
- if(fabs(m_vecTurnSpeed.x) >= 0.01f ||
- fabs(m_vecTurnSpeed.y) >= 0.01f ||
- fabs(m_vecTurnSpeed.z) >= 0.01f)
+ if(Abs(m_vecTurnSpeed.x) >= 0.01f ||
+ Abs(m_vecTurnSpeed.y) >= 0.01f ||
+ Abs(m_vecTurnSpeed.z) >= 0.01f)
return false;
return true;
}