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); float cos = DotProduct(kfA->rotation, kfB->rotation);
if(cos > 1.0f) if(cos > 1.0f)
cos = 1.0f; cos = 1.0f;
theta = acos(cos); theta = Acos(cos);
invSin = theta == 0.0f ? 0.0f : 1.0f/sin(theta); invSin = theta == 0.0f ? 0.0f : 1.0f/Sin(theta);
} }
void void

View File

@ -10,7 +10,7 @@ class CAnimBlendNode
public: public:
// for slerp // for slerp
float theta; // angle between quaternions float theta; // angle between quaternions
float invSin; // 1/sin(theta) float invSin; // 1/Sin(theta)
// indices into array in sequence // indices into array in sequence
int32 frameA; // next key frame int32 frameA; // next key frame
int32 frameB; // previous key frame int32 frameB; // previous key frame

View File

@ -53,7 +53,7 @@ FrameUpdateCallBack(AnimBlendFrameData *frame, void *arg)
if(norm == 0.0f) if(norm == 0.0f)
rot.w = 1.0f; rot.w = 1.0f;
else else
rot *= 1.0f/sqrt(norm); rot *= 1.0f/Sqrt(norm);
rot.Get(mat); rot.Get(mat);
} }
@ -127,7 +127,7 @@ FrameUpdateCallBackWithVelocityExtraction(AnimBlendFrameData *frame, void *arg)
if(norm == 0.0f) if(norm == 0.0f)
rot.w = 1.0f; rot.w = 1.0f;
else else
rot *= 1.0f/sqrt(norm); rot *= 1.0f/Sqrt(norm);
rot.Get(mat); rot.Get(mat);
} }
@ -206,7 +206,7 @@ FrameUpdateCallBackWith3dVelocityExtraction(AnimBlendFrameData *frame, void *arg
if(norm == 0.0f) if(norm == 0.0f)
rot.w = 1.0f; rot.w = 1.0f;
else else
rot *= 1.0f/sqrt(norm); rot *= 1.0f/Sqrt(norm);
rot.Get(mat); rot.Get(mat);
} }

View File

@ -355,8 +355,8 @@ CCam::Process_FollowPed(const CVector &CameraTarget, float TargetOrientation, fl
// TODO: what's transition beta? // TODO: what's transition beta?
if(TheCamera.m_bUseTransitionBeta && ResetStatics){ if(TheCamera.m_bUseTransitionBeta && ResetStatics){
CVector VecDistance; CVector VecDistance;
IdealSource.x = TargetCoors.x + GroundDist*cos(m_fTransitionBeta); IdealSource.x = TargetCoors.x + GroundDist*Cos(m_fTransitionBeta);
IdealSource.y = TargetCoors.y + GroundDist*sin(m_fTransitionBeta); IdealSource.y = TargetCoors.y + GroundDist*Sin(m_fTransitionBeta);
Beta = CGeneral::GetATanOfXY(IdealSource.x - TargetCoors.x, IdealSource.y - TargetCoors.y); Beta = CGeneral::GetATanOfXY(IdealSource.x - TargetCoors.x, IdealSource.y - TargetCoors.y);
}else }else
Beta = CGeneral::GetATanOfXY(Source.x - TargetCoors.x, Source.y - TargetCoors.y); 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()) if(CCullZones::CamNoRain() || CCullZones::PlayerNoRain())
AlphaTarget = DEGTORAD(14.0f); AlphaTarget = DEGTORAD(14.0f);
WellBufferMe(AlphaTarget, &Alpha, &AlphaSpeed, 0.1f, 0.05f, true); 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()){ if(FindPlayerVehicle()){
m_fUnknownZOffSet = 0.0f; 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); CWorld::FindRoofZFor3DCoord(TargetCoors.x - SideX, TargetCoors.y - SideY, CarBottom, &FoundRoofSide2);
// Now find out at what height we'd like to place the camera // 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; float CamTargetZ = 0.0f;
if(FoundCamGround){ if(FoundCamGround){
// This is the normal case // 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? // 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; bool FoundGround, FoundRoof;
float CamGround2 = CWorld::FindGroundZFor3DCoord(Source.x, Source.y, CamZ, &FoundGround); float CamGround2 = CWorld::FindGroundZFor3DCoord(Source.x, Source.y, CamZ, &FoundGround);
if(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); Obscured1 = CWorld::ProcessLineOfSight(EntityPos, TempSource, colPoint, ent, true, false, false, true, false, true, true);
}else if(m_bFixingBeta){ }else if(m_bFixingBeta){
float d = (TempSource - Target).Magnitude(); float d = (TempSource - Target).Magnitude();
TempSource.x = Target.x - d*cos(TargetOrientation); TempSource.x = Target.x - d*Cos(TargetOrientation);
TempSource.y = Target.y - d*sin(TargetOrientation); TempSource.y = Target.y - d*Sin(TargetOrientation);
// same check again // same check again
Obscured2 = CWorld::ProcessLineOfSight(Target, TempSource, colPoint, ent, true, false, false, true, false, true, true); 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; dist = sph.center - p;
float lensq = dist.MagnitudeSqr(); float lensq = dist.MagnitudeSqr();
if(lensq < mindistsq){ if(lensq < mindistsq){
point.normal = dist * (1.0f/sqrt(lensq)); point.normal = dist * (1.0f/Sqrt(lensq));
point.point = sph.center - point.normal; point.point = sph.center - point.normal;
point.surfaceA = sph.surface; point.surfaceA = sph.surface;
point.pieceA = sph.piece; point.pieceA = sph.piece;

View File

@ -70,12 +70,12 @@ public:
if (y > 0.0f) if (y > 0.0f)
return PI - Atan2(x / y, 1.0f); return PI - Atan2(x / y, 1.0f);
else else
return -atan2(x / y, 1.0f); return -Atan2(x / y, 1.0f);
} else { } else {
if (y > 0.0f) if (y > 0.0f)
return -(PI + Atan2(x / y, 1.0f)); return -(PI + Atan2(x / y, 1.0f));
else 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; float s, c;
s = -sin(TheCamera.GetForward().Heading()); 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) { 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 else
forward = TheCamera.Cams[TheCamera.ActiveCam].CamTargetEntity->GetPosition() - TheCamera.Cams[TheCamera.ActiveCam].SourceBeforeLookBehind; forward = TheCamera.Cams[TheCamera.ActiveCam].CamTargetEntity->GetPosition() - TheCamera.Cams[TheCamera.ActiveCam].SourceBeforeLookBehind;
s = -sin(forward.Heading()); s = -Sin(forward.Heading());
c = Cos(forward.Heading()); c = Cos(forward.Heading());
} }

View File

@ -48,7 +48,7 @@
#include "RpAnimBlend.h" #include "RpAnimBlend.h"
#include "Frontend.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; GlobalScene &Scene = *(GlobalScene*)0x726768;

View File

@ -30,7 +30,7 @@ public:
void Normalise(void) { void Normalise(void) {
float sq = MagnitudeSqr(); float sq = MagnitudeSqr();
if(sq > 0.0f){ if(sq > 0.0f){
float invsqrt = 1.0f/sqrt(sq); // CMaths::RecipSqrt float invsqrt = 1.0f/Sqrt(sq); // CMaths::RecipSqrt
x *= invsqrt; x *= invsqrt;
y *= invsqrt; y *= invsqrt;
z *= invsqrt; z *= invsqrt;

View File

@ -13,7 +13,7 @@ public:
void Normalise(void){ void Normalise(void){
float sq = MagnitudeSqr(); float sq = MagnitudeSqr();
if(sq > 0.0f){ if(sq > 0.0f){
float invsqrt = 1.0f/sqrt(sq); float invsqrt = 1.0f/Sqrt(sq);
x *= invsqrt; x *= invsqrt;
y *= invsqrt; y *= invsqrt;
}else }else

View File

@ -14,7 +14,7 @@ CQuaternion::Slerp(const CQuaternion &q1, const CQuaternion &q2, float theta, fl
if(theta > PI/2){ if(theta > PI/2){
theta = PI - theta; theta = PI - theta;
w1 = Sin((1.0f - t) * theta) * invSin; w1 = Sin((1.0f - t) * theta) * invSin;
w2 = -sin(t * theta) * invSin; w2 = -Sin(t * theta) * invSin;
}else{ }else{
w1 = Sin((1.0f - t) * theta) * invSin; w1 = Sin((1.0f - t) * theta) * invSin;
w2 = Sin(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 // in gta they are in CMaths but that makes the code rather noisy
inline float Sin(float x) { return sinf(x); } 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 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 Abs(float x) { return fabs(x); }
inline float Sqrt(float x) { return sqrtf(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/Sqrt(x); }
inline float RecipSqrt(float x) { return 1.0f/sqrtf(x); }
inline float Pow(float x, float y) { return powf(x, y); } 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. // 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 // 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 forward.Normalise(); // this is kinda pointless
// Move forward 1.25 meters // Move forward 1.25 meters
@ -2153,7 +2153,7 @@ 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.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.y = DotProduct2D(m_vecAnimMoveDelta, forward); // m_vecAnimMoveDelta.y* Cos(m_fRotationCur) + (m_vecAnimMoveDelta.x * Sin(m_fRotationCur));
if (CTimer::GetTimeStep() >= 0.01f) { if (CTimer::GetTimeStep() >= 0.01f) {
@ -2179,7 +2179,7 @@ CPed::CalculateNewVelocity(void)
// Interestingly this part is responsible for diagonal walking. // Interestingly this part is responsible for diagonal walking.
if (localWalkAngle > -DEGTORAD(50.0f) && localWalkAngle < DEGTORAD(50.0f)) { if (localWalkAngle > -DEGTORAD(50.0f) && localWalkAngle < DEGTORAD(50.0f)) {
TheCamera.Cams[TheCamera.ActiveCam].m_fPlayerVelocity = pedSpeed; 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); CAnimBlendAssociation *idleAssoc = RpAnimBlendClumpGetAssociation((RpClump*) m_rwObject, ANIM_IDLE_STANCE);
@ -2239,7 +2239,7 @@ CPed::CanPedDriveOff(void)
bool bool
CPed::CanPedJumpThis(int32 unused) CPed::CanPedJumpThis(int32 unused)
{ {
CVector2D forward(-sin(m_fRotationCur), Cos(m_fRotationCur)); CVector2D forward(-Sin(m_fRotationCur), Cos(m_fRotationCur));
CVector pos = GetPosition(); CVector pos = GetPosition();
// wat? // wat?
CVector forwardPos( CVector forwardPos(

View File

@ -51,7 +51,7 @@ CPedIK::RotateTorso(AnimBlendFrameData *animBlend, LimbOrientation *limb, bool c
float dotProduct = DotProduct(mat->at, inversedForward); float dotProduct = DotProduct(mat->at, inversedForward);
if(dotProduct > 1.0f) dotProduct = 1.0f; if(dotProduct > 1.0f) dotProduct = 1.0f;
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) if(mat->at.z < 0.0f)
alpha = -alpha; 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); float c = Sqrt(mat->right.x * mat->right.x + mat->right.y * mat->right.y);
if(c > 1.0f) if(c > 1.0f)
c = 1.0f; c = 1.0f;
ms_cameraRoll = acos(c); ms_cameraRoll = Acos(c);
if(mat->right.z < 0.0f) if(mat->right.z < 0.0f)
ms_cameraRoll = -ms_cameraRoll; ms_cameraRoll = -ms_cameraRoll;

View File

@ -50,8 +50,8 @@ CDraw::ConvertFOV(float hfov)
float ar1 = DEFAULT_ASPECT_RATIO; float ar1 = DEFAULT_ASPECT_RATIO;
float ar2 = GetAspectRatio(); float ar2 = GetAspectRatio();
hfov = DEGTORAD(hfov); hfov = DEGTORAD(hfov);
float vfov = atan(tan(hfov/2) / ar1) *2; float vfov = Atan(tan(hfov/2) / ar1) *2;
hfov = atan(tan(vfov/2) * ar2) *2; hfov = Atan(tan(vfov/2) * ar2) *2;
return RADTODEG(hfov); return RADTODEG(hfov);
} }
#endif #endif

View File

@ -213,7 +213,7 @@ CPointLights::RenderFogEffect(void)
if(dot > 0.0f && dot < FOG_AREA_LENGTH && linedistsq < sq(FOG_AREA_WIDTH)){ if(dot > 0.0f && dot < FOG_AREA_LENGTH && linedistsq < sq(FOG_AREA_WIDTH)){
float intensity = 158.0f * fogginess; float intensity = 158.0f * fogginess;
// more intensity the smaller the angle // more intensity the smaller the angle
intensity *= dot/sqrt(distsq); intensity *= dot/Sqrt(distsq);
// more intensity the closer to light source // more intensity the closer to light source
intensity *= 1.0f - sq(dot/FOG_AREA_LENGTH); intensity *= 1.0f - sq(dot/FOG_AREA_LENGTH);
// more intensity the closer to line // 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); float angle = DEGTORAD((float)js.rgdwPOV[0] / 100.0f);
leftStickPos.x = Sin(angle); 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 ) 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()); m_vecTurnSpeed.y *= Pow(0.9f, CTimer::GetTimeStep());
moveSpeed = m_vecMoveSpeed.MagnitudeSqr(); moveSpeed = m_vecMoveSpeed.MagnitudeSqr();
if(moveSpeed > 2.25f) if(moveSpeed > 2.25f)
m_vecMoveSpeed *= 1.5f/sqrt(moveSpeed); m_vecMoveSpeed *= 1.5f/Sqrt(moveSpeed);
float turnSpeed = m_vecTurnSpeed.MagnitudeSqr(); float turnSpeed = m_vecTurnSpeed.MagnitudeSqr();
if(turnSpeed > 0.04f) if(turnSpeed > 0.04f)
m_vecTurnSpeed *= 0.2f/sqrt(turnSpeed); m_vecTurnSpeed *= 0.2f/Sqrt(turnSpeed);
} }
break; break;