From 90e093cd47fb2af10617b1d404fc65ca813782ec Mon Sep 17 00:00:00 2001 From: aap Date: Wed, 10 Jul 2019 17:34:11 +0200 Subject: and of course the last commit didnt fix everything --- src/animation/AnimBlendNode.cpp | 4 ++-- src/animation/AnimBlendNode.h | 2 +- src/animation/FrameUpdate.cpp | 6 +++--- src/core/Camera.cpp | 14 +++++++------- src/core/Collision.cpp | 2 +- src/core/General.h | 4 ++-- src/core/Radar.cpp | 4 ++-- src/core/main.cpp | 2 +- src/math/Vector.h | 2 +- src/math/Vector2D.h | 2 +- src/math/math.cpp | 2 +- src/math/maths.h | 8 ++++++-- src/peds/Ped.cpp | 8 ++++---- src/peds/PedIK.cpp | 2 +- src/render/Clouds.cpp | 2 +- src/render/Draw.cpp | 4 ++-- src/render/PointLights.cpp | 2 +- src/skel/win/win.cpp | 2 +- src/vehicles/Vehicle.cpp | 4 ++-- 19 files changed, 40 insertions(+), 36 deletions(-) (limited to 'src') diff --git a/src/animation/AnimBlendNode.cpp b/src/animation/AnimBlendNode.cpp index 3d3d80ec..be5fcc9c 100644 --- a/src/animation/AnimBlendNode.cpp +++ b/src/animation/AnimBlendNode.cpp @@ -125,8 +125,8 @@ CAnimBlendNode::CalcDeltas(void) float cos = DotProduct(kfA->rotation, kfB->rotation); if(cos > 1.0f) cos = 1.0f; - theta = acos(cos); - invSin = theta == 0.0f ? 0.0f : 1.0f/sin(theta); + theta = Acos(cos); + invSin = theta == 0.0f ? 0.0f : 1.0f/Sin(theta); } void diff --git a/src/animation/AnimBlendNode.h b/src/animation/AnimBlendNode.h index ea75fbfa..361a4134 100644 --- a/src/animation/AnimBlendNode.h +++ b/src/animation/AnimBlendNode.h @@ -10,7 +10,7 @@ class CAnimBlendNode public: // for slerp float theta; // angle between quaternions - float invSin; // 1/sin(theta) + float invSin; // 1/Sin(theta) // indices into array in sequence int32 frameA; // next key frame int32 frameB; // previous key frame diff --git a/src/animation/FrameUpdate.cpp b/src/animation/FrameUpdate.cpp index 62300527..dcb71944 100644 --- a/src/animation/FrameUpdate.cpp +++ b/src/animation/FrameUpdate.cpp @@ -53,7 +53,7 @@ FrameUpdateCallBack(AnimBlendFrameData *frame, void *arg) if(norm == 0.0f) rot.w = 1.0f; else - rot *= 1.0f/sqrt(norm); + rot *= 1.0f/Sqrt(norm); rot.Get(mat); } @@ -127,7 +127,7 @@ FrameUpdateCallBackWithVelocityExtraction(AnimBlendFrameData *frame, void *arg) if(norm == 0.0f) rot.w = 1.0f; else - rot *= 1.0f/sqrt(norm); + rot *= 1.0f/Sqrt(norm); rot.Get(mat); } @@ -206,7 +206,7 @@ FrameUpdateCallBackWith3dVelocityExtraction(AnimBlendFrameData *frame, void *arg if(norm == 0.0f) rot.w = 1.0f; else - rot *= 1.0f/sqrt(norm); + rot *= 1.0f/Sqrt(norm); rot.Get(mat); } diff --git a/src/core/Camera.cpp b/src/core/Camera.cpp index 4e988c15..c06ee48b 100644 --- a/src/core/Camera.cpp +++ b/src/core/Camera.cpp @@ -355,8 +355,8 @@ CCam::Process_FollowPed(const CVector &CameraTarget, float TargetOrientation, fl // TODO: what's transition beta? if(TheCamera.m_bUseTransitionBeta && ResetStatics){ CVector VecDistance; - IdealSource.x = TargetCoors.x + GroundDist*cos(m_fTransitionBeta); - IdealSource.y = TargetCoors.y + GroundDist*sin(m_fTransitionBeta); + IdealSource.x = TargetCoors.x + GroundDist*Cos(m_fTransitionBeta); + IdealSource.y = TargetCoors.y + GroundDist*Sin(m_fTransitionBeta); Beta = CGeneral::GetATanOfXY(IdealSource.x - TargetCoors.x, IdealSource.y - TargetCoors.y); }else Beta = CGeneral::GetATanOfXY(Source.x - TargetCoors.x, Source.y - TargetCoors.y); @@ -799,7 +799,7 @@ CCam::WorkOutCamHeightWeeCar(CVector &TargetCoors, float TargetOrientation) if(CCullZones::CamNoRain() || CCullZones::PlayerNoRain()) AlphaTarget = DEGTORAD(14.0f); WellBufferMe(AlphaTarget, &Alpha, &AlphaSpeed, 0.1f, 0.05f, true); - Source.z = TargetCoors.z + CA_MAX_DISTANCE*sin(Alpha); + Source.z = TargetCoors.z + CA_MAX_DISTANCE*Sin(Alpha); if(FindPlayerVehicle()){ m_fUnknownZOffSet = 0.0f; @@ -945,7 +945,7 @@ CCam::WorkOutCamHeight(const CVector &TargetCoors, float TargetOrientation, floa CWorld::FindRoofZFor3DCoord(TargetCoors.x - SideX, TargetCoors.y - SideY, CarBottom, &FoundRoofSide2); // Now find out at what height we'd like to place the camera - float CamGround = CWorld::FindGroundZFor3DCoord(Source.x, Source.y, TargetCoors.z + Length*sin(Alpha + ModeAlpha) + m_fCloseInCarHeightOffset, &FoundCamGround); + float CamGround = CWorld::FindGroundZFor3DCoord(Source.x, Source.y, TargetCoors.z + Length*Sin(Alpha + ModeAlpha) + m_fCloseInCarHeightOffset, &FoundCamGround); float CamTargetZ = 0.0f; if(FoundCamGround){ // This is the normal case @@ -992,7 +992,7 @@ CCam::WorkOutCamHeight(const CVector &TargetCoors, float TargetOrientation, floa } // Now do things if CamClear...but what is that anyway? - float CamZ = TargetCoors.z + Length*sin(Alpha + DeltaAlpha + ModeAlpha) + m_fCloseInCarHeightOffset; + float CamZ = TargetCoors.z + Length*Sin(Alpha + DeltaAlpha + ModeAlpha) + m_fCloseInCarHeightOffset; bool FoundGround, FoundRoof; float CamGround2 = CWorld::FindGroundZFor3DCoord(Source.x, Source.y, CamZ, &FoundGround); if(FoundGround){ @@ -1138,8 +1138,8 @@ CCam::FixCamIfObscured(CVector &TargetCoors, float TargetHeight, float TargetOri Obscured1 = CWorld::ProcessLineOfSight(EntityPos, TempSource, colPoint, ent, true, false, false, true, false, true, true); }else if(m_bFixingBeta){ float d = (TempSource - Target).Magnitude(); - TempSource.x = Target.x - d*cos(TargetOrientation); - TempSource.y = Target.y - d*sin(TargetOrientation); + TempSource.x = Target.x - d*Cos(TargetOrientation); + TempSource.y = Target.y - d*Sin(TargetOrientation); // same check again Obscured2 = CWorld::ProcessLineOfSight(Target, TempSource, colPoint, ent, true, false, false, true, false, true, true); diff --git a/src/core/Collision.cpp b/src/core/Collision.cpp index 6241b79a..1ed08867 100644 --- a/src/core/Collision.cpp +++ b/src/core/Collision.cpp @@ -627,7 +627,7 @@ CCollision::ProcessSphereBox(const CColSphere &sph, const CColBox &box, CColPoin dist = sph.center - p; float lensq = dist.MagnitudeSqr(); if(lensq < mindistsq){ - point.normal = dist * (1.0f/sqrt(lensq)); + point.normal = dist * (1.0f/Sqrt(lensq)); point.point = sph.center - point.normal; point.surfaceA = sph.surface; point.pieceA = sph.piece; diff --git a/src/core/General.h b/src/core/General.h index a08b622b..64613478 100644 --- a/src/core/General.h +++ b/src/core/General.h @@ -70,12 +70,12 @@ public: if (y > 0.0f) return PI - Atan2(x / y, 1.0f); else - return -atan2(x / y, 1.0f); + return -Atan2(x / y, 1.0f); } else { if (y > 0.0f) return -(PI + Atan2(x / y, 1.0f)); else - return -atan2(x / y, 1.0f); + return -Atan2(x / y, 1.0f); } } diff --git a/src/core/Radar.cpp b/src/core/Radar.cpp index b634e4f5..ea7a7ffa 100644 --- a/src/core/Radar.cpp +++ b/src/core/Radar.cpp @@ -868,7 +868,7 @@ void CRadar::TransformRadarPointToRealWorldSpace(CVector2D &out, const CVector2D { float s, c; - s = -sin(TheCamera.GetForward().Heading()); + s = -Sin(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) { @@ -885,7 +885,7 @@ void CRadar::TransformRadarPointToRealWorldSpace(CVector2D &out, const CVector2D else forward = TheCamera.Cams[TheCamera.ActiveCam].CamTargetEntity->GetPosition() - TheCamera.Cams[TheCamera.ActiveCam].SourceBeforeLookBehind; - s = -sin(forward.Heading()); + s = -Sin(forward.Heading()); c = Cos(forward.Heading()); } diff --git a/src/core/main.cpp b/src/core/main.cpp index 9ac271f9..ffde80bb 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -48,7 +48,7 @@ #include "RpAnimBlend.h" #include "Frontend.h" -#define DEFAULT_VIEWWINDOW (tan(DEGTORAD(CDraw::GetFOV() * 0.5f))) +#define DEFAULT_VIEWWINDOW (Tan(DEGTORAD(CDraw::GetFOV() * 0.5f))) GlobalScene &Scene = *(GlobalScene*)0x726768; diff --git a/src/math/Vector.h b/src/math/Vector.h index 9a1dde7a..de8092eb 100644 --- a/src/math/Vector.h +++ b/src/math/Vector.h @@ -30,7 +30,7 @@ public: void Normalise(void) { float sq = MagnitudeSqr(); if(sq > 0.0f){ - float invsqrt = 1.0f/sqrt(sq); // CMaths::RecipSqrt + float invsqrt = 1.0f/Sqrt(sq); // CMaths::RecipSqrt x *= invsqrt; y *= invsqrt; z *= invsqrt; diff --git a/src/math/Vector2D.h b/src/math/Vector2D.h index d0580545..e6b04c14 100644 --- a/src/math/Vector2D.h +++ b/src/math/Vector2D.h @@ -13,7 +13,7 @@ public: void Normalise(void){ float sq = MagnitudeSqr(); if(sq > 0.0f){ - float invsqrt = 1.0f/sqrt(sq); + float invsqrt = 1.0f/Sqrt(sq); x *= invsqrt; y *= invsqrt; }else diff --git a/src/math/math.cpp b/src/math/math.cpp index b4ba9c98..c1199fcc 100644 --- a/src/math/math.cpp +++ b/src/math/math.cpp @@ -14,7 +14,7 @@ CQuaternion::Slerp(const CQuaternion &q1, const CQuaternion &q2, float theta, fl if(theta > PI/2){ theta = PI - theta; w1 = Sin((1.0f - t) * theta) * invSin; - w2 = -sin(t * theta) * invSin; + w2 = -Sin(t * theta) * invSin; }else{ w1 = Sin((1.0f - t) * theta) * invSin; w2 = Sin(t * theta) * invSin; diff --git a/src/math/maths.h b/src/math/maths.h index 49e39631..a1c3f109 100644 --- a/src/math/maths.h +++ b/src/math/maths.h @@ -4,9 +4,13 @@ // in gta they are in CMaths but that makes the code rather noisy inline float Sin(float x) { return sinf(x); } +inline float Asin(float x) { return asinf(x); } inline float Cos(float x) { return cosf(x); } +inline float Acos(float x) { return acosf(x); } +inline float Tan(float x) { return tanf(x); } +inline float Atan(float x) { return atanf(x); } +inline float Atan2(float y, float x) { return atan2f(y, 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 RecipSqrt(float x) { return 1.0f/Sqrt(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 c9a9cfb5..4ad4ac1b 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -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 @@ -2153,7 +2153,7 @@ CPed::CalculateNewVelocity(void) 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.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) { @@ -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( diff --git a/src/peds/PedIK.cpp b/src/peds/PedIK.cpp index 0bd49459..9b3f401f 100644 --- a/src/peds/PedIK.cpp +++ b/src/peds/PedIK.cpp @@ -51,7 +51,7 @@ CPedIK::RotateTorso(AnimBlendFrameData *animBlend, LimbOrientation *limb, bool c float dotProduct = DotProduct(mat->at, inversedForward); if(dotProduct > 1.0f) dotProduct = 1.0f; if(dotProduct < -1.0f) dotProduct = -1.0f; - float alpha = acos(dotProduct); + float alpha = Acos(dotProduct); if(mat->at.z < 0.0f) alpha = -alpha; diff --git a/src/render/Clouds.cpp b/src/render/Clouds.cpp index 2ead715b..2884894c 100644 --- a/src/render/Clouds.cpp +++ b/src/render/Clouds.cpp @@ -305,7 +305,7 @@ CClouds::RenderBackground(int16 topred, int16 topgreen, int16 topblue, 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); + ms_cameraRoll = Acos(c); if(mat->right.z < 0.0f) ms_cameraRoll = -ms_cameraRoll; diff --git a/src/render/Draw.cpp b/src/render/Draw.cpp index 5a377214..beb3443d 100644 --- a/src/render/Draw.cpp +++ b/src/render/Draw.cpp @@ -50,8 +50,8 @@ CDraw::ConvertFOV(float hfov) float ar1 = DEFAULT_ASPECT_RATIO; float ar2 = GetAspectRatio(); hfov = DEGTORAD(hfov); - float vfov = atan(tan(hfov/2) / ar1) *2; - hfov = atan(tan(vfov/2) * ar2) *2; + float vfov = Atan(tan(hfov/2) / ar1) *2; + hfov = Atan(tan(vfov/2) * ar2) *2; return RADTODEG(hfov); } #endif diff --git a/src/render/PointLights.cpp b/src/render/PointLights.cpp index b5d4ece1..a015ec54 100644 --- a/src/render/PointLights.cpp +++ b/src/render/PointLights.cpp @@ -213,7 +213,7 @@ CPointLights::RenderFogEffect(void) if(dot > 0.0f && dot < FOG_AREA_LENGTH && linedistsq < sq(FOG_AREA_WIDTH)){ float intensity = 158.0f * fogginess; // more intensity the smaller the angle - intensity *= dot/sqrt(distsq); + intensity *= dot/Sqrt(distsq); // more intensity the closer to light source intensity *= 1.0f - sq(dot/FOG_AREA_LENGTH); // more intensity the closer to line diff --git a/src/skel/win/win.cpp b/src/skel/win/win.cpp index 9c7d0106..ac0460f1 100644 --- a/src/skel/win/win.cpp +++ b/src/skel/win/win.cpp @@ -2341,7 +2341,7 @@ HRESULT CapturePad(RwInt32 padID) float angle = DEGTORAD((float)js.rgdwPOV[0] / 100.0f); leftStickPos.x = Sin(angle); - leftStickPos.y = -cos(angle); + leftStickPos.y = -Cos(angle); } if ( AllValidWinJoys.m_aJoys[bs.padID].m_bHasAxisR && AllValidWinJoys.m_aJoys[bs.padID].m_bHasAxisZ ) diff --git a/src/vehicles/Vehicle.cpp b/src/vehicles/Vehicle.cpp index 688496c1..d8ed1a15 100644 --- a/src/vehicles/Vehicle.cpp +++ b/src/vehicles/Vehicle.cpp @@ -216,11 +216,11 @@ CVehicle::FlyingControl(eFlightModel flightModel) m_vecTurnSpeed.y *= Pow(0.9f, CTimer::GetTimeStep()); moveSpeed = m_vecMoveSpeed.MagnitudeSqr(); if(moveSpeed > 2.25f) - m_vecMoveSpeed *= 1.5f/sqrt(moveSpeed); + m_vecMoveSpeed *= 1.5f/Sqrt(moveSpeed); float turnSpeed = m_vecTurnSpeed.MagnitudeSqr(); if(turnSpeed > 0.04f) - m_vecTurnSpeed *= 0.2f/sqrt(turnSpeed); + m_vecTurnSpeed *= 0.2f/Sqrt(turnSpeed); } break; -- cgit v1.2.3