2018-10-07 03:42:33 +00:00
|
|
|
#pragma once
|
2017-08-22 03:20:22 +00:00
|
|
|
|
2019-09-28 02:53:03 +00:00
|
|
|
#include <utility>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "Runtime/CRandom16.hpp"
|
|
|
|
#include "Runtime/RetroTypes.hpp"
|
|
|
|
#include "Runtime/rstl.hpp"
|
|
|
|
#include "Runtime/Graphics/CLineRenderer.hpp"
|
|
|
|
|
|
|
|
#include <zeus/CVector3f.hpp>
|
2017-08-22 03:20:22 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce {
|
2017-08-22 03:20:22 +00:00
|
|
|
class CStateManager;
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
class CRainSplashGenerator {
|
|
|
|
struct SSplashLine {
|
|
|
|
float x0_t = 0.f;
|
|
|
|
float x4_xEnd = 0.f;
|
|
|
|
float x8_yEnd = 0.f;
|
|
|
|
float xc_speed = 4.f;
|
|
|
|
float x10_zParabolaHeight = 0.015625f;
|
|
|
|
u8 x14_ = 3;
|
|
|
|
u8 x15_length = 1;
|
|
|
|
bool x16_active = true; // used to be one-bit bitfield
|
2020-04-10 01:40:46 +00:00
|
|
|
CLineRenderer m_renderer;
|
2020-09-28 20:54:40 +00:00
|
|
|
explicit SSplashLine();
|
2017-08-22 03:20:22 +00:00
|
|
|
void Update(float dt, CStateManager& mgr);
|
2020-04-10 01:40:46 +00:00
|
|
|
void Draw(float alpha, float dt, const zeus::CVector3f& pos);
|
2018-12-08 05:30:43 +00:00
|
|
|
void SetActive() { x16_active = true; }
|
|
|
|
};
|
|
|
|
struct SRainSplash {
|
|
|
|
rstl::reserved_vector<SSplashLine, 4> x0_lines;
|
|
|
|
zeus::CVector3f x64_pos;
|
|
|
|
float x70_ = 0.f;
|
2020-09-28 20:54:40 +00:00
|
|
|
explicit SRainSplash();
|
2018-12-08 05:30:43 +00:00
|
|
|
SRainSplash(const SRainSplash&) = delete;
|
|
|
|
SRainSplash& operator=(const SRainSplash&) = delete;
|
|
|
|
SRainSplash(SRainSplash&&) = default;
|
|
|
|
SRainSplash& operator=(SRainSplash&&) = default;
|
|
|
|
void Update(float dt, CStateManager& mgr);
|
|
|
|
bool IsActive() const;
|
2020-04-10 01:40:46 +00:00
|
|
|
void Draw(float alpha, float dt, const zeus::CVector3f& pos);
|
2018-12-08 05:30:43 +00:00
|
|
|
void SetPoint(const zeus::CVector3f& pos);
|
|
|
|
};
|
|
|
|
std::vector<SRainSplash> x0_rainSplashes;
|
2020-04-11 19:35:44 +00:00
|
|
|
CRandom16 x10_random{99};
|
2018-12-08 05:30:43 +00:00
|
|
|
zeus::CVector3f x14_scale;
|
2020-04-07 17:01:58 +00:00
|
|
|
float x20_generateTimer = 0.0f;
|
|
|
|
float x24_generateInterval = 0.0f;
|
|
|
|
float x28_dt = 0.0f;
|
2018-12-08 05:30:43 +00:00
|
|
|
float x2c_minZ;
|
|
|
|
float x30_alpha;
|
|
|
|
u32 x34_curPoint = 0;
|
|
|
|
u32 x38_queueTail = 0;
|
|
|
|
u32 x3c_queueHead = 0;
|
|
|
|
u32 x40_queueSize = 0;
|
|
|
|
u32 x44_genRate;
|
2020-04-21 07:22:41 +00:00
|
|
|
bool x48_24 : 1 = false;
|
|
|
|
bool x48_25_raining : 1 = true;
|
2018-12-08 05:30:43 +00:00
|
|
|
void UpdateRainSplashRange(CStateManager& mgr, int start, int end, float dt);
|
|
|
|
void UpdateRainSplashes(CStateManager& mgr, float magnitude, float dt);
|
2020-04-10 01:40:46 +00:00
|
|
|
void DoDraw(const zeus::CTransform& xf);
|
2018-12-08 05:30:43 +00:00
|
|
|
static u32 GetNextBestPt(u32 pt, const std::vector<std::pair<zeus::CVector3f, zeus::CVector3f>>& vn, CRandom16& rand,
|
|
|
|
float minZ);
|
|
|
|
void AddPoint(const zeus::CVector3f& pos);
|
2017-08-22 03:20:22 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
public:
|
|
|
|
CRainSplashGenerator(const zeus::CVector3f& scale, u32 maxSplashes, u32 genRate, float minZ, float alpha);
|
|
|
|
void Update(float dt, CStateManager& mgr);
|
|
|
|
void GeneratePoints(const std::vector<std::pair<zeus::CVector3f, zeus::CVector3f>>& vn);
|
2020-04-10 01:40:46 +00:00
|
|
|
void Draw(const zeus::CTransform& xf);
|
2018-12-08 05:30:43 +00:00
|
|
|
bool IsRaining() const { return x48_25_raining; }
|
|
|
|
};
|
2017-08-22 03:20:22 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce
|