Skip to content

Commit 6c93a49

Browse files
authored
Add setVolumetricShadowsEnabled function (#3528)
* add shadow by script * fixes * apply checkbox setting in reconnect * notation fix * add function IsVolumetricShadowsEnabled * review * logic error * fixes * space * Revert "Merge remote-tracking branch 'upstream/master' into shadow" This reverts commit fbad125, reversing changes made to 60e29ed. * Reapply "Merge remote-tracking branch 'upstream/master' into shadow" This reverts commit d026afc. * conflicts * conflicts fixes * review fixes adding resetVolumetricShadows() function
1 parent 80b5adf commit 6c93a49

File tree

6 files changed

+48
-5
lines changed

6 files changed

+48
-5
lines changed

Client/game_sa/CSettingsSA.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ void CSettingsSA::Save()
273273
}
274274
}
275275

276-
bool CSettingsSA::IsVolumetricShadowsEnabled()
276+
bool CSettingsSA::IsVolumetricShadowsEnabled() const noexcept
277277
{
278278
return m_bVolumetricShadowsEnabled && !m_bVolumetricShadowsSuspended;
279279
}
@@ -287,6 +287,20 @@ void CSettingsSA::SetVolumetricShadowsEnabled(bool bEnable)
287287
MemPut<BYTE>(0x5E682A + 1, bEnable);
288288
}
289289

290+
291+
bool CSettingsSA::GetVolumetricShadowsEnabledByVideoSetting() const noexcept
292+
{
293+
bool volumetricShadow;
294+
g_pCore->GetCVars()->Get("volumetric_shadows", volumetricShadow);
295+
return volumetricShadow;
296+
}
297+
298+
bool CSettingsSA::ResetVolumetricShadows() noexcept
299+
{
300+
pGame->GetSettings()->SetVolumetricShadowsEnabled(pGame->GetSettings()->GetVolumetricShadowsEnabledByVideoSetting());
301+
return true;
302+
}
303+
290304
void CSettingsSA::SetVolumetricShadowsSuspended(bool bSuspended)
291305
{
292306
m_bVolumetricShadowsSuspended = bSuspended;

Client/game_sa/CSettingsSA.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,10 @@ class CSettingsSA : public CGameSettings
138138
bool IsMipMappingEnabled();
139139
void SetMipMappingEnabled(bool bEnable);
140140

141-
bool IsVolumetricShadowsEnabled();
141+
bool IsVolumetricShadowsEnabled() const noexcept;
142+
bool GetVolumetricShadowsEnabledByVideoSetting() const noexcept;
143+
bool ResetVolumetricShadows() noexcept;
144+
142145
void SetVolumetricShadowsEnabled(bool bEnable);
143146
void SetVolumetricShadowsSuspended(bool bSuspended);
144147

Client/mods/deathmatch/logic/CClientGame.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5558,6 +5558,7 @@ void CClientGame::ResetMapInfo()
55585558
g_pGame->GetWeather()->ResetWaterFog();
55595559
g_pGame->GetWeather()->ResetSandstorm();
55605560
g_pGame->GetWeather()->ResetRainbow();
5561+
g_pGame->GetSettings()->ResetVolumetricShadows();
55615562

55625563
// Disable the change of any player stats
55635564
g_pMultiplayer->SetLocalStatsStatic(true);

Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.cpp

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ void CLuaWorldDefs::LoadFunctions()
105105
{"restoreAllWorldModels", RestoreWorldBuildings},
106106
{"restoreWorldModel", RestoreWorldBuilding},
107107
{"setTimeFrozen", ArgumentParser<SetTimeFrozen>},
108+
{"setVolumetricShadowsEnabled", ArgumentParser<SetVolumetricShadowsEnabled>},
108109

109110
// World create funcs
110111
{"createSWATRope", CreateSWATRope},
@@ -128,14 +129,16 @@ void CLuaWorldDefs::LoadFunctions()
128129
{"resetBlurLevel", ResetBlurLevel},
129130
{"resetWorldProperty", ArgumentParserWarn<false, ResetWorldProperty>},
130131
{"resetTimeFrozen", ArgumentParser<ResetTimeFrozen>},
131-
132+
{"resetVolumetricShadows", ArgumentParser<ResetVolumetricShadows>},
133+
132134
// World check funcs
133135
{"areTrafficLightsLocked", AreTrafficLightsLocked},
134136
{"isPedTargetingMarkerEnabled", IsPedTargetingMarkerEnabled},
135137
{"isLineOfSightClear", IsLineOfSightClear},
136138
{"isWorldSpecialPropertyEnabled", ArgumentParserWarn<false, IsWorldSpecialPropertyEnabled>},
137139
{"isGarageOpen", IsGarageOpen},
138-
{"isTimeFrozen", ArgumentParser<IsTimeFrozen>}};
140+
{"isTimeFrozen", ArgumentParser<IsTimeFrozen>},
141+
{"isVolumetricShadowsEnabled", ArgumentParser<IsVolumetricShadowsEnabled>}};
139142

140143
// Add functions
141144
for (const auto& [name, func] : functions)
@@ -2253,3 +2256,19 @@ bool CLuaWorldDefs::ResetTimeFrozen() noexcept
22532256
{
22542257
return g_pGame->GetClock()->ResetTimeFrozen();
22552258
}
2259+
2260+
bool CLuaWorldDefs::SetVolumetricShadowsEnabled(bool enable) noexcept
2261+
{
2262+
g_pGame->GetSettings()->SetVolumetricShadowsEnabled(enable);
2263+
return true;
2264+
}
2265+
2266+
bool CLuaWorldDefs::IsVolumetricShadowsEnabled() noexcept
2267+
{
2268+
return g_pGame->GetSettings()->IsVolumetricShadowsEnabled();
2269+
}
2270+
2271+
bool CLuaWorldDefs::ResetVolumetricShadows() noexcept
2272+
{
2273+
return g_pGame->GetSettings()->ResetVolumetricShadows();
2274+
}

Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,5 +134,9 @@ class CLuaWorldDefs : public CLuaDefs
134134
static bool SetTimeFrozen(bool value) noexcept;
135135
static bool IsTimeFrozen() noexcept;
136136
static bool ResetTimeFrozen() noexcept;
137+
138+
static bool SetVolumetricShadowsEnabled(bool enable) noexcept;
139+
static bool IsVolumetricShadowsEnabled() noexcept;
140+
static bool ResetVolumetricShadows() noexcept;
137141
};
138142

Client/sdk/game/CSettings.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,11 @@ class CGameSettings
132132
virtual bool IsMipMappingEnabled() = 0;
133133
virtual void SetMipMappingEnabled(bool bEnable) = 0;
134134

135-
virtual bool IsVolumetricShadowsEnabled() = 0;
135+
virtual bool IsVolumetricShadowsEnabled() const noexcept = 0;
136+
virtual bool GetVolumetricShadowsEnabledByVideoSetting() const noexcept = 0;
136137
virtual void SetVolumetricShadowsEnabled(bool bEnable) = 0;
137138
virtual void SetVolumetricShadowsSuspended(bool bSuspended) = 0;
139+
virtual bool ResetVolumetricShadows() noexcept = 0;
138140

139141
virtual bool IsDynamicPedShadowsEnabled() = 0;
140142
virtual void SetDynamicPedShadowsEnabled(bool bEnable) = 0;

0 commit comments

Comments
 (0)