void CLeanMgr::CalculateNewPosRot( LTVector &vOutPos, LTRotation &rOutRot, float fAngle ) { float fPitch = g_pPlayerMgr->GetPitch(); float fYaw = g_pPlayerMgr->GetYaw(); float fRoll = g_pPlayerMgr->GetRoll(); // Use the current camera angles and just add the new roll for the camera rotation... rOutRot = LTRotation( fPitch, fYaw, fRoll + fAngle ); // Don't factor in the pitch so the position isn't affected by it... LTMatrix mRotation; LTRotation rRotation( 0.0f, fYaw, fRoll + fAngle ); rRotation.ConvertToMatrix( mRotation ); vOutPos = (mRotation * m_vRotationPtOffset) + m_vRotationPt; // Make sure we are actually in the world before we try to clip... ClientIntersectQuery iQuery; ClientIntersectInfo iInfo; iQuery.m_Flags = INTERSECT_OBJECTS | IGNORE_NONSOLID | INTERSECT_HPOLY; iQuery.m_From = m_vRotationPt + m_vRotationPtOffset; iQuery.m_To = vOutPos; if( g_pLTClient->IntersectSegment( &iQuery, &iInfo )) { vOutPos = iInfo.m_Point + iInfo.m_Plane.m_Normal; } // Keep us far away from walls to avoid clipping... float fCamClipDist = g_vtCameraClipDistance.GetFloat(); g_vtCameraClipDistance.SetFloat( g_vtLeanCamClipDist.GetFloat() ); g_pPlayerMgr->GetPlayerCamera()->CalcNonClipPos( vOutPos, rOutRot ); g_vtCameraClipDistance.SetFloat( fCamClipDist ); }
void CCameraOffsetMgr::ProcessTestingVars() { CameraDelta delta; // See if any testing vars were set... if (g_vtCamWeaponImpact.GetFloat() > 0.0f) { g_vtCamWeaponImpact.SetFloat(0.0f); switch(GetRandom(1, 3)) { case 1: { delta.Pitch.fVar = GetRandom(1, 2) == 1 ? -DEG2RAD(5.0f) : DEG2RAD(5.0f); delta.Pitch.fTime1 = 0.1f; delta.Pitch.fTime2 = 0.25f; delta.Pitch.eWave1 = Wave_SlowOff; delta.Pitch.eWave2 = Wave_SlowOff; g_pLTClient->CPrint("Test Impact Pitch = %.4f (in Deg = %.2f)", delta.Pitch.fVar, RAD2DEG(delta.Pitch.fVar)); } break; case 2 : { delta.Yaw.fVar = GetRandom(1, 2) == 1 ? -DEG2RAD(5.0f) : DEG2RAD(5.0f); delta.Yaw.fTime1 = 0.1f; delta.Yaw.fTime2 = 0.25f; delta.Yaw.eWave1 = Wave_SlowOff; delta.Yaw.eWave2 = Wave_SlowOff; g_pLTClient->CPrint("Test Impact Yaw = %.4f (in Deg = %.2f)", delta.Yaw.fVar, RAD2DEG(delta.Yaw.fVar)); } break; default : case 3 : { delta.Roll.fVar = GetRandom(1, 2) == 1 ? -DEG2RAD(5.0f) : DEG2RAD(5.0f); delta.Roll.fTime1 = 0.1f; delta.Roll.fTime2 = 0.25f; delta.Roll.eWave1 = Wave_SlowOff; delta.Roll.eWave2 = Wave_SlowOff; g_pLTClient->CPrint("Test Impact Roll = %.4f (in Deg = %.2f)", delta.Roll.fVar, RAD2DEG(delta.Roll.fVar)); } break; } AddDelta(delta); } }
void CCursorMgr::CheckForReinit() { // because of driver bugs, we need to wait a frame after reinitializing the renderer and // reinitialize the cursor int nCursorHackFrameDelay = (int)g_vtCursorHack.GetFloat(); if (nCursorHackFrameDelay) { nCursorHackFrameDelay--; g_vtCursorHack.SetFloat((LTFLOAT)nCursorHackFrameDelay); if (nCursorHackFrameDelay == 1) Init(); } }
// Lock a set of render targets, and associate with a token for later release bool LockRenderTarget(uint32 nToken, HRENDERTARGET *pShadowBuffer, HRENDERTARGET *pSliceBuffer) { // Reset our render target list if our resolution has changed if ((m_nCurSliceRes != (uint32)g_cvarVolumetricLightSliceRes.GetFloat()) || (m_nCurShadowRes != (uint32)g_cvarVolumetricLightShadowRes.GetFloat()) || (m_bShadowsEnabled != (g_cvarVolumetricLightShadow.GetFloat() != 0.0f)) || (m_bFloatBuffersEnabled != (g_cvarVolumetricLightFloat.GetFloat() != 0.0f))) { m_nCurSliceRes = (uint32)g_cvarVolumetricLightSliceRes.GetFloat(); m_nCurShadowRes = (uint32)g_cvarVolumetricLightShadowRes.GetFloat(); m_bShadowsEnabled = (g_cvarVolumetricLightShadow.GetFloat() != 0); m_bFloatBuffersEnabled = (g_cvarVolumetricLightFloat.GetFloat() != 0); FlushRenderTargets(); } // Allocate a new target if necessary if (m_aFreeList.empty()) { // Add null buffers to the free list m_aFreeList.push_back(m_aShadowBuffers.size()); m_aShadowBuffers.push_back(NULL); m_aSliceBuffers.push_back(NULL); m_aLockTokens.push_back(0); } // Pull a buffer set from the free list uint32 nIndex = m_aFreeList.back(); m_aFreeList.pop_back(); m_aLockTokens[nIndex] = nToken; HRENDERTARGET hShadowBuffer = m_aShadowBuffers[nIndex]; // Allocate a shadow buffer if necessary // Note: These aren't allocated until they're requested so we don't allocate shadow // buffers if they're turned off. if (m_bShadowsEnabled && (hShadowBuffer == NULL)) { LTRESULT nResult = LT_ERROR; nResult = g_pLTRenderer->CreateRenderTarget(m_nCurShadowRes, m_nCurShadowRes, eRTO_DepthBuffer, hShadowBuffer); if (nResult != LT_OK) return false; m_aShadowBuffers[nIndex] = hShadowBuffer; } HRENDERTARGET hSliceBuffer = m_aSliceBuffers[nIndex]; // Allocate a slice buffer (use floating point precision if possible) if necessary if (hSliceBuffer == NULL) { LTRESULT nResult = LT_ERROR; LTVector2 vSliceRes = GetSliceBufferRes(); if (m_bFloatBuffersEnabled) { nResult = g_pLTRenderer->CreateRenderTarget((uint32)vSliceRes.x, (uint32)vSliceRes.y, eRTO_DepthBuffer | eRTO_FloatBuffer, hSliceBuffer); if (nResult != LT_OK) { // Floating point buffers not supported. Stop trying to allocate them. m_bFloatBuffersEnabled = false; g_cvarVolumetricLightFloat.SetFloat(0.0f); } } if (!m_bFloatBuffersEnabled) { nResult = g_pLTRenderer->CreateRenderTarget((uint32)vSliceRes.x, (uint32)vSliceRes.y, eRTO_DepthBuffer, hSliceBuffer); if (nResult != LT_OK) { g_pLTRenderer->ReleaseRenderTarget(hShadowBuffer); return false; } } m_aSliceBuffers[nIndex] = hSliceBuffer; } // Return those buffers *pShadowBuffer = hShadowBuffer; *pSliceBuffer = hSliceBuffer; return true; }
void CCursorMgr::ScheduleReinit(float fDelay) { g_vtCursorHack.SetFloat(fDelay); }