diff options
author | aap <aap@papnet.eu> | 2019-07-10 17:18:26 +0200 |
---|---|---|
committer | aap <aap@papnet.eu> | 2019-07-10 17:18:26 +0200 |
commit | 4a36d64f15f898854bb8a76be86ac9a8c536b291 (patch) | |
tree | 2ff1344fb2f1e9859ba15cd56c461d40683359f9 /src/core | |
parent | Merge pull request #128 from erorcun/erorcun (diff) | |
download | re3-4a36d64f15f898854bb8a76be86ac9a8c536b291.tar re3-4a36d64f15f898854bb8a76be86ac9a8c536b291.tar.gz re3-4a36d64f15f898854bb8a76be86ac9a8c536b291.tar.bz2 re3-4a36d64f15f898854bb8a76be86ac9a8c536b291.tar.lz re3-4a36d64f15f898854bb8a76be86ac9a8c536b291.tar.xz re3-4a36d64f15f898854bb8a76be86ac9a8c536b291.tar.zst re3-4a36d64f15f898854bb8a76be86ac9a8c536b291.zip |
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/Camera.cpp | 56 | ||||
-rw-r--r-- | src/core/Collision.cpp | 20 | ||||
-rw-r--r-- | src/core/FileLoader.cpp | 6 | ||||
-rw-r--r-- | src/core/General.h | 24 | ||||
-rw-r--r-- | src/core/Pad.cpp | 22 | ||||
-rw-r--r-- | src/core/Radar.cpp | 20 | ||||
-rw-r--r-- | src/core/Streaming.cpp | 10 | ||||
-rw-r--r-- | src/core/common.h | 1 |
8 files changed, 80 insertions, 79 deletions
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" |