SweptBox material wasn't initialized, corrected some stuff

This commit is contained in:
Kamay Xutax 2024-07-16 01:08:33 +02:00
parent 95bb5cb8a5
commit 469c74b8b3
6 changed files with 75 additions and 34 deletions

View file

@ -5611,7 +5611,7 @@ void C_BaseAnimating::DrawClientHitboxes( float duration /*= 0.0f*/, bool monoco
b = ( int ) ( 255.0f * hullcolor[j][2] );
}
debugoverlay->AddBoxOverlay( position, pbox->bbmin, pbox->bbmax, angles, r, g, b, 0 ,duration );
debugoverlay->AddBoxOverlay( position, pbox->bbmin, pbox->bbmax, angles, r, g, b, 127 ,duration );
}
}
@ -5647,7 +5647,7 @@ void C_BaseAnimating::DrawServerHitboxes( float duration /*= 0.0f*/, bool monoco
b = ( int ) ( 255.0f * hullcolor[j][2] );
}
debugoverlay->AddBoxOverlay( m_vecHitboxServerPositions[i], pbox->bbmin, pbox->bbmax, m_angHitboxServerAngles[i], r, g, b, 0 ,duration );
debugoverlay->AddBoxOverlay( m_vecHitboxServerPositions[i], pbox->bbmin, pbox->bbmax, m_angHitboxServerAngles[i], r, g, b, 127 ,duration );
}
}

View file

@ -2135,9 +2135,11 @@ void C_BasePlayer::Simulate()
ResetLatched();
}
static ConVarRef cl_showimpacts("cl_showimpacts");
static ConVarRef cl_showfirebullethitboxes("cl_showfirebullethitboxes");
bool shouldShowFireBulletHitbox = m_nTickBaseFireBullet <= m_nTickBase && m_nTickBaseFireBullet != -1;
if (shouldShowFireBulletHitbox)
if (shouldShowFireBulletHitbox && (cl_showimpacts.GetInt() == 1 || cl_showimpacts.GetInt() == 3 || cl_showfirebullethitboxes.GetBool()))
{
DrawServerHitboxes(60.0f, true);
m_nTickBaseFireBullet = -1;

View file

@ -2230,7 +2230,7 @@ void C_CSPlayer::Simulate( void )
static ConVarRef cl_showimpacts("cl_showimpacts");
if ((cl_showimpacts.GetInt() == 1 || cl_showimpacts.GetInt() == 3) && m_iBulletServerPositionCount > 0 && m_lastBulletDiameter != -1.0f)
if ((cl_showimpacts.GetInt() == 1 || cl_showimpacts.GetInt() == 3) && m_lastBulletDiameter != -1.0f)
{
auto weaponInfo = GetActiveWeapon();

View file

@ -98,7 +98,7 @@ ConVar thirdperson_platformer( "thirdperson_platformer", "0", 0, "Player will ai
ConVar thirdperson_screenspace( "thirdperson_screenspace", "0", 0, "Movement will be relative to the camera, eg: left means screen-left" );
ConVar sv_noclipduringpause( "sv_noclipduringpause", "0", FCVAR_REPLICATED | FCVAR_CHEAT, "If cheats are enabled, then you can noclip with the game paused (for doing screenshots, etc.)." );
ConVar cl_showimpacts("cl_showimpacts", "0", FCVAR_NONE, "Shows client (red) and server (blue) bullet impact point (1=both, 2=client-only, 3=server-only)" );
ConVar cl_showimpacts("cl_showimpacts", "0");
ConVar cl_showfirebullethitboxes( "cl_showfirebullethitboxes", "0" );
extern ConVar cl_mouselook;

View file

@ -8,6 +8,8 @@
#include "debugoverlay_shared.h"
#ifndef CLIENT_DLL
#include "player.h"
#else
#include "cdll_client_int.h"
#endif
#include "weapon_csbase.h"
#include "decals.h"
@ -455,10 +457,6 @@ void CCSPlayer::FireBullet(
GetBulletTypeParameters( iBulletType, flPenetrationPower, flPenetrationDistance, flBulletDiameter );
#ifdef CLIENT_DLL
m_lastBulletDiameter = flBulletDiameter;
#endif
Vector vecBulletDiameterMaxs(flBulletDiameter, flBulletDiameter, flBulletDiameter);
vecBulletDiameterMaxs /= 2.0f;
Vector vecBulletDiameterMins(-flBulletDiameter, -flBulletDiameter, -flBulletDiameter);
@ -500,25 +498,35 @@ void CCSPlayer::FireBullet(
CBasePlayer *lastPlayerHit = NULL;
MDLCACHE_CRITICAL_SECTION();
#ifdef CLIENT_DLL
static ConVarRef cl_showfirebullethitboxes("cl_showfirebullethitboxes");
if (cl_showfirebullethitboxes.GetBool())
{
for (int i = 1; i <= gpGlobals->maxClients; i++)
{
CBasePlayer* lagPlayer = UTIL_PlayerByIndex(i);
if ( lagPlayer && !lagPlayer->IsLocalPlayer() && IsLocalPlayer())
{
lagPlayer->DrawClientHitboxes(60, true);
lagPlayer->m_nTickBaseFireBullet = int(lagPlayer->GetTimeBase() / TICK_INTERVAL);
}
}
}
#else
if ( m_pCurrentCommand->debug_hitboxes == CUserCmd::DEBUG_HITBOXES_ON_BULLET || m_pCurrentCommand->debug_hitboxes == CUserCmd::DEBUG_HITBOXES_ALWAYS_ON )
{
for (int i = 1; i <= gpGlobals->maxClients; i++)
{
CBasePlayer* lagPlayer = UTIL_PlayerByIndex(i);
#ifdef CLIENT_DLL
if( lagPlayer && !lagPlayer->IsLocalPlayer() && IsLocalPlayer())
{
lagPlayer->DrawClientHitboxes(60, true);
lagPlayer->m_nTickBaseFireBullet = int(lagPlayer->GetTimeBase() / TICK_INTERVAL);
}
#else
if( lagPlayer )
{
lagPlayer->RecordServerHitboxes(this);
}
#endif
}
}
#endif
while ( fCurrentDamage > 0 )
{
@ -564,34 +572,63 @@ void CCSPlayer::FireBullet(
flDamageModifier = 0.99f;
}
if ( m_pCurrentCommand->debug_hitboxes == CUserCmd::DEBUG_HITBOXES_ON_HIT || m_pCurrentCommand->debug_hitboxes == CUserCmd::DEBUG_HITBOXES_ALWAYS_ON )
{
#ifdef CLIENT_DLL
// draw red client impact markers
NDebugOverlay::SweptBox(vecSrc, tr.endpos, vecBulletDiameterMins, vecBulletDiameterMaxs, QAngle( 0, 0, 0), 255,0,0,127, 60 );
m_lastBulletDiameter = flBulletDiameter;
#endif
if ( tr.m_pEnt && tr.m_pEnt->IsPlayer() )
#ifdef CLIENT_DLL
static ConVarRef cl_showimpacts("cl_showimpacts");
if (cl_showimpacts.GetInt() == 1 || cl_showimpacts.GetInt() == 2)
{
NDebugOverlay::SweptBox(vecSrc,
tr.endpos,
vecBulletDiameterMins,
vecBulletDiameterMaxs,
QAngle(0, 0, 0),
255,
0,
0,
127,
60.0f);
}
if (tr.m_pEnt && tr.m_pEnt->IsPlayer())
{
C_BasePlayer* player = ToBasePlayer(tr.m_pEnt);
if (cl_showimpacts.GetInt() == 1
|| cl_showimpacts.GetInt() == 2)
{
C_BasePlayer *player = ToBasePlayer( tr.m_pEnt );
player->DrawClientHitboxes( 60, true );
player->m_nTickBaseFireBullet = int(player->GetTimeBase() / TICK_INTERVAL);
player->DrawClientHitboxes(60.0f, true);
}
player->m_nTickBaseFireBullet = int(player->GetTimeBase()
/ TICK_INTERVAL);
}
#else
if ( tr.m_pEnt && tr.m_pEnt->IsPlayer() )
if ( m_pCurrentCommand->debug_hitboxes == CUserCmd::DEBUG_HITBOXES_ON_HIT || m_pCurrentCommand->debug_hitboxes == CUserCmd::DEBUG_HITBOXES_ALWAYS_ON )
{
if (m_iBulletServerPositionCount.Get()
< MAX_PLAYER_BULLET_SERVER_POSITIONS)
{
m_vecBulletServerPositions.Set(
m_iBulletServerPositionCount.Get(),
tr.endpos);
m_vecServerShootPosition.Set(
m_iBulletServerPositionCount.Get(),
vecSrc);
m_iBulletServerPositionCount.Set(
m_iBulletServerPositionCount.Get() + 1);
}
if ( tr.m_pEnt && tr.m_pEnt->IsPlayer() )
{
CBasePlayer *player = ToBasePlayer( tr.m_pEnt );
player->RecordServerHitboxes( this );
}
if (m_iBulletServerPositionCount.Get() < MAX_PLAYER_BULLET_SERVER_POSITIONS)
{
m_vecBulletServerPositions.Set(m_iBulletServerPositionCount.Get(), tr.endpos);
m_vecServerShootPosition.Set(m_iBulletServerPositionCount.Get(), vecSrc);
m_iBulletServerPositionCount.Set(m_iBulletServerPositionCount.Get() + 1);
}
#endif
}
#endif
//calculate the damage based on the distance the bullet travelled.
flCurrentDistance += tr.fraction * flDistance;

View file

@ -666,6 +666,8 @@ static void DrawExtrusionFace( const Vector& start, const Vector& end,
void RenderWireframeSweptBox( const Vector &vStart, const Vector &vEnd, const QAngle &angles, const Vector &vMins, const Vector &vMaxs, Color c, bool bZBuffer )
{
InitializeStandardMaterials();
CMatRenderContextPtr pRenderContext( g_pMaterialSystem );
pRenderContext->Bind( bZBuffer ? s_pWireframe : s_pWireframeIgnoreZ );