Ejemplo n.º 1
0
void CModelInfoSA::SetLODDistance ( float fDistance )
{
#if 0
    // fLodDistanceUnscaled values:
    //
    // With the draw distance setting in GTA SP options menu set to maximum:
    //      0 - 170     roughly correlates to a LOD distance of 0 - 300 game units
    //      170 - 480   sets the LOD distance to 300 game units and has a negative effect on the alpha fade-in
    //      490 - 1e7   sets the LOD distance to 300 game units and removes the alpha fade-in completely
    //
    // With the draw distance setting in GTA SP options menu set to minimum:
    //      0 - 325     roughly correlates to a LOD distance of 0 - 300 game units
    //      340 - 960   sets the LOD distance to 300 game units and has a negative effect on the alpha fade-in
    //      1000 - 1e7  sets the LOD distance to 300 game units and removes the alpha fade-in completely
    //
    // So, to ensure the maximum draw distance with a working alpha fade-in, fLodDistanceUnscaled has to be
    // no more than: 325 - (325-170) * draw_distance_setting
    //

    // Change GTA draw distance value from 0.925 to 1.8 into 0 to 1
    float fDrawDistanceSetting = UnlerpClamped ( 0.925f, CSettingsSA ().GetDrawDistance (), 1.8f );

    // Calc max setting allowed for fLodDistanceUnscaled to preserve alpha fade-in
    float fMaximumValue = Lerp ( 325.f, fDrawDistanceSetting, 170.f );

    // Ensure fDistance is in range
    fDistance = Min ( fDistance, fMaximumValue );
#endif
    // Limit to 325.f as is goes horrible after that
    fDistance = Min ( fDistance, 325.f );
    m_pInterface = ppModelInfo [ m_dwModelID ];
    if ( m_pInterface )
        m_pInterface->fLodDistanceUnscaled = fDistance;
}
////////////////////////////////////////////////////////////////
//
// CEffectClonerImpl::MaybeTidyUp
//
// Tidy up if been a little while since last time
//
////////////////////////////////////////////////////////////////
void CEffectClonerImpl::MaybeTidyUp ( bool bForceDrasticMeasures, CEffectTemplate* pKeepThis )
{
    if ( !bForceDrasticMeasures && m_TidyupTimer.Get () < 1000 )
        return;

    m_TidyupTimer.Reset ();

    // Everything in Old List can go if not being used
    for ( uint i = 0 ; i < m_OldList.size () ; i++ )
    {
        CEffectTemplate* pEffectTemplate = m_OldList[i];
        if ( pEffectTemplate != pKeepThis && pEffectTemplate->GetTicksSinceLastUsed () > ( bForceDrasticMeasures ? 0 : 1 ) )
        {
            OutputDebugLine ( "[Shader] CEffectClonerImpl::MaybeTidyUp: Releasing old EffectTemplate" );
            SAFE_RELEASE( pEffectTemplate );
            ListRemoveIndex ( m_OldList, i-- );
        }
    }

    // Complex calculation to guess how long to leave an effect unused before deleting
    // 0=30 mins  100=25 mins  200=16 mins  300=1 sec
    float fTicksAlpha = UnlerpClamped ( 0, m_ValidMap.size (), 300 );
    int iTicks = static_cast < int > ( ( 1 - fTicksAlpha * fTicksAlpha ) * 30 * 60 * 1000 ) + 1000;

#ifdef MTA_DEBUG
    iTicks /= 60;  // Mins to seconds for debug
#endif

    // Valid Effect not used for a little while can go
    for ( std::map < SString, CEffectTemplate* >::iterator iter = m_ValidMap.begin () ; iter != m_ValidMap.end () ; )
    {
        CEffectTemplate* pEffectTemplate = iter->second;
        if ( pEffectTemplate != pKeepThis && pEffectTemplate->GetTicksSinceLastUsed () > ( bForceDrasticMeasures ? 0 : iTicks ) )
        {
            OutputDebugLine ( "[Shader] CEffectClonerImpl::MaybeTidyUp: Releasing valid EffectTemplate" );
            SAFE_RELEASE( pEffectTemplate );
            m_ValidMap.erase ( iter++ );
        }
        else
            ++iter;
    }

    if ( bForceDrasticMeasures )
    {
        CGraphics::GetSingleton().GetDevice()->EvictManagedResources();
    }
}
Ejemplo n.º 3
0
void CBassAudio::Process3D ( const CVector& vecPlayerPosition, const CVector& vecCameraPosition, const CVector& vecLookAt )
{
    assert ( m_b3D && m_pSound );

    float fDistance = DistanceBetweenPoints3D ( vecCameraPosition, m_vecPosition );
    if ( m_bPan )
    {
        // Limit panning when getting close to the min distance
        float fPanSharpness = UnlerpClamped ( m_fMinDistance, fDistance, m_fMinDistance * 2 );
        float fPanLimit = Lerp ( 0.35f, fPanSharpness, 1.0f );

        // Pan
        CVector vecLook = vecLookAt - vecCameraPosition;
        CVector vecSound = m_vecPosition - vecCameraPosition;
        vecLook.fZ = vecSound.fZ = 0.0f;
        vecLook.Normalize ();
        vecSound.Normalize ();

        vecLook.CrossProduct ( &vecSound );
        // The length of the cross product (which is simply fZ in this case)
        // is equal to the sine of the angle between the vectors
        float fPan = Clamp ( -fPanLimit, -vecLook.fZ, fPanLimit );

        BASS_ChannelSetAttribute( m_pSound, BASS_ATTRIB_PAN, fPan );
    }
    else
    {
        // Revert to middle.
        BASS_ChannelSetAttribute( m_pSound, BASS_ATTRIB_PAN, 0.0f );
    }

    // Volume
    float fDistDiff = m_fMaxDistance - m_fMinDistance;

    //Transform e^-x to suit our sound
    float fVolume;
    if ( fDistance <= m_fMinDistance )
        fVolume = 1.0f;
    else if ( fDistance >= m_fMaxDistance )
        fVolume = 0.0f;
    else
        fVolume = exp ( - ( fDistance - m_fMinDistance ) * ( CUT_OFF / fDistDiff ) );

    BASS_ChannelSetAttribute( m_pSound, BASS_ATTRIB_VOL, fVolume * m_fVolume );
}
Ejemplo n.º 4
0
float CSettingsSA::GetMouseSensitivity ( )
{
    float fRawValue = *(FLOAT *)VAR_fMouseSensitivity;
    return UnlerpClamped( MOUSE_SENSITIVITY_MIN, fRawValue, MOUSE_SENSITIVITY_MAX );    // Remap to 0-1
}
float CControllerConfigManagerSA::GetVerticalAimSensitivity()
{
    float fRawValue = GetVerticalAimSensitivityRawValue();
    return UnlerpClamped(VERTICAL_AIM_SENSITIVITY_MIN, fRawValue, VERTICAL_AIM_SENSITIVITY_MAX);            // Remap to 0-1
}