mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-18 07:49:19 +02:00
Merge branch 'tmj-dev' into milek-dev
This commit is contained in:
42
Camera.cpp
42
Camera.cpp
@@ -27,7 +27,7 @@ void TCamera::Init( Math3D::vector3 NPos, Math3D::vector3 NAngle) {
|
||||
Roll = NAngle.z;
|
||||
Pos = NPos;
|
||||
|
||||
Type = (Global.bFreeFly ? tp_Free : tp_Follow);
|
||||
Type = (Global.bFreeFly ? TCameraType::tp_Free : TCameraType::tp_Follow);
|
||||
};
|
||||
|
||||
void TCamera::Reset() {
|
||||
@@ -67,8 +67,8 @@ TCamera::OnCommand( command_data const &Command ) {
|
||||
case user_command::viewturn: {
|
||||
|
||||
OnCursorMove(
|
||||
reinterpret_cast<double const &>( Command.param1 ) * 0.005 * Global.fMouseXScale / Global.ZoomFactor,
|
||||
reinterpret_cast<double const &>( Command.param2 ) * 0.01 * Global.fMouseYScale / Global.ZoomFactor );
|
||||
Command.param1 * 0.005 * Global.fMouseXScale / Global.ZoomFactor,
|
||||
Command.param2 * 0.01 * Global.fMouseYScale / Global.ZoomFactor );
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -76,17 +76,17 @@ TCamera::OnCommand( command_data const &Command ) {
|
||||
case user_command::movehorizontalfast: {
|
||||
|
||||
auto const movespeed = (
|
||||
Type == tp_Free ? runspeed :
|
||||
Type == tp_Follow ? walkspeed :
|
||||
Type == TCameraType::tp_Free ? runspeed :
|
||||
Type == TCameraType::tp_Follow ? walkspeed :
|
||||
0.0 );
|
||||
|
||||
auto const speedmultiplier = (
|
||||
( ( Type == tp_Free ) && ( Command.command == user_command::movehorizontalfast ) ) ?
|
||||
( ( Type == TCameraType::tp_Free ) && ( Command.command == user_command::movehorizontalfast ) ) ?
|
||||
30.0 :
|
||||
1.0 );
|
||||
|
||||
// left-right
|
||||
auto const movexparam { reinterpret_cast<double const &>( Command.param1 ) };
|
||||
auto const movexparam { Command.param1 };
|
||||
// 2/3rd of the stick range enables walk speed, past that we lerp between walk and run speed
|
||||
auto const movex { walkspeed + ( std::max( 0.0, std::abs( movexparam ) - 0.65 ) / 0.35 ) * ( movespeed - walkspeed ) };
|
||||
|
||||
@@ -96,7 +96,7 @@ TCamera::OnCommand( command_data const &Command ) {
|
||||
0.0 );
|
||||
|
||||
// forward-back
|
||||
double const movezparam { reinterpret_cast<double const &>( Command.param2 ) };
|
||||
double const movezparam { Command.param2 };
|
||||
auto const movez { walkspeed + ( std::max( 0.0, std::abs( movezparam ) - 0.65 ) / 0.35 ) * ( movespeed - walkspeed ) };
|
||||
// NOTE: z-axis is flipped given world coordinate system
|
||||
m_moverate.z = (
|
||||
@@ -111,17 +111,17 @@ TCamera::OnCommand( command_data const &Command ) {
|
||||
case user_command::moveverticalfast: {
|
||||
|
||||
auto const movespeed = (
|
||||
Type == tp_Free ? runspeed * 0.5 :
|
||||
Type == tp_Follow ? walkspeed :
|
||||
Type == TCameraType::tp_Free ? runspeed * 0.5 :
|
||||
Type == TCameraType::tp_Follow ? walkspeed :
|
||||
0.0 );
|
||||
|
||||
auto const speedmultiplier = (
|
||||
( ( Type == tp_Free ) && ( Command.command == user_command::moveverticalfast ) ) ?
|
||||
( ( Type == TCameraType::tp_Free ) && ( Command.command == user_command::moveverticalfast ) ) ?
|
||||
10.0 :
|
||||
1.0 );
|
||||
|
||||
// up-down
|
||||
auto const moveyparam { reinterpret_cast<double const &>( Command.param1 ) };
|
||||
auto const moveyparam { Command.param1 };
|
||||
// 2/3rd of the stick range enables walk speed, past that we lerp between walk and run speed
|
||||
auto const movey { walkspeed + ( std::max( 0.0, std::abs( moveyparam ) - 0.65 ) / 0.35 ) * ( movespeed - walkspeed ) };
|
||||
|
||||
@@ -145,8 +145,8 @@ TCamera::OnCommand( command_data const &Command ) {
|
||||
|
||||
void TCamera::Update()
|
||||
{
|
||||
if( FreeFlyModeFlag == true ) { Type = tp_Free; }
|
||||
else { Type = tp_Follow; }
|
||||
if( FreeFlyModeFlag == true ) { Type = TCameraType::tp_Free; }
|
||||
else { Type = TCameraType::tp_Follow; }
|
||||
|
||||
// check for sent user commands
|
||||
// NOTE: this is a temporary arrangement, for the transition period from old command setup to the new one
|
||||
@@ -162,7 +162,7 @@ void TCamera::Update()
|
||||
auto const deltatime { Timer::GetDeltaRenderTime() }; // czas bez pauzy
|
||||
|
||||
// update position
|
||||
if( ( Type == tp_Free )
|
||||
if( ( Type == TCameraType::tp_Free )
|
||||
|| ( false == Global.ctrlState )
|
||||
|| ( true == DebugCameraFlag ) ) {
|
||||
// ctrl is used for mirror view, so we ignore the controls when in vehicle if ctrl is pressed
|
||||
@@ -172,7 +172,7 @@ void TCamera::Update()
|
||||
Velocity.y = clamp( Velocity.y + m_moverate.y * 10.0 * deltatime, -std::abs( m_moverate.y ), std::abs( m_moverate.y ) );
|
||||
}
|
||||
|
||||
if( ( Type == tp_Free )
|
||||
if( ( Type == TCameraType::tp_Free )
|
||||
|| ( true == DebugCameraFlag ) ) {
|
||||
// free movement position update is handled here, movement while in vehicle is handled by train update
|
||||
Math3D::vector3 Vec = Velocity;
|
||||
@@ -193,7 +193,7 @@ void TCamera::Update()
|
||||
|
||||
Pitch -= rotationfactor * m_rotationoffsets.x;
|
||||
m_rotationoffsets.x *= ( 1.0 - rotationfactor );
|
||||
if( Type == tp_Follow ) {
|
||||
if( Type == TCameraType::tp_Follow ) {
|
||||
// jeżeli jazda z pojazdem ograniczenie kąta spoglądania w dół i w górę
|
||||
Pitch = clamp( Pitch, -M_PI_4, M_PI_4 );
|
||||
}
|
||||
@@ -211,7 +211,7 @@ bool TCamera::SetMatrix( glm::dmat4 &Matrix ) {
|
||||
Matrix = glm::rotate( Matrix, -Pitch, glm::dvec3( 1.0, 0.0, 0.0 ) );
|
||||
Matrix = glm::rotate( Matrix, -Yaw, glm::dvec3( 0.0, 1.0, 0.0 ) ); // w zewnętrznym widoku: kierunek patrzenia
|
||||
|
||||
if( ( Type == tp_Follow ) && ( false == DebugCameraFlag ) ) {
|
||||
if( ( Type == TCameraType::tp_Follow ) && ( false == DebugCameraFlag ) ) {
|
||||
|
||||
Matrix *= glm::lookAt(
|
||||
glm::dvec3{ Pos },
|
||||
@@ -238,9 +238,3 @@ void TCamera::RaLook()
|
||||
m_rotationoffsets.x = 0.0;
|
||||
}
|
||||
};
|
||||
|
||||
void TCamera::Stop()
|
||||
{ // wyłącznie bezwładnego ruchu po powrocie do kabiny
|
||||
Type = tp_Follow;
|
||||
Velocity = Math3D::vector3(0, 0, 0);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user