Skip to content

Commit ea1b5a6

Browse files
avoitishinXottab-DUTY
authored andcommitted
+ tree amplitude (sway amount) aka LA. For best visuals, set tree_amplitude_intensity, wind_direction, and wind_velocity for each weather config. Can be completely disabled with TREE_WIND_EFFECT define
1 parent a91ff26 commit ea1b5a6

File tree

7 files changed

+91
-5
lines changed

7 files changed

+91
-5
lines changed

src/Common/Config.hpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,17 @@
99
//#define MOUSE_MOVE_CALLBACK // expose mouse move callback to scripts (configure in bind_stalker)
1010
//#define KEY_RELEASE_CALLBACK // expose key release callback to scripts (configure in bind_stalker)
1111
//#define KEY_HOLD_CALLBACK // expose key hold callback to scripts (configure in bind_stalker)
12-
//#define FP_DEATH // first person death view
12+
13+
// VISUAL:
1314
#define DETAIL_RADIUS // detail draw radius (by K.D.)
14-
#define ECO_RENDER //ECO_RENDER adds a small delay between rendering, reduce FPS in main menu or in videos
15-
#define NEW_ANIMS // use new animations. Please enclose any new animation additions with this define
16-
#define NEW_SOUNDS // use new sounds. Please enclose any new sound additions with this define
15+
#define ECO_RENDER // limit FPS in menu to prevent video card overheat (by alpet)
16+
#define TREE_WIND_EFFECT // configurable tree sway, can be used to have trees sway more during storms or lightly on clear days.
17+
//-VISUAL
18+
19+
// TWEAKS:
20+
//#define FP_DEATH // first person death view
1721
#define DEAD_BODY_COLLISION // restore collision with dead bodies (thanks malandrinus)
22+
#define NEW_ANIMS // use new animations. Please enclose any new animation addions with this define
23+
#define NEW_SOUNDS // use new sounds. Please enclose any new sound addions with this define
1824
//#define CONFIG_SUN_MOVEMENT // With this defined sun will move as configured in weather ltx files
25+
//-TWEAKS

src/Layers/xrRender/FTreeVisual.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#include "xrCore/FMesh.hpp"
88
#include "FTreeVisual.h"
99

10+
#include "Common/Config.hpp"
11+
1012
shared_str m_xform;
1113
shared_str m_xform_v;
1214
shared_str c_consts;
@@ -92,11 +94,26 @@ struct FTreeVisual_setup
9294
{
9395
dwFrame = Device.dwFrame;
9496

95-
// Calc wind-vector3, scale
9697
float tm_rot = PI_MUL_2 * Device.fTimeGlobal / ps_r__Tree_w_rot;
98+
99+
// Calc wind-vector3, scale
100+
#ifdef TREE_WIND_EFFECT
101+
CEnvDescriptor& env = *g_pGamePersistent->Environment().CurrentEnv;
102+
97103
wind.set(_sin(tm_rot), 0, _cos(tm_rot), 0);
98104
wind.normalize();
105+
#if RENDER!=R_R1
106+
float fValue = env.m_fTreeAmplitudeIntensity;
107+
wind.mul(fValue); // dir1*amplitude
108+
#else // R1
99109
wind.mul(ps_r__Tree_w_amp); // dir1*amplitude
110+
#endif //-RENDER!=R_R1
111+
#else //!TREE_WIND_EFFECT
112+
wind.set(_sin(tm_rot), 0, _cos(tm_rot), 0);
113+
wind.normalize();
114+
wind.mul(ps_r__Tree_w_amp); // dir1*amplitude
115+
#endif //-TREE_WIND_EFFECT
116+
100117
scale = 1.f / float(FTreeVisual_quant);
101118

102119
// setup constants

src/Layers/xrRenderPC_R2/r2.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#include "Layers/xrRender/dxWallMarkArray.h"
1313
#include "Layers/xrRender/dxUIShader.h"
1414

15+
#include "Common/Config.hpp"
16+
1517
CRender RImplementation;
1618

1719
//////////////////////////////////////////////////////////////////////////
@@ -84,6 +86,18 @@ static class cl_water_intensity : public R_constant_setup
8486
}
8587
} binder_water_intensity;
8688

89+
#ifdef TREE_WIND_EFFECT
90+
static class cl_tree_amplitude_intensity : public R_constant_setup
91+
{
92+
void setup(R_constant* C) override
93+
{
94+
CEnvDescriptor& env = *g_pGamePersistent->Environment().CurrentEnv;
95+
float fValue = env.m_fTreeAmplitudeIntensity;
96+
RCache.set_c(C, fValue, fValue, fValue, 0);
97+
}
98+
} binder_tree_amplitude_intensity;
99+
#endif
100+
87101
static class cl_sun_shafts_intensity : public R_constant_setup
88102
{
89103
virtual void setup(R_constant* C)

src/Layers/xrRenderPC_R3/r3.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#include "Layers/xrRenderDX10/3DFluid/dx103DFluidManager.h"
1515
#include "D3DX10Core.h"
1616

17+
#include "Common/Config.hpp"
18+
1719
CRender RImplementation;
1820

1921
//////////////////////////////////////////////////////////////////////////
@@ -95,6 +97,18 @@ static class cl_water_intensity : public R_constant_setup
9597
}
9698
} binder_water_intensity;
9799

100+
#ifdef TREE_WIND_EFFECT
101+
static class cl_tree_amplitude_intensity : public R_constant_setup
102+
{
103+
void setup(R_constant* C) override
104+
{
105+
CEnvDescriptor& env = *g_pGamePersistent->Environment().CurrentEnv;
106+
float fValue = env.m_fTreeAmplitudeIntensity;
107+
RCache.set_c(C, fValue, fValue, fValue, 0);
108+
}
109+
} binder_tree_amplitude_intensity;
110+
#endif
111+
98112
static class cl_sun_shafts_intensity : public R_constant_setup
99113
{
100114
virtual void setup(R_constant* C)

src/Layers/xrRenderPC_R4/r4.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#include "Layers/xrRender/ShaderResourceTraits.h"
1616
#include "D3DX10Core.h"
1717

18+
#include "Common/Config.hpp"
19+
1820
CRender RImplementation;
1921

2022
//////////////////////////////////////////////////////////////////////////
@@ -101,6 +103,18 @@ static class cl_water_intensity : public R_constant_setup
101103
}
102104
} binder_water_intensity;
103105

106+
#ifdef TREE_WIND_EFFECT
107+
static class cl_tree_amplitude_intensity : public R_constant_setup
108+
{
109+
void setup(R_constant* C) override
110+
{
111+
CEnvDescriptor& env = *g_pGamePersistent->Environment().CurrentEnv;
112+
float fValue = env.m_fTreeAmplitudeIntensity;
113+
RCache.set_c(C, fValue, fValue, fValue, 0);
114+
}
115+
} binder_tree_amplitude_intensity;
116+
#endif
117+
104118
static class cl_sun_shafts_intensity : public R_constant_setup
105119
{
106120
virtual void setup(R_constant* C)

src/xrEngine/Environment.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "xrCommon/xr_vector.h"
1010
#include "xrCommon/xr_map.h"
1111

12+
#include "Common/Config.hpp"
1213

1314
// refs
1415
class ENGINE_API IRender_Visual;
@@ -172,6 +173,10 @@ class ENGINE_API CEnvDescriptor
172173
float m_fSunShaftsIntensity;
173174
float m_fWaterIntensity;
174175

176+
#ifdef TREE_WIND_EFFECT
177+
float m_fTreeAmplitudeIntensity;
178+
#endif
179+
175180
// int lens_flare_id;
176181
// int tb_id;
177182
shared_str lens_flare_id;

src/xrEngine/Environment_misc.cpp

Lines changed: 15 additions & 0 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+
#include "Common/Config.hpp"
14+
1315
void CEnvModifier::load(IReader* fs, u32 version)
1416
{
1517
use_flags.one();
@@ -218,6 +220,10 @@ CEnvDescriptor::CEnvDescriptor(shared_str const& identifier) : m_identifier(iden
218220
m_fSunShaftsIntensity = 0;
219221
m_fWaterIntensity = 1;
220222

223+
#ifdef TREE_WIND_EFFECT
224+
m_fTreeAmplitudeIntensity = 0.01;
225+
#endif
226+
221227
lens_flare_id = "";
222228
tb_id = "";
223229

@@ -295,6 +301,11 @@ void CEnvDescriptor::load(CEnvironment& environment, CInifile& config)
295301
if (config.line_exist(m_identifier.c_str(), "water_intensity"))
296302
m_fWaterIntensity = config.r_float(m_identifier.c_str(), "water_intensity");
297303

304+
#ifdef TREE_WIND_EFFECT
305+
if (config.line_exist(m_identifier.c_str(), "tree_amplitude_intensity"))
306+
m_fTreeAmplitudeIntensity = config.r_float(m_identifier.c_str(), "tree_amplitude_intensity");
307+
#endif
308+
298309
C_CHECK(clouds_color);
299310
C_CHECK(sky_color);
300311
C_CHECK(fog_color);
@@ -436,6 +447,10 @@ void CEnvDescriptorMixer::lerp(
436447
m_fSunShaftsIntensity = fi * A.m_fSunShaftsIntensity + f * B.m_fSunShaftsIntensity;
437448
m_fWaterIntensity = fi * A.m_fWaterIntensity + f * B.m_fWaterIntensity;
438449

450+
#ifdef TREE_WIND_EFFECT
451+
m_fTreeAmplitudeIntensity = fi * A.m_fTreeAmplitudeIntensity + f * B.m_fTreeAmplitudeIntensity;
452+
#endif
453+
439454
// colors
440455
//. sky_color.lerp (A.sky_color,B.sky_color,f).add(Mdf.sky_color).mul(modif_power);
441456
sky_color.lerp(A.sky_color, B.sky_color, f);

0 commit comments

Comments
 (0)