Skip to content
Merged
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
17 changes: 10 additions & 7 deletions src/game/client/c_baseanimating.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3619,16 +3619,19 @@ int C_BaseAnimating::InternalDrawModel( int flags )
#ifdef NEO
if (IsViewModel())
{ // view models become dark when standing close to and facing a wall, change lighting origin
auto pOwner = UTIL_PlayerByIndex(GetLocalPlayerIndex());
if (pOwner)
if (!engine->IsHLTV())
{
static Vector ownerOrigin;
ownerOrigin = pOwner->EyePosition();
pInfo->pLightingOrigin = &ownerOrigin;
auto pOwner = UTIL_PlayerByIndex(GetLocalPlayerIndex());
if (pOwner)
{
static Vector ownerOrigin;
ownerOrigin = pOwner->EyePosition();
pInfo->pLightingOrigin = &ownerOrigin;
}
}
}
else if (IsBaseCombatWeapon())
{
else if (IsBaseCombatWeapon() && !GetMoveParent())
{ // dropped weapons can become dark when they rotate such that their origin falls through the floor
static Vector worldSpaceCenter;
worldSpaceCenter = WorldSpaceCenter();
pInfo->pLightingOrigin = &worldSpaceCenter;
Expand Down
83 changes: 83 additions & 0 deletions src/game/client/cdll_client_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@

#endif

#ifdef NEO
#include <vgui_controls/Button.h>
#include <vgui_controls/MenuButton.h>
#endif

extern vgui::IInputInternal *g_InputInternal;

Expand Down Expand Up @@ -1943,6 +1947,79 @@ void CHLClient::DecodeUserCmdFromBuffer( bf_read& buf, int slot )
input->DecodeUserCmdFromBuffer( buf, slot );
}

#ifdef NEO
inline static vgui::VPANEL ChildOf(const vgui::VPANEL parent, const char* childName)
{
Assert(parent);
const auto& children = vgui::ipanel()->GetChildren(parent);
for (const auto& child : children)
{
const char* name = vgui::ipanel()->GetName(child);
Assert(childName && *childName);
if (name && V_strcmp(name, childName) == 0)
return child;
}
return {};
}

static void FixupDemoSmoother()
{
VPROF_BUDGET(__FUNCTION__, VPROF_BUDGETGROUP_REPLAY);

static bool alreadyDone = false;
if (alreadyDone)
return;

// Don't spam the vgui iteration attempts too often...
static float lastAttemptTime{};
if (gpGlobals->curtime - lastAttemptTime < 1)
{
// ...except if we're not ticking, since who knows how long it's been.
// Luckily perf doesn't really matter if the entire game is currently frozen.
if (!engine->IsPaused())
{
return;
}
}

lastAttemptTime = gpGlobals->curtime;

Assert(enginevgui);
const auto toolsPanel = enginevgui->GetPanel(PANEL_TOOLS);
const auto demoUiPanel = ChildOf(toolsPanel, "DemoUIPanel");
const auto demoSmootherPanel = ChildOf(demoUiPanel, "DemoSmootherPanel");
if (!demoSmootherPanel)
return;

constexpr const char* demoSmootherPanelButtonsToFix[]{
"DemoSmoothFixFrameButton",
"DemoSmootherType" };

int numFixed = 0;
for (const auto& buttonName : demoSmootherPanelButtonsToFix)
{
auto button = vgui::ipanel()->GetPanel(ChildOf(demoSmootherPanel, buttonName), "BaseUI");
if (!button)
continue;

// The buttons live in engine dll, so this could theoretically change in SDK update.
using ExpectedButtonType = vgui::MenuButton;
// And so we check
if (!dynamic_cast<ExpectedButtonType*>(button))
{
Assert(false);
alreadyDone = true; // nothing we can do until code fix... just mark as done
return;
}

((ExpectedButtonType*)button)->SetButtonActivationType(vgui::Button::ACTIVATE_ONPRESSED);
++numFixed;
}

alreadyDone = (numFixed == ARRAYSIZE(demoSmootherPanelButtonsToFix));
}
#endif

//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
Expand All @@ -1956,6 +2033,12 @@ void CHLClient::View_Render( vrect_t *rect )

view->Render( rect );
UpdatePerfStats();
#ifdef NEO
if (engine->IsPlayingDemo())
{
FixupDemoSmoother();
}
#endif
}


Expand Down
83 changes: 57 additions & 26 deletions src/game/client/game_controls/SpectatorGUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ void AddSubKeyNamed( KeyValues *pKeys, const char *pszName );
#include "c_team.h"
#include "neo_gamerules.h"
#include "c_neo_player.h"
#include "view.h"
#include "hltvcamera.h"
#endif

// memdbgon must be the last include file in a .cpp file!!!
Expand Down Expand Up @@ -986,48 +988,77 @@ CON_COMMAND_F( spec_player, "Spectate player by partial name, steamid, or userid
}
}

#ifdef NEO
#ifdef NEO
CON_COMMAND_F( spec_player_under_mouse, "Spectate player by partial name, steamid, or userid", FCVAR_CLIENTCMD_CAN_EXECUTE )
{
if (engine->IsHLTV() && HLTVCamera()->IsPVSLocked())
{
ConMsg( "%s: HLTV Camera is PVS locked\n", __FUNCTION__ );
return;
}

C_NEO_Player *pNeoPlayer = C_NEO_Player::GetLocalNEOPlayer();
if ( !pNeoPlayer || !pNeoPlayer->IsObserver() )
return;

if (!engine->IsHLTV() || !HLTVCamera()->IsPVSLocked())
C_BaseEntity* currentTarget = pNeoPlayer->GetObserverTarget();
C_NEO_Player *target = nullptr;
float targetDotProduct = -1;
for (int i = 1; i <= gpGlobals->maxClients; i++)
{
C_BaseEntity* currentTarget = pNeoPlayer->GetObserverTarget();
C_NEO_Player *target = nullptr;
float targetDotProduct = -1;
for (int i = 1; i < gpGlobals->maxClients; i++)
C_NEO_Player* pPlayer = ToNEOPlayer(UTIL_PlayerByIndex(i));
if (currentTarget != pPlayer && pNeoPlayer->IsValidObserverTarget(pPlayer) && pPlayer->IsAlive())
{
C_NEO_Player* pPlayer = ToNEOPlayer(UTIL_PlayerByIndex(i));
if (currentTarget != pPlayer && pNeoPlayer->IsValidObserverTarget(pPlayer) && pPlayer->IsAlive())
Vector vecToTarget = pPlayer->WorldSpaceCenter() - MainViewOrigin();
vecToTarget.NormalizeInPlace();
float dotProduct = DotProduct(MainViewForward(), vecToTarget);
if (dotProduct > targetDotProduct && dotProduct > 0.5)
{
Vector vecForward;
AngleVectors( pNeoPlayer->EyeAngles(), &vecForward );

Vector vecToTarget = pPlayer->WorldSpaceCenter() - pNeoPlayer->EyePosition();
vecToTarget.NormalizeInPlace();
float dotProduct = DotProduct(vecForward, vecToTarget);
if (dotProduct > targetDotProduct && dotProduct > 0.5)
{
targetDotProduct = dotProduct;
target = pPlayer;
}
targetDotProduct = dotProduct;
target = pPlayer;
}
}
}

if (target)
{
engine->IsHLTV() ? HLTVCamera()->SetPrimaryTarget(target->entindex()) : engine->ClientCmd(VarArgs("spec_player_entity_number %d", target->entindex()));
}
}

if (target)
CON_COMMAND_F( spec_fastest_player, "Spectate the fastest player", FCVAR_CLIENTCMD_CAN_EXECUTE )
{
C_NEO_Player *pNeoPlayer = C_NEO_Player::GetLocalNEOPlayer();
if ( !pNeoPlayer || !pNeoPlayer->IsObserver() )
return;

if (engine->IsHLTV())
{
if (HLTVCamera()->IsPVSLocked())
{
if (engine->IsHLTV())
{
HLTVCamera()->SetPrimaryTarget(target->entindex());
}
else
ConMsg( "%s: HLTV Camera is PVS locked\n", __FUNCTION__ );
return;
}

// We have up to date information on all the players, just do it here
float fastestSpeedSquared = 0;
CBasePlayer* pFastestEntity = nullptr;
for (int i = 1; i <= gpGlobals->maxClients; i++)
{
CBasePlayer* pPlayer = UTIL_PlayerByIndex(i);
if (pPlayer && !pPlayer->IsObserver() && pPlayer->GetAbsVelocity().LengthSqr() > fastestSpeedSquared)
{
engine->ClientCmd( VarArgs("spec_player_entity_number %d", target->entindex()) );
fastestSpeedSquared = pPlayer->GetAbsVelocity().LengthSqr();
pFastestEntity = pPlayer;
}
}

if (pFastestEntity)
HLTVCamera()->SetPrimaryTarget(pFastestEntity->entindex());
}
else
{
engine->ClientCmd(VarArgs("spectate_fastest_player"));
}
}
#endif // NEO
Expand Down
4 changes: 4 additions & 0 deletions src/game/client/glow_overlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,11 @@ void CGlowOverlay::UpdateSkyGlowObstruction( float zFar, bool bCacheFullSceneSta
if ( PixelVisibility_IsAvailable() )
{
// Trace a ray at the object.
#ifdef NEO
Vector pos = CurrentViewOrigin() + m_vDirection * zFar * 0.99f;
#else
Vector pos = CurrentViewOrigin() + m_vDirection * zFar * 0.999f;
#endif

// UNDONE: Can probably do only the pixelvis query in this case if you can figure out where
// to put it - or save the position of this trace
Expand Down
Loading
Loading