Skip to content

Commit

Permalink
Fix showing weapon hand and body when not in VR.
Browse files Browse the repository at this point in the history
For now, always draw the laser sight if enabled in the options.
Fix bug calling CalculateHideRise for both hands.
Fix some warnings about size_t.
Add commented out debugging in console.
  • Loading branch information
CarlKenner committed May 23, 2019
1 parent 0fc328c commit dbf55b4
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 14 deletions.
16 changes: 7 additions & 9 deletions neo/d3xp/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,7 @@ bool idInventory::Give( idPlayer* owner, const idDict& spawnArgs, const char* st
}
else
{
len = strlen( pos );
len = (int)strlen( pos );
}

idStr weaponName( pos, 0, len );
Expand Down Expand Up @@ -1364,7 +1364,7 @@ void idInventory::InitRechargeAmmo( idPlayer* owner )
while( kv )
{
idStr key = kv->GetKey();
idStr ammoname = key.Right( key.Length() - strlen( "ammorecharge_" ) );
idStr ammoname = key.Right( key.Length() - (int)strlen( "ammorecharge_" ) );
int ammoType = AmmoIndexForAmmoClass( ammoname );
rechargeAmmo[ammoType].ammo = ( atof( kv->GetValue().c_str() ) * 1000 );
strcpy( rechargeAmmo[ammoType].ammoName, ammoname );
Expand Down Expand Up @@ -13507,7 +13507,7 @@ void idPlayer::UpdateLaserSight( int hand )
showTeleport = showTeleport && !AI_DEAD && !gameLocal.inCinematic && !Flicksync_InCutscene && !game->IsPDAOpen();

// check if lasersight should be hidden
if ( !IsGameStereoRendered() ||
if ( //!IsGameStereoRendered() ||
!hands[hand].laserSightActive || // Koz allow user to toggle lasersight.
sightMode == -1 ||
!weapon->ShowCrosshair() ||
Expand Down Expand Up @@ -13590,7 +13590,7 @@ void idPlayer::UpdateLaserSight( int hand )

hands[hand].laserSightRenderEntity.shaderParms[SHADERPARM_BEAM_WIDTH] = g_laserSightWidth.GetFloat();

if ( IsGameStereoRendered() && hands[hand].laserSightHandle == -1 )
if ( /*IsGameStereoRendered() &&*/ hands[hand].laserSightHandle == -1 )
{
hands[hand].laserSightHandle = gameRenderWorld->AddEntityDef( &hands[hand].laserSightRenderEntity );
}
Expand Down Expand Up @@ -13744,7 +13744,7 @@ void idPlayer::UpdateLaserSight( int hand )
}
oldTeleport = showTeleport;

if ( IsGameStereoRendered() && hands[hand].crosshairHandle == -1 )
if ( /*IsGameStereoRendered() &&*/ hands[hand].crosshairHandle == -1 )
{
hands[hand].crosshairHandle = gameRenderWorld->AddEntityDef( &hands[hand].crosshairEntity );
}
Expand Down Expand Up @@ -16748,7 +16748,7 @@ Calculate the bobbing position of the view weapon
void idPlayer::CalculateViewWeaponPos( int hand, idVec3& origin, idMat3& axis )
{

if ( game->isVR )
if ( game->isVR || true )
{
CalculateViewWeaponPosVR( hand, origin, axis );
return;
Expand Down Expand Up @@ -16822,9 +16822,7 @@ void idPlayer::CalculateViewWeaponPos( int hand, idVec3& origin, idMat3& axis )

axis = scaledMat * viewAxis;

for( int h = 0; h < 2; h++ )
hands[ h ].weapon->CalculateHideRise( origin, axis ); // Koz

hands[ hand ].weapon->CalculateHideRise( origin, axis ); // Koz
}

void DebugCross( idVec3 origin, idMat3 axis, idVec4 color )
Expand Down
6 changes: 3 additions & 3 deletions neo/d3xp/Weapon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ void idWeapon::Restore( idRestoreGame* savefile )
else
{
// Koz get jointhandles for hand attachers
if (game->isVR)
if (game->isVR || true)
{
weaponHandAttacher[0] = animator.GetJointHandle("RhandAttacher");
if (weaponHandAttacher[0] != INVALID_JOINT)
Expand Down Expand Up @@ -1287,7 +1287,7 @@ void idWeapon::GetWeaponDef( const char* objectname, int ammoinclip )
// Koz get jointhandles for hand attachers


if ( game->isVR )
if ( game->isVR || true )
{
weaponHandAttacher[0] = animator.GetJointHandle( "RhandAttacher" );
if ( weaponHandAttacher[0] != INVALID_JOINT )
Expand Down Expand Up @@ -3543,7 +3543,7 @@ void idWeapon::PresentWeapon( bool showViewModel, int hand )

// in VR don't suppress drawing the player's body
// also show the viewmodel
if ( game->isVR )
if ( game->isVR || true )
{
if ( (hide && disabled) ) // hide the weapon if in a cinematic
{
Expand Down
43 changes: 41 additions & 2 deletions neo/framework/Console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,12 @@ float idConsoleLocal::DrawFPS( float y )
#if 0
if( gameLocal.GetLocalPlayer() && gameLocal.GetLocalPlayer()->GetPhysics() )
{
idStr s;
int w;
idPlayer* player = gameLocal.GetLocalPlayer();
y += SMALLCHAR_HEIGHT + 4;
idStr s;
s.Format( "%d %d %d", (int)player->GetPhysics()->GetOrigin().x, (int)player->GetPhysics()->GetOrigin().y, (int)player->GetPhysics()->GetOrigin().z );
int w = s.LengthWithoutColors() * SMALLCHAR_WIDTH;
w = s.LengthWithoutColors() * SMALLCHAR_WIDTH;
renderSystem->DrawSmallStringExt( LOCALSAFE_RIGHT - w, idMath::Ftoi( y ) + 2, s.c_str(), colorYellow, false );
y += SMALLCHAR_HEIGHT + 4;
s.Format( "%d %d %d", (int)player->firstPersonViewOrigin.x, (int)player->firstPersonViewOrigin.y, (int)player->firstPersonViewOrigin.z );
Expand All @@ -291,6 +292,44 @@ float idConsoleLocal::DrawFPS( float y )
renderSystem->DrawSmallStringExt( LOCALSAFE_RIGHT - w, idMath::Ftoi( y ) + 2, s.c_str(), colorCyan, false );
y += SMALLCHAR_HEIGHT + 4;
}
#endif
#if 0
if( gameLocal.GetLocalPlayer() && gameLocal.GetLocalPlayer()->GetPhysics() && gameLocal.GetLocalPlayer()->hands[0].weapon )
{
idStr s;
int w;
idPlayer* player = gameLocal.GetLocalPlayer();
idPlayerHand* hand = &player->hands[0];
idWeapon* weapon = hand->weapon;
y += SMALLCHAR_HEIGHT + 4;
// Red: Head View
s.Format( "eye: %d %d %d", (int)player->firstPersonViewOrigin.x, (int)player->firstPersonViewOrigin.y, (int)player->firstPersonViewOrigin.z );
w = s.LengthWithoutColors() * SMALLCHAR_WIDTH;
renderSystem->DrawSmallStringExt( LOCALSAFE_RIGHT - w, idMath::Ftoi( y ) + 2, s.c_str(), colorGreen, false );
y += SMALLCHAR_HEIGHT + 4;
s.Format( "eye: %d %d %d", (int)player->GetEyePosition().x, (int)player->GetEyePosition().y, (int)player->GetEyePosition().z );
w = s.LengthWithoutColors() * SMALLCHAR_WIDTH;
renderSystem->DrawSmallStringExt( LOCALSAFE_RIGHT - w, idMath::Ftoi( y ) + 2, s.c_str(), colorBlue, false );
y += SMALLCHAR_HEIGHT + 4;
s.Format( "weap: %d %d %d", (int)weapon->GetPhysics()->GetOrigin().x, (int)weapon->GetPhysics()->GetOrigin().y, (int)weapon->GetPhysics()->GetOrigin().z );
w = s.LengthWithoutColors() * SMALLCHAR_WIDTH;
renderSystem->DrawSmallStringExt( LOCALSAFE_RIGHT - w, idMath::Ftoi( y ) + 2, s.c_str(), colorYellow, false );
y += SMALLCHAR_HEIGHT + 4;
s.Format( "hand: %d %d %d", (int)hand->handOrigin.x, (int)hand->handOrigin.y, (int)hand->handOrigin.z );
w = s.LengthWithoutColors() * SMALLCHAR_WIDTH;
renderSystem->DrawSmallStringExt( LOCALSAFE_RIGHT - w, idMath::Ftoi( y ) + 2, s.c_str(), colorRed, false );
y += SMALLCHAR_HEIGHT + 4;
/*
s.Format( "%d %d %d", (int)player->eyeOffset.x, (int)player->eyeOffset.y, (int)player->eyeOffset.z );
w = s.LengthWithoutColors() * SMALLCHAR_WIDTH;
renderSystem->DrawSmallStringExt( LOCALSAFE_RIGHT - w, idMath::Ftoi( y ) + 2, s.c_str(), colorBlue, false );
y += SMALLCHAR_HEIGHT + 4;
s.Format( "%d", (int)commonVr->headHeightDiff );
w = s.LengthWithoutColors() * SMALLCHAR_WIDTH;
renderSystem->DrawSmallStringExt( LOCALSAFE_RIGHT - w, idMath::Ftoi( y ) + 2, s.c_str(), colorCyan, false );
y += SMALLCHAR_HEIGHT + 4;
*/
}
#endif
return y;
}
Expand Down

0 comments on commit dbf55b4

Please sign in to comment.