Skip to content
This repository was archived by the owner on May 25, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions mp/src/game/client/in_camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ static ConVar cam_command( "cam_command", "0", FCVAR_CHEAT | FCVAR_CHEAT); // t
static ConVar cam_snapto( "cam_snapto", "0", FCVAR_ARCHIVE | FCVAR_CHEAT); // snap to thirdperson view
static ConVar cam_ideallag( "cam_ideallag", "4.0", FCVAR_ARCHIVE| FCVAR_CHEAT, "Amount of lag used when matching offset to ideal angles in thirdperson view" );
static ConVar cam_idealdelta( "cam_idealdelta", "4.0", FCVAR_ARCHIVE| FCVAR_CHEAT, "Controls the speed when matching offset to ideal angles in thirdperson view" );
ConVar cam_idealyaw( "cam_idealyaw", "0", FCVAR_ARCHIVE| FCVAR_CHEAT ); // thirdperson yaw
ConVar cam_idealyaw( "cam_idealyaw", "1", FCVAR_ARCHIVE| FCVAR_CHEAT ); // thirdperson yaw
ConVar cam_idealpitch( "cam_idealpitch", "0", FCVAR_ARCHIVE | FCVAR_CHEAT ); // thirperson pitch
ConVar cam_idealdist( "cam_idealdist", "150", FCVAR_ARCHIVE | FCVAR_CHEAT ); // thirdperson distance
ConVar cam_idealdistright( "cam_idealdistright", "0", FCVAR_ARCHIVE | FCVAR_CHEAT ); // thirdperson distance
ConVar cam_idealdist( "cam_idealdist", "40", FCVAR_ARCHIVE | FCVAR_CHEAT ); // thirdperson distance
ConVar cam_idealdistright( "cam_idealdistright", "15", FCVAR_ARCHIVE | FCVAR_CHEAT ); // thirdperson distance
ConVar cam_idealdistup( "cam_idealdistup", "0", FCVAR_ARCHIVE | FCVAR_CHEAT ); // thirdperson distance
static ConVar cam_collision( "cam_collision", "1", FCVAR_ARCHIVE | FCVAR_CHEAT, "When in thirdperson and cam_collision is set to 1, an attempt is made to keep the camera from passing though walls." );
static ConVar cam_showangles( "cam_showangles", "0", FCVAR_CHEAT, "When in thirdperson, print viewangles/idealangles/cameraoffsets to the console." );
Expand Down
5 changes: 4 additions & 1 deletion mp/src/game/client/neo/c_neo_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,10 @@ void C_NEO_Player::PostThink(void)
Vector eyeForward;
this->EyeVectors(&eyeForward, NULL, NULL);
Assert(eyeForward.IsValid());
m_pPlayerAnimState->Update(eyeForward[YAW], eyeForward[PITCH]);

float flPitch = asin(-eyeForward[2]);
float flYaw = atan2(eyeForward[1], eyeForward[0]);
m_pPlayerAnimState->Update(RAD2DEG(flYaw), RAD2DEG(flPitch));
}

bool C_NEO_Player::IsAllowedToSuperJump(void)
Expand Down
6 changes: 5 additions & 1 deletion mp/src/game/server/neo/neo_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,10 @@ void CNEO_Player::PostThink(void)
Vector eyeForward;
this->EyeVectors(&eyeForward, NULL, NULL);
Assert(eyeForward.IsValid());
m_pPlayerAnimState->Update(eyeForward[YAW], eyeForward[PITCH]);

float flPitch = asin(-eyeForward[2]);
float flYaw = atan2(eyeForward[1], eyeForward[0]);
m_pPlayerAnimState->Update(RAD2DEG(flYaw), RAD2DEG(flPitch));
}

void CNEO_Player::PlayerDeathThink()
Expand Down Expand Up @@ -1450,6 +1453,7 @@ bool CNEO_Player::Weapon_Switch( CBaseCombatWeapon *pWeapon,
int viewmodelindex )
{
ShowCrosshair(false);
Weapon_SetZoom(false);

return BaseClass::Weapon_Switch(pWeapon, viewmodelindex);
}
Expand Down
43 changes: 16 additions & 27 deletions mp/src/game/shared/hl2mp/hl2mp_player_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,41 +428,30 @@ void CPlayerAnimState::ComputePoseParam_BodyXY(void)
((speed / ((GetOuter()->GetFlags() & FL_DUCKING) ? NEO_RECON_CROUCH_SPEED : NEO_RECON_NORM_SPEED))),
0, 1);

int forwardSign = 0;
if (GetOuter()->m_nButtons & IN_FORWARD)
{
if (!(GetOuter()->m_nButtons & IN_BACK))
{
forwardSign = 1;
}
}
else if (GetOuter()->m_nButtons & IN_BACK)
{
forwardSign = -1;
}
Vector eyeForward;
GetOuter()->EyeVectors(&eyeForward, NULL, NULL);
Assert(eyeForward.IsValid());
Vector velocity = GetOuter()->GetLocalVelocity();

int sideSign = 0;
if (GetOuter()->m_nButtons & IN_MOVERIGHT)
{
if (!(GetOuter()->m_nButtons & IN_MOVELEFT))
{
sideSign = 1;
}
}
else if (GetOuter()->m_nButtons & IN_MOVELEFT)
{
sideSign = -1;
}
Vector2D eyeForward2D = eyeForward.AsVector2D();
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potentially don't have to define new vectors if we can somehow isolate and normalise the first two components of this 3D vector on their own

Vector2D velocity2D = velocity.AsVector2D();

float speed_x = speedScale * forwardSign;
float speed_y = speedScale * sideSign;
eyeForward2D.NormalizeInPlace();
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normalizing a vector involves division which could make this a very expensive operation

velocity2D.NormalizeInPlace();

float forwardDot = eyeForward2D[0] * velocity2D[0] + eyeForward2D[1] * velocity2D[1];
Vector2D eyeRight2D = Vector2D(eyeForward2D[1], eyeForward2D[0] * -1); // eyeForward2D rotated by 90 degrees
float sideDot = eyeRight2D[0] * velocity2D[0] + eyeRight2D[1] * velocity2D[1];
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is nice to read but maybe to save some resources we could delete line 443 and have line 444 read
float sideDot = eyeForward2D[1] * velocity2D[0] + eyeForward2D[0] * -1 * velocity2D[1];


float speed_x = speedScale * forwardDot;
float speed_y = speedScale * sideDot;

GetOuter()->SetPoseParameter(poseparam_move_x, speed_x);
GetOuter()->SetPoseParameter("move_y", speed_y);

bool bIsMoving;
const float flPlaybackRate = CalcMovementPlaybackRate(speed, GetOuter()->GetSequenceGroundSpeed(GetOuter()->GetSequence()), &bIsMoving) * sv_neo_animrate_scale.GetFloat();

if (bIsMoving)
{
GetOuter()->SetPlaybackRate(flPlaybackRate);
Expand Down
Loading