From dbf55b4ff77308b44484f029776b315322406c05 Mon Sep 17 00:00:00 2001 From: CarlKenner Date: Thu, 23 May 2019 15:22:03 +0930 Subject: [PATCH] Fix showing weapon hand and body when not in VR. 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. --- neo/d3xp/Player.cpp | 16 +++++++-------- neo/d3xp/Weapon.cpp | 6 +++--- neo/framework/Console.cpp | 43 +++++++++++++++++++++++++++++++++++++-- 3 files changed, 51 insertions(+), 14 deletions(-) diff --git a/neo/d3xp/Player.cpp b/neo/d3xp/Player.cpp index fcd6d893c..5b10eb374 100644 --- a/neo/d3xp/Player.cpp +++ b/neo/d3xp/Player.cpp @@ -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 ); @@ -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 ); @@ -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() || @@ -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 ); } @@ -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 ); } @@ -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; @@ -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 ) diff --git a/neo/d3xp/Weapon.cpp b/neo/d3xp/Weapon.cpp index 5e908a78b..03452a2da 100644 --- a/neo/d3xp/Weapon.cpp +++ b/neo/d3xp/Weapon.cpp @@ -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) @@ -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 ) @@ -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 { diff --git a/neo/framework/Console.cpp b/neo/framework/Console.cpp index fbe0d71a0..e50b1e6f9 100644 --- a/neo/framework/Console.cpp +++ b/neo/framework/Console.cpp @@ -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 ); @@ -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; }