diff options
author | majestic <majesticcoding@gmail.com> | 2020-08-05 04:11:42 +0200 |
---|---|---|
committer | majestic <majesticcoding@gmail.com> | 2020-08-09 21:32:30 +0200 |
commit | b73b6b8e130a545687aad4024465fc977e3f01ee (patch) | |
tree | cd760add299e13c801504becf7e59aa948eb22c3 /src/render/WindModifiers.cpp | |
parent | Merge pull request #668 from majesticCoding/miami (diff) | |
download | re3-b73b6b8e130a545687aad4024465fc977e3f01ee.tar re3-b73b6b8e130a545687aad4024465fc977e3f01ee.tar.gz re3-b73b6b8e130a545687aad4024465fc977e3f01ee.tar.bz2 re3-b73b6b8e130a545687aad4024465fc977e3f01ee.tar.lz re3-b73b6b8e130a545687aad4024465fc977e3f01ee.tar.xz re3-b73b6b8e130a545687aad4024465fc977e3f01ee.tar.zst re3-b73b6b8e130a545687aad4024465fc977e3f01ee.zip |
Diffstat (limited to 'src/render/WindModifiers.cpp')
-rw-r--r-- | src/render/WindModifiers.cpp | 44 |
1 files changed, 41 insertions, 3 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; } |