Merge pull request #378 from aap/master

finished CCamera
This commit is contained in:
aap 2020-04-05 14:30:28 +02:00 committed by GitHub
commit 5e9ae94298
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 3544 additions and 447 deletions

View File

@ -42,7 +42,6 @@ cAudioManager - WIP
CBoat CBoat
CBrightLights CBrightLights
CBulletInfo CBulletInfo
CCamera
CCrane CCrane
CCranes CCranes
CCullZone CCullZone

View File

@ -5,6 +5,7 @@
#include "config.h" #include "config.h"
class CVehicle; class CVehicle;
class CCamera;
enum eGarageState : int8 enum eGarageState : int8
{ {
@ -168,6 +169,7 @@ class CGarage
friend class CGarages; friend class CGarages;
friend class cAudioManager; friend class cAudioManager;
friend class CCamera;
}; };
static_assert(sizeof(CGarage) == 140, "CGarage"); static_assert(sizeof(CGarage) == 140, "CGarage");

View File

@ -35,7 +35,7 @@ CRemote::GivePlayerRemoteControlledCar(float x, float y, float z, float rot, uin
CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle = car; CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle = car;
CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle->RegisterReference((CEntity**)&CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle); CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle->RegisterReference((CEntity**)&CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle);
TheCamera.TakeControl(car, CCam::MODE_BEHINDCAR, INTERPOLATION, CAM_CONTROLLER_1); TheCamera.TakeControl(car, CCam::MODE_BEHINDCAR, INTERPOLATION, CAMCONTROL_SCRIPT);
} }
void void

View File

@ -2,6 +2,7 @@
#include "patcher.h" #include "patcher.h"
#include "SceneEdit.h" #include "SceneEdit.h"
bool &CSceneEdit::m_bEditOn = *(bool*)0x95CD77;
int32 &CSceneEdit::m_bCameraFollowActor = *(int*)0x940590; int32 &CSceneEdit::m_bCameraFollowActor = *(int*)0x940590;
bool &CSceneEdit::m_bRecording = *(bool*)0x95CD1F; bool &CSceneEdit::m_bRecording = *(bool*)0x95CD1F;
CVector &CSceneEdit::m_vecCurrentPosition = *(CVector*)0x943064; CVector &CSceneEdit::m_vecCurrentPosition = *(CVector*)0x943064;

View File

@ -3,6 +3,7 @@
class CSceneEdit class CSceneEdit
{ {
public: public:
static bool &m_bEditOn;
static int32 &m_bCameraFollowActor; static int32 &m_bCameraFollowActor;
static bool &m_bRecording; static bool &m_bRecording;
static CVector &m_vecCurrentPosition; static CVector &m_vecCurrentPosition;

View File

@ -3073,7 +3073,7 @@ int8 CRunningScript::ProcessCommands300To399(int32 command)
{ {
CollectParameters(&m_nIp, 3); CollectParameters(&m_nIp, 3);
// ScriptParams[0] is unused. // ScriptParams[0] is unused.
TheCamera.TakeControl(nil, ScriptParams[1], ScriptParams[2], CAM_CONTROLLER_1); TheCamera.TakeControl(nil, ScriptParams[1], ScriptParams[2], CAMCONTROL_SCRIPT);
return 0; return 0;
} }
case COMMAND_POINT_CAMERA_AT_CAR: case COMMAND_POINT_CAMERA_AT_CAR:
@ -3081,7 +3081,7 @@ int8 CRunningScript::ProcessCommands300To399(int32 command)
CollectParameters(&m_nIp, 3); CollectParameters(&m_nIp, 3);
CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
assert(pVehicle); assert(pVehicle);
TheCamera.TakeControl(pVehicle, ScriptParams[1], ScriptParams[2], CAM_CONTROLLER_1); TheCamera.TakeControl(pVehicle, ScriptParams[1], ScriptParams[2], CAMCONTROL_SCRIPT);
return 0; return 0;
} }
case COMMAND_POINT_CAMERA_AT_CHAR: case COMMAND_POINT_CAMERA_AT_CHAR:
@ -3089,7 +3089,7 @@ int8 CRunningScript::ProcessCommands300To399(int32 command)
CollectParameters(&m_nIp, 3); CollectParameters(&m_nIp, 3);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
assert(pPed); assert(pPed);
TheCamera.TakeControl(pPed, ScriptParams[1], ScriptParams[2], CAM_CONTROLLER_1); TheCamera.TakeControl(pPed, ScriptParams[1], ScriptParams[2], CAMCONTROL_SCRIPT);
return 0; return 0;
} }
case COMMAND_RESTORE_CAMERA: case COMMAND_RESTORE_CAMERA:
@ -3140,7 +3140,7 @@ int8 CRunningScript::ProcessCommands300To399(int32 command)
CVector pos = *(CVector*)&ScriptParams[0]; CVector pos = *(CVector*)&ScriptParams[0];
if (pos.z <= MAP_Z_LOW_LIMIT) if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
TheCamera.TakeControlNoEntity(pos, ScriptParams[3], CAM_CONTROLLER_1); TheCamera.TakeControlNoEntity(pos, ScriptParams[3], CAMCONTROL_SCRIPT);
return 0; return 0;
} }
case COMMAND_ADD_BLIP_FOR_CAR_OLD: case COMMAND_ADD_BLIP_FOR_CAR_OLD:

View File

@ -294,7 +294,7 @@ CAnimViewer::Update(void)
} }
newEntity->GetPosition() = CVector(0.0f, 0.0f, 0.0f); newEntity->GetPosition() = CVector(0.0f, 0.0f, 0.0f);
CWorld::Add(newEntity); CWorld::Add(newEntity);
TheCamera.TakeControl(pTarget, CCam::MODE_MODELVIEW, JUMP_CUT, CAM_CONTROLLER_1); TheCamera.TakeControl(pTarget, CCam::MODE_MODELVIEW, JUMP_CUT, CAMCONTROL_SCRIPT);
} }
if (pTarget->m_type == ENTITY_TYPE_VEHICLE || pTarget->m_type == ENTITY_TYPE_PED || pTarget->m_type == ENTITY_TYPE_OBJECT) { if (pTarget->m_type == ENTITY_TYPE_VEHICLE || pTarget->m_type == ENTITY_TYPE_PED || pTarget->m_type == ENTITY_TYPE_OBJECT) {
((CPhysical*)pTarget)->m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); ((CPhysical*)pTarget)->m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f);

View File

@ -31,8 +31,7 @@ bool PrintDebugCode = false;
int16 &DebugCamMode = *(int16*)0x95CCF2; int16 &DebugCamMode = *(int16*)0x95CCF2;
#ifdef FREE_CAM #ifdef FREE_CAM
bool bFreePadCam = false; bool CCamera::bFreeCam = false;
bool bFreeMouseCam = false;
int nPreviousMode = -1; int nPreviousMode = -1;
#endif #endif
@ -146,7 +145,7 @@ CCam::Process(void)
Process_FollowPedWithMouse(CameraTarget, TargetOrientation, SpeedVar, TargetSpeedVar); Process_FollowPedWithMouse(CameraTarget, TargetOrientation, SpeedVar, TargetSpeedVar);
else else
#ifdef FREE_CAM #ifdef FREE_CAM
if(bFreePadCam) if(CCamera::bFreeCam)
Process_FollowPed_Rotation(CameraTarget, TargetOrientation, SpeedVar, TargetSpeedVar); Process_FollowPed_Rotation(CameraTarget, TargetOrientation, SpeedVar, TargetSpeedVar);
else else
#endif #endif
@ -187,7 +186,7 @@ CCam::Process(void)
break; break;
case MODE_CAM_ON_A_STRING: case MODE_CAM_ON_A_STRING:
#ifdef FREE_CAM #ifdef FREE_CAM
if(bFreeMouseCam || bFreePadCam) if(CCamera::bFreeCam)
Process_FollowCar_SA(CameraTarget, TargetOrientation, SpeedVar, TargetSpeedVar); Process_FollowCar_SA(CameraTarget, TargetOrientation, SpeedVar, TargetSpeedVar);
else else
#endif #endif
@ -204,7 +203,7 @@ CCam::Process(void)
break; break;
case MODE_BEHINDBOAT: case MODE_BEHINDBOAT:
#ifdef FREE_CAM #ifdef FREE_CAM
if (bFreeMouseCam || bFreePadCam) if (CCamera::bFreeCam)
Process_FollowCar_SA(CameraTarget, TargetOrientation, SpeedVar, TargetSpeedVar); Process_FollowCar_SA(CameraTarget, TargetOrientation, SpeedVar, TargetSpeedVar);
else else
#endif #endif
@ -267,7 +266,7 @@ CCam::Process(void)
float DistOnGround = TargetToCam.Magnitude2D(); float DistOnGround = TargetToCam.Magnitude2D();
m_fTrueBeta = CGeneral::GetATanOfXY(TargetToCam.x, TargetToCam.y); m_fTrueBeta = CGeneral::GetATanOfXY(TargetToCam.x, TargetToCam.y);
m_fTrueAlpha = CGeneral::GetATanOfXY(TargetToCam.z, DistOnGround); m_fTrueAlpha = CGeneral::GetATanOfXY(TargetToCam.z, DistOnGround);
if(TheCamera.m_uiTransitionState == 0) // TODO? what values are possible? enum? if(TheCamera.m_uiTransitionState == 0)
KeepTrackOfTheSpeed(Source, m_cvecTargetCoorsForFudgeInter, Up, m_fTrueAlpha, m_fTrueBeta, FOV); KeepTrackOfTheSpeed(Source, m_cvecTargetCoorsForFudgeInter, Up, m_fTrueAlpha, m_fTrueBeta, FOV);
// Look Behind, Left, Right // Look Behind, Left, Right
@ -421,11 +420,11 @@ CCam::ProcessSpecialHeightRoutines(void)
float DistScale = (2.1f - dist)/2.1f; float DistScale = (2.1f - dist)/2.1f;
if(Mode == MODE_FOLLOWPED){ if(Mode == MODE_FOLLOWPED){
if(TheCamera.PedZoomIndicator == 1.0f) if(TheCamera.PedZoomIndicator == CAM_ZOOM_1)
Offset = 0.45*DistScale + PedZDist; Offset = 0.45*DistScale + PedZDist;
if(TheCamera.PedZoomIndicator == 2.0f) if(TheCamera.PedZoomIndicator == CAM_ZOOM_2)
Offset = 0.35*DistScale + PedZDist; Offset = 0.35*DistScale + PedZDist;
if(TheCamera.PedZoomIndicator == 3.0f) if(TheCamera.PedZoomIndicator == CAM_ZOOM_3)
Offset = 0.25*DistScale + PedZDist; Offset = 0.25*DistScale + PedZDist;
if(Abs(CGeneral::GetRadianAngleBetweenPoints(CamToPed.x, CamToPed.y, CamToTarget.x, CamToTarget.y)) > HALFPI) if(Abs(CGeneral::GetRadianAngleBetweenPoints(CamToPed.x, CamToPed.y, CamToTarget.x, CamToTarget.y)) > HALFPI)
Offset += 0.3f; Offset += 0.3f;
@ -575,11 +574,11 @@ CCam::ProcessSpecialHeightRoutines(void)
m_fRoadOffSet = 1.4f; m_fRoadOffSet = 1.4f;
}else{ }else{
if(Mode == MODE_FOLLOWPED){ if(Mode == MODE_FOLLOWPED){
if(TheCamera.PedZoomIndicator == 1.0f) if(TheCamera.PedZoomIndicator == CAM_ZOOM_1)
m_fRoadOffSet += 0.2f; m_fRoadOffSet += 0.2f;
if(TheCamera.PedZoomIndicator == 2.0f) if(TheCamera.PedZoomIndicator == CAM_ZOOM_2)
m_fRoadOffSet += 0.5f; m_fRoadOffSet += 0.5f;
if(TheCamera.PedZoomIndicator == 3.0f) if(TheCamera.PedZoomIndicator == CAM_ZOOM_3)
m_fRoadOffSet += 0.95f; m_fRoadOffSet += 0.95f;
} }
} }
@ -636,7 +635,7 @@ CCam::LookBehind(void)
Source.y = Dist*Sin(TargetOrientation) + TargetCoors.y; Source.y = Dist*Sin(TargetOrientation) + TargetCoors.y;
Source.z -= 1.0f; Source.z -= 1.0f;
if(CWorld::ProcessLineOfSight(TargetCoors, Source, colPoint, entity, true, false, false, true, false, true, true)){ if(CWorld::ProcessLineOfSight(TargetCoors, Source, colPoint, entity, true, false, false, true, false, true, true)){
RwCameraSetNearClipPlane(Scene.camera, 0.9f); RwCameraSetNearClipPlane(Scene.camera, DEFAULT_NEAR);
Source = colPoint.point; Source = colPoint.point;
} }
Source.z += 1.0f; Source.z += 1.0f;
@ -800,7 +799,7 @@ CCam::ClipIfPedInFrontOfPlayer(void)
if(Abs(DeltaAngle) < HALFPI){ if(Abs(DeltaAngle) < HALFPI){
fDist = Sqrt(SQR(vDist.x) + SQR(vDist.y)); fDist = Sqrt(SQR(vDist.x) + SQR(vDist.y));
if(fDist < 1.25f){ if(fDist < 1.25f){
Near = 0.9f - (1.25f - fDist); Near = DEFAULT_NEAR - (1.25f - fDist);
if(Near < 0.05f) if(Near < 0.05f)
Near = 0.05f; Near = 0.05f;
RwCameraSetNearClipPlane(Scene.camera, Near); RwCameraSetNearClipPlane(Scene.camera, Near);
@ -1044,7 +1043,7 @@ CCam::Process_FollowPed(const CVector &CameraTarget, float TargetOrientation, fl
}else{ }else{
LateralDist = 0.8f; LateralDist = 0.8f;
CenterDist = 1.35f; CenterDist = 1.35f;
if(TheCamera.PedZoomIndicator == 1.0f || TheCamera.PedZoomIndicator == 4.0f){ if(TheCamera.PedZoomIndicator == CAM_ZOOM_1 || TheCamera.PedZoomIndicator == CAM_ZOOM_TOPDOWN){
LateralDist = 1.25f; LateralDist = 1.25f;
CenterDist = 1.6f; CenterDist = 1.6f;
} }
@ -1082,7 +1081,6 @@ CCam::Process_FollowPed(const CVector &CameraTarget, float TargetOrientation, fl
else else
IdealSource = TargetCoors + CVector(1.0f, 1.0f, 0.0f); IdealSource = TargetCoors + CVector(1.0f, 1.0f, 0.0f);
// 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);
@ -1111,17 +1109,17 @@ CCam::Process_FollowPed(const CVector &CameraTarget, float TargetOrientation, fl
// BUG? is this ever used? // BUG? is this ever used?
// The values seem to be roughly m_fPedZoomValueSmooth + 1.85 // The values seem to be roughly m_fPedZoomValueSmooth + 1.85
if(ResetStatics){ if(ResetStatics){
if(TheCamera.PedZoomIndicator == 1.0) m_fRealGroundDist = 2.090556f; if(TheCamera.PedZoomIndicator == CAM_ZOOM_1) m_fRealGroundDist = 2.090556f;
if(TheCamera.PedZoomIndicator == 2.0) m_fRealGroundDist = 3.34973f; if(TheCamera.PedZoomIndicator == CAM_ZOOM_2) m_fRealGroundDist = 3.34973f;
if(TheCamera.PedZoomIndicator == 3.0) m_fRealGroundDist = 4.704914f; if(TheCamera.PedZoomIndicator == CAM_ZOOM_3) m_fRealGroundDist = 4.704914f;
if(TheCamera.PedZoomIndicator == 4.0) m_fRealGroundDist = 2.090556f; if(TheCamera.PedZoomIndicator == CAM_ZOOM_TOPDOWN) m_fRealGroundDist = 2.090556f;
} }
// And what is this? It's only used for collision and rotation it seems // And what is this? It's only used for collision and rotation it seems
float RealGroundDist; float RealGroundDist;
if(TheCamera.PedZoomIndicator == 1.0) RealGroundDist = 2.090556f; if(TheCamera.PedZoomIndicator == CAM_ZOOM_1) RealGroundDist = 2.090556f;
if(TheCamera.PedZoomIndicator == 2.0) RealGroundDist = 3.34973f; if(TheCamera.PedZoomIndicator == CAM_ZOOM_2) RealGroundDist = 3.34973f;
if(TheCamera.PedZoomIndicator == 3.0) RealGroundDist = 4.704914f; if(TheCamera.PedZoomIndicator == CAM_ZOOM_3) RealGroundDist = 4.704914f;
if(TheCamera.PedZoomIndicator == 4.0) RealGroundDist = 2.090556f; if(TheCamera.PedZoomIndicator == CAM_ZOOM_TOPDOWN) RealGroundDist = 2.090556f;
if(m_fCloseInPedHeightOffset > 0.00001f) if(m_fCloseInPedHeightOffset > 0.00001f)
RealGroundDist = 1.7016f; RealGroundDist = 1.7016f;
@ -1292,8 +1290,8 @@ CCam::Process_FollowPed(const CVector &CameraTarget, float TargetOrientation, fl
// Now do the Beta rotation // Now do the Beta rotation
float Distance = (IdealSource - TargetCoors).Magnitude2D(); float RotDistance = (IdealSource - TargetCoors).Magnitude2D();
m_fDistanceBeforeChanges = Distance; m_fDistanceBeforeChanges = RotDistance;
if(Rotating){ if(Rotating){
m_bFixingBeta = true; m_bFixingBeta = true;
@ -1334,8 +1332,8 @@ 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 + RotDistance * Cos(Beta);
Source.y = TargetCoors.y + Distance * Sin(Beta); Source.y = TargetCoors.y + RotDistance * Sin(Beta);
// Check if we can stop rotating // Check if we can stop rotating
DeltaBeta = FixedTargetOrientation - Beta; DeltaBeta = FixedTargetOrientation - Beta;
@ -1354,18 +1352,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 + RotDistance * Cos(Beta);
Source.y = TargetCoors.y + Distance * Sin(Beta); Source.y = TargetCoors.y + RotDistance * 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 + RotDistance * Cos(Beta);
Source.y = TargetCoors.y + Distance * Sin(Beta); Source.y = TargetCoors.y + RotDistance * Sin(Beta);
} }
if(HackPlayerOnStoppingTrain){ if(HackPlayerOnStoppingTrain){
Beta = TargetOrientation + PI; Beta = TargetOrientation + PI;
Source.x = TargetCoors.x + Distance * Cos(Beta); Source.x = TargetCoors.x + RotDistance * Cos(Beta);
Source.y = TargetCoors.y + Distance * Sin(Beta); Source.y = TargetCoors.y + RotDistance * 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;
@ -1551,7 +1549,7 @@ CCam::Process_FollowPedWithMouse(const CVector &CameraTarget, float TargetOrient
// SA code // SA code
#ifdef FREE_CAM #ifdef FREE_CAM
if((bFreeMouseCam && Alpha > 0.0f) || (!bFreeMouseCam && Alpha > fBaseDist)) if((CCamera::bFreeCam && Alpha > 0.0f) || (!CCamera::bFreeCam && Alpha > fBaseDist))
#else #else
if(Alpha > fBaseDist) // comparing an angle against a distance? if(Alpha > fBaseDist) // comparing an angle against a distance?
#endif #endif
@ -1586,14 +1584,14 @@ CCam::Process_FollowPedWithMouse(const CVector &CameraTarget, float TargetOrient
if(CWorld::ProcessLineOfSight(colPoint.point, Source, colPoint, entity, true, true, true, true, false, false, true)){ if(CWorld::ProcessLineOfSight(colPoint.point, Source, colPoint, entity, true, true, true, true, false, false, true)){
PedColDist = (TargetCoors - colPoint.point).Magnitude(); PedColDist = (TargetCoors - colPoint.point).Magnitude();
Source = colPoint.point; Source = colPoint.point;
if(PedColDist < 0.9f + 0.3f) if(PedColDist < DEFAULT_NEAR + 0.3f)
RwCameraSetNearClipPlane(Scene.camera, max(PedColDist-0.3f, 0.05f)); RwCameraSetNearClipPlane(Scene.camera, max(PedColDist-0.3f, 0.05f));
}else{ }else{
RwCameraSetNearClipPlane(Scene.camera, min(ColCamDist-0.35f, 0.9f)); RwCameraSetNearClipPlane(Scene.camera, min(ColCamDist-0.35f, DEFAULT_NEAR));
} }
}else{ }else{
Source = colPoint.point; Source = colPoint.point;
if(PedColDist < 0.9f + 0.3f) if(PedColDist < DEFAULT_NEAR + 0.3f)
RwCameraSetNearClipPlane(Scene.camera, max(PedColDist-0.3f, 0.05f)); RwCameraSetNearClipPlane(Scene.camera, max(PedColDist-0.3f, 0.05f));
} }
} }
@ -1640,7 +1638,7 @@ CCam::Process_FollowPedWithMouse(const CVector &CameraTarget, float TargetOrient
CPed *player = FindPlayerPed(); CPed *player = FindPlayerPed();
float PlayerDist = (Source - player->GetPosition()).Magnitude(); float PlayerDist = (Source - player->GetPosition()).Magnitude();
if(PlayerDist < 2.75f) if(PlayerDist < 2.75f)
Near = PlayerDist/2.75f * 0.9f - 0.3f; Near = PlayerDist/2.75f * DEFAULT_NEAR - 0.3f;
RwCameraSetNearClipPlane(Scene.camera, max(Near, 0.1f)); RwCameraSetNearClipPlane(Scene.camera, max(Near, 0.1f));
} }
} }
@ -1800,11 +1798,11 @@ CCam::WorkOutCamHeight(const CVector &TargetCoors, float TargetOrientation, floa
float zoomvalue = TheCamera.CarZoomValueSmooth; float zoomvalue = TheCamera.CarZoomValueSmooth;
if(zoomvalue < 0.1f) if(zoomvalue < 0.1f)
zoomvalue = 0.1f; zoomvalue = 0.1f;
if(TheCamera.CarZoomIndicator == 1.0f) if(TheCamera.CarZoomIndicator == CAM_ZOOM_1)
ModeAlpha = CGeneral::GetATanOfXY(23.0f, zoomvalue); // near ModeAlpha = CGeneral::GetATanOfXY(23.0f, zoomvalue); // near
else if(TheCamera.CarZoomIndicator == 2.0f) else if(TheCamera.CarZoomIndicator == CAM_ZOOM_2)
ModeAlpha = CGeneral::GetATanOfXY(10.8f, zoomvalue); // mid ModeAlpha = CGeneral::GetATanOfXY(10.8f, zoomvalue); // mid
else if(TheCamera.CarZoomIndicator == 3.0f) else if(TheCamera.CarZoomIndicator == CAM_ZOOM_3)
ModeAlpha = CGeneral::GetATanOfXY(7.0f, zoomvalue); // far ModeAlpha = CGeneral::GetATanOfXY(7.0f, zoomvalue); // far
@ -1900,7 +1898,7 @@ CCam::WorkOutCamHeight(const CVector &TargetCoors, float TargetOrientation, floa
PreviousNearCheckNearClipSmall = false; PreviousNearCheckNearClipSmall = false;
if(!CamClear){ if(!CamClear){
PreviousNearCheckNearClipSmall = true; PreviousNearCheckNearClipSmall = true;
RwCameraSetNearClipPlane(Scene.camera, 0.9f); RwCameraSetNearClipPlane(Scene.camera, DEFAULT_NEAR);
DeltaAlpha = TargetAlpha - (Alpha + ModeAlpha); DeltaAlpha = TargetAlpha - (Alpha + ModeAlpha);
while(DeltaAlpha >= PI) DeltaAlpha -= 2*PI; while(DeltaAlpha >= PI) DeltaAlpha -= 2*PI;
@ -1918,7 +1916,7 @@ CCam::WorkOutCamHeight(const CVector &TargetCoors, float TargetOrientation, floa
if(CamClear) if(CamClear)
if(CamZ - CamGround2 < 1.5f){ if(CamZ - CamGround2 < 1.5f){
PreviousNearCheckNearClipSmall = true; PreviousNearCheckNearClipSmall = true;
RwCameraSetNearClipPlane(Scene.camera, 0.9f); RwCameraSetNearClipPlane(Scene.camera, DEFAULT_NEAR);
float a; float a;
if(Length == 0.0f || CamGround2 + 1.5f - TargetCoors.z == 0.0f) if(Length == 0.0f || CamGround2 + 1.5f - TargetCoors.z == 0.0f)
@ -1934,7 +1932,7 @@ CCam::WorkOutCamHeight(const CVector &TargetCoors, float TargetOrientation, floa
float CamRoof2 = CWorld::FindRoofZFor3DCoord(Source.x, Source.y, CamZ, &FoundRoof); float CamRoof2 = CWorld::FindRoofZFor3DCoord(Source.x, Source.y, CamZ, &FoundRoof);
if(FoundRoof && CamZ - CamRoof2 < 1.5f){ if(FoundRoof && CamZ - CamRoof2 < 1.5f){
PreviousNearCheckNearClipSmall = true; PreviousNearCheckNearClipSmall = true;
RwCameraSetNearClipPlane(Scene.camera, 0.9f); RwCameraSetNearClipPlane(Scene.camera, DEFAULT_NEAR);
if(CamRoof2 > TargetCoors.z + 3.5f) if(CamRoof2 > TargetCoors.z + 3.5f)
CamRoof2 = TargetCoors.z + 3.5f; CamRoof2 = TargetCoors.z + 3.5f;
@ -1956,7 +1954,7 @@ CCam::WorkOutCamHeight(const CVector &TargetCoors, float TargetOrientation, floa
LastAlphaSpeedStep = AlphaSpeedStep; LastAlphaSpeedStep = AlphaSpeedStep;
}else{ }else{
if(PreviousNearCheckNearClipSmall) if(PreviousNearCheckNearClipSmall)
RwCameraSetNearClipPlane(Scene.camera, 0.9f); RwCameraSetNearClipPlane(Scene.camera, DEFAULT_NEAR);
} }
WellBufferMe(LastTargetAlphaWithCollisionOn, &Alpha, &AlphaSpeed, LastTopAlphaSpeed, LastAlphaSpeedStep, true); WellBufferMe(LastTargetAlphaWithCollisionOn, &Alpha, &AlphaSpeed, LastTopAlphaSpeed, LastAlphaSpeedStep, true);
@ -3204,7 +3202,8 @@ CCam::Process_BehindBoat(const CVector &CameraTarget, float TargetOrientation, f
static float WaterZAddition = 2.75f; static float WaterZAddition = 2.75f;
float WaterLevel = 0.0f; float WaterLevel = 0.0f;
float s, c; float s, c;
float Beta = CGeneral::GetATanOfXY(TargetCoors.x - Source.x, TargetCoors.y - Source.y);
Beta = CGeneral::GetATanOfXY(TargetCoors.x - Source.x, TargetCoors.y - Source.y);
FOV = DefaultFOV; FOV = DefaultFOV;
if(ResetStatics){ if(ResetStatics){
@ -3717,7 +3716,7 @@ CCam::Process_Debug(const CVector&, float, float, float)
static float PanSpeedY = 0.0f; static float PanSpeedY = 0.0f;
CVector TargetCoors; CVector TargetCoors;
RwCameraSetNearClipPlane(Scene.camera, 0.9f); RwCameraSetNearClipPlane(Scene.camera, DEFAULT_NEAR);
FOV = DefaultFOV; FOV = DefaultFOV;
Alpha += DEGTORAD(CPad::GetPad(1)->GetLeftStickY()) / 50.0f; Alpha += DEGTORAD(CPad::GetPad(1)->GetLeftStickY()) / 50.0f;
Beta += DEGTORAD(CPad::GetPad(1)->GetLeftStickX())*1.5f / 19.0f; Beta += DEGTORAD(CPad::GetPad(1)->GetLeftStickX())*1.5f / 19.0f;
@ -3814,7 +3813,7 @@ CCam::Process_Debug(const CVector&, float, float, float)
static float Speed = 0.0f; static float Speed = 0.0f;
CVector TargetCoors; CVector TargetCoors;
RwCameraSetNearClipPlane(Scene.camera, 0.9f); RwCameraSetNearClipPlane(Scene.camera, DEFAULT_NEAR);
FOV = DefaultFOV; FOV = DefaultFOV;
Alpha += DEGTORAD(CPad::GetPad(1)->GetLeftStickY()) / 50.0f; Alpha += DEGTORAD(CPad::GetPad(1)->GetLeftStickY()) / 50.0f;
Beta += DEGTORAD(CPad::GetPad(1)->GetLeftStickX())*1.5f / 19.0f; Beta += DEGTORAD(CPad::GetPad(1)->GetLeftStickX())*1.5f / 19.0f;
@ -3887,7 +3886,7 @@ CCam::Process_Editor(const CVector&, float, float, float)
} }
ResetStatics = false; ResetStatics = false;
RwCameraSetNearClipPlane(Scene.camera, 0.9f); RwCameraSetNearClipPlane(Scene.camera, DEFAULT_NEAR);
FOV = DefaultFOV; FOV = DefaultFOV;
Alpha += DEGTORAD(CPad::GetPad(1)->GetLeftStickY()) / 50.0f; Alpha += DEGTORAD(CPad::GetPad(1)->GetLeftStickY()) / 50.0f;
Beta += DEGTORAD(CPad::GetPad(1)->GetLeftStickX())*1.5f / 19.0f; Beta += DEGTORAD(CPad::GetPad(1)->GetLeftStickX())*1.5f / 19.0f;
@ -4465,11 +4464,14 @@ CCam::Process_FollowPed_Rotation(const CVector &CameraTarget, float TargetOrient
float MouseX = CPad::GetPad(0)->GetMouseX(); float MouseX = CPad::GetPad(0)->GetMouseX();
float MouseY = CPad::GetPad(0)->GetMouseY(); float MouseY = CPad::GetPad(0)->GetMouseY();
float LookLeftRight, LookUpDown; float LookLeftRight, LookUpDown;
if(bFreeMouseCam && (MouseX != 0.0f || MouseY != 0.0f) && !CPad::GetPad(0)->ArePlayerControlsDisabled()){ /*
if((MouseX != 0.0f || MouseY != 0.0f) && !CPad::GetPad(0)->ArePlayerControlsDisabled()){
UseMouse = true; UseMouse = true;
LookLeftRight = -2.5f*MouseX; LookLeftRight = -2.5f*MouseX;
LookUpDown = 4.0f*MouseY; LookUpDown = 4.0f*MouseY;
}else{ }else
*/
{
LookLeftRight = -CPad::GetPad(0)->LookAroundLeftRight(); LookLeftRight = -CPad::GetPad(0)->LookAroundLeftRight();
LookUpDown = CPad::GetPad(0)->LookAroundUpDown(); LookUpDown = CPad::GetPad(0)->LookAroundUpDown();
} }
@ -4553,14 +4555,14 @@ CCam::Process_FollowPed_Rotation(const CVector &CameraTarget, float TargetOrient
if(CWorld::ProcessLineOfSight(colPoint.point, Source, colPoint, entity, true, true, true, true, false, false, true)){ if(CWorld::ProcessLineOfSight(colPoint.point, Source, colPoint, entity, true, true, true, true, false, false, true)){
PedColDist = (TargetCoors - colPoint.point).Magnitude(); PedColDist = (TargetCoors - colPoint.point).Magnitude();
Source = colPoint.point; Source = colPoint.point;
if(PedColDist < 0.9f + 0.3f) if(PedColDist < DEFAULT_NEAR + 0.3f)
RwCameraSetNearClipPlane(Scene.camera, max(PedColDist-0.3f, 0.05f)); RwCameraSetNearClipPlane(Scene.camera, max(PedColDist-0.3f, 0.05f));
}else{ }else{
RwCameraSetNearClipPlane(Scene.camera, min(ColCamDist-0.35f, 0.9f)); RwCameraSetNearClipPlane(Scene.camera, min(ColCamDist-0.35f, DEFAULT_NEAR));
} }
}else{ }else{
Source = colPoint.point; Source = colPoint.point;
if(PedColDist < 0.9f + 0.3f) if(PedColDist < DEFAULT_NEAR + 0.3f)
RwCameraSetNearClipPlane(Scene.camera, max(PedColDist-0.3f, 0.05f)); RwCameraSetNearClipPlane(Scene.camera, max(PedColDist-0.3f, 0.05f));
} }
} }
@ -4922,7 +4924,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
bool mouseChangesBeta = false; bool mouseChangesBeta = false;
// FIX: Disable mouse movement in drive-by, it's buggy. Original SA bug. // FIX: Disable mouse movement in drive-by, it's buggy. Original SA bug.
if (bFreeMouseCam && CCamera::m_bUseMouse3rdPerson && !pad->ArePlayerControlsDisabled() && nextDirectionIsForward) { if (/*bFreeMouseCam &&*/ CCamera::m_bUseMouse3rdPerson && !pad->ArePlayerControlsDisabled() && nextDirectionIsForward) {
float mouseY = pad->GetMouseY() * 2.0f; float mouseY = pad->GetMouseY() * 2.0f;
float mouseX = pad->GetMouseX() * -2.0f; float mouseX = pad->GetMouseX() * -2.0f;
@ -5093,10 +5095,10 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
} else { } else {
if (!CWorld::ProcessLineOfSight(foundCol.point, Source, foundCol, foundEnt, true, dontCollideWithCars < 0.1f, false, true, false, true, false)) { if (!CWorld::ProcessLineOfSight(foundCol.point, Source, foundCol, foundEnt, true, dontCollideWithCars < 0.1f, false, true, false, true, false)) {
float lessClip = obstacleCamDist - 0.35f; float lessClip = obstacleCamDist - 0.35f;
if (lessClip <= 0.9f) if (lessClip <= DEFAULT_NEAR)
RwCameraSetNearClipPlane(Scene.camera, lessClip); RwCameraSetNearClipPlane(Scene.camera, lessClip);
else else
RwCameraSetNearClipPlane(Scene.camera, 0.9f); RwCameraSetNearClipPlane(Scene.camera, DEFAULT_NEAR);
} else { } else {
obstacleTargetDist = (TargetCoors - foundCol.point).Magnitude(); obstacleTargetDist = (TargetCoors - foundCol.point).Magnitude();
Source = foundCol.point; Source = foundCol.point;
@ -5238,9 +5240,6 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
#endif #endif
STARTPATCHES STARTPATCHES
#ifdef FREE_CAM
Nop(0x468E7B, 0x468E90-0x468E7B); // disable first person
#endif
InjectHook(0x456F40, WellBufferMe, PATCH_JUMP); InjectHook(0x456F40, WellBufferMe, PATCH_JUMP);
InjectHook(0x458410, &CCam::Init, PATCH_JUMP); InjectHook(0x458410, &CCam::Init, PATCH_JUMP);
InjectHook(0x4582F0, &CCam::GetVectorsReadyForRW, PATCH_JUMP); InjectHook(0x4582F0, &CCam::GetVectorsReadyForRW, PATCH_JUMP);
@ -5290,6 +5289,4 @@ STARTPATCHES
InjectHook(0x456CE0, &FindSplinePathPositionFloat, PATCH_JUMP); InjectHook(0x456CE0, &FindSplinePathPositionFloat, PATCH_JUMP);
InjectHook(0x4569A0, &FindSplinePathPositionVector, PATCH_JUMP); InjectHook(0x4569A0, &FindSplinePathPositionVector, PATCH_JUMP);
InjectHook(0x473250, &CCamera::dtor, PATCH_JUMP);
ENDPATCHES ENDPATCHES

File diff suppressed because it is too large Load Diff

View File

@ -4,13 +4,28 @@
class CEntity; class CEntity;
class CPed; class CPed;
class CAutomobile; class CAutomobile;
class CGarage;
extern int16 &DebugCamMode; extern int16 &DebugCamMode;
#define NUMBER_OF_VECTORS_FOR_AVERAGE 2 enum
struct CCam
{ {
NUMBER_OF_VECTORS_FOR_AVERAGE = 2,
MAX_NUM_OF_SPLINETYPES = 4,
MAX_NUM_OF_NODES = 800 // for trains
};
#define DEFAULT_NEAR (0.9f)
#define CAM_ZOOM_1STPRS (0.0f)
#define CAM_ZOOM_1 (1.0f)
#define CAM_ZOOM_2 (2.0f)
#define CAM_ZOOM_3 (3.0f)
#define CAM_ZOOM_TOPDOWN (4.0f)
#define CAM_ZOOM_CINEMATIC (5.0f)
class CCam
{
public:
enum enum
{ {
MODE_NONE = 0, MODE_NONE = 0,
@ -230,9 +245,12 @@ static_assert(sizeof(CCam) == 0x1A4, "CCam: wrong size");
static_assert(offsetof(CCam, Alpha) == 0xA8, "CCam: error"); static_assert(offsetof(CCam, Alpha) == 0xA8, "CCam: error");
static_assert(offsetof(CCam, Front) == 0x140, "CCam: error"); static_assert(offsetof(CCam, Front) == 0x140, "CCam: error");
struct CCamPathSplines class CCamPathSplines
{ {
float m_arr_PathData[800]; public:
enum {MAXPATHLENGTH=800};
float m_arr_PathData[MAXPATHLENGTH];
CCamPathSplines(void);
}; };
struct CTrainCamNode struct CTrainCamNode
@ -296,13 +314,14 @@ enum
enum enum
{ {
CAM_CONTROLLER_0, CAMCONTROL_GAME,
CAM_CONTROLLER_1, CAMCONTROL_SCRIPT,
CAM_CONTROLLER_2 CAMCONTROL_OBBE
}; };
struct CCamera : public CPlaceable class CCamera : public CPlaceable
{ {
public:
bool m_bAboveGroundTrainNodesLoaded; bool m_bAboveGroundTrainNodesLoaded;
bool m_bBelowGroundTrainNodesLoaded; bool m_bBelowGroundTrainNodesLoaded;
bool m_bCamDirectlyBehind; bool m_bCamDirectlyBehind;
@ -344,16 +363,12 @@ struct CCamera : public CPlaceable
bool m_bHeadBob; bool m_bHeadBob;
bool m_bFailedCullZoneTestPreviously; bool m_bFailedCullZoneTestPreviously;
bool m_FadeTargetIsSplashScreen; bool m_FadeTargetIsSplashScreen;
bool WorldViewerBeingUsed; bool WorldViewerBeingUsed;
uint8 ActiveCam; uint8 ActiveCam;
uint32 m_uiCamShakeStart; uint32 m_uiCamShakeStart;
uint32 m_uiFirstPersonCamLastInputTime; uint32 m_uiFirstPersonCamLastInputTime;
// where are those?
//bool m_bVehicleSuspenHigh;
//bool m_bEnable1rstPersonCamCntrlsScript;
//bool m_bAllow1rstPersonWeaponsCamera;
uint32 m_uiLongestTimeInMill; uint32 m_uiLongestTimeInMill;
uint32 m_uiNumberOfTrainCamNodes; uint32 m_uiNumberOfTrainCamNodes;
@ -369,7 +384,7 @@ bool m_FadeTargetIsSplashScreen;
int m_BlurRed; int m_BlurRed;
int m_BlurType; int m_BlurType;
uint32 unknown; uint32 unknown; // some counter having to do with music
int m_iWorkOutSpeedThisNumFrames; int m_iWorkOutSpeedThisNumFrames;
int m_iNumFramesSoFar; int m_iNumFramesSoFar;
@ -435,8 +450,8 @@ uint32 unknown;
CCam Cams[3]; CCam Cams[3];
void *pToGarageWeAreIn; CGarage *pToGarageWeAreIn;
void *pToGarageWeAreInForHackAvoidFirstPerson; CGarage *pToGarageWeAreInForHackAvoidFirstPerson;
CQueuedMode m_PlayerMode; CQueuedMode m_PlayerMode;
CQueuedMode PlayerWeaponMode; CQueuedMode PlayerWeaponMode;
CVector m_PreviousCameraPosition; CVector m_PreviousCameraPosition;
@ -447,7 +462,6 @@ uint32 unknown;
CVector m_vecFixedModeUpOffSet; CVector m_vecFixedModeUpOffSet;
CVector m_vecCutSceneOffset; CVector m_vecCutSceneOffset;
// one of those has to go
CVector m_cvecStartingSourceForInterPol; CVector m_cvecStartingSourceForInterPol;
CVector m_cvecStartingTargetForInterPol; CVector m_cvecStartingTargetForInterPol;
CVector m_cvecStartingUpForInterPol; CVector m_cvecStartingUpForInterPol;
@ -457,7 +471,6 @@ uint32 unknown;
CVector m_vecSourceWhenInterPol; CVector m_vecSourceWhenInterPol;
CVector m_vecTargetWhenInterPol; CVector m_vecTargetWhenInterPol;
CVector m_vecUpWhenInterPol; CVector m_vecUpWhenInterPol;
//CVector m_vecClearGeometryVec;
CVector m_vecGameCamPos; CVector m_vecGameCamPos;
CVector SourceDuringInter; CVector SourceDuringInter;
@ -465,8 +478,8 @@ uint32 unknown;
CVector UpDuringInter; CVector UpDuringInter;
RwCamera *m_pRwCamera; RwCamera *m_pRwCamera;
CEntity *pTargetEntity; CEntity *pTargetEntity;
CCamPathSplines m_arrPathArray[4]; CCamPathSplines m_arrPathArray[MAX_NUM_OF_SPLINETYPES];
CTrainCamNode m_arrTrainCamNode[800]; CTrainCamNode m_arrTrainCamNode[MAX_NUM_OF_NODES];
CMatrix m_cameraMatrix; CMatrix m_cameraMatrix;
bool m_bGarageFixedCamPositionSet; bool m_bGarageFixedCamPositionSet;
bool m_vecDoingSpecialInterPolation; bool m_vecDoingSpecialInterPolation;
@ -490,7 +503,7 @@ uint32 unknown;
float m_fScriptPercentageInterToStopMoving; float m_fScriptPercentageInterToStopMoving;
float m_fScriptPercentageInterToCatchUp; float m_fScriptPercentageInterToCatchUp;
uint32 m_fScriptTimeForInterPolation; uint32 m_fScriptTimeForInterPolation;
int16 m_iFadingDirection; int16 m_iFadingDirection;
@ -503,68 +516,97 @@ uint32 m_fScriptTimeForInterPolation;
uint32 m_uiFadeTimeStartedMusic; uint32 m_uiFadeTimeStartedMusic;
static bool &m_bUseMouse3rdPerson; static bool &m_bUseMouse3rdPerson;
#ifdef FREE_CAM
static bool bFreeCam;
#endif
// High level and misc
void Init(void);
void Process(void);
void CamControl(void);
void UpdateTargetEntity(void);
void UpdateSoundDistances(void);
void InitialiseCameraForDebugMode(void);
void CamShake(float strength, float x, float y, float z);
bool Get_Just_Switched_Status() { return m_bJust_Switched; } bool Get_Just_Switched_Status() { return m_bJust_Switched; }
inline const CMatrix& GetCameraMatrix(void) { return m_cameraMatrix; }
CVector &GetGameCamPosition(void) { return m_vecGameCamPos; } // Who's in control
void TakeControl(CEntity *target, int16 mode, int16 typeOfSwitch, int32 controller);
void TakeControlNoEntity(const CVector &position, int16 typeOfSwitch, int32 controller);
void TakeControlWithSpline(int16 typeOfSwitch);
void Restore(void);
void RestoreWithJumpCut(void);
void SetCamPositionForFixedMode(const CVector &Source, const CVector &UppOffSet);
// Transition
void StartTransition(int16 mode);
void StartTransitionWhenNotFinishedInter(int16 mode);
void StoreValuesDuringInterPol(CVector &source, CVector &target, CVector &up, float &FOV);
// Widescreen borders
void SetWideScreenOn(void);
void SetWideScreenOff(void);
void ProcessWideScreenOn(void);
void DrawBordersForWideScreen(void);
// Obbe's cam
bool IsItTimeForNewcam(int32 obbeMode, int32 time);
bool TryToStartNewCamMode(int32 obbeMode);
void DontProcessObbeCinemaCamera(void);
void ProcessObbeCinemaCameraCar(void);
void ProcessObbeCinemaCameraPed(void);
// Train
void LoadTrainCamNodes(char const *name);
void Process_Train_Camera_Control(void);
// Script
void LoadPathSplines(int file);
void FinishCutscene(void);
float GetPositionAlongSpline(void) { return m_fPositionAlongSpline; } float GetPositionAlongSpline(void) { return m_fPositionAlongSpline; }
uint32 GetCutSceneFinishTime(void);
void SetCamCutSceneOffSet(const CVector &pos);
void SetPercentAlongCutScene(float percent);
void SetParametersForScriptInterpolation(float stopMoving, float catchUp, int32 time);
void SetZoomValueFollowPedScript(int16 dist);
void SetZoomValueCamStringScript(int16 dist);
void SetNearClipScript(float);
// Fading
void ProcessFade(void);
void ProcessMusicFade(void);
void Fade(float timeout, int16 direction);
void SetFadeColour(uint8 r, uint8 g, uint8 b);
bool GetFading(void);
int GetFadingDirection(void);
int GetScreenFadeStatus(void);
// Motion blur
void RenderMotionBlur(void);
void SetMotionBlur(int r, int g, int b, int a, int type);
void SetMotionBlurAlpha(int a);
// Player looking and aiming
int GetLookDirection(void);
bool GetLookingForwardFirstPerson(void);
bool GetLookingLRBFirstPerson(void);
void SetCameraDirectlyInFrontForFollowPed_CamOnAString(void);
void SetCameraDirectlyBehindForFollowPed_CamOnAString(void);
void SetNewPlayerWeaponMode(int16 mode, int16 minZoom, int16 maxZoom);
void ClearPlayerWeaponMode(void);
void UpdateAimingCoors(CVector const &coors);
void Find3rdPersonCamTargetVector(float dist, CVector pos, CVector &source, CVector &target);
float Find3rdPersonQuickAimPitch(void);
// Physical camera
void SetRwCamera(RwCamera *cam);
const CMatrix& GetCameraMatrix(void) { return m_cameraMatrix; }
CVector &GetGameCamPosition(void) { return m_vecGameCamPos; }
void CalculateDerivedValues(void);
bool IsPointVisible(const CVector &center, const CMatrix *mat); bool IsPointVisible(const CVector &center, const CMatrix *mat);
bool IsSphereVisible(const CVector &center, float radius, const CMatrix *mat); bool IsSphereVisible(const CVector &center, float radius, const CMatrix *mat);
bool IsSphereVisible(const CVector &center, float radius); bool IsSphereVisible(const CVector &center, float radius);
bool IsBoxVisible(RwV3d *box, const CMatrix *mat); bool IsBoxVisible(RwV3d *box, const CMatrix *mat);
int GetLookDirection(void);
bool GetLookingForwardFirstPerson(void);
void Fade(float timeout, int16 direction);
int GetScreenFadeStatus(void);
void ProcessFade(void);
void ProcessMusicFade(void);
void SetFadeColour(uint8 r, uint8 g, uint8 b);
void CamShake(float strength, float x, float y, float z);
void SetMotionBlur(int r, int g, int b, int a, int type);
void SetMotionBlurAlpha(int a);
void RenderMotionBlur(void);
void ClearPlayerWeaponMode();
void CalculateDerivedValues(void);
void DrawBordersForWideScreen(void);
void Restore(void);
void SetWideScreenOn(void);
void SetWideScreenOff(void);
void SetNearClipScript(float);
float Find3rdPersonQuickAimPitch(void);
void TakeControl(CEntity*, int16, int16, int32);
void TakeControlNoEntity(const CVector&, int16, int32);
void SetCamPositionForFixedMode(const CVector&, const CVector&);
bool GetFading();
int GetFadingDirection();
void Init();
void SetRwCamera(RwCamera*);
void Process();
void LoadPathSplines(int file);
uint32 GetCutSceneFinishTime(void);
void FinishCutscene(void);
void SetCamCutSceneOffSet(const CVector&);
void TakeControlWithSpline(short);
void RestoreWithJumpCut(void);
void SetCameraDirectlyInFrontForFollowPed_CamOnAString(void);
void SetCameraDirectlyBehindForFollowPed_CamOnAString(void);
void SetZoomValueFollowPedScript(int16);
void SetZoomValueCamStringScript(int16);
void SetNewPlayerWeaponMode(int16, int16, int16);
void UpdateAimingCoors(CVector const &);
void SetPercentAlongCutScene(float);
void SetParametersForScriptInterpolation(float, float, int32);
void dtor(void) { this->CCamera::~CCamera(); }
}; };
static_assert(offsetof(CCamera, DistanceToWater) == 0xe4, "CCamera: error"); static_assert(offsetof(CCamera, DistanceToWater) == 0xe4, "CCamera: error");
static_assert(offsetof(CCamera, m_WideScreenOn) == 0x70, "CCamera: error"); static_assert(offsetof(CCamera, m_WideScreenOn) == 0x70, "CCamera: error");
@ -583,3 +625,5 @@ static_assert(sizeof(CCamera) == 0xE9D8, "CCamera: wrong size");
extern CCamera &TheCamera; extern CCamera &TheCamera;
void CamShakeNoPos(CCamera*, float); void CamShakeNoPos(CCamera*, float);
void MakeAngleLessThan180(float &Angle);
void WellBufferMe(float Target, float *CurrentValue, float *CurrentSpeed, float MaxSpeed, float Acceleration, bool IsAngle);

View File

@ -29,6 +29,7 @@ public:
static void SetRunning(bool running) { ms_running = running; } static void SetRunning(bool running) { ms_running = running; }
static bool IsRunning(void) { return ms_running; } static bool IsRunning(void) { return ms_running; }
static bool IsCutsceneProcessing(void) { return ms_cutsceneProcessing; } static bool IsCutsceneProcessing(void) { return ms_cutsceneProcessing; }
static bool UseLodMultiplier(void) { return ms_useLodMultiplier; }
static CCutsceneObject* GetCutsceneObject(int id) { return ms_pCutsceneObjects[id]; } static CCutsceneObject* GetCutsceneObject(int id) { return ms_pCutsceneObjects[id]; }
static int GetCutsceneTimeInMilleseconds(void) { return 1000.0f * ms_cutsceneTimer; } static int GetCutsceneTimeInMilleseconds(void) { return 1000.0f * ms_cutsceneTimer; }
static char *GetCutsceneName(void) { return ms_cutsceneName; } static char *GetCutsceneName(void) { return ms_cutsceneName; }

View File

@ -529,7 +529,7 @@ WRAPPER void CMenuManager::DoSettingsBeforeStartingAGame() { EAXJMP(0x48AB40); }
#else #else
void CMenuManager::DoSettingsBeforeStartingAGame() void CMenuManager::DoSettingsBeforeStartingAGame()
{ {
CCamera::m_bUseMouse3rdPerson = m_ControlMethod == CONTROL_STANDART; CCamera::m_bUseMouse3rdPerson = m_ControlMethod == CONTROL_STANDARD;
if (m_PrefsVsyncDisp != m_PrefsVsync) if (m_PrefsVsyncDisp != m_PrefsVsync)
m_PrefsVsync = m_PrefsVsyncDisp; m_PrefsVsync = m_PrefsVsyncDisp;
@ -2069,7 +2069,7 @@ void CMenuManager::Process(void)
} }
if (m_nCurrScreen == MENUPAGE_LOADING_IN_PROGRESS) { if (m_nCurrScreen == MENUPAGE_LOADING_IN_PROGRESS) {
if (CheckSlotDataValid(m_nCurrSaveSlot)) { if (CheckSlotDataValid(m_nCurrSaveSlot)) {
TheCamera.m_bUseMouse3rdPerson = m_ControlMethod == CONTROL_STANDART; TheCamera.m_bUseMouse3rdPerson = m_ControlMethod == CONTROL_STANDARD;
if (m_PrefsVsyncDisp != m_PrefsVsync) if (m_PrefsVsyncDisp != m_PrefsVsync)
m_PrefsVsync = m_PrefsVsyncDisp; m_PrefsVsync = m_PrefsVsyncDisp;
DMAudio.Service(); DMAudio.Service();
@ -3166,7 +3166,7 @@ CMenuManager::ProcessButtonPresses(void)
PSGLOBAL(joy1)->GetCapabilities(&devCaps); PSGLOBAL(joy1)->GetCapabilities(&devCaps);
ControlsManager.InitDefaultControlConfigJoyPad(devCaps.dwButtons); ControlsManager.InitDefaultControlConfigJoyPad(devCaps.dwButtons);
} }
CMenuManager::m_ControlMethod = CONTROL_STANDART; CMenuManager::m_ControlMethod = CONTROL_STANDARD;
MousePointerStateHelper.bInvertVertically = false; MousePointerStateHelper.bInvertVertically = false;
TheCamera.m_fMouseAccelHorzntl = 0.0025f; TheCamera.m_fMouseAccelHorzntl = 0.0025f;
CVehicle::m_bDisableMouseSteering = true; CVehicle::m_bDisableMouseSteering = true;
@ -3179,7 +3179,7 @@ CMenuManager::ProcessButtonPresses(void)
#ifndef TIDY_UP_PBP #ifndef TIDY_UP_PBP
if (CMenuManager::m_ControlMethod == CONTROL_CLASSIC) { if (CMenuManager::m_ControlMethod == CONTROL_CLASSIC) {
CCamera::m_bUseMouse3rdPerson = true; CCamera::m_bUseMouse3rdPerson = true;
CMenuManager::m_ControlMethod = CONTROL_STANDART; CMenuManager::m_ControlMethod = CONTROL_STANDARD;
} else { } else {
CCamera::m_bUseMouse3rdPerson = false; CCamera::m_bUseMouse3rdPerson = false;
CMenuManager::m_ControlMethod = CONTROL_CLASSIC; CMenuManager::m_ControlMethod = CONTROL_CLASSIC;

View File

@ -363,7 +363,7 @@ enum
enum eControlMethod enum eControlMethod
{ {
CONTROL_STANDART = 0, CONTROL_STANDARD = 0,
CONTROL_CLASSIC, CONTROL_CLASSIC,
}; };

View File

@ -2,7 +2,7 @@
enum { enum {
PLAYERCONTROL_ENABLED = 0, PLAYERCONTROL_ENABLED = 0,
PLAYERCONTROL_DISABLED_1 = 1, PLAYERCONTROL_DISABLED_1 = 1, // used by first person camera
PLAYERCONTROL_DISABLED_2 = 2, PLAYERCONTROL_DISABLED_2 = 2,
PLAYERCONTROL_GARAGE = 4, PLAYERCONTROL_GARAGE = 4,
PLAYERCONTROL_DISABLED_8 = 8, PLAYERCONTROL_DISABLED_8 = 8,

View File

@ -215,4 +215,4 @@ enum Config {
// Camera // Camera
#define IMPROVED_CAMERA // Better Debug cam, and maybe more in the future #define IMPROVED_CAMERA // Better Debug cam, and maybe more in the future
//#define FREE_CAM // Rotating cam #define FREE_CAM // Rotating cam

View File

@ -372,11 +372,9 @@ DebugMenuPopulate(void)
extern bool PrintDebugCode; extern bool PrintDebugCode;
extern int16 &DebugCamMode; extern int16 &DebugCamMode;
DebugMenuAddVarBool8("Cam", "Use mouse Cam", (int8*)&CCamera::m_bUseMouse3rdPerson, nil);
#ifdef FREE_CAM #ifdef FREE_CAM
extern bool bFreePadCam; DebugMenuAddVarBool8("Cam", "Free Cam", (int8*)&CCamera::bFreeCam, nil);
extern bool bFreeMouseCam;
DebugMenuAddVarBool8("Cam", "Free Gamepad Cam", (int8*)&bFreePadCam, nil);
DebugMenuAddVarBool8("Cam", "Free Mouse Cam", (int8*)&bFreeMouseCam, nil);
#endif #endif
DebugMenuAddVarBool8("Cam", "Print Debug Code", (int8*)&PrintDebugCode, nil); DebugMenuAddVarBool8("Cam", "Print Debug Code", (int8*)&PrintDebugCode, nil);
DebugMenuAddVar("Cam", "Cam Mode", &DebugCamMode, nil, 1, 0, CCam::MODE_EDITOR, nil); DebugMenuAddVar("Cam", "Cam Mode", &DebugCamMode, nil, 1, 0, CCam::MODE_EDITOR, nil);

View File

@ -59,10 +59,6 @@
#define CAN_SEE_ENTITY_ANGLE_THRESHOLD DEGTORAD(60.0f) #define CAN_SEE_ENTITY_ANGLE_THRESHOLD DEGTORAD(60.0f)
#ifdef FREE_CAM
extern bool bFreeMouseCam;
#endif
CPed *gapTempPedList[50]; CPed *gapTempPedList[50];
uint16 gnNumTempPedList; uint16 gnNumTempPedList;
@ -812,7 +808,7 @@ bool
CPed::CanStrafeOrMouseControl(void) CPed::CanStrafeOrMouseControl(void)
{ {
#ifdef FREE_CAM #ifdef FREE_CAM
if (bFreeMouseCam) if (CCamera::bFreeCam)
return false; return false;
#endif #endif
return m_nPedState == PED_NONE || m_nPedState == PED_IDLE || m_nPedState == PED_FLEE_POS || m_nPedState == PED_FLEE_ENTITY || return m_nPedState == PED_NONE || m_nPedState == PED_IDLE || m_nPedState == PED_FLEE_POS || m_nPedState == PED_FLEE_ENTITY ||
@ -6993,7 +6989,7 @@ CPed::FinishLaunchCB(CAnimBlendAssociation *animAssoc, void *arg)
) { ) {
#ifdef FREE_CAM #ifdef FREE_CAM
if (TheCamera.Cams[0].Using3rdPersonMouseCam() && !bFreeMouseCam) { if (TheCamera.Cams[0].Using3rdPersonMouseCam() && !CCamera::bFreeCam) {
#else #else
if (TheCamera.Cams[0].Using3rdPersonMouseCam()) { if (TheCamera.Cams[0].Using3rdPersonMouseCam()) {
#endif #endif

View File

@ -18,10 +18,6 @@
#define PAD_MOVE_TO_GAME_WORLD_MOVE 60.0f #define PAD_MOVE_TO_GAME_WORLD_MOVE 60.0f
#ifdef FREE_CAM
extern bool bFreeMouseCam;
#endif
CPlayerPed::~CPlayerPed() CPlayerPed::~CPlayerPed()
{ {
delete m_pWanted; delete m_pWanted;
@ -693,7 +689,7 @@ CPlayerPed::PlayerControl1stPersonRunAround(CPad *padUsed)
float padMoveInGameUnit = padMove / PAD_MOVE_TO_GAME_WORLD_MOVE; float padMoveInGameUnit = padMove / PAD_MOVE_TO_GAME_WORLD_MOVE;
if (padMoveInGameUnit > 0.0f) { if (padMoveInGameUnit > 0.0f) {
#ifdef FREE_CAM #ifdef FREE_CAM
if (!bFreeMouseCam) if (!CCamera::bFreeCam)
m_fRotationDest = CGeneral::LimitRadianAngle(TheCamera.Orientation); m_fRotationDest = CGeneral::LimitRadianAngle(TheCamera.Orientation);
else else
m_fRotationDest = CGeneral::GetRadianAngleBetweenPoints(0.0f, 0.0f, -leftRight, upDown) - TheCamera.Orientation; m_fRotationDest = CGeneral::GetRadianAngleBetweenPoints(0.0f, 0.0f, -leftRight, upDown) - TheCamera.Orientation;
@ -993,7 +989,7 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed)
SetStoredState(); SetStoredState();
m_nPedState = PED_SNIPER_MODE; m_nPedState = PED_SNIPER_MODE;
#ifdef FREE_CAM #ifdef FREE_CAM
if (bFreeMouseCam && TheCamera.Cams[0].Using3rdPersonMouseCam()) { if (CCamera::bFreeCam && TheCamera.Cams[0].Using3rdPersonMouseCam()) {
m_fRotationCur = CGeneral::LimitRadianAngle(-TheCamera.Orientation); m_fRotationCur = CGeneral::LimitRadianAngle(-TheCamera.Orientation);
SetHeading(m_fRotationCur); SetHeading(m_fRotationCur);
} }
@ -1018,7 +1014,7 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed)
if (m_nSelectedWepSlot == m_currentWeapon) { if (m_nSelectedWepSlot == m_currentWeapon) {
if (m_pPointGunAt) { if (m_pPointGunAt) {
#ifdef FREE_CAM #ifdef FREE_CAM
if (bFreeMouseCam && weaponInfo->m_eWeaponFire == WEAPON_FIRE_MELEE && m_fMoveSpeed < 1.0f) if (CCamera::bFreeCam && weaponInfo->m_eWeaponFire == WEAPON_FIRE_MELEE && m_fMoveSpeed < 1.0f)
StartFightAttack(padUsed->GetWeapon()); StartFightAttack(padUsed->GetWeapon());
else else
#endif #endif
@ -1052,7 +1048,7 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed)
#ifdef FREE_CAM #ifdef FREE_CAM
// Rotate player/arm when shooting. We don't have auto-rotation anymore // Rotate player/arm when shooting. We don't have auto-rotation anymore
if (CCamera::m_bUseMouse3rdPerson && bFreeMouseCam && if (CCamera::m_bUseMouse3rdPerson && CCamera::bFreeCam &&
m_nSelectedWepSlot == m_currentWeapon && m_nMoveState != PEDMOVE_SPRINT) { m_nSelectedWepSlot == m_currentWeapon && m_nMoveState != PEDMOVE_SPRINT) {
// Weapons except throwable and melee ones // Weapons except throwable and melee ones
@ -1103,7 +1099,7 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed)
// what?? // what??
if (!m_pPointGunAt if (!m_pPointGunAt
#ifdef FREE_CAM #ifdef FREE_CAM
|| (!bFreeMouseCam && CCamera::m_bUseMouse3rdPerson) || (!CCamera::bFreeCam && CCamera::m_bUseMouse3rdPerson)
#else #else
|| CCamera::m_bUseMouse3rdPerson || CCamera::m_bUseMouse3rdPerson
#endif #endif
@ -1125,7 +1121,7 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed)
TheCamera.UpdateAimingCoors(m_pPointGunAt->GetPosition()); TheCamera.UpdateAimingCoors(m_pPointGunAt->GetPosition());
} }
#ifdef FREE_CAM #ifdef FREE_CAM
else if ((bFreeMouseCam && weaponInfo->m_eWeaponFire == WEAPON_FIRE_MELEE) || (weaponInfo->m_bCanAim && !CCamera::m_bUseMouse3rdPerson)) { else if ((CCamera::bFreeCam && weaponInfo->m_eWeaponFire == WEAPON_FIRE_MELEE) || (weaponInfo->m_bCanAim && !CCamera::m_bUseMouse3rdPerson)) {
#else #else
else if (weaponInfo->m_bCanAim && !CCamera::m_bUseMouse3rdPerson) { else if (weaponInfo->m_bCanAim && !CCamera::m_bUseMouse3rdPerson) {
#endif #endif

View File

@ -2340,8 +2340,7 @@ CAutomobile::FireTruckControl(void)
if(!CPad::GetPad(0)->GetWeapon()) if(!CPad::GetPad(0)->GetWeapon())
return; return;
#ifdef FREE_CAM #ifdef FREE_CAM
extern bool bFreeMouseCam; if (!CCamera::bFreeCam)
if (!bFreeMouseCam)
#endif #endif
{ {
m_fCarGunLR += CPad::GetPad(0)->GetCarGunLeftRight() * 0.00025f * CTimer::GetTimeStep(); m_fCarGunLR += CPad::GetPad(0)->GetCarGunLeftRight() * 0.00025f * CTimer::GetTimeStep();
@ -2416,8 +2415,7 @@ CAutomobile::TankControl(void)
// Rotate turret // Rotate turret
float prevAngle = m_fCarGunLR; float prevAngle = m_fCarGunLR;
#ifdef FREE_CAM #ifdef FREE_CAM
extern bool bFreeMouseCam; if(!CCamera::bFreeCam)
if(!bFreeMouseCam)
#endif #endif
m_fCarGunLR -= CPad::GetPad(0)->GetCarGunLeftRight() * 0.00015f * CTimer::GetTimeStep(); m_fCarGunLR -= CPad::GetPad(0)->GetCarGunLeftRight() * 0.00015f * CTimer::GetTimeStep();