Skip to content

Commit

Permalink
Added new console commands: set_weather, r__sunshafts_intensity
Browse files Browse the repository at this point in the history
  • Loading branch information
qweasdd136963 committed Oct 4, 2018
1 parent c462859 commit 587c66c
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 28 deletions.
13 changes: 13 additions & 0 deletions src/Layers/xrRender/xrRender_console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,15 @@ class CCC_DumpResources : public IConsole_Command
}
};

#ifdef DEBUG
class CCC_SunshaftsIntensity : public CCC_Float
{
public:
CCC_SunshaftsIntensity(LPCSTR N, float* V, float _min, float _max) : CCC_Float(N, V, _min, _max) {}
virtual void Save(IWriter*) { ; }
};
#endif

// Allow real-time fog config reload
#if (RENDER == R_R3) || (RENDER == R_R4)
#ifdef DEBUG
Expand Down Expand Up @@ -874,6 +883,10 @@ void xrRender_initconsole()
//float ps_r2_dof_near = 0.f; // 0.f
//float ps_r2_dof_focus = 1.4f; // 1.4f

#ifdef DEBUG
CMD4(CCC_SunshaftsIntensity, "r__sunshafts_intensity", &SunshaftsIntensity, 0.f, 1.f);
#endif

CMD3(CCC_Mask, "r2_volumetric_lights", &ps_r2_ls_flags, R2FLAG_VOLUMETRIC_LIGHTS);
//CMD3(CCC_Mask, "r2_sun_shafts", &ps_r2_ls_flags, R2FLAG_SUN_SHAFTS);
CMD3(CCC_Token, "r2_sun_shafts", &ps_r_sun_shafts, qsun_shafts_token);
Expand Down
1 change: 1 addition & 0 deletions src/xrEngine/Environment.h
Original file line number Diff line number Diff line change
Expand Up @@ -387,5 +387,6 @@ class ENGINE_API CEnvironment

ENGINE_API extern Flags32 psEnvFlags;
ENGINE_API extern float psVisDistance;
ENGINE_API extern float SunshaftsIntensity;

#endif // EnvironmentH
66 changes: 38 additions & 28 deletions src/xrEngine/Environment_misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include "Common/object_broker.h"
#include "Common/LevelGameDef.h"

ENGINE_API float SunshaftsIntensity = 0.f;

void CEnvModifier::load(IReader* fs, u32 version)
{
use_flags.one();
Expand Down Expand Up @@ -438,42 +440,50 @@ void CEnvDescriptorMixer::lerp(
wind_velocity = fi * A.wind_velocity + f * B.wind_velocity;
wind_direction = fi * A.wind_direction + f * B.wind_direction;

m_fSunShaftsIntensity = fi * A.m_fSunShaftsIntensity + f * B.m_fSunShaftsIntensity;
m_fWaterIntensity = fi * A.m_fWaterIntensity + f * B.m_fWaterIntensity;
#ifdef DEBUG
if (SunshaftsIntensity > 0.f)
m_fSunShaftsIntensity = SunshaftsIntensity;
else
#endif
{
m_fSunShaftsIntensity = fi * A.m_fSunShaftsIntensity + f * B.m_fSunShaftsIntensity;
}

m_fTreeAmplitudeIntensity = fi * A.m_fTreeAmplitudeIntensity + f * B.m_fTreeAmplitudeIntensity;
m_fWaterIntensity = fi * A.m_fWaterIntensity + f * B.m_fWaterIntensity;

// colors
//. sky_color.lerp (A.sky_color,B.sky_color,f).add(Mdf.sky_color).mul(modif_power);
sky_color.lerp(A.sky_color, B.sky_color, f);
if (Mdf.use_flags.test(eSkyColor))
sky_color.add(Mdf.sky_color).mul(modif_power);
m_fTreeAmplitudeIntensity = fi * A.m_fTreeAmplitudeIntensity + f * B.m_fTreeAmplitudeIntensity;

//. ambient.lerp (A.ambient,B.ambient,f).add(Mdf.ambient).mul(modif_power);
ambient.lerp(A.ambient, B.ambient, f);
if (Mdf.use_flags.test(eAmbientColor))
ambient.add(Mdf.ambient).mul(modif_power);
// colors
//. sky_color.lerp (A.sky_color,B.sky_color,f).add(Mdf.sky_color).mul(modif_power);
sky_color.lerp(A.sky_color, B.sky_color, f);
if (Mdf.use_flags.test(eSkyColor))
sky_color.add(Mdf.sky_color).mul(modif_power);

hemi_color.lerp(A.hemi_color, B.hemi_color, f);
//. ambient.lerp (A.ambient,B.ambient,f).add(Mdf.ambient).mul(modif_power);
ambient.lerp(A.ambient, B.ambient, f);
if (Mdf.use_flags.test(eAmbientColor))
ambient.add(Mdf.ambient).mul(modif_power);

if (Mdf.use_flags.test(eHemiColor))
{
hemi_color.x += Mdf.hemi_color.x;
hemi_color.y += Mdf.hemi_color.y;
hemi_color.z += Mdf.hemi_color.z;
hemi_color.x *= modif_power;
hemi_color.y *= modif_power;
hemi_color.z *= modif_power;
}
hemi_color.lerp(A.hemi_color, B.hemi_color, f);

sun_color.lerp(A.sun_color, B.sun_color, f);
if (Mdf.use_flags.test(eHemiColor))
{
hemi_color.x += Mdf.hemi_color.x;
hemi_color.y += Mdf.hemi_color.y;
hemi_color.z += Mdf.hemi_color.z;
hemi_color.x *= modif_power;
hemi_color.y *= modif_power;
hemi_color.z *= modif_power;
}

R_ASSERT(_valid(A.sun_dir));
R_ASSERT(_valid(B.sun_dir));
sun_dir.lerp(A.sun_dir, B.sun_dir, f).normalize();
R_ASSERT(_valid(sun_dir));
sun_color.lerp(A.sun_color, B.sun_color, f);

R_ASSERT(_valid(A.sun_dir));
R_ASSERT(_valid(B.sun_dir));
sun_dir.lerp(A.sun_dir, B.sun_dir, f).normalize();
R_ASSERT(_valid(sun_dir));

VERIFY2(sun_dir.y < 0, "Invalid sun direction settings while lerp");
VERIFY2(sun_dir.y < 0, "Invalid sun direction settings while lerp");
}

//-----------------------------------------------------------------------------
Expand Down
17 changes: 17 additions & 0 deletions src/xrGame/console_commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1726,6 +1726,22 @@ class CCC_DbgVar : public IConsole_Command
}
};

// Change weather immediately
class CCC_SetWeather : public IConsole_Command
{
public:
CCC_SetWeather(LPCSTR N) : IConsole_Command(N){};
virtual void Execute(LPCSTR args)
{
if (!xr_strlen(args))
return;
if (!g_pGamePersistent)
return;
if (!Device.editor())
g_pGamePersistent->Environment().SetWeather(args, true);
}
};

void CCC_RegisterCommands()
{
// options
Expand Down Expand Up @@ -1898,6 +1914,7 @@ void CCC_RegisterCommands()
CMD4(CCC_Integer, "ph_tri_clear_disable_count", &ph_console::ph_tri_clear_disable_count, 0, 255);
CMD4(CCC_FloatBlock, "ph_tri_query_ex_aabb_rate", &ph_console::ph_tri_query_ex_aabb_rate, 1.01f, 3.f);
CMD3(CCC_Mask, "g_no_clip", &psActorFlags, AF_NO_CLIP);
CMD1(CCC_SetWeather, "set_weather");
#endif // DEBUG

#ifndef MASTER_GOLD
Expand Down

0 comments on commit 587c66c

Please sign in to comment.