Skip to content

Commit 587c66c

Browse files
committed
Added new console commands: set_weather, r__sunshafts_intensity
1 parent c462859 commit 587c66c

File tree

4 files changed

+69
-28
lines changed

4 files changed

+69
-28
lines changed

src/Layers/xrRender/xrRender_console.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,15 @@ class CCC_DumpResources : public IConsole_Command
664664
}
665665
};
666666

667+
#ifdef DEBUG
668+
class CCC_SunshaftsIntensity : public CCC_Float
669+
{
670+
public:
671+
CCC_SunshaftsIntensity(LPCSTR N, float* V, float _min, float _max) : CCC_Float(N, V, _min, _max) {}
672+
virtual void Save(IWriter*) { ; }
673+
};
674+
#endif
675+
667676
// Allow real-time fog config reload
668677
#if (RENDER == R_R3) || (RENDER == R_R4)
669678
#ifdef DEBUG
@@ -874,6 +883,10 @@ void xrRender_initconsole()
874883
//float ps_r2_dof_near = 0.f; // 0.f
875884
//float ps_r2_dof_focus = 1.4f; // 1.4f
876885

886+
#ifdef DEBUG
887+
CMD4(CCC_SunshaftsIntensity, "r__sunshafts_intensity", &SunshaftsIntensity, 0.f, 1.f);
888+
#endif
889+
877890
CMD3(CCC_Mask, "r2_volumetric_lights", &ps_r2_ls_flags, R2FLAG_VOLUMETRIC_LIGHTS);
878891
//CMD3(CCC_Mask, "r2_sun_shafts", &ps_r2_ls_flags, R2FLAG_SUN_SHAFTS);
879892
CMD3(CCC_Token, "r2_sun_shafts", &ps_r_sun_shafts, qsun_shafts_token);

src/xrEngine/Environment.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,5 +387,6 @@ class ENGINE_API CEnvironment
387387

388388
ENGINE_API extern Flags32 psEnvFlags;
389389
ENGINE_API extern float psVisDistance;
390+
ENGINE_API extern float SunshaftsIntensity;
390391

391392
#endif // EnvironmentH

src/xrEngine/Environment_misc.cpp

Lines changed: 38 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#include "Common/object_broker.h"
1111
#include "Common/LevelGameDef.h"
1212

13+
ENGINE_API float SunshaftsIntensity = 0.f;
14+
1315
void CEnvModifier::load(IReader* fs, u32 version)
1416
{
1517
use_flags.one();
@@ -438,42 +440,50 @@ void CEnvDescriptorMixer::lerp(
438440
wind_velocity = fi * A.wind_velocity + f * B.wind_velocity;
439441
wind_direction = fi * A.wind_direction + f * B.wind_direction;
440442

441-
m_fSunShaftsIntensity = fi * A.m_fSunShaftsIntensity + f * B.m_fSunShaftsIntensity;
442-
m_fWaterIntensity = fi * A.m_fWaterIntensity + f * B.m_fWaterIntensity;
443+
#ifdef DEBUG
444+
if (SunshaftsIntensity > 0.f)
445+
m_fSunShaftsIntensity = SunshaftsIntensity;
446+
else
447+
#endif
448+
{
449+
m_fSunShaftsIntensity = fi * A.m_fSunShaftsIntensity + f * B.m_fSunShaftsIntensity;
450+
}
443451

444-
m_fTreeAmplitudeIntensity = fi * A.m_fTreeAmplitudeIntensity + f * B.m_fTreeAmplitudeIntensity;
452+
m_fWaterIntensity = fi * A.m_fWaterIntensity + f * B.m_fWaterIntensity;
445453

446-
// colors
447-
//. sky_color.lerp (A.sky_color,B.sky_color,f).add(Mdf.sky_color).mul(modif_power);
448-
sky_color.lerp(A.sky_color, B.sky_color, f);
449-
if (Mdf.use_flags.test(eSkyColor))
450-
sky_color.add(Mdf.sky_color).mul(modif_power);
454+
m_fTreeAmplitudeIntensity = fi * A.m_fTreeAmplitudeIntensity + f * B.m_fTreeAmplitudeIntensity;
451455

452-
//. ambient.lerp (A.ambient,B.ambient,f).add(Mdf.ambient).mul(modif_power);
453-
ambient.lerp(A.ambient, B.ambient, f);
454-
if (Mdf.use_flags.test(eAmbientColor))
455-
ambient.add(Mdf.ambient).mul(modif_power);
456+
// colors
457+
//. sky_color.lerp (A.sky_color,B.sky_color,f).add(Mdf.sky_color).mul(modif_power);
458+
sky_color.lerp(A.sky_color, B.sky_color, f);
459+
if (Mdf.use_flags.test(eSkyColor))
460+
sky_color.add(Mdf.sky_color).mul(modif_power);
456461

457-
hemi_color.lerp(A.hemi_color, B.hemi_color, f);
462+
//. ambient.lerp (A.ambient,B.ambient,f).add(Mdf.ambient).mul(modif_power);
463+
ambient.lerp(A.ambient, B.ambient, f);
464+
if (Mdf.use_flags.test(eAmbientColor))
465+
ambient.add(Mdf.ambient).mul(modif_power);
458466

459-
if (Mdf.use_flags.test(eHemiColor))
460-
{
461-
hemi_color.x += Mdf.hemi_color.x;
462-
hemi_color.y += Mdf.hemi_color.y;
463-
hemi_color.z += Mdf.hemi_color.z;
464-
hemi_color.x *= modif_power;
465-
hemi_color.y *= modif_power;
466-
hemi_color.z *= modif_power;
467-
}
467+
hemi_color.lerp(A.hemi_color, B.hemi_color, f);
468468

469-
sun_color.lerp(A.sun_color, B.sun_color, f);
469+
if (Mdf.use_flags.test(eHemiColor))
470+
{
471+
hemi_color.x += Mdf.hemi_color.x;
472+
hemi_color.y += Mdf.hemi_color.y;
473+
hemi_color.z += Mdf.hemi_color.z;
474+
hemi_color.x *= modif_power;
475+
hemi_color.y *= modif_power;
476+
hemi_color.z *= modif_power;
477+
}
470478

471-
R_ASSERT(_valid(A.sun_dir));
472-
R_ASSERT(_valid(B.sun_dir));
473-
sun_dir.lerp(A.sun_dir, B.sun_dir, f).normalize();
474-
R_ASSERT(_valid(sun_dir));
479+
sun_color.lerp(A.sun_color, B.sun_color, f);
480+
481+
R_ASSERT(_valid(A.sun_dir));
482+
R_ASSERT(_valid(B.sun_dir));
483+
sun_dir.lerp(A.sun_dir, B.sun_dir, f).normalize();
484+
R_ASSERT(_valid(sun_dir));
475485

476-
VERIFY2(sun_dir.y < 0, "Invalid sun direction settings while lerp");
486+
VERIFY2(sun_dir.y < 0, "Invalid sun direction settings while lerp");
477487
}
478488

479489
//-----------------------------------------------------------------------------

src/xrGame/console_commands.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1726,6 +1726,22 @@ class CCC_DbgVar : public IConsole_Command
17261726
}
17271727
};
17281728

1729+
// Change weather immediately
1730+
class CCC_SetWeather : public IConsole_Command
1731+
{
1732+
public:
1733+
CCC_SetWeather(LPCSTR N) : IConsole_Command(N){};
1734+
virtual void Execute(LPCSTR args)
1735+
{
1736+
if (!xr_strlen(args))
1737+
return;
1738+
if (!g_pGamePersistent)
1739+
return;
1740+
if (!Device.editor())
1741+
g_pGamePersistent->Environment().SetWeather(args, true);
1742+
}
1743+
};
1744+
17291745
void CCC_RegisterCommands()
17301746
{
17311747
// options
@@ -1898,6 +1914,7 @@ void CCC_RegisterCommands()
18981914
CMD4(CCC_Integer, "ph_tri_clear_disable_count", &ph_console::ph_tri_clear_disable_count, 0, 255);
18991915
CMD4(CCC_FloatBlock, "ph_tri_query_ex_aabb_rate", &ph_console::ph_tri_query_ex_aabb_rate, 1.01f, 3.f);
19001916
CMD3(CCC_Mask, "g_no_clip", &psActorFlags, AF_NO_CLIP);
1917+
CMD1(CCC_SetWeather, "set_weather");
19011918
#endif // DEBUG
19021919

19031920
#ifndef MASTER_GOLD

0 commit comments

Comments
 (0)