summaryrefslogtreecommitdiffstats
path: root/src/render
diff options
context:
space:
mode:
authoraap <aap@papnet.eu>2020-08-10 17:12:32 +0200
committerGitHub <noreply@github.com>2020-08-10 17:12:32 +0200
commitc2c65207a30eb17fa9acbe56c5ca7a8a25400bd3 (patch)
tree42869c3dbea87fd406ae7f44dbae714e11b9490f /src/render
parentupdate librw (shadows are working now) (diff)
parentCWindModifiers (diff)
downloadre3-c2c65207a30eb17fa9acbe56c5ca7a8a25400bd3.tar
re3-c2c65207a30eb17fa9acbe56c5ca7a8a25400bd3.tar.gz
re3-c2c65207a30eb17fa9acbe56c5ca7a8a25400bd3.tar.bz2
re3-c2c65207a30eb17fa9acbe56c5ca7a8a25400bd3.tar.lz
re3-c2c65207a30eb17fa9acbe56c5ca7a8a25400bd3.tar.xz
re3-c2c65207a30eb17fa9acbe56c5ca7a8a25400bd3.tar.zst
re3-c2c65207a30eb17fa9acbe56c5ca7a8a25400bd3.zip
Diffstat (limited to 'src/render')
-rw-r--r--src/render/WindModifiers.cpp44
-rw-r--r--src/render/WindModifiers.h7
2 files changed, 46 insertions, 5 deletions
diff --git a/src/render/WindModifiers.cpp b/src/render/WindModifiers.cpp
index 49e7c96a..2061df6a 100644
--- a/src/render/WindModifiers.cpp
+++ b/src/render/WindModifiers.cpp
@@ -1,13 +1,51 @@
#include "common.h"
#include "WindModifiers.h"
+#include "Camera.h"
+#include "General.h"
+
+#define MAX_HEIGHT_DIST 40.0f
+#define MIN_FADE_DIST 20.0f
+#define MAX_FADE_DIST 50.0f
+
+CWindModifiers Array[16];
+int32 CWindModifiers::Number;
void
-CWindModifiers::RegisterOne(CVector pos, int32 unk)
+CWindModifiers::RegisterOne(CVector pos, int32 type = 1)
{
+ if (CWindModifiers::Number < 16 && (pos - TheCamera.GetPosition()).Magnitude() < 100.0f) {
+ Array[Number].m_pos = pos;
+ Array[Number].m_type = type;
+ Number++;
+ }
}
-int32
+bool
CWindModifiers::FindWindModifier(CVector pos, float *x, float *y)
{
- return 0;
+ bool bWasWindModifierFound = false;
+ CVector2D dir;
+ for (int i = 0; i < Number; i++) {
+ if (Array[i].m_type == 1) {
+ float zDist = Abs(15.0f + pos.z - Array[i].m_pos.z);
+
+ if (zDist < MAX_HEIGHT_DIST) {
+ float dist = (pos - Array[i].m_pos).Magnitude();
+ if (dist < MAX_FADE_DIST) {
+ float distFade = dist < MIN_FADE_DIST ? 1.0f : 1.0f - (dist - MIN_FADE_DIST) / (MAX_FADE_DIST - MIN_FADE_DIST);
+ float heightFade = 1.0f - zDist / MAX_HEIGHT_DIST;
+ dir = (pos - Array[i].m_pos) * heightFade / dist;
+ bWasWindModifierFound = true;
+ }
+ }
+ }
+ }
+
+ if (bWasWindModifierFound) {
+ float directionMult = ((CGeneral::GetRandomNumber() & 0x1F) - 16) * 0.0035f + 1.0f;
+ *x += dir.x * directionMult;
+ *y += dir.y * directionMult;
+ }
+
+ return bWasWindModifierFound;
}
diff --git a/src/render/WindModifiers.h b/src/render/WindModifiers.h
index c42e185d..7c2e57bd 100644
--- a/src/render/WindModifiers.h
+++ b/src/render/WindModifiers.h
@@ -2,7 +2,10 @@
class CWindModifiers
{
+ CVector m_pos;
+ int32 m_type;
public:
- static void RegisterOne(CVector pos, int32 unk);
- static int32 FindWindModifier(CVector pos, float *x, float *y);
+ static int32 Number;
+ static void RegisterOne(CVector pos, int32 windSourceType);
+ static bool FindWindModifier(CVector pos, float *x, float *y);
};