Skip to content

Commit

Permalink
Add setVolumetricShadowsEnabled function (#3528)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Proxy-99 authored Sep 5, 2024
1 parent 80b5adf commit 6c93a49
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 5 deletions.
16 changes: 15 additions & 1 deletion Client/game_sa/CSettingsSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ void CSettingsSA::Save()
}
}

bool CSettingsSA::IsVolumetricShadowsEnabled()
bool CSettingsSA::IsVolumetricShadowsEnabled() const noexcept
{
return m_bVolumetricShadowsEnabled && !m_bVolumetricShadowsSuspended;
}
Expand All @@ -287,6 +287,20 @@ void CSettingsSA::SetVolumetricShadowsEnabled(bool bEnable)
MemPut<BYTE>(0x5E682A + 1, bEnable);
}


bool CSettingsSA::GetVolumetricShadowsEnabledByVideoSetting() const noexcept
{
bool volumetricShadow;
g_pCore->GetCVars()->Get("volumetric_shadows", volumetricShadow);
return volumetricShadow;
}

bool CSettingsSA::ResetVolumetricShadows() noexcept
{
pGame->GetSettings()->SetVolumetricShadowsEnabled(pGame->GetSettings()->GetVolumetricShadowsEnabledByVideoSetting());
return true;
}

void CSettingsSA::SetVolumetricShadowsSuspended(bool bSuspended)
{
m_bVolumetricShadowsSuspended = bSuspended;
Expand Down
5 changes: 4 additions & 1 deletion Client/game_sa/CSettingsSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,10 @@ class CSettingsSA : public CGameSettings
bool IsMipMappingEnabled();
void SetMipMappingEnabled(bool bEnable);

bool IsVolumetricShadowsEnabled();
bool IsVolumetricShadowsEnabled() const noexcept;
bool GetVolumetricShadowsEnabledByVideoSetting() const noexcept;
bool ResetVolumetricShadows() noexcept;

void SetVolumetricShadowsEnabled(bool bEnable);
void SetVolumetricShadowsSuspended(bool bSuspended);

Expand Down
1 change: 1 addition & 0 deletions Client/mods/deathmatch/logic/CClientGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5558,6 +5558,7 @@ void CClientGame::ResetMapInfo()
g_pGame->GetWeather()->ResetWaterFog();
g_pGame->GetWeather()->ResetSandstorm();
g_pGame->GetWeather()->ResetRainbow();
g_pGame->GetSettings()->ResetVolumetricShadows();

// Disable the change of any player stats
g_pMultiplayer->SetLocalStatsStatic(true);
Expand Down
23 changes: 21 additions & 2 deletions Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ void CLuaWorldDefs::LoadFunctions()
{"restoreAllWorldModels", RestoreWorldBuildings},
{"restoreWorldModel", RestoreWorldBuilding},
{"setTimeFrozen", ArgumentParser<SetTimeFrozen>},
{"setVolumetricShadowsEnabled", ArgumentParser<SetVolumetricShadowsEnabled>},

// World create funcs
{"createSWATRope", CreateSWATRope},
Expand All @@ -128,14 +129,16 @@ void CLuaWorldDefs::LoadFunctions()
{"resetBlurLevel", ResetBlurLevel},
{"resetWorldProperty", ArgumentParserWarn<false, ResetWorldProperty>},
{"resetTimeFrozen", ArgumentParser<ResetTimeFrozen>},

{"resetVolumetricShadows", ArgumentParser<ResetVolumetricShadows>},

// World check funcs
{"areTrafficLightsLocked", AreTrafficLightsLocked},
{"isPedTargetingMarkerEnabled", IsPedTargetingMarkerEnabled},
{"isLineOfSightClear", IsLineOfSightClear},
{"isWorldSpecialPropertyEnabled", ArgumentParserWarn<false, IsWorldSpecialPropertyEnabled>},
{"isGarageOpen", IsGarageOpen},
{"isTimeFrozen", ArgumentParser<IsTimeFrozen>}};
{"isTimeFrozen", ArgumentParser<IsTimeFrozen>},
{"isVolumetricShadowsEnabled", ArgumentParser<IsVolumetricShadowsEnabled>}};

// Add functions
for (const auto& [name, func] : functions)
Expand Down Expand Up @@ -2253,3 +2256,19 @@ bool CLuaWorldDefs::ResetTimeFrozen() noexcept
{
return g_pGame->GetClock()->ResetTimeFrozen();
}

bool CLuaWorldDefs::SetVolumetricShadowsEnabled(bool enable) noexcept
{
g_pGame->GetSettings()->SetVolumetricShadowsEnabled(enable);
return true;
}

bool CLuaWorldDefs::IsVolumetricShadowsEnabled() noexcept
{
return g_pGame->GetSettings()->IsVolumetricShadowsEnabled();
}

bool CLuaWorldDefs::ResetVolumetricShadows() noexcept
{
return g_pGame->GetSettings()->ResetVolumetricShadows();
}
4 changes: 4 additions & 0 deletions Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,9 @@ class CLuaWorldDefs : public CLuaDefs
static bool SetTimeFrozen(bool value) noexcept;
static bool IsTimeFrozen() noexcept;
static bool ResetTimeFrozen() noexcept;

static bool SetVolumetricShadowsEnabled(bool enable) noexcept;
static bool IsVolumetricShadowsEnabled() noexcept;
static bool ResetVolumetricShadows() noexcept;
};

4 changes: 3 additions & 1 deletion Client/sdk/game/CSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,11 @@ class CGameSettings
virtual bool IsMipMappingEnabled() = 0;
virtual void SetMipMappingEnabled(bool bEnable) = 0;

virtual bool IsVolumetricShadowsEnabled() = 0;
virtual bool IsVolumetricShadowsEnabled() const noexcept = 0;
virtual bool GetVolumetricShadowsEnabledByVideoSetting() const noexcept = 0;
virtual void SetVolumetricShadowsEnabled(bool bEnable) = 0;
virtual void SetVolumetricShadowsSuspended(bool bSuspended) = 0;
virtual bool ResetVolumetricShadows() noexcept = 0;

virtual bool IsDynamicPedShadowsEnabled() = 0;
virtual void SetDynamicPedShadowsEnabled(bool bEnable) = 0;
Expand Down

0 comments on commit 6c93a49

Please sign in to comment.