/* ======================== idAimAssist::ComputeEntityAimAssistScore ======================== */ float idAimAssist::ComputeEntityAimAssistScore( const idVec3& targetPos, const idVec3& cameraPos, const idMat3& cameraAxis ) { float score = 0.0f; idVec3 dirToTarget = targetPos - cameraPos; float distanceToTarget = dirToTarget.Length(); // Compute a score in the range of 0..1 for how much are looking towards the target. idVec3 forward = cameraAxis[0]; forward.Normalize(); dirToTarget.Normalize(); float ViewDirDotTargetDir = idMath::ClampFloat( 0.0f, 1.0f, forward * dirToTarget ); // compute the dot and clamp to account for floating point error // the more we look at the target the higher our score score = ViewDirDotTargetDir; // weigh the score from the view angle higher than the distance score static float aimWeight = 0.8f; score *= aimWeight; // Add a score of 0..1 for how close the target is to the player if ( distanceToTarget < aa_targetMaxDistance.GetFloat() ) { float distanceScore = 1.0f - ( distanceToTarget / aa_targetMaxDistance.GetFloat() ); float distanceWeight = 1.0f - aimWeight; score += ( distanceScore * distanceWeight ); } return score * 1000.0f; }
/* ======================== idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings::IsDataChanged ======================== */ bool idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings::IsDataChanged() const { if( originalFramerate != com_engineHz.GetInteger() ) { return true; } if( originalAntialias != r_multiSamples.GetInteger() ) { return true; } if( originalMotionBlur != r_motionBlur.GetInteger() ) { return true; } if( originalVsync != r_swapInterval.GetInteger() ) { return true; } if( originalBrightness != r_lightScale.GetFloat() ) { return true; } if( originalVolume != s_volume_dB.GetFloat() ) { return true; } // RB begin if( originalShadowMapping != r_useShadowMapping.GetInteger() ) { return true; } // RB end return false; }
/* ============== UpdateDisplayFraction Scrolls the console up or down based on conspeed ============== */ void idConsoleLocal::UpdateDisplayFraction() { if( con_speed.GetFloat() <= 0.1f ) { fracTime = Sys_Milliseconds(); displayFrac = finalFrac; return; } // scroll towards the destination height if( finalFrac < displayFrac ) { displayFrac -= con_speed.GetFloat() * ( Sys_Milliseconds() - fracTime ) * 0.001f; if( finalFrac > displayFrac ) { displayFrac = finalFrac; } fracTime = Sys_Milliseconds(); } else if( finalFrac > displayFrac ) { displayFrac += con_speed.GetFloat() * ( Sys_Milliseconds() - fracTime ) * 0.001f; if( finalFrac < displayFrac ) { displayFrac = finalFrac; } fracTime = Sys_Milliseconds(); } }
/* ======================== idAimAssist::UpdateFriction ======================== */ void idAimAssist::UpdateFriction( idEntity* pTarget, const idVec3& targetPos ) { if ( !aa_targetFrictionEnable.GetBool() ) { return; } if ( pTarget == NULL ) { return; } idVec3 cameraPos; idMat3 cameraAxis; player->GetViewPos(cameraPos, cameraAxis); idVec3 dirToTarget = targetPos - cameraPos; float distanceToTarget = dirToTarget.Length(); idVec3 forward = cameraAxis[0]; forward.Normalize(); dirToTarget.Normalize(); float ViewDirDotTargetDir = idMath::ClampFloat( 0.0f, 1.0f, forward * dirToTarget ); // compute the dot and clamp to account for floating point error float aimLength = ViewDirDotTargetDir * distanceToTarget; idVec3 aimPoint = cameraPos + ( forward * aimLength ); float delta = idMath::Sqrt( Square( distanceToTarget ) - Square( aimLength ) ); const float radius = ComputeFrictionRadius( distanceToTarget ); if ( delta < radius ) { float alpha = 1.0f - ( delta / radius ); frictionScalar = Lerp( aa_targetFrictionMultiplierMin.GetFloat(), aa_targetFrictionMultiplierMax.GetFloat(), alpha ); } }
/* ======================== idSoundWorldLocal::CurrentShakeAmplitude ======================== */ float idSoundWorldLocal::CurrentShakeAmplitude() { if( s_constantAmplitude.GetFloat() >= 0.0f ) { return s_constantAmplitude.GetFloat(); } return shakeAmp; }
float GetScreenSeparationForGuis() { const stereoDistances_t dists = CaclulateStereoDistances( stereoRender_interOccularCentimeters.GetFloat(), renderSystem->GetPhysicalScreenWidthInCentimeters(), stereoRender_convergence.GetFloat(), 80.0f /* fov */ ); return dists.screenSeparation; }
/* ======================== AdjustForCushionChannels In the very common case of having more sounds that would contribute to the mix than there are available hardware voices, it can be an audible discontinuity when a channel initially gets a voice or loses a voice. To avoid this, make sure that the last few hardware voices are mixed with a volume of zero, so they won't make a difference as they come and go. It isn't obvious what the exact best volume ramping method should be, just that it smoothly change frame to frame. ======================== */ static float AdjustForCushionChannels( const idStaticList< idActiveChannel, MAX_HARDWARE_VOICES >& activeEmitterChannels, const int uncushionedChannels, const float currentCushionDB, const float driftRate ) { float targetCushionDB; if( activeEmitterChannels.Num() <= uncushionedChannels ) { // we should be able to hear all of them targetCushionDB = DB_SILENCE; } else { // we should be able to hear all of them targetCushionDB = activeEmitterChannels[uncushionedChannels].channel->volumeDB; if( targetCushionDB < DB_SILENCE ) { targetCushionDB = DB_SILENCE; } else if( targetCushionDB > s_cushionFadeLimit.GetFloat() ) { targetCushionDB = s_cushionFadeLimit.GetFloat(); } } // linearly drift the currentTargetCushionDB towards targetCushionDB float driftedDB = currentCushionDB; if( driftedDB < targetCushionDB ) { driftedDB += driftRate; if( driftedDB > targetCushionDB ) { driftedDB = targetCushionDB; } } else { driftedDB -= driftRate; if( driftedDB < targetCushionDB ) { driftedDB = targetCushionDB; } } // ramp the lower sound volumes down for( int i = 0; i < activeEmitterChannels.Num(); i++ ) { idSoundChannel* chan = activeEmitterChannels[i].channel; chan->volumeDB = MapVolumeFromFadeDB( chan->volumeDB, driftedDB ); } return driftedDB; }
/* ======================== idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings::AdjustField ======================== */ void idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings::AdjustField( const int fieldIndex, const int adjustAmount ) { switch ( fieldIndex ) { case SYSTEM_FIELD_FRAMERATE: { //Carl: Oculus Rift DK1 can be hacked to use refresh rates from 60Hz to 83Hz (71Hz max undistorted). CV1 will probably support 90Hz. //Carl: Doom 3 BFG also originally supported 120Hz. So list everything from 60 to 83, with 90 and 120 last. static const int numValues = 26; static const int values[numValues] = { 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 90, 120 }; com_engineHz.SetInteger( AdjustOption( com_engineHz.GetInteger(), values, numValues, adjustAmount ) ); break; } case SYSTEM_FIELD_VSYNC: { static const int numValues = 3; static const int values[numValues] = { 0, 1, 2 }; r_swapInterval.SetInteger( AdjustOption( r_swapInterval.GetInteger(), values, numValues, adjustAmount ) ); break; } case SYSTEM_FIELD_ANTIALIASING: { static const int numValues = 5; static const int values[numValues] = { 0, 2, 4, 8, 16 }; r_multiSamples.SetInteger( AdjustOption( r_multiSamples.GetInteger(), values, numValues, adjustAmount ) ); break; } case SYSTEM_FIELD_MOTIONBLUR: { static const int numValues = 5; static const int values[numValues] = { 0, 2, 3, 4, 5 }; r_motionBlur.SetInteger( AdjustOption( r_motionBlur.GetInteger(), values, numValues, adjustAmount ) ); break; } case SYSTEM_FIELD_LODBIAS: { const float percent = LinearAdjust( r_lodBias.GetFloat(), -1.0f, 1.0f, 0.0f, 100.0f ); const float adjusted = percent + (float)adjustAmount * 5.0f; const float clamped = idMath::ClampFloat( 0.0f, 100.0f, adjusted ); r_lodBias.SetFloat( LinearAdjust( clamped, 0.0f, 100.0f, -1.0f, 1.0f ) ); break; } case SYSTEM_FIELD_BRIGHTNESS: { const float percent = LinearAdjust( r_lightScale.GetFloat(), 2.0f, 4.0f, 0.0f, 100.0f ); const float adjusted = percent + (float)adjustAmount; const float clamped = idMath::ClampFloat( 0.0f, 100.0f, adjusted ); r_lightScale.SetFloat( LinearAdjust( clamped, 0.0f, 100.0f, 2.0f, 4.0f ) ); break; } case SYSTEM_FIELD_VOLUME: { const float percent = 100.0f * Square( 1.0f - ( s_volume_dB.GetFloat() / DB_SILENCE ) ); const float adjusted = percent + (float)adjustAmount; const float clamped = idMath::ClampFloat( 0.0f, 100.0f, adjusted ); s_volume_dB.SetFloat( DB_SILENCE - ( idMath::Sqrt( clamped / 100.0f ) * DB_SILENCE ) ); break; } } cvarSystem->ClearModifiedFlags( CVAR_ARCHIVE ); }
/* ======================== idMenuScreen_Shell_Gamepad::idMenuDataSource_AudioSettings::LoadData ======================== */ void idMenuScreen_Shell_Gamepad::idMenuDataSource_GamepadSettings::LoadData() { idPlayerProfile * profile = session->GetProfileFromMasterLocalUser(); fields[ GAMEPAD_FIELD_INVERT ].SetBool( in_invertLook.GetBool() ); fields[ GAMEPAD_FIELD_LEFTY ].SetBool( profile ? profile->GetLeftyFlip() : false ); fields[ GAMEPAD_FIELD_VIBRATE ].SetBool( in_joystickRumble.GetBool() ); fields[ GAMEPAD_FIELD_HOR_SENS ].SetFloat( 100.0f * ( ( joy_yawSpeed.GetFloat() - 0.0f ) / 400.0f ) ); fields[ GAMEPAD_FIELD_VERT_SENS ].SetFloat( 100.0f * ( ( joy_pitchSpeed.GetFloat() - 0.0f ) / 260.0f ) ); fields[ GAMEPAD_FIELD_ACCELERATION ].SetBool( joy_gammaLook.GetBool() ); fields[ GAMEPAD_FIELD_THRESHOLD ].SetBool( joy_mergedThreshold.GetBool() ); originalFields = fields; }
/* ======================== idResolutionScale::GetCurrentResolutionScale ======================== */ void idResolutionScale::GetCurrentResolutionScale( float& x, float& y ) { assert( currentResolution >= MINIMUM_RESOLUTION_SCALE ); assert( currentResolution <= MAXIMUM_RESOLUTION_SCALE ); x = MAXIMUM_RESOLUTION_SCALE; y = MAXIMUM_RESOLUTION_SCALE; // foresthale 2014-05-28: don't allow resolution scaling with editors, we don't really care about framerate and we don't refresh constantly anyway if (com_editors) return; switch( rs_enable.GetInteger() ) { case 0: return; case 1: x = currentResolution; break; case 2: y = currentResolution; break; case 3: { const float middle = ( MINIMUM_RESOLUTION_SCALE + MAXIMUM_RESOLUTION_SCALE ) * 0.5f; if( currentResolution >= middle ) { // First scale horizontally from max to min x = MINIMUM_RESOLUTION_SCALE + ( currentResolution - middle ) * 2.0f; } else { // Then scale vertically from max to min x = MINIMUM_RESOLUTION_SCALE; y = MINIMUM_RESOLUTION_SCALE + ( currentResolution - MINIMUM_RESOLUTION_SCALE ) * 2.0f; } break; } } float forceFrac = rs_forceFractionX.GetFloat(); if( forceFrac > 0.0f && forceFrac <= MAXIMUM_RESOLUTION_SCALE ) { x = forceFrac; } forceFrac = rs_forceFractionY.GetFloat(); if( forceFrac > 0.0f && forceFrac <= MAXIMUM_RESOLUTION_SCALE ) { y = forceFrac; } }
/* ======================== idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings::LoadData ======================== */ void idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings::LoadData() { originalFramerate = com_engineHz.GetInteger(); originalAntialias = r_multiSamples.GetInteger(); originalMotionBlur = r_motionBlur.GetInteger(); originalVsync = r_swapInterval.GetInteger(); originalBrightness = r_lightScale.GetFloat(); originalVolume = s_volume_dB.GetFloat(); const int fullscreen = r_fullscreen.GetInteger(); if ( fullscreen > 0 ) { R_GetModeListForDisplay( fullscreen - 1, modeList ); } else { modeList.Clear(); } }
/* ======================== idMenuScreen_HUD::UpdateStamina ======================== */ void idMenuScreen_HUD::UpdateStamina( idPlayer* player ) { if( !stamina || !player ) { return; } idSWFSpriteInstance* stamSprite = stamina->GetSprite(); if( stamSprite != NULL ) { if( common->IsMultiplayer() ) { stamSprite->SetVisible( false ); } else { float max_stamina = pm_stamina.GetFloat(); if( !max_stamina ) { stamSprite->SetVisible( false ); } else { stamSprite->SetVisible( true ); float staminaPercent = idMath::Ftoi( 100.0f * player->stamina / max_stamina ); stamSprite->StopFrame( staminaPercent + 1 ); } } } }
/* ============================= idGameBearShootWindow::UpdateButtons ============================= */ void idGameBearShootWindow::UpdateButtons() { if ( onFire ) { idVec2 vec; gui->HandleNamedEvent( "DisableFireButton" ); common->SW()->PlayShaderDirectly( "arcade_sargeshoot" ); bear->SetVisible( true ); bearScale = 1.f; bear->SetSize( BEAR_SIZE, BEAR_SIZE ); vec.x = idMath::Cos( DEG2RAD(turretAngle) ); vec.x += ( 1 - vec.x ) * 0.18f; vec.y = -idMath::Sin( DEG2RAD(turretAngle) ); turretForce = bearTurretForce.GetFloat(); bear->position.x = 80 + ( 96 * vec.x ); bear->position.y = 334 + ( 96 * vec.y ); bear->velocity.x = vec.x * turretForce; bear->velocity.y = vec.y * turretForce; gunblast->position.x = 55 + ( 96 * vec.x ); gunblast->position.y = 310 + ( 100 * vec.y ); gunblast->SetVisible( true ); gunblast->entColor.w = 1.f; gunblast->rotation = turretAngle; gunblast->fadeOut = true; bearHitTarget = false; onFire = false; } }
void IN_MotionSensor_Read(float &roll, float &pitch, float &yaw) { if (SFusion.IsAttachedToSensor()) { float predictionDelta = in_sensorPrediction.GetFloat() * (1.0f / 1000.0f); if (SFusion.GetPredictionDelta() != predictionDelta) { SFusion.SetPrediction(predictionDelta); } Quatf hmdOrient = SFusion.GetPredictedOrientation(); float y = 0.0f, p = 0.0f, r = 0.0f; hmdOrient.GetEulerAngles<Axis_Y, Axis_X, Axis_Z>(&y, &p, &r); roll = -RADIANS_TO_DEGREES(r); // ??? pitch = -RADIANS_TO_DEGREES(p); // should be degrees down yaw = RADIANS_TO_DEGREES(y); // should be degrees left } else if (hasVR920Tracker && IWRGetTracking) { LONG y=0, p=0, r=0; if (IWRGetTracking(&y, &p, &r)==ERROR_SUCCESS) { yaw = y * 180.0f/32767.0f; pitch = p * -180.0f/32767.0f; roll = r * 180.0f/32767.0f; } } else { roll = angles[ROLL]; pitch = angles[PITCH]; yaw = angles[YAW]; } }
void M_DrawOptions(void) { V_DrawPatchDirect (108,15,0,(patch_t*)W_CacheLumpName("M_OPTTTL",PU_CACHE_SHARED)); //V_DrawPatchDirect (::g->OptionsDef.x + 175,::g->OptionsDef.y+LINEHEIGHT*detail,0, // (patch_t*)W_CacheLumpName(detailNames[::g->detailLevel],PU_CACHE_SHARED)); int fullscreenOnOff = r_fullscreen.GetInteger() >= 1 ? 1 : 0; V_DrawPatchDirect (::g->OptionsDef.x + 150,::g->OptionsDef.y+LINEHEIGHT*endgame,0, (patch_t*)W_CacheLumpName(msgNames[fullscreenOnOff],PU_CACHE_SHARED)); V_DrawPatchDirect (::g->OptionsDef.x + 120,::g->OptionsDef.y+LINEHEIGHT*scrnsize,0, (patch_t*)W_CacheLumpName(msgNames[in_useJoystick.GetInteger()],PU_CACHE_SHARED)); V_DrawPatchDirect (::g->OptionsDef.x + 120,::g->OptionsDef.y+LINEHEIGHT*messages,0, (patch_t*)W_CacheLumpName(msgNames[m_show_messages.GetInteger()],PU_CACHE_SHARED)); extern idCVar in_mouseSpeed; const int roundedMouseSpeed = M_GetMouseSpeedForMenu( in_mouseSpeed.GetFloat() ); M_DrawThermo( ::g->OptionsDef.x, ::g->OptionsDef.y + LINEHEIGHT * ( mousesens + 1 ), 16, roundedMouseSpeed ); //M_DrawThermo(::g->OptionsDef.x,::g->OptionsDef.y+LINEHEIGHT*(scrnsize+1), // 9,::g->screenSize); }
/* ======================== idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings::GetField ======================== */ idSWFScriptVar idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings::GetField( const int fieldIndex ) const { switch ( fieldIndex ) { case SYSTEM_FIELD_FULLSCREEN: { const int fullscreen = r_fullscreen.GetInteger(); const int vidmode = r_vidMode.GetInteger(); if ( fullscreen == 0 ) { return "#str_swf_disabled"; } if ( fullscreen < 0 || vidmode < 0 || vidmode >= modeList.Num() ) { return "???"; } if ( modeList[vidmode].displayHz == 60 ) { return va( "%4i x %4i", modeList[vidmode].width, modeList[vidmode].height ); } else { return va( "%4i x %4i @ %dhz", modeList[vidmode].width, modeList[vidmode].height, modeList[vidmode].displayHz ); } } case SYSTEM_FIELD_FRAMERATE: return va( "%d FPS", com_engineHz.GetInteger() ); case SYSTEM_FIELD_VSYNC: if ( r_swapInterval.GetInteger() == 1 ) { return "#str_swf_smart"; } else if ( r_swapInterval.GetInteger() == 2 ) { return "#str_swf_enabled"; } else { return "#str_swf_disabled"; } case SYSTEM_FIELD_ANTIALIASING: if ( r_multiSamples.GetInteger() == 0 ) { return "#str_swf_disabled"; } return va( "%dx", r_multiSamples.GetInteger() ); case SYSTEM_FIELD_MOTIONBLUR: if ( r_motionBlur.GetInteger() == 0 ) { return "#str_swf_disabled"; } return va( "%dx", idMath::IPow( 2, r_motionBlur.GetInteger() ) ); case SYSTEM_FIELD_LODBIAS: return LinearAdjust( r_lodBias.GetFloat(), -1.0f, 1.0f, 0.0f, 100.0f ); case SYSTEM_FIELD_BRIGHTNESS: return LinearAdjust( r_lightScale.GetFloat(), 2.0f, 4.0f, 0.0f, 100.0f ); case SYSTEM_FIELD_VOLUME: { return 100.0f * Square( 1.0f - ( s_volume_dB.GetFloat() / DB_SILENCE ) ); } } return false; }
/* ======================== idResolutionScale::SetCurrentGPUFrameTime ======================== */ void idResolutionScale::SetCurrentGPUFrameTime( int microseconds ) { float old = currentResolution; float milliseconds = microseconds * 0.001f; if( milliseconds > dropMilliseconds ) { // We missed our target, so drop the resolution. // The target should be set conservatively so this does not // necessarily imply a missed VBL. // // we might consider making the drop in some way // proportional to how badly we missed currentResolution -= rs_dropFraction.GetFloat(); if( currentResolution < MINIMUM_RESOLUTION_SCALE ) { currentResolution = MINIMUM_RESOLUTION_SCALE; } } else if( milliseconds < raiseMilliseconds ) { // We seem to have speed to spare, so increase the resolution // if we stay here consistantly. The raise fraction should // be smaller than the drop fraction to avoid ping-ponging // back and forth. if( ++framesAboveRaise >= rs_raiseFrames.GetInteger() ) { framesAboveRaise = 0; currentResolution += rs_raiseFraction.GetFloat(); if( currentResolution > MAXIMUM_RESOLUTION_SCALE ) { currentResolution = MAXIMUM_RESOLUTION_SCALE; } } } else { // we are inside the target range framesAboveRaise = 0; } if( rs_showResolutionChanges.GetInteger() > 1 || ( rs_showResolutionChanges.GetInteger() == 1 && currentResolution != old ) ) { idLib::Printf( "GPU msec: %4.1f resolutionScale: %4.2f\n", milliseconds, currentResolution ); } }
/* ================ idUsercmdGenLocal::AdjustAngles Moves the local angle positions ================ */ void idUsercmdGenLocal::AdjustAngles( void ) { float speed; if ( toggled_run.on ^ ( in_alwaysRun.GetBool() && idAsyncNetwork::IsActive() ) ) { speed = idMath::M_MS2SEC * USERCMD_MSEC * in_angleSpeedKey.GetFloat(); } else { speed = idMath::M_MS2SEC * USERCMD_MSEC; } if ( !ButtonState( UB_STRAFE ) ) { viewangles[YAW] -= speed * in_yawSpeed.GetFloat() * ButtonState( UB_RIGHT ); viewangles[YAW] += speed * in_yawSpeed.GetFloat() * ButtonState( UB_LEFT ); } viewangles[PITCH] -= speed * in_pitchSpeed.GetFloat() * ButtonState( UB_LOOKUP ); viewangles[PITCH] += speed * in_pitchSpeed.GetFloat() * ButtonState( UB_LOOKDOWN ); }
/* ======================== idResolutionScale::GetCurrentResolutionScale ======================== */ void idResolutionScale::GetCurrentResolutionScale( float& x, float& y ) { assert( currentResolution >= MINIMUM_RESOLUTION_SCALE ); assert( currentResolution <= MAXIMUM_RESOLUTION_SCALE ); x = MAXIMUM_RESOLUTION_SCALE; y = MAXIMUM_RESOLUTION_SCALE; switch( rs_enable.GetInteger() ) { case 0: return; case 1: x = currentResolution; break; case 2: y = currentResolution; break; case 3: { const float middle = ( MINIMUM_RESOLUTION_SCALE + MAXIMUM_RESOLUTION_SCALE ) * 0.5f; if( currentResolution >= middle ) { // First scale horizontally from max to min x = MINIMUM_RESOLUTION_SCALE + ( currentResolution - middle ) * 2.0f; } else { // Then scale vertically from max to min x = MINIMUM_RESOLUTION_SCALE; y = MINIMUM_RESOLUTION_SCALE + ( currentResolution - MINIMUM_RESOLUTION_SCALE ) * 2.0f; } break; } } float forceFrac = rs_forceFractionX.GetFloat(); if( forceFrac > 0.0f && forceFrac <= MAXIMUM_RESOLUTION_SCALE ) { x = forceFrac; } forceFrac = rs_forceFractionY.GetFloat(); if( forceFrac > 0.0f && forceFrac <= MAXIMUM_RESOLUTION_SCALE ) { y = forceFrac; } }
/* ======================== idMenuScreen_Shell_Controls::idMenuDataSource_AudioSettings::LoadData ======================== */ void idMenuScreen_Shell_Controls::idMenuDataSource_ControlSettings::LoadData() { fields[ CONTROLS_FIELD_INVERT_MOUSE ].SetBool( in_mouseInvertLook.GetBool() ); float mouseSpeed = ( ( in_mouseSpeed.GetFloat() - 0.25f ) / ( 4.0f - 0.25 ) ) * 100.0f; fields[ CONTROLS_FIELD_MOUSE_SENS ].SetFloat( mouseSpeed ); fields[ CONTROLS_FIELD_GAMEPAD_ENABLED ].SetBool( in_useJoystick.GetBool() ); originalFields = fields; }
/* ======================== idMenuScreen_Shell_Stereoscopics::idMenuDataSource_StereoSettings::LoadData ======================== */ void idMenuScreen_Shell_Stereoscopics::idMenuDataSource_StereoSettings::LoadData() { fields[ STEREO_FIELD_ENABLE ].SetInteger( renderSystem->GetStereoScopicRenderingMode() ); fields[ STEREO_FIELD_SEPERATION ].SetFloat( 100.0f * ( stereoRender_interOccularCentimeters.GetFloat() / MAX_INTEROCCULAR_DISTANCE ) ); fields[ STEREO_FIELD_SWAP_EYES ].SetBool( stereoRender_swapEyes.GetBool() ); originalFields = fields; }
/* ================= idUsercmdGenLocal::JoystickMove ================= */ void idUsercmdGenLocal::JoystickMove( void ) { float anglespeed; if ( toggled_run.on ^ ( in_alwaysRun.GetBool() && idAsyncNetwork::IsActive() ) ) { anglespeed = idMath::M_MS2SEC * USERCMD_MSEC * in_angleSpeedKey.GetFloat(); } else { anglespeed = idMath::M_MS2SEC * USERCMD_MSEC; } if ( !ButtonState( UB_STRAFE ) ) { viewangles[YAW] += anglespeed * in_yawSpeed.GetFloat() * joystickAxis[AXIS_SIDE]; viewangles[PITCH] += anglespeed * in_pitchSpeed.GetFloat() * joystickAxis[AXIS_FORWARD]; } else { cmd.rightmove = idMath::ClampChar( cmd.rightmove + joystickAxis[AXIS_SIDE] ); cmd.forwardmove = idMath::ClampChar( cmd.forwardmove + joystickAxis[AXIS_FORWARD] ); } cmd.upmove = idMath::ClampChar( cmd.upmove + joystickAxis[AXIS_UP] ); }
/* ================ DrawNotify Draws the last few lines of output transparently over the game top ================ */ void idConsoleLocal::DrawNotify() { int x, v; short* text_p; int i; int time; int currentColor; if( con_noPrint.GetBool() ) { return; } currentColor = idStr::ColorIndex( C_COLOR_WHITE ); renderSystem->SetColor( idStr::ColorForIndex( currentColor ) ); v = 0; for( i = current - NUM_CON_TIMES + 1; i <= current; i++ ) { if( i < 0 ) { continue; } time = times[i % NUM_CON_TIMES]; if( time == 0 ) { continue; } time = Sys_Milliseconds() - time; if( time > con_notifyTime.GetFloat() * 1000 ) { continue; } text_p = text + ( i % TOTAL_LINES ) * LINE_WIDTH; for( x = 0; x < LINE_WIDTH; x++ ) { if( ( text_p[x] & 0xff ) == ' ' ) { continue; } if( idStr::ColorIndex( text_p[x] >> 8 ) != currentColor ) { currentColor = idStr::ColorIndex( text_p[x] >> 8 ); renderSystem->SetColor( idStr::ColorForIndex( currentColor ) ); } renderSystem->DrawSmallChar( LOCALSAFE_LEFT + ( x + 1 )*SMALLCHAR_WIDTH, v, text_p[x] & 0xff ); } v += SMALLCHAR_HEIGHT; } renderSystem->SetColor( colorCyan ); }
/* ======================== idSWFTextInstance::GetTextLength ======================== */ float idSWFTextInstance::GetTextLength() { // CURRENTLY ONLY WORKS FOR SINGLE LINE TEXTFIELDS if ( lengthCalculated && variable.IsEmpty() ) { return textLength; } idStr txtLengthCheck = ""; float len = 0.0f; if ( verify( swf != NULL ) ) { if ( !variable.IsEmpty() ) { idSWFScriptVar var = swf->GetGlobal( variable ); if ( var.IsUndefined() ) { txtLengthCheck = text; } else { txtLengthCheck = var.ToString(); } txtLengthCheck = idLocalization::GetString( txtLengthCheck ); } else { txtLengthCheck = idLocalization::GetString( text ); } const idSWFEditText * shape = editText; idSWFDictionaryEntry * fontEntry = swf->FindDictionaryEntry( shape->fontID, SWF_DICT_FONT ); idSWFFont * swfFont = fontEntry->font; float width = fabs( shape->bounds.br.x - shape->bounds.tl.x ); float postTrans = SWFTWIP( shape->fontHeight ); const idFont * fontInfo = swfFont->fontID; float glyphScale = postTrans / 48.0f; int tlen = txtLengthCheck.Length(); int index = 0; while ( index < tlen ) { scaledGlyphInfo_t glyph; fontInfo->GetScaledGlyph( glyphScale, txtLengthCheck.UTF8Char( index ), glyph ); len += glyph.xSkip; if ( useStroke ) { len += ( swf_textStrokeSizeGlyphSpacer.GetFloat() * strokeWeight * glyphScale ); } if ( !( shape->flags & SWF_ET_AUTOSIZE ) && len >= width ) { len = width; break; } } } lengthCalculated = true; textLength = len; return textLength; }
/* =================== idPlayerView::EmitStereoEyeView =================== */ void idPlayerView::EmitStereoEyeView( const int eye, idMenuHandler_HUD * hudManager ) { renderView_t * view = player->GetRenderView(); if ( view == NULL ) { return; } renderView_t eyeView = *view; const stereoDistances_t dists = CaclulateStereoDistances( stereoRender_interOccularCentimeters.GetFloat(), renderSystem->GetPhysicalScreenWidthInCentimeters(), stereoRender_convergence.GetFloat(), view->fov_x ); eyeView.vieworg += eye * dists.worldSeparation * eyeView.viewaxis[1]; eyeView.viewEyeBuffer = stereoRender_swapEyes.GetBool() ? eye : -eye; eyeView.stereoScreenSeparation = eye * dists.screenSeparation; SingleView( &eyeView, hudManager ); }
/* ================ idCommonLocal::StartWipe Draws and captures the current state, then starts a wipe with that image ================ */ void idCommonLocal::StartWipe( const char *_wipeMaterial, bool hold ) { console->Close(); Draw(); renderSystem->CaptureRenderToImage( "_currentRender" ); wipeMaterial = declManager->FindMaterial( _wipeMaterial, false ); wipeStartTime = Sys_Milliseconds(); wipeStopTime = wipeStartTime + SEC2MS( com_wipeSeconds.GetFloat() ); wipeHold = hold; }
/* ======================== idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings::LoadData ======================== */ void idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings::LoadData() { originalFramerate = com_engineHz.GetInteger(); originalAntialias = r_antiAliasing.GetInteger(); originalMotionBlur = r_motionBlur.GetInteger(); originalVsync = r_swapInterval.GetInteger(); originalBrightness = r_exposure.GetFloat(); originalVolume = s_volume_dB.GetFloat(); // RB begin originalShadowMapping = r_useShadowMapping.GetInteger(); // RB end const int fullscreen = r_fullscreen.GetInteger(); if( fullscreen > 0 ) { R_GetModeListForDisplay( fullscreen - 1, modeList ); } else { modeList.Clear(); } }
/* ======================== idAimAssist::UpdateNewAimAssist ======================== */ void idAimAssist::UpdateNewAimAssist() { angleCorrection = ang_zero; frictionScalar = 1.0f; idEntity* lastTarget = targetEntity; targetEntity = NULL; // is aim assisting allowed? If not then just bail out if( !aa_targetAimAssistEnable.GetBool() ) { return; } bool forceLastTarget = false; idVec3 targetPos; idEntity* entity = NULL; if( forceLastTarget ) { entity = lastTarget; targetPos = lastTargetPos; } else { entity = FindAimAssistTarget( targetPos ); } if( entity != NULL ) { UpdateFriction( entity, targetPos ); // by default we don't allow adhesion when we are standing still const float playerMovementSpeedThreshold = Square( aa_targetAdhesionPlayerSpeedThreshold.GetFloat() ); float playerSpeed = player->GetPhysics()->GetLinearVelocity().LengthSqr(); // only allow adhesion on actors (ai) or players. Disallow adhesion on any static world entities such as explosive barrels if( playerSpeed > playerMovementSpeedThreshold ) { UpdateAdhesion( entity, targetPos ); } targetEntity = entity; } lastTargetPos = targetPos; }
/* ======================== MapVolumeFromFadeDB Ramp down volumes that are close to fadeDB so that fadeDB is DB_SILENCE ======================== */ float MapVolumeFromFadeDB( const float volumeDB, const float fadeDB ) { if ( volumeDB <= fadeDB ) { return DB_SILENCE; } const float fadeOver = s_cushionFadeOver.GetFloat(); const float fadeFrom = fadeDB + fadeOver; if ( volumeDB >= fadeFrom ) { // unchanged return volumeDB; } const float fadeFraction = ( volumeDB - fadeDB ) / fadeOver; const float mappedDB = DB_SILENCE + ( fadeFrom - DB_SILENCE ) * fadeFraction; return mappedDB; }
/* ======================== idAimAssist::ComputeFrictionRadius ======================== */ float idAimAssist::ComputeFrictionRadius( float distanceToTarget ) { if ( ( distanceToTarget <= idMath::FLT_SMALLEST_NON_DENORMAL ) || distanceToTarget > aa_targetFrictionMaxDistance.GetFloat() ) { return aa_targetFrictionRadius.GetFloat(); } float distanceContributionScalar = ( aa_targetFrictionOptimalDistance.GetFloat() > 0.0f ) ? ( distanceToTarget / aa_targetFrictionOptimalDistance.GetFloat() ) : 0.0f; if ( distanceToTarget > aa_targetFrictionOptimalDistance.GetFloat() ) { const float range = idMath::ClampFloat( 0.0f, aa_targetFrictionMaxDistance.GetFloat(), aa_targetFrictionMaxDistance.GetFloat() - aa_targetFrictionOptimalDistance.GetFloat() ); if ( range > idMath::FLT_SMALLEST_NON_DENORMAL ) { distanceContributionScalar = 1.0f - ( ( distanceToTarget - aa_targetFrictionOptimalDistance.GetFloat() ) / range ); } } return Lerp( aa_targetFrictionRadius.GetFloat(), aa_targetFrictionOptimalRadius.GetFloat(), distanceContributionScalar ); }