and of course the last commit didnt fix everything

This commit is contained in:
aap 2019-07-10 17:34:11 +02:00
parent 4a36d64f15
commit 90e093cd47
19 changed files with 40 additions and 36 deletions

View File

@ -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

View File

@ -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

View File

@ -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);
}

View File

@ -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);

View File

@ -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;

View File

@ -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);
}
}

View File

@ -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());
}

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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); }

View File

@ -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(

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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 )

View File

@ -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;