mirror of
https://gitlab.com/GaryOderNichts/re3-wiiu.git
synced 2024-11-27 03:24:15 +01:00
added wrappers around math functions
This commit is contained in:
parent
80e0409d6a
commit
4a36d64f15
@ -445,7 +445,7 @@ void
|
|||||||
cAudioManager::CalculateDistance(bool *ptr, float dist)
|
cAudioManager::CalculateDistance(bool *ptr, float dist)
|
||||||
{
|
{
|
||||||
if(*ptr == false) {
|
if(*ptr == false) {
|
||||||
m_sQueueSample.m_fDistance = sqrt(dist);
|
m_sQueueSample.m_fDistance = Sqrt(dist);
|
||||||
*ptr = true;
|
*ptr = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -146,8 +146,8 @@ CPathFind::PreparePathData(void)
|
|||||||
numExtern++;
|
numExtern++;
|
||||||
if(InfoForTileCars[k].numLeftLanes + InfoForTileCars[k].numRightLanes > numLanes)
|
if(InfoForTileCars[k].numLeftLanes + InfoForTileCars[k].numRightLanes > numLanes)
|
||||||
numLanes = InfoForTileCars[k].numLeftLanes + InfoForTileCars[k].numRightLanes;
|
numLanes = InfoForTileCars[k].numLeftLanes + InfoForTileCars[k].numRightLanes;
|
||||||
maxX = max(maxX, fabs(InfoForTileCars[k].x));
|
maxX = max(maxX, Abs(InfoForTileCars[k].x));
|
||||||
maxY = max(maxY, fabs(InfoForTileCars[k].y));
|
maxY = max(maxY, Abs(InfoForTileCars[k].y));
|
||||||
}else if(InfoForTileCars[k].type == NodeTypeIntern)
|
}else if(InfoForTileCars[k].type == NodeTypeIntern)
|
||||||
numIntern++;
|
numIntern++;
|
||||||
}
|
}
|
||||||
@ -327,10 +327,10 @@ CPathFind::PreparePathDataForType(uint8 type, CTempNode *tempnodes, CPathInfoFor
|
|||||||
if(tempnodes[k].linkState != 1)
|
if(tempnodes[k].linkState != 1)
|
||||||
continue;
|
continue;
|
||||||
dx = tempnodes[k].pos.x - CoorsXFormed.x;
|
dx = tempnodes[k].pos.x - CoorsXFormed.x;
|
||||||
if(fabs(dx) < nearestDist){
|
if(Abs(dx) < nearestDist){
|
||||||
dy = tempnodes[k].pos.y - CoorsXFormed.y;
|
dy = tempnodes[k].pos.y - CoorsXFormed.y;
|
||||||
if(fabs(dy) < nearestDist){
|
if(Abs(dy) < nearestDist){
|
||||||
nearestDist = max(fabs(dx), fabs(dy));
|
nearestDist = max(Abs(dx), Abs(dy));
|
||||||
nearestId = k;
|
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;
|
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;
|
dy = m_pathNodes[tempnodes[nearestId].link1].pos.y - m_pathNodes[tempnodes[nearestId].link2].pos.y;
|
||||||
tempnodes[nearestId].pos = (tempnodes[nearestId].pos + CoorsXFormed)*0.5f;
|
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].dirX = dx/mag;
|
||||||
tempnodes[nearestId].dirY = dy/mag;
|
tempnodes[nearestId].dirY = dy/mag;
|
||||||
// do something when number of lanes doesn't agree
|
// 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;
|
posy = (m_pathNodes[i].pos.y + m_pathNodes[j].pos.y)*0.5f;
|
||||||
dx = m_pathNodes[j].pos.x - m_pathNodes[i].pos.x;
|
dx = m_pathNodes[j].pos.x - m_pathNodes[i].pos.x;
|
||||||
dy = m_pathNodes[j].pos.y - m_pathNodes[i].pos.y;
|
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;
|
dx /= mag;
|
||||||
dy /= mag;
|
dy /= mag;
|
||||||
if(i < j){
|
if(i < j){
|
||||||
|
@ -1505,9 +1505,9 @@ void CReplay::ProcessLookAroundCam(void)
|
|||||||
else
|
else
|
||||||
fAlphaAngleLookAroundCam = max(0.1f, min(1.5f, fAlphaAngleLookAroundCam + y_moved));
|
fAlphaAngleLookAroundCam = max(0.1f, min(1.5f, fAlphaAngleLookAroundCam + y_moved));
|
||||||
CVector camera_pt(
|
CVector camera_pt(
|
||||||
fDistanceLookAroundCam * sin(fBetaAngleLookAroundCam) * cos(fAlphaAngleLookAroundCam),
|
fDistanceLookAroundCam * Sin(fBetaAngleLookAroundCam) * Cos(fAlphaAngleLookAroundCam),
|
||||||
fDistanceLookAroundCam * cos(fBetaAngleLookAroundCam) * cos(fAlphaAngleLookAroundCam),
|
fDistanceLookAroundCam * Cos(fBetaAngleLookAroundCam) * Cos(fAlphaAngleLookAroundCam),
|
||||||
fDistanceLookAroundCam * sin(fAlphaAngleLookAroundCam)
|
fDistanceLookAroundCam * Sin(fAlphaAngleLookAroundCam)
|
||||||
);
|
);
|
||||||
CVector focus = CVector(CameraFocusX, CameraFocusY, CameraFocusZ);
|
CVector focus = CVector(CameraFocusX, CameraFocusY, CameraFocusZ);
|
||||||
camera_pt += focus;
|
camera_pt += focus;
|
||||||
|
@ -170,9 +170,9 @@ WellBufferMe(float Target, float *CurrentValue, float *CurrentSpeed, float MaxSp
|
|||||||
float TargetSpeed = Delta * MaxSpeed;
|
float TargetSpeed = Delta * MaxSpeed;
|
||||||
// Add or subtract absolute depending on sign, genius!
|
// Add or subtract absolute depending on sign, genius!
|
||||||
// if(TargetSpeed - *CurrentSpeed > 0.0f)
|
// if(TargetSpeed - *CurrentSpeed > 0.0f)
|
||||||
// *CurrentSpeed += Acceleration * fabs(TargetSpeed - *CurrentSpeed) * CTimer::GetTimeStep();
|
// *CurrentSpeed += Acceleration * Abs(TargetSpeed - *CurrentSpeed) * CTimer::GetTimeStep();
|
||||||
// else
|
// else
|
||||||
// *CurrentSpeed -= Acceleration * fabs(TargetSpeed - *CurrentSpeed) * CTimer::GetTimeStep();
|
// *CurrentSpeed -= Acceleration * Abs(TargetSpeed - *CurrentSpeed) * CTimer::GetTimeStep();
|
||||||
// this is simpler:
|
// this is simpler:
|
||||||
*CurrentSpeed += Acceleration * (TargetSpeed - *CurrentSpeed) * CTimer::GetTimeStep();
|
*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)){
|
for(a = 0.0f; a <= PI; a += DEGTORAD(5.0f)){
|
||||||
if(BetaOffset <= 0.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,
|
if(!CWorld::ProcessLineOfSight(Target, Target + ToSource,
|
||||||
point, ent, checkBuildings, checkVehicles, checkPeds,
|
point, ent, checkBuildings, checkVehicles, checkPeds,
|
||||||
checkObjects, checkDummies, true, true))
|
checkObjects, checkDummies, true, true))
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
if(BetaOffset >= 0.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,
|
if(!CWorld::ProcessLineOfSight(Target, Target + ToSource,
|
||||||
point, ent, checkBuildings, checkVehicles, checkPeds,
|
point, ent, checkBuildings, checkVehicles, checkPeds,
|
||||||
checkObjects, checkDummies, true, true))
|
checkObjects, checkDummies, true, true))
|
||||||
@ -500,7 +500,7 @@ CCam::Process_FollowPed(const CVector &CameraTarget, float TargetOrientation, fl
|
|||||||
CVector PlayerPos = FindPlayerPed()->GetPosition();
|
CVector PlayerPos = FindPlayerPed()->GetPosition();
|
||||||
float RotationDist = (AngleToGoTo == Center ? CenterDist : LateralDist) * RealGroundDist;
|
float RotationDist = (AngleToGoTo == Center ? CenterDist : LateralDist) * RealGroundDist;
|
||||||
// What's going on here? - AngleToGoTo?
|
// 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;
|
CColPoint colpoint;
|
||||||
CEntity *entity;
|
CEntity *entity;
|
||||||
@ -584,9 +584,9 @@ CCam::Process_FollowPed(const CVector &CameraTarget, float TargetOrientation, fl
|
|||||||
float ReqSpeed = DeltaBeta * MaxSpeed;
|
float ReqSpeed = DeltaBeta * MaxSpeed;
|
||||||
// Add or subtract absolute depending on sign, genius!
|
// Add or subtract absolute depending on sign, genius!
|
||||||
if(ReqSpeed - BetaSpeed > 0.0f)
|
if(ReqSpeed - BetaSpeed > 0.0f)
|
||||||
BetaSpeed += SpeedStep * fabs(ReqSpeed - BetaSpeed) * CTimer::GetTimeStep();
|
BetaSpeed += SpeedStep * Abs(ReqSpeed - BetaSpeed) * CTimer::GetTimeStep();
|
||||||
else
|
else
|
||||||
BetaSpeed -= SpeedStep * fabs(ReqSpeed - BetaSpeed) * CTimer::GetTimeStep();
|
BetaSpeed -= SpeedStep * Abs(ReqSpeed - BetaSpeed) * CTimer::GetTimeStep();
|
||||||
// this would be simpler:
|
// this would be simpler:
|
||||||
// BetaSpeed += SpeedStep * (ReqSpeed - BetaSpeed) * CTimer::ms_fTimeStep;
|
// BetaSpeed += SpeedStep * (ReqSpeed - BetaSpeed) * CTimer::ms_fTimeStep;
|
||||||
|
|
||||||
@ -604,14 +604,14 @@ CCam::Process_FollowPed(const CVector &CameraTarget, float TargetOrientation, fl
|
|||||||
BetaSpeed = 0.0f;
|
BetaSpeed = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
Source.x = TargetCoors.x + Distance * cos(Beta);
|
Source.x = TargetCoors.x + Distance * Cos(Beta);
|
||||||
Source.y = TargetCoors.y + Distance * sin(Beta);
|
Source.y = TargetCoors.y + Distance * Sin(Beta);
|
||||||
|
|
||||||
// Check if we can stop rotating
|
// Check if we can stop rotating
|
||||||
DeltaBeta = FixedTargetOrientation - Beta;
|
DeltaBeta = FixedTargetOrientation - Beta;
|
||||||
while(DeltaBeta >= PI) DeltaBeta -= 2*PI;
|
while(DeltaBeta >= PI) DeltaBeta -= 2*PI;
|
||||||
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
|
// Stop rotation
|
||||||
PickedASide = false;
|
PickedASide = false;
|
||||||
Rotating = false;
|
Rotating = false;
|
||||||
@ -624,18 +624,18 @@ CCam::Process_FollowPed(const CVector &CameraTarget, float TargetOrientation, fl
|
|||||||
HackPlayerOnStoppingTrain || Rotating){
|
HackPlayerOnStoppingTrain || Rotating){
|
||||||
if(TheCamera.m_bCamDirectlyBehind){
|
if(TheCamera.m_bCamDirectlyBehind){
|
||||||
Beta = TargetOrientation + PI;
|
Beta = TargetOrientation + PI;
|
||||||
Source.x = TargetCoors.x + Distance * cos(Beta);
|
Source.x = TargetCoors.x + Distance * Cos(Beta);
|
||||||
Source.y = TargetCoors.y + Distance * sin(Beta);
|
Source.y = TargetCoors.y + Distance * Sin(Beta);
|
||||||
}
|
}
|
||||||
if(TheCamera.m_bCamDirectlyInFront){
|
if(TheCamera.m_bCamDirectlyInFront){
|
||||||
Beta = TargetOrientation;
|
Beta = TargetOrientation;
|
||||||
Source.x = TargetCoors.x + Distance * cos(Beta);
|
Source.x = TargetCoors.x + Distance * Cos(Beta);
|
||||||
Source.y = TargetCoors.y + Distance * sin(Beta);
|
Source.y = TargetCoors.y + Distance * Sin(Beta);
|
||||||
}
|
}
|
||||||
if(HackPlayerOnStoppingTrain){
|
if(HackPlayerOnStoppingTrain){
|
||||||
Beta = TargetOrientation + PI;
|
Beta = TargetOrientation + PI;
|
||||||
Source.x = TargetCoors.x + Distance * cos(Beta);
|
Source.x = TargetCoors.x + Distance * Cos(Beta);
|
||||||
Source.y = TargetCoors.y + Distance * sin(Beta);
|
Source.y = TargetCoors.y + Distance * Sin(Beta);
|
||||||
m_fDimensionOfHighestNearCar = 0.0f;
|
m_fDimensionOfHighestNearCar = 0.0f;
|
||||||
m_fCamBufferedHeight = 0.0f;
|
m_fCamBufferedHeight = 0.0f;
|
||||||
m_fCamBufferedHeightSpeed = 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;
|
||||||
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;
|
CarAlpha = -CarAlpha * BehindCarNess;
|
||||||
if(CarAlpha < -0.01f)
|
if(CarAlpha < -0.01f)
|
||||||
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 = CamTargetEntity->GetForward(); // we actually still have that...
|
||||||
Forward.Normalise(); // shouldn't be necessary
|
Forward.Normalise(); // shouldn't be necessary
|
||||||
float CarSideAngle = CGeneral::GetATanOfXY(Forward.x, Forward.y) + PI/2.0f;
|
float CarSideAngle = CGeneral::GetATanOfXY(Forward.x, Forward.y) + PI/2.0f;
|
||||||
float SideX = 2.5f * cos(CarSideAngle);
|
float SideX = 2.5f * Cos(CarSideAngle);
|
||||||
float SideY = 2.5f * sin(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, &FoundRoofSide1);
|
||||||
CWorld::FindRoofZFor3DCoord(TargetCoors.x - SideX, TargetCoors.y - SideY, CarBottom, &FoundRoofSide2);
|
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);
|
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
|
// 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;
|
||||||
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;
|
m_bFixingBeta = true;
|
||||||
|
|
||||||
CPad *pad = CPad::GetPad(0);
|
CPad *pad = CPad::GetPad(0);
|
||||||
@ -1088,14 +1088,14 @@ CCam::RotCamIfInFrontCar(CVector &TargetCoors, float TargetOrientation)
|
|||||||
if(TheCamera.m_bUseTransitionBeta && &TheCamera.Cams[TheCamera.ActiveCam] == this)
|
if(TheCamera.m_bUseTransitionBeta && &TheCamera.Cams[TheCamera.ActiveCam] == this)
|
||||||
Beta = m_fTransitionBeta;
|
Beta = m_fTransitionBeta;
|
||||||
|
|
||||||
Source.x = TargetCoors.x - cos(Beta)*Dist;
|
Source.x = TargetCoors.x - Cos(Beta)*Dist;
|
||||||
Source.y = TargetCoors.y - sin(Beta)*Dist;
|
Source.y = TargetCoors.y - Sin(Beta)*Dist;
|
||||||
|
|
||||||
// Check if we're done
|
// Check if we're done
|
||||||
DeltaBeta = TargetOrientation - Beta;
|
DeltaBeta = TargetOrientation - Beta;
|
||||||
while(DeltaBeta >= PI) DeltaBeta -= 2*PI;
|
while(DeltaBeta >= PI) DeltaBeta -= 2*PI;
|
||||||
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;
|
m_bFixingBeta = false;
|
||||||
}
|
}
|
||||||
TheCamera.m_bCamDirectlyBehind = false;
|
TheCamera.m_bCamDirectlyBehind = false;
|
||||||
@ -1157,14 +1157,14 @@ CCam::FixCamIfObscured(CVector &TargetCoors, float TargetHeight, float TargetOri
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(Fix1){
|
if(Fix1){
|
||||||
Source.x = Target.x - cos(Beta)*Dist1;
|
Source.x = Target.x - Cos(Beta)*Dist1;
|
||||||
Source.y = Target.y - sin(Beta)*Dist1;
|
Source.y = Target.y - Sin(Beta)*Dist1;
|
||||||
if(Mode == MODE_BEHINDCAR)
|
if(Mode == MODE_BEHINDCAR)
|
||||||
Source = colPoint.point;
|
Source = colPoint.point;
|
||||||
}else{
|
}else{
|
||||||
WellBufferMe(Dist2, &m_fDistanceBeforeChanges, &DistanceSpeed, 0.2f, 0.025f, false);
|
WellBufferMe(Dist2, &m_fDistanceBeforeChanges, &DistanceSpeed, 0.2f, 0.025f, false);
|
||||||
Source.x = Target.x - cos(Beta)*m_fDistanceBeforeChanges;
|
Source.x = Target.x - Cos(Beta)*m_fDistanceBeforeChanges;
|
||||||
Source.y = Target.y - sin(Beta)*m_fDistanceBeforeChanges;
|
Source.y = Target.y - Sin(Beta)*m_fDistanceBeforeChanges;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ResetStatics){
|
if(ResetStatics){
|
||||||
|
@ -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
|
// 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
|
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.
|
// 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!
|
// Negative if p0 is inside the sphere! This breaks the test!
|
||||||
float tansq = 4.0f * linesq *
|
float tansq = 4.0f * linesq *
|
||||||
(sph.center.MagnitudeSqr() - 2.0f*DotProduct(sph.center, line.p0) + line.p0.MagnitudeSqr() - sph.radius*sph.radius);
|
(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;
|
return false;
|
||||||
// projline (negative in GTA for some reason) is the point on the line
|
// projline (negative in GTA for some reason) is the point on the line
|
||||||
// in the middle of the two intersection points (startin from p0).
|
// 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.
|
// midpoint to the intersection points.
|
||||||
// So subtract that and get rid of the awkward scaling:
|
// 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]
|
// f should now be in range [0, 1] for [p0, p1]
|
||||||
return f >= 0.0f && f <= 1.0f;
|
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)
|
const CVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane)
|
||||||
{
|
{
|
||||||
// If sphere and plane don't intersect, no collision
|
// 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;
|
return false;
|
||||||
|
|
||||||
const CVector &va = verts[tri.a];
|
const CVector &va = verts[tri.a];
|
||||||
@ -669,7 +669,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){
|
||||||
float len = sqrt(lensq);
|
float len = Sqrt(lensq);
|
||||||
point.point = p;
|
point.point = p;
|
||||||
point.normal = dist * (1.0f/len);
|
point.normal = dist * (1.0f/len);
|
||||||
point.surfaceA = sph.surface;
|
point.surfaceA = sph.surface;
|
||||||
@ -816,7 +816,7 @@ CCollision::ProcessLineSphere(const CColLine &line, const CColSphere &sphere, CC
|
|||||||
if(diffsq < 0.0f)
|
if(diffsq < 0.0f)
|
||||||
return false;
|
return false;
|
||||||
// point of first intersection, in range [0,1] between p0 and p1
|
// 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 not on line or beyond mindist, no intersection
|
||||||
if(t < 0.0f || t > 1.0f || t >= mindist)
|
if(t < 0.0f || t > 1.0f || t >= mindist)
|
||||||
return false;
|
return false;
|
||||||
@ -1010,7 +1010,7 @@ CCollision::ProcessSphereTriangle(const CColSphere &sphere,
|
|||||||
// If sphere and plane don't intersect, no collision
|
// If sphere and plane don't intersect, no collision
|
||||||
float planedist = plane.CalcPoint(sphere.center);
|
float planedist = plane.CalcPoint(sphere.center);
|
||||||
float distsq = planedist*planedist;
|
float distsq = planedist*planedist;
|
||||||
if(fabs(planedist) > sphere.radius || distsq > mindistsq)
|
if(Abs(planedist) > sphere.radius || distsq > mindistsq)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const CVector &va = verts[tri.a];
|
const CVector &va = verts[tri.a];
|
||||||
@ -1057,7 +1057,7 @@ CCollision::ProcessSphereTriangle(const CColSphere &sphere,
|
|||||||
else assert(0);
|
else assert(0);
|
||||||
}else if(testcase == 3){
|
}else if(testcase == 3){
|
||||||
// center is in triangle
|
// center is in triangle
|
||||||
dist = fabs(planedist);
|
dist = Abs(planedist);
|
||||||
p = sphere.center - normal*planedist;
|
p = sphere.center - normal*planedist;
|
||||||
}else
|
}else
|
||||||
assert(0); // front fell off
|
assert(0); // front fell off
|
||||||
@ -1333,7 +1333,7 @@ CCollision::DistToLine(const CVector *l0, const CVector *l1, const CVector *poin
|
|||||||
if(dot >= lensq)
|
if(dot >= lensq)
|
||||||
return (*point - *l1).Magnitude();
|
return (*point - *l1).Magnitude();
|
||||||
// distance to line
|
// 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
|
// 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 = CrossProduct(vc-va, vb-va);
|
||||||
normal.Normalise();
|
normal.Normalise();
|
||||||
dist = DotProduct(normal, va);
|
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
|
// find out largest component and its direction
|
||||||
if(an.x > an.y && an.x > an.z)
|
if(an.x > an.y && an.x > an.z)
|
||||||
dir = normal.x < 0.0f ? DIR_X_NEG : DIR_X_POS;
|
dir = normal.x < 0.0f ? DIR_X_NEG : DIR_X_POS;
|
||||||
|
@ -262,9 +262,9 @@ CFileLoader::LoadCollisionModel(uint8 *buf, CColModel &model, char *modelname)
|
|||||||
model.vertices = (CVector*)RwMalloc(numVertices*sizeof(CVector));
|
model.vertices = (CVector*)RwMalloc(numVertices*sizeof(CVector));
|
||||||
for(i = 0; i < numVertices; i++){
|
for(i = 0; i < numVertices; i++){
|
||||||
model.vertices[i] = *(CVector*)buf;
|
model.vertices[i] = *(CVector*)buf;
|
||||||
if(fabs(model.vertices[i].x) >= 256.0f ||
|
if(Abs(model.vertices[i].x) >= 256.0f ||
|
||||||
fabs(model.vertices[i].y) >= 256.0f ||
|
Abs(model.vertices[i].y) >= 256.0f ||
|
||||||
fabs(model.vertices[i].z) >= 256.0f)
|
Abs(model.vertices[i].z) >= 256.0f)
|
||||||
printf("%s:Collision volume too big\n", modelname);
|
printf("%s:Collision volume too big\n", modelname);
|
||||||
buf += 12;
|
buf += 12;
|
||||||
}
|
}
|
||||||
|
@ -6,32 +6,32 @@ public:
|
|||||||
static float GetATanOfXY(float x, float y){
|
static float GetATanOfXY(float x, float y){
|
||||||
if(x == 0.0f && y == 0.0f)
|
if(x == 0.0f && y == 0.0f)
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
float xabs = fabs(x);
|
float xabs = Abs(x);
|
||||||
float yabs = fabs(y);
|
float yabs = Abs(y);
|
||||||
|
|
||||||
if(xabs < yabs){
|
if(xabs < yabs){
|
||||||
if(y > 0.0f){
|
if(y > 0.0f){
|
||||||
if(x > 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
|
else
|
||||||
return 0.5f*PI + atan2(-x / y, 1.0f);
|
return 0.5f*PI + Atan2(-x / y, 1.0f);
|
||||||
}else{
|
}else{
|
||||||
if(x > 0.0f)
|
if(x > 0.0f)
|
||||||
return 1.5f*PI + atan2(x / -y, 1.0f);
|
return 1.5f*PI + Atan2(x / -y, 1.0f);
|
||||||
else
|
else
|
||||||
return 1.5f*PI - atan2(-x / -y, 1.0f);
|
return 1.5f*PI - Atan2(-x / -y, 1.0f);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
if(y > 0.0f){
|
if(y > 0.0f){
|
||||||
if(x > 0.0f)
|
if(x > 0.0f)
|
||||||
return atan2(y / x, 1.0f);
|
return Atan2(y / x, 1.0f);
|
||||||
else
|
else
|
||||||
return PI - atan2(y / -x, 1.0f);
|
return PI - Atan2(y / -x, 1.0f);
|
||||||
}else{
|
}else{
|
||||||
if(x > 0.0f)
|
if(x > 0.0f)
|
||||||
return 2.0f*PI - atan2(-y / x, 1.0f);
|
return 2.0f*PI - Atan2(-y / x, 1.0f);
|
||||||
else
|
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 (x > 0.0f) {
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
@ -670,7 +670,7 @@ int16 CPad::GetSteeringLeftRight(void)
|
|||||||
int16 axis = NewState.LeftStickX;
|
int16 axis = NewState.LeftStickX;
|
||||||
int16 dpad = (NewState.DPadRight - NewState.DPadLeft) / 2;
|
int16 dpad = (NewState.DPadRight - NewState.DPadLeft) / 2;
|
||||||
|
|
||||||
if ( abs(axis) > abs(dpad) )
|
if ( Abs(axis) > Abs(dpad) )
|
||||||
return axis;
|
return axis;
|
||||||
else
|
else
|
||||||
return dpad;
|
return dpad;
|
||||||
@ -703,7 +703,7 @@ int16 CPad::GetSteeringUpDown(void)
|
|||||||
int16 axis = NewState.LeftStickY;
|
int16 axis = NewState.LeftStickY;
|
||||||
int16 dpad = (NewState.DPadUp - NewState.DPadDown) / 2;
|
int16 dpad = (NewState.DPadUp - NewState.DPadDown) / 2;
|
||||||
|
|
||||||
if ( abs(axis) > abs(dpad) )
|
if ( Abs(axis) > Abs(dpad) )
|
||||||
return axis;
|
return axis;
|
||||||
else
|
else
|
||||||
return dpad;
|
return dpad;
|
||||||
@ -790,7 +790,7 @@ int16 CPad::GetPedWalkLeftRight(void)
|
|||||||
int16 axis = NewState.LeftStickX;
|
int16 axis = NewState.LeftStickX;
|
||||||
int16 dpad = (NewState.DPadRight - NewState.DPadLeft) / 2;
|
int16 dpad = (NewState.DPadRight - NewState.DPadLeft) / 2;
|
||||||
|
|
||||||
if ( abs(axis) > abs(dpad) )
|
if ( Abs(axis) > Abs(dpad) )
|
||||||
return axis;
|
return axis;
|
||||||
else
|
else
|
||||||
return dpad;
|
return dpad;
|
||||||
@ -824,7 +824,7 @@ int16 CPad::GetPedWalkUpDown(void)
|
|||||||
int16 axis = NewState.LeftStickY;
|
int16 axis = NewState.LeftStickY;
|
||||||
int16 dpad = (NewState.DPadDown - NewState.DPadUp) / 2;
|
int16 dpad = (NewState.DPadDown - NewState.DPadUp) / 2;
|
||||||
|
|
||||||
if ( abs(axis) > abs(dpad) )
|
if ( Abs(axis) > Abs(dpad) )
|
||||||
return axis;
|
return axis;
|
||||||
else
|
else
|
||||||
return dpad;
|
return dpad;
|
||||||
@ -854,7 +854,7 @@ int16 CPad::GetAnalogueUpDown(void)
|
|||||||
int16 axis = NewState.LeftStickY;
|
int16 axis = NewState.LeftStickY;
|
||||||
int16 dpad = (NewState.DPadDown - NewState.DPadUp) / 2;
|
int16 dpad = (NewState.DPadDown - NewState.DPadUp) / 2;
|
||||||
|
|
||||||
if ( abs(axis) > abs(dpad) )
|
if ( Abs(axis) > Abs(dpad) )
|
||||||
return axis;
|
return axis;
|
||||||
else
|
else
|
||||||
return dpad;
|
return dpad;
|
||||||
@ -1683,7 +1683,7 @@ int16 CPad::SniperModeLookLeftRight(void)
|
|||||||
int16 axis = NewState.LeftStickX;
|
int16 axis = NewState.LeftStickX;
|
||||||
int16 dpad = (NewState.DPadRight - NewState.DPadLeft) / 2;
|
int16 dpad = (NewState.DPadRight - NewState.DPadLeft) / 2;
|
||||||
|
|
||||||
if ( abs(axis) > abs(dpad) )
|
if ( Abs(axis) > Abs(dpad) )
|
||||||
return axis;
|
return axis;
|
||||||
else
|
else
|
||||||
return dpad;
|
return dpad;
|
||||||
@ -1694,7 +1694,7 @@ int16 CPad::SniperModeLookUpDown(void)
|
|||||||
int16 axis = NewState.LeftStickY;
|
int16 axis = NewState.LeftStickY;
|
||||||
int16 dpad = (NewState.DPadUp - NewState.DPadDown) / 2;
|
int16 dpad = (NewState.DPadUp - NewState.DPadDown) / 2;
|
||||||
|
|
||||||
if ( abs(axis) > abs(dpad) )
|
if ( Abs(axis) > Abs(dpad) )
|
||||||
return axis;
|
return axis;
|
||||||
else
|
else
|
||||||
return dpad;
|
return dpad;
|
||||||
@ -1704,11 +1704,11 @@ int16 CPad::LookAroundLeftRight(void)
|
|||||||
{
|
{
|
||||||
float axis = GetPad(0)->NewState.RightStickX;
|
float axis = GetPad(0)->NewState.RightStickX;
|
||||||
|
|
||||||
if ( fabs(axis) > 85 && !GetLookBehindForPed() )
|
if ( Abs(axis) > 85 && !GetLookBehindForPed() )
|
||||||
return (int16) ( (axis + ( ( axis > 0 ) ? -85 : 85) )
|
return (int16) ( (axis + ( ( axis > 0 ) ? -85 : 85) )
|
||||||
* (127.0f / 32.0f) ); // 3.96875f
|
* (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) )
|
return (int16) ( (axis + ( ( axis > 0 ) ? -10 : 10) )
|
||||||
* (127.0f / 64.0f) ); // 1.984375f
|
* (127.0f / 64.0f) ); // 1.984375f
|
||||||
|
|
||||||
@ -1719,11 +1719,11 @@ int16 CPad::LookAroundUpDown(void)
|
|||||||
{
|
{
|
||||||
int16 axis = GetPad(0)->NewState.RightStickY;
|
int16 axis = GetPad(0)->NewState.RightStickY;
|
||||||
|
|
||||||
if ( abs(axis) > 85 && !GetLookBehindForPed() )
|
if ( Abs(axis) > 85 && !GetLookBehindForPed() )
|
||||||
return (int16) ( (axis + ( ( axis > 0 ) ? -85 : 85) )
|
return (int16) ( (axis + ( ( axis > 0 ) ? -85 : 85) )
|
||||||
* (127.0f / 32.0f) ); // 3.96875f
|
* (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) )
|
return (int16) ( (axis + ( ( axis > 0 ) ? -40 : 40) )
|
||||||
* (127.0f / 64.0f) ); // 1.984375f
|
* (127.0f / 64.0f) ); // 1.984375f
|
||||||
|
|
||||||
|
@ -469,8 +469,8 @@ void CRadar::DrawRadarMask()
|
|||||||
|
|
||||||
// Then generate a quarter of the circle
|
// Then generate a quarter of the circle
|
||||||
for (int j = 0; j < 7; j++) {
|
for (int j = 0; j < 7; j++) {
|
||||||
in.x = corners[i].x * cos(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));
|
in.y = corners[i].y * Sin(j * (PI / 2.0f / 6.0f));
|
||||||
TransformRadarPointToScreenSpace(out[j + 1], in);
|
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++) {
|
for (uint32 i = 0; i < 4; i++) {
|
||||||
oldPosn[i] = curPosn[i];
|
oldPosn[i] = curPosn[i];
|
||||||
|
|
||||||
curPosn[i].x = x + (oldPosn[i].x - x) * cosf(angle) + (oldPosn[i].y - y) * sinf(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) * sinf(angle) + (oldPosn[i].y - y) * cosf(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));
|
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;
|
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) {
|
||||||
s = 0.0f;
|
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;
|
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());
|
||||||
}
|
}
|
||||||
|
|
||||||
out.x = s * in.y + c * in.x;
|
out.x = s * in.y + c * in.x;
|
||||||
@ -915,8 +915,8 @@ void CRadar::TransformRealWorldPointToRadarSpace(CVector2D &out, const CVector2D
|
|||||||
c = 1.0f;
|
c = 1.0f;
|
||||||
}
|
}
|
||||||
else if (TheCamera.GetLookDirection() == LOOKING_FORWARD) {
|
else if (TheCamera.GetLookDirection() == LOOKING_FORWARD) {
|
||||||
s = sin(TheCamera.GetForward().Heading());
|
s = Sin(TheCamera.GetForward().Heading());
|
||||||
c = cos(TheCamera.GetForward().Heading());
|
c = Cos(TheCamera.GetForward().Heading());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
CVector forward;
|
CVector forward;
|
||||||
@ -928,8 +928,8 @@ void CRadar::TransformRealWorldPointToRadarSpace(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());
|
||||||
}
|
}
|
||||||
|
|
||||||
float x = (in.x - vec2DRadarOrigin.x) * (1.0f / m_RadarRange);
|
float x = (in.x - vec2DRadarOrigin.x) * (1.0f / m_RadarRange);
|
||||||
|
@ -2131,8 +2131,8 @@ CStreaming::DeleteRwObjectsAfterDeath(const CVector &pos)
|
|||||||
|
|
||||||
for(x = 0; x < NUMSECTORS_X; x++)
|
for(x = 0; x < NUMSECTORS_X; x++)
|
||||||
for(y = 0; y < NUMSECTORS_Y; y++)
|
for(y = 0; y < NUMSECTORS_Y; y++)
|
||||||
if(fabs(ix - x) > 3.0f &&
|
if(Abs(ix - x) > 3.0f &&
|
||||||
fabs(iy - y) > 3.0f){
|
Abs(iy - y) > 3.0f){
|
||||||
sect = CWorld::GetSector(x, y);
|
sect = CWorld::GetSector(x, y);
|
||||||
DeleteRwObjectsInSectorList(sect->m_lists[ENTITYLIST_BUILDINGS]);
|
DeleteRwObjectsInSectorList(sect->m_lists[ENTITYLIST_BUILDINGS]);
|
||||||
DeleteRwObjectsInSectorList(sect->m_lists[ENTITYLIST_BUILDINGS_OVERLAP]);
|
DeleteRwObjectsInSectorList(sect->m_lists[ENTITYLIST_BUILDINGS_OVERLAP]);
|
||||||
@ -2158,7 +2158,7 @@ CStreaming::DeleteRwObjectsBehindCamera(int32 mem)
|
|||||||
ix = CWorld::GetSectorIndexX(TheCamera.GetPosition().x);
|
ix = CWorld::GetSectorIndexX(TheCamera.GetPosition().x);
|
||||||
iy = CWorld::GetSectorIndexX(TheCamera.GetPosition().y);
|
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
|
// looking west/east
|
||||||
|
|
||||||
ymin = max(iy - 10, 0);
|
ymin = max(iy - 10, 0);
|
||||||
@ -2312,13 +2312,13 @@ CStreaming::DeleteRwObjectsInOverlapSectorList(CPtrList &list, int32 x, int32 y)
|
|||||||
e = (CEntity*)node->item;
|
e = (CEntity*)node->item;
|
||||||
if(e->m_rwObject && !e->bStreamingDontDelete && !e->bImBeingRendered){
|
if(e->m_rwObject && !e->bStreamingDontDelete && !e->bImBeingRendered){
|
||||||
// Now this is pretty weird...
|
// 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();
|
e->DeleteRwObject();
|
||||||
// return; // BUG?
|
// return; // BUG?
|
||||||
// }
|
// }
|
||||||
else // FIX?
|
else // FIX?
|
||||||
if(fabs(CWorld::GetSectorIndexY(e->GetPosition().y) - y) >= 2.0f)
|
if(Abs(CWorld::GetSectorIndexY(e->GetPosition().y) - y) >= 2.0f)
|
||||||
e->DeleteRwObject();
|
e->DeleteRwObject();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,6 +97,7 @@ extern void **rwengine;
|
|||||||
#define SCREEN_SCALE_AR(a) (a)
|
#define SCREEN_SCALE_AR(a) (a)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "math/maths.h"
|
||||||
#include "math/Vector.h"
|
#include "math/Vector.h"
|
||||||
#include "math/Vector2D.h"
|
#include "math/Vector2D.h"
|
||||||
#include "math/Matrix.h"
|
#include "math/Matrix.h"
|
||||||
|
@ -806,12 +806,12 @@ CEntity::ModifyMatrixForTreeInWind(void)
|
|||||||
}else if(CWeather::Wind >= 0.2){
|
}else if(CWeather::Wind >= 0.2){
|
||||||
t = (uintptr)this + CTimer::GetTimeInMilliseconds();
|
t = (uintptr)this + CTimer::GetTimeInMilliseconds();
|
||||||
f = (t & 0xFFF)/(float)0x1000;
|
f = (t & 0xFFF)/(float)0x1000;
|
||||||
flutter = sin(f * 6.28f);
|
flutter = Sin(f * 6.28f);
|
||||||
strength = 0.008f;
|
strength = 0.008f;
|
||||||
}else{
|
}else{
|
||||||
t = (uintptr)this + CTimer::GetTimeInMilliseconds();
|
t = (uintptr)this + CTimer::GetTimeInMilliseconds();
|
||||||
f = (t & 0xFFF)/(float)0x1000;
|
f = (t & 0xFFF)/(float)0x1000;
|
||||||
flutter = sin(f * 6.28f);
|
flutter = Sin(f * 6.28f);
|
||||||
strength = 0.005f;
|
strength = 0.005f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -857,7 +857,7 @@ CEntity::ModifyMatrixForBannerInWind(void)
|
|||||||
right.z = 0.0f;
|
right.z = 0.0f;
|
||||||
right.Normalise();
|
right.Normalise();
|
||||||
up = right * flutter;
|
up = right * flutter;
|
||||||
up.z = sqrt(sq(1.0f) - sq(flutter));
|
up.z = Sqrt(sq(1.0f) - sq(flutter));
|
||||||
GetRight() = CrossProduct(GetForward(), up);
|
GetRight() = CrossProduct(GetForward(), up);
|
||||||
GetUp() = up;
|
GetUp() = up;
|
||||||
|
|
||||||
|
@ -476,7 +476,7 @@ CPhysical::ApplySpringDampening(float damping, CVector &springDir, CVector &poin
|
|||||||
// what is this?
|
// what is this?
|
||||||
float a = m_fTurnMass / ((point.MagnitudeSqr() + 1.0f) * 2.0f * m_fMass);
|
float a = m_fTurnMass / ((point.MagnitudeSqr() + 1.0f) * 2.0f * m_fMass);
|
||||||
a = min(a, 1.0f);
|
a = min(a, 1.0f);
|
||||||
float b = fabs(impulse / (speedB * m_fMass));
|
float b = Abs(impulse / (speedB * m_fMass));
|
||||||
if(a < b)
|
if(a < b)
|
||||||
impulse *= a/b;
|
impulse *= a/b;
|
||||||
|
|
||||||
@ -505,11 +505,11 @@ void
|
|||||||
CPhysical::ApplyAirResistance(void)
|
CPhysical::ApplyAirResistance(void)
|
||||||
{
|
{
|
||||||
if(m_fAirResistance > 0.1f){
|
if(m_fAirResistance > 0.1f){
|
||||||
float f = powf(m_fAirResistance, CTimer::GetTimeStep());
|
float f = Pow(m_fAirResistance, CTimer::GetTimeStep());
|
||||||
m_vecMoveSpeed *= f;
|
m_vecMoveSpeed *= f;
|
||||||
m_vecTurnSpeed *= f;
|
m_vecTurnSpeed *= f;
|
||||||
}else{
|
}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_vecMoveSpeed *= f;
|
||||||
m_vecTurnSpeed *= 0.99f;
|
m_vecTurnSpeed *= 0.99f;
|
||||||
}
|
}
|
||||||
@ -719,7 +719,7 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
|
|||||||
if(!B->bInfiniteMass){
|
if(!B->bInfiniteMass){
|
||||||
if(fB.z < 0.0f){
|
if(fB.z < 0.0f){
|
||||||
fB.z = 0.0f;
|
fB.z = 0.0f;
|
||||||
if(fabs(speedA) < 0.01f)
|
if(Abs(speedA) < 0.01f)
|
||||||
fB *= 0.5f;
|
fB *= 0.5f;
|
||||||
}
|
}
|
||||||
if(ispedcontactA){
|
if(ispedcontactA){
|
||||||
@ -815,9 +815,9 @@ CPhysical::ApplyCollisionAlt(CEntity *B, CColPoint &colpoint, float &impulse, CV
|
|||||||
float minspeed = 0.0104f * CTimer::GetTimeStep();
|
float minspeed = 0.0104f * CTimer::GetTimeStep();
|
||||||
if((IsObject() || IsVehicle() && GetUp().z < -0.3f) &&
|
if((IsObject() || IsVehicle() && GetUp().z < -0.3f) &&
|
||||||
!bHasContacted &&
|
!bHasContacted &&
|
||||||
fabs(m_vecMoveSpeed.x) < minspeed &&
|
Abs(m_vecMoveSpeed.x) < minspeed &&
|
||||||
fabs(m_vecMoveSpeed.y) < minspeed &&
|
Abs(m_vecMoveSpeed.y) < minspeed &&
|
||||||
fabs(m_vecMoveSpeed.z) < minspeed*2.0f)
|
Abs(m_vecMoveSpeed.z) < minspeed*2.0f)
|
||||||
e = -1.0f;
|
e = -1.0f;
|
||||||
else
|
else
|
||||||
e = -(m_fElasticity + 1.0f);
|
e = -(m_fElasticity + 1.0f);
|
||||||
@ -1150,14 +1150,14 @@ CPhysical::ProcessShiftSectorList(CPtrList *lists)
|
|||||||
shift += dir * colpoints[mostColliding].depth * 0.5f;
|
shift += dir * colpoints[mostColliding].depth * 0.5f;
|
||||||
}else if(A->IsPed() && B->IsVehicle() && ((CVehicle*)B)->IsBoat()){
|
}else if(A->IsPed() && B->IsVehicle() && ((CVehicle*)B)->IsBoat()){
|
||||||
CVector dir = colpoints[mostColliding].normal;
|
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.z = 0.0f;
|
||||||
dir.Normalise();
|
dir.Normalise();
|
||||||
shift += dir * colpoints[mostColliding].depth / (1.0f - f);
|
shift += dir * colpoints[mostColliding].depth / (1.0f - f);
|
||||||
boat = B;
|
boat = B;
|
||||||
}else if(B->IsPed() && A->IsVehicle() && ((CVehicle*)A)->IsBoat()){
|
}else if(B->IsPed() && A->IsVehicle() && ((CVehicle*)A)->IsBoat()){
|
||||||
CVector dir = colpoints[mostColliding].normal * -1.0f;
|
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.z = 0.0f;
|
||||||
dir.Normalise();
|
dir.Normalise();
|
||||||
B->GetPosition() += dir * colpoints[mostColliding].depth / (1.0f - f);
|
B->GetPosition() += dir * colpoints[mostColliding].depth / (1.0f - f);
|
||||||
@ -1498,8 +1498,8 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
|
|||||||
|
|
||||||
float imp = impulseA;
|
float imp = impulseA;
|
||||||
if(A->IsVehicle() && A->GetUp().z < -0.6f &&
|
if(A->IsVehicle() && A->GetUp().z < -0.6f &&
|
||||||
fabs(A->m_vecMoveSpeed.x) < 0.05f &&
|
Abs(A->m_vecMoveSpeed.x) < 0.05f &&
|
||||||
fabs(A->m_vecMoveSpeed.y) < 0.05f)
|
Abs(A->m_vecMoveSpeed.y) < 0.05f)
|
||||||
imp *= 0.1f;
|
imp *= 0.1f;
|
||||||
|
|
||||||
float turnSpeedDiff = A->m_vecTurnSpeed.MagnitudeSqr();
|
float turnSpeedDiff = A->m_vecTurnSpeed.MagnitudeSqr();
|
||||||
@ -1519,8 +1519,8 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
|
|||||||
|
|
||||||
float imp = impulseA;
|
float imp = impulseA;
|
||||||
if(A->IsVehicle() && A->GetUp().z < -0.6f &&
|
if(A->IsVehicle() && A->GetUp().z < -0.6f &&
|
||||||
fabs(A->m_vecMoveSpeed.x) < 0.05f &&
|
Abs(A->m_vecMoveSpeed.x) < 0.05f &&
|
||||||
fabs(A->m_vecMoveSpeed.y) < 0.05f)
|
Abs(A->m_vecMoveSpeed.y) < 0.05f)
|
||||||
imp *= 0.1f;
|
imp *= 0.1f;
|
||||||
|
|
||||||
float turnSpeedDiff = A->m_vecTurnSpeed.MagnitudeSqr();
|
float turnSpeedDiff = A->m_vecTurnSpeed.MagnitudeSqr();
|
||||||
@ -1557,8 +1557,8 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
|
|||||||
m_vecTurnSpeed += turnSpeed / numResponses;
|
m_vecTurnSpeed += turnSpeed / numResponses;
|
||||||
if(!CWorld::bNoMoreCollisionTorque &&
|
if(!CWorld::bNoMoreCollisionTorque &&
|
||||||
A->m_status == STATUS_PLAYER && A->IsVehicle() &&
|
A->m_status == STATUS_PLAYER && A->IsVehicle() &&
|
||||||
fabs(A->m_vecMoveSpeed.x) > 0.2f &&
|
Abs(A->m_vecMoveSpeed.x) > 0.2f &&
|
||||||
fabs(A->m_vecMoveSpeed.y) > 0.2f){
|
Abs(A->m_vecMoveSpeed.y) > 0.2f){
|
||||||
A->m_vecMoveFriction.x += moveSpeed.x * -0.3f / numCollisions;
|
A->m_vecMoveFriction.x += moveSpeed.x * -0.3f / numCollisions;
|
||||||
A->m_vecMoveFriction.y += moveSpeed.y * -0.3f / numCollisions;
|
A->m_vecMoveFriction.y += moveSpeed.y * -0.3f / numCollisions;
|
||||||
A->m_vecTurnFriction += turnSpeed * -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
|
// 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
|
void
|
||||||
CPhysical::ProcessCollision(void)
|
CPhysical::ProcessCollision(void)
|
||||||
|
@ -127,8 +127,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SetRotateXOnly(float angle){
|
void SetRotateXOnly(float angle){
|
||||||
float c = cos(angle);
|
float c = Cos(angle);
|
||||||
float s = sin(angle);
|
float s = Sin(angle);
|
||||||
|
|
||||||
m_matrix.right.x = 1.0f;
|
m_matrix.right.x = 1.0f;
|
||||||
m_matrix.right.y = 0.0f;
|
m_matrix.right.y = 0.0f;
|
||||||
@ -149,8 +149,8 @@ public:
|
|||||||
m_matrix.pos.z = 0.0f;
|
m_matrix.pos.z = 0.0f;
|
||||||
}
|
}
|
||||||
void SetRotateYOnly(float angle){
|
void SetRotateYOnly(float angle){
|
||||||
float c = cos(angle);
|
float c = Cos(angle);
|
||||||
float s = sin(angle);
|
float s = Sin(angle);
|
||||||
|
|
||||||
m_matrix.right.x = c;
|
m_matrix.right.x = c;
|
||||||
m_matrix.right.y = 0.0f;
|
m_matrix.right.y = 0.0f;
|
||||||
@ -171,8 +171,8 @@ public:
|
|||||||
m_matrix.pos.z = 0.0f;
|
m_matrix.pos.z = 0.0f;
|
||||||
}
|
}
|
||||||
void SetRotateZOnly(float angle){
|
void SetRotateZOnly(float angle){
|
||||||
float c = cos(angle);
|
float c = Cos(angle);
|
||||||
float s = sin(angle);
|
float s = Sin(angle);
|
||||||
|
|
||||||
m_matrix.right.x = c;
|
m_matrix.right.x = c;
|
||||||
m_matrix.right.y = s;
|
m_matrix.right.y = s;
|
||||||
@ -193,12 +193,12 @@ public:
|
|||||||
m_matrix.pos.z = 0.0f;
|
m_matrix.pos.z = 0.0f;
|
||||||
}
|
}
|
||||||
void SetRotate(float xAngle, float yAngle, float zAngle) {
|
void SetRotate(float xAngle, float yAngle, float zAngle) {
|
||||||
float cX = cos(xAngle);
|
float cX = Cos(xAngle);
|
||||||
float sX = sin(xAngle);
|
float sX = Sin(xAngle);
|
||||||
float cY = cos(yAngle);
|
float cY = Cos(yAngle);
|
||||||
float sY = sin(yAngle);
|
float sY = Sin(yAngle);
|
||||||
float cZ = cos(zAngle);
|
float cZ = Cos(zAngle);
|
||||||
float sZ = sin(zAngle);
|
float sZ = Sin(zAngle);
|
||||||
|
|
||||||
m_matrix.right.x = cZ * cY - (sZ * sX) * sY;
|
m_matrix.right.x = cZ * cY - (sZ * sX) * sY;
|
||||||
m_matrix.right.y = (cZ * sX) * sY + sZ * cY;
|
m_matrix.right.y = (cZ * sX) * sY + sZ * cY;
|
||||||
|
@ -8,7 +8,7 @@ public:
|
|||||||
CQuaternion(void) {}
|
CQuaternion(void) {}
|
||||||
CQuaternion(float x, float y, float z, float w) : x(x), y(y), z(z), w(w) {}
|
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; }
|
float MagnitudeSqr(void) const { return x*x + y*y + z*z + w*w; }
|
||||||
|
|
||||||
const CQuaternion &operator+=(CQuaternion const &right) {
|
const CQuaternion &operator+=(CQuaternion const &right) {
|
||||||
|
@ -22,10 +22,10 @@ public:
|
|||||||
return *((RwV3d*)this);
|
return *((RwV3d*)this);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
float Heading(void) const { return atan2(-x, y); }
|
float Heading(void) const { return Atan2(-x, y); }
|
||||||
float Magnitude(void) const { return sqrt(x*x + y*y + z*z); }
|
float Magnitude(void) const { return Sqrt(x*x + y*y + z*z); }
|
||||||
float MagnitudeSqr(void) const { return 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; }
|
float MagnitudeSqr2D(void) const { return x*x + y*y; }
|
||||||
void Normalise(void) {
|
void Normalise(void) {
|
||||||
float sq = MagnitudeSqr();
|
float sq = MagnitudeSqr();
|
||||||
|
@ -7,7 +7,7 @@ public:
|
|||||||
CVector2D(void) {}
|
CVector2D(void) {}
|
||||||
CVector2D(float x, float y) : x(x), y(y) {}
|
CVector2D(float x, float y) : x(x), y(y) {}
|
||||||
CVector2D(const CVector &v) : x(v.x), y(v.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; }
|
float MagnitudeSqr(void) const { return x*x + y*y; }
|
||||||
|
|
||||||
void Normalise(void){
|
void Normalise(void){
|
||||||
|
@ -13,11 +13,11 @@ CQuaternion::Slerp(const CQuaternion &q1, const CQuaternion &q2, float theta, fl
|
|||||||
float w1, w2;
|
float w1, w2;
|
||||||
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;
|
||||||
}
|
}
|
||||||
*this = w1*q1 + w2*q2;
|
*this = w1*q1 + w2*q2;
|
||||||
}
|
}
|
||||||
|
12
src/math/maths.h
Normal file
12
src/math/maths.h
Normal file
@ -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); }
|
@ -551,7 +551,7 @@ CheckForPedsOnGroundToAttack(CPlayerPed *player, CPed **pedOnGround)
|
|||||||
angleToFace = CGeneral::LimitRadianAngle(angleToFace);
|
angleToFace = CGeneral::LimitRadianAngle(angleToFace);
|
||||||
player->m_fRotationCur = CGeneral::LimitRadianAngle(player->m_fRotationCur);
|
player->m_fRotationCur = CGeneral::LimitRadianAngle(player->m_fRotationCur);
|
||||||
|
|
||||||
angleDiff = fabs(angleToFace - player->m_fRotationCur);
|
angleDiff = Abs(angleToFace - player->m_fRotationCur);
|
||||||
|
|
||||||
if (angleDiff > PI)
|
if (angleDiff > PI)
|
||||||
angleDiff = 2 * PI - angleDiff;
|
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.
|
// 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
|
||||||
@ -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.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) {
|
||||||
m_moved = m_moved * (1 / CTimer::GetTimeStep());
|
m_moved = m_moved * (1 / CTimer::GetTimeStep());
|
||||||
@ -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(
|
||||||
@ -2276,7 +2276,7 @@ CPed::CanSeeEntity(CEntity *entity, float threshold)
|
|||||||
else if (ourAngle > 2 * PI)
|
else if (ourAngle > 2 * PI)
|
||||||
ourAngle -= 2 * PI;
|
ourAngle -= 2 * PI;
|
||||||
|
|
||||||
float neededTurn = fabs(neededAngle - ourAngle);
|
float neededTurn = Abs(neededAngle - ourAngle);
|
||||||
|
|
||||||
return neededTurn < threshold || 2 * PI - threshold < neededTurn;
|
return neededTurn < threshold || 2 * PI - threshold < neededTurn;
|
||||||
}
|
}
|
||||||
@ -2811,7 +2811,7 @@ CPed::TurnBody(void)
|
|||||||
float neededTurn = currentRot - limitedLookDir;
|
float neededTurn = currentRot - limitedLookDir;
|
||||||
m_fRotationDest = limitedLookDir;
|
m_fRotationDest = limitedLookDir;
|
||||||
|
|
||||||
if (fabs(neededTurn) > 0.05f) {
|
if (Abs(neededTurn) > 0.05f) {
|
||||||
doneSmoothly = false;
|
doneSmoothly = false;
|
||||||
currentRot -= neededTurn * 0.2f;
|
currentRot -= neededTurn * 0.2f;
|
||||||
}
|
}
|
||||||
|
@ -34,8 +34,8 @@ CPedIK::RotateTorso(AnimBlendFrameData *animBlend, LimbOrientation *limb, bool c
|
|||||||
|
|
||||||
// rotation == 0 -> looking in y direction
|
// rotation == 0 -> looking in y direction
|
||||||
// left? vector
|
// left? vector
|
||||||
float c = cos(m_ped->m_fRotationCur);
|
float c = Cos(m_ped->m_fRotationCur);
|
||||||
float s = sin(m_ped->m_fRotationCur);
|
float s = Sin(m_ped->m_fRotationCur);
|
||||||
rightVector.x = -(c*mat->right.x + s*mat->right.y);
|
rightVector.x = -(c*mat->right.x + s*mat->right.y);
|
||||||
rightVector.y = -(c*mat->up.x + s*mat->up.y);
|
rightVector.y = -(c*mat->up.x + s*mat->up.y);
|
||||||
rightVector.z = -(c*mat->at.x + s*mat->at.y);
|
rightVector.z = -(c*mat->at.x + s*mat->at.y);
|
||||||
|
@ -53,7 +53,7 @@ CClouds::Shutdown(void)
|
|||||||
void
|
void
|
||||||
CClouds::Update(void)
|
CClouds::Update(void)
|
||||||
{
|
{
|
||||||
float s = sin(TheCamera.Orientation - 0.85f);
|
float s = Sin(TheCamera.Orientation - 0.85f);
|
||||||
CloudRotation += CWeather::Wind*s*0.0025f;
|
CloudRotation += CWeather::Wind*s*0.0025f;
|
||||||
IndividualRotation += (CWeather::Wind*CTimer::GetTimeStep() + 0.3f) * 60.0f;
|
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;
|
float coverage = CWeather::CloudCoverage <= CWeather::Foggyness ? CWeather::Foggyness : CWeather::CloudCoverage;
|
||||||
|
|
||||||
// Moon
|
// 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
|
if(moonfadeout < 180){ // fade in/out 3 hours
|
||||||
int brightness = (1.0f - coverage) * (180 - moonfadeout);
|
int brightness = (1.0f - coverage) * (180 - moonfadeout);
|
||||||
RwV3d pos = { 0.0f, -100.0f, 15.0f };
|
RwV3d pos = { 0.0f, -100.0f, 15.0f };
|
||||||
@ -169,8 +169,8 @@ CClouds::Render(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fluffy clouds
|
// Fluffy clouds
|
||||||
float rot_sin = sin(CloudRotation);
|
float rot_sin = Sin(CloudRotation);
|
||||||
float rot_cos = cos(CloudRotation);
|
float rot_cos = Cos(CloudRotation);
|
||||||
int fluffyalpha = 160 * (1.0f - CWeather::Foggyness);
|
int fluffyalpha = 160 * (1.0f - CWeather::Foggyness);
|
||||||
if(fluffyalpha != 0){
|
if(fluffyalpha != 0){
|
||||||
static float CoorsOffsetX[37] = {
|
static float CoorsOffsetX[37] = {
|
||||||
@ -210,7 +210,7 @@ CClouds::Render(void)
|
|||||||
worldpos.z = pos.z;
|
worldpos.z = pos.z;
|
||||||
|
|
||||||
if(CSprite::CalcScreenCoors(worldpos, &screenpos, &szx, &szy, false)){
|
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 tr = CTimeCycle::GetFluffyCloudsTopRed();
|
||||||
int tg = CTimeCycle::GetFluffyCloudsTopGreen();
|
int tg = CTimeCycle::GetFluffyCloudsTopGreen();
|
||||||
int tb = CTimeCycle::GetFluffyCloudsTopBlue();
|
int tb = CTimeCycle::GetFluffyCloudsTopBlue();
|
||||||
@ -302,7 +302,7 @@ CClouds::RenderBackground(int16 topred, int16 topgreen, int16 topblue,
|
|||||||
int16 botred, int16 botgreen, int16 botblue, int16 alpha)
|
int16 botred, int16 botgreen, int16 botblue, int16 alpha)
|
||||||
{
|
{
|
||||||
RwMatrix *mat = RwFrameGetLTM(RwCameraGetFrame(TheCamera.m_pRwCamera));
|
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)
|
if(c > 1.0f)
|
||||||
c = 1.0f;
|
c = 1.0f;
|
||||||
ms_cameraRoll = acos(c);
|
ms_cameraRoll = acos(c);
|
||||||
@ -424,7 +424,7 @@ CClouds::RenderHorizon(void)
|
|||||||
SCREEN_HEIGHT/300.0f * max(TheCamera.GetPosition().z, 0.0f);
|
SCREEN_HEIGHT/300.0f * max(TheCamera.GetPosition().z, 0.0f);
|
||||||
float b = TheCamera.GetUp().z < 0.0f ?
|
float b = TheCamera.GetUp().z < 0.0f ?
|
||||||
SCREEN_HEIGHT :
|
SCREEN_HEIGHT :
|
||||||
SCREEN_HEIGHT * fabs(TheCamera.GetRight().z);
|
SCREEN_HEIGHT * Abs(TheCamera.GetRight().z);
|
||||||
float z2 = z1 + (a + b)*TheCamera.LODDistMultiplier;
|
float z2 = z1 + (a + b)*TheCamera.LODDistMultiplier;
|
||||||
z2 = min(z2, SCREEN_HEIGHT);
|
z2 = min(z2, SCREEN_HEIGHT);
|
||||||
CSprite2d::DrawRect(CRect(0, z1, SCREEN_WIDTH, z2),
|
CSprite2d::DrawRect(CRect(0, z1, SCREEN_WIDTH, z2),
|
||||||
|
@ -286,8 +286,8 @@ CCoronas::Render(void)
|
|||||||
|
|
||||||
// if distance too big, break streak
|
// if distance too big, break streak
|
||||||
if(aCoronas[i].hasValue[1]){
|
if(aCoronas[i].hasValue[1]){
|
||||||
if(fabs(aCoronas[i].prevX[0] - aCoronas[i].prevX[1]) > 50.0f ||
|
if(Abs(aCoronas[i].prevX[0] - aCoronas[i].prevX[1]) > 50.0f ||
|
||||||
fabs(aCoronas[i].prevY[0] - aCoronas[i].prevY[1]) > 50.0f)
|
Abs(aCoronas[i].prevY[0] - aCoronas[i].prevY[1]) > 50.0f)
|
||||||
aCoronas[i].hasValue[0] = false;
|
aCoronas[i].hasValue[0] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -173,7 +173,7 @@ void CHud::Draw()
|
|||||||
|
|
||||||
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE);
|
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);
|
float fMultBright = SpriteBrightness * 0.03f * (0.25f * fStep + 0.75f);
|
||||||
CRect rect;
|
CRect rect;
|
||||||
#ifndef ASPECT_RATIO_SCALE
|
#ifndef ASPECT_RATIO_SCALE
|
||||||
|
@ -299,8 +299,8 @@ void CParticle::Initialise()
|
|||||||
{
|
{
|
||||||
float angle = DEGTORAD(float(i) * float(360.0f / SIN_COS_TABLE_SIZE));
|
float angle = DEGTORAD(float(i) * float(360.0f / SIN_COS_TABLE_SIZE));
|
||||||
|
|
||||||
m_SinTable[i] = sin(angle);
|
m_SinTable[i] = Sin(angle);
|
||||||
m_CosTable[i] = cos(angle);
|
m_CosTable[i] = Cos(angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 slot = CTxdStore::FindTxdSlot("particle");
|
int32 slot = CTxdStore::FindTxdSlot("particle");
|
||||||
@ -1599,7 +1599,7 @@ void CParticle::Render()
|
|||||||
|
|
||||||
fTrailLength = fDist;
|
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);
|
float fRot = asinf(vecDist.x / fDist);
|
||||||
|
|
||||||
fRotation = fRot;
|
fRotation = fRot;
|
||||||
@ -1651,7 +1651,7 @@ void CParticle::Render()
|
|||||||
|
|
||||||
fTrailLength = fDist;
|
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);
|
float fRot = asinf(vecDist.x / fDist);
|
||||||
|
|
||||||
fRotation = fRot;
|
fRotation = fRot;
|
||||||
|
@ -33,7 +33,7 @@ CPointLights::AddLight(uint8 type, CVector coors, CVector dir, float radius, flo
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
dist = coors - TheCamera.GetPosition();
|
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();
|
distance = dist.Magnitude();
|
||||||
if(distance < MAX_DIST){
|
if(distance < MAX_DIST){
|
||||||
aLights[NumLights].type = type;
|
aLights[NumLights].type = type;
|
||||||
@ -73,9 +73,9 @@ CPointLights::GenerateLightsAffectingObject(CVector *objCoors)
|
|||||||
// same weird distance calculation. simplified here
|
// same weird distance calculation. simplified here
|
||||||
dist = aLights[i].coors - *objCoors;
|
dist = aLights[i].coors - *objCoors;
|
||||||
radius = aLights[i].radius;
|
radius = aLights[i].radius;
|
||||||
if(fabs(dist.x) < radius &&
|
if(Abs(dist.x) < radius &&
|
||||||
fabs(dist.y) < radius &&
|
Abs(dist.y) < radius &&
|
||||||
fabs(dist.z) < radius){
|
Abs(dist.z) < radius){
|
||||||
|
|
||||||
distance = dist.Magnitude();
|
distance = dist.Magnitude();
|
||||||
if(distance < radius){
|
if(distance < radius){
|
||||||
@ -217,7 +217,7 @@ CPointLights::RenderFogEffect(void)
|
|||||||
// 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
|
||||||
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)){
|
if(CSprite::CalcScreenCoors(fogcoors, spriteCoors, &spritew, &spriteh, true)){
|
||||||
float rotation = (CTimer::GetTimeInMilliseconds()&0x1FFF) * 2*3.14f / 0x1FFF;
|
float rotation = (CTimer::GetTimeInMilliseconds()&0x1FFF) * 2*3.14f / 0x1FFF;
|
||||||
@ -251,11 +251,11 @@ CPointLights::RenderFogEffect(void)
|
|||||||
|
|
||||||
float dx = xi - aLights[i].coors.x;
|
float dx = xi - aLights[i].coors.x;
|
||||||
float dy = yi - aLights[i].coors.y;
|
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){
|
if(lightdist < FOG_AREA_RADIUS){
|
||||||
dx = xi - TheCamera.GetPosition().x;
|
dx = xi - TheCamera.GetPosition().x;
|
||||||
dy = yi - TheCamera.GetPosition().y;
|
dy = yi - TheCamera.GetPosition().y;
|
||||||
float camdist = sqrt(sq(dx) + sq(dy));
|
float camdist = Sqrt(sq(dx) + sq(dy));
|
||||||
if(camdist < MAX_DIST){
|
if(camdist < MAX_DIST){
|
||||||
float intensity;
|
float intensity;
|
||||||
// distance fade
|
// distance fade
|
||||||
|
@ -135,8 +135,8 @@ CSprite::RenderOneXLUSprite(float x, float y, float z, float w, float h, uint8 r
|
|||||||
void
|
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)
|
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 c = Cos(DEGTORAD(rotation));
|
||||||
float s = sin(DEGTORAD(rotation));
|
float s = Sin(DEGTORAD(rotation));
|
||||||
|
|
||||||
float xs[4];
|
float xs[4];
|
||||||
float ys[4];
|
float ys[4];
|
||||||
@ -261,8 +261,8 @@ CSprite::RenderBufferedOneXLUSprite_Rotate_Dimension(float x, float y, float z,
|
|||||||
{
|
{
|
||||||
m_bFlushSpriteBufferSwitchZTest = 0;
|
m_bFlushSpriteBufferSwitchZTest = 0;
|
||||||
// TODO: replace with lookup
|
// TODO: replace with lookup
|
||||||
float c = cos(DEGTORAD(rotation));
|
float c = Cos(DEGTORAD(rotation));
|
||||||
float s = sin(DEGTORAD(rotation));
|
float s = Sin(DEGTORAD(rotation));
|
||||||
|
|
||||||
float xs[4];
|
float xs[4];
|
||||||
float ys[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)
|
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;
|
m_bFlushSpriteBufferSwitchZTest = 0;
|
||||||
float c = cos(DEGTORAD(rotation));
|
float c = Cos(DEGTORAD(rotation));
|
||||||
float s = sin(DEGTORAD(rotation));
|
float s = Sin(DEGTORAD(rotation));
|
||||||
|
|
||||||
float xs[4];
|
float xs[4];
|
||||||
float ys[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)
|
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;
|
m_bFlushSpriteBufferSwitchZTest = 0;
|
||||||
float c = cos(DEGTORAD(rotation));
|
float c = Cos(DEGTORAD(rotation));
|
||||||
float s = sin(DEGTORAD(rotation));
|
float s = Sin(DEGTORAD(rotation));
|
||||||
|
|
||||||
float xs[4];
|
float xs[4];
|
||||||
float ys[4];
|
float ys[4];
|
||||||
@ -572,8 +572,8 @@ CSprite::RenderBufferedOneXLUSprite2D_Rotate_Dimension(float x, float y, float w
|
|||||||
{
|
{
|
||||||
m_bFlushSpriteBufferSwitchZTest = 1;
|
m_bFlushSpriteBufferSwitchZTest = 1;
|
||||||
CRGBA col(intens * colour.red >> 8, intens * colour.green >> 8, intens * colour.blue >> 8, alpha);
|
CRGBA col(intens * colour.red >> 8, intens * colour.green >> 8, intens * colour.blue >> 8, alpha);
|
||||||
float c = cos(DEGTORAD(rotation));
|
float c = Cos(DEGTORAD(rotation));
|
||||||
float s = sin(DEGTORAD(rotation));
|
float s = Sin(DEGTORAD(rotation));
|
||||||
|
|
||||||
Set6Vertices2D(&SpriteBufferVerts[6 * nSpriteBufferIndex],
|
Set6Vertices2D(&SpriteBufferVerts[6 * nSpriteBufferIndex],
|
||||||
x + c*w - s*h,
|
x + c*w - s*h,
|
||||||
|
@ -299,9 +299,9 @@ CTimeCycle::Update(void)
|
|||||||
|
|
||||||
float sunAngle = 2*PI*(CClock::GetMinutes() + CClock::GetHours()*60)/(24*60);
|
float sunAngle = 2*PI*(CClock::GetMinutes() + CClock::GetHours()*60)/(24*60);
|
||||||
CVector &sunPos = GetSunPosition();
|
CVector &sunPos = GetSunPosition();
|
||||||
sunPos.x = sinf(sunAngle);
|
sunPos.x = Sin(sunAngle);
|
||||||
sunPos.y = 1.0f;
|
sunPos.y = 1.0f;
|
||||||
sunPos.z = 0.2f - cosf(sunAngle);
|
sunPos.z = 0.2f - Cos(sunAngle);
|
||||||
sunPos.Normalise();
|
sunPos.Normalise();
|
||||||
|
|
||||||
CShadows::CalcPedShadowValues(sunPos,
|
CShadows::CalcPedShadowValues(sunPos,
|
||||||
|
@ -2340,7 +2340,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2365,16 +2365,16 @@ HRESULT CapturePad(RwInt32 padID)
|
|||||||
|
|
||||||
CPad *pad = CPad::GetPad(bs.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);
|
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);
|
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);
|
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);
|
pad->PCTempJoyState.RightStickY = (int32)(rightStickPos.y * 128.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ CDoor::Process(CVehicle *vehicle)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
fSpeedDiff = clamp(fSpeedDiff, -0.2f, 0.2f);
|
fSpeedDiff = clamp(fSpeedDiff, -0.2f, 0.2f);
|
||||||
if(fabs(fSpeedDiff) > 0.002f)
|
if(Abs(fSpeedDiff) > 0.002f)
|
||||||
m_fAngVel += fSpeedDiff;
|
m_fAngVel += fSpeedDiff;
|
||||||
m_fAngVel *= 0.945f;
|
m_fAngVel *= 0.945f;
|
||||||
m_fAngVel = clamp(m_fAngVel, -0.3f, 0.3f);
|
m_fAngVel = clamp(m_fAngVel, -0.3f, 0.3f);
|
||||||
@ -76,7 +76,7 @@ CDoor::Process(CVehicle *vehicle)
|
|||||||
float
|
float
|
||||||
CDoor::RetAngleWhenClosed(void)
|
CDoor::RetAngleWhenClosed(void)
|
||||||
{
|
{
|
||||||
if(fabs(m_fMaxAngle) < fabs(m_fMinAngle))
|
if(Abs(m_fMaxAngle) < Abs(m_fMinAngle))
|
||||||
return m_fMaxAngle;
|
return m_fMaxAngle;
|
||||||
else
|
else
|
||||||
return m_fMinAngle;
|
return m_fMinAngle;
|
||||||
@ -85,7 +85,7 @@ CDoor::RetAngleWhenClosed(void)
|
|||||||
float
|
float
|
||||||
CDoor::RetAngleWhenOpen(void)
|
CDoor::RetAngleWhenOpen(void)
|
||||||
{
|
{
|
||||||
if(fabs(m_fMaxAngle) < fabs(m_fMinAngle))
|
if(Abs(m_fMaxAngle) < Abs(m_fMinAngle))
|
||||||
return m_fMinAngle;
|
return m_fMinAngle;
|
||||||
else
|
else
|
||||||
return m_fMaxAngle;
|
return m_fMaxAngle;
|
||||||
@ -104,7 +104,7 @@ bool
|
|||||||
CDoor::IsFullyOpen(void)
|
CDoor::IsFullyOpen(void)
|
||||||
{
|
{
|
||||||
// why -0.5? that's around 28 deg less than fully open
|
// 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 false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -213,7 +213,7 @@ CVehicle::FlyingControl(eFlightModel flightModel)
|
|||||||
ApplyTurnForce(impulse*GetUp(), 2.0f*GetUp() + com);
|
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();
|
moveSpeed = m_vecMoveSpeed.MagnitudeSqr();
|
||||||
if(moveSpeed > 2.25f)
|
if(moveSpeed > 2.25f)
|
||||||
m_vecMoveSpeed *= 1.5f/sqrt(moveSpeed);
|
m_vecMoveSpeed *= 1.5f/sqrt(moveSpeed);
|
||||||
@ -296,7 +296,7 @@ CVehicle::ProcessWheel(CVector &wheelFwd, CVector &wheelRight, CVector &wheelCon
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(brake > adhesion){
|
if(brake > adhesion){
|
||||||
if(fabs(contactSpeedFwd) > 0.005f)
|
if(Abs(contactSpeedFwd) > 0.005f)
|
||||||
*wheelState = WHEEL_STATE_STATIC;
|
*wheelState = WHEEL_STATE_STATIC;
|
||||||
}else {
|
}else {
|
||||||
if(fwd > 0.0f){
|
if(fwd > 0.0f){
|
||||||
@ -317,7 +317,7 @@ CVehicle::ProcessWheel(CVector &wheelFwd, CVector &wheelRight, CVector &wheelCon
|
|||||||
*wheelState = WHEEL_STATE_2;
|
*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;
|
float tractionLoss = bAlreadySkidding ? 1.0f : m_handling->fTractionLoss;
|
||||||
right *= adhesion * tractionLoss / l;
|
right *= adhesion * tractionLoss / l;
|
||||||
fwd *= adhesion * tractionLoss / l;
|
fwd *= adhesion * tractionLoss / l;
|
||||||
@ -552,9 +552,9 @@ CVehicle::CanPedExitCar(void)
|
|||||||
if(m_vecMoveSpeed.MagnitudeSqr() > 0.005f)
|
if(m_vecMoveSpeed.MagnitudeSqr() > 0.005f)
|
||||||
return false;
|
return false;
|
||||||
// if car is slow enough, check turn speed
|
// if car is slow enough, check turn speed
|
||||||
if(fabs(m_vecTurnSpeed.x) > 0.01f ||
|
if(Abs(m_vecTurnSpeed.x) > 0.01f ||
|
||||||
fabs(m_vecTurnSpeed.y) > 0.01f ||
|
Abs(m_vecTurnSpeed.y) > 0.01f ||
|
||||||
fabs(m_vecTurnSpeed.z) > 0.01f)
|
Abs(m_vecTurnSpeed.z) > 0.01f)
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}else{
|
}else{
|
||||||
@ -564,9 +564,9 @@ CVehicle::CanPedExitCar(void)
|
|||||||
if(m_vecMoveSpeed.MagnitudeSqr() >= 0.005f)
|
if(m_vecMoveSpeed.MagnitudeSqr() >= 0.005f)
|
||||||
return false;
|
return false;
|
||||||
// if car is slow enough, check turn speed
|
// if car is slow enough, check turn speed
|
||||||
if(fabs(m_vecTurnSpeed.x) >= 0.01f ||
|
if(Abs(m_vecTurnSpeed.x) >= 0.01f ||
|
||||||
fabs(m_vecTurnSpeed.y) >= 0.01f ||
|
Abs(m_vecTurnSpeed.y) >= 0.01f ||
|
||||||
fabs(m_vecTurnSpeed.z) >= 0.01f)
|
Abs(m_vecTurnSpeed.z) >= 0.01f)
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user