Add CRipple::CRipple

Former-commit-id: bda30a003b
This commit is contained in:
Henrique Gemignani Passos Lima 2022-10-17 01:32:15 +03:00
parent dd5e5fb342
commit 2fb748f25c
3 changed files with 74 additions and 0 deletions

View File

@ -8,6 +8,8 @@
class CScriptWater;
class CStateManager;
extern "C" uint sub_8012f098();
class CFluidPlaneCPURender {
public:
struct SPatchInfo {};

View File

@ -0,0 +1,28 @@
#ifndef _CRIPPLE
#define _CRIPPLE
#include "MetroidPrime/TGameTypes.hpp"
#include "Kyoto/Math/CVector3f.hpp"
class CRipple {
TUniqueId x0_id;
float x4_time;
CVector3f x8_center;
float x14_timeFalloff;
float x18_distFalloff;
float x1c_frequency;
float x20_amplitude;
float x24_lookupAmplitude;
float x28_ooTimeFalloff;
float x2c_ooDistFalloff;
float x30_ooPhase;
float x34_phase;
float x38_lookupPhase;
uint x3c_;
public:
CRipple(TUniqueId id, const CVector3f& center, float intensity);
};
#endif // _CRIPPLE

View File

@ -0,0 +1,44 @@
#include "MetroidPrime/CRipple.hpp"
#include "MetroidPrime/CFluidPlane.hpp"
#include "Kyoto/CRandom16.hpp"
#include "Kyoto/Math/CMath.hpp"
#include "rstl/math.hpp"
CRipple::CRipple(TUniqueId id, const CVector3f& center, float intensity)
: x0_id(id)
, x4_time(0.f)
, x8_center(center)
, x14_timeFalloff(2.f)
, x18_distFalloff(12.f)
, x1c_frequency(3.f)
, x20_amplitude(0.25f)
, x24_lookupAmplitude(0.00098039221f)
, x28_ooTimeFalloff(0.f)
, x2c_ooDistFalloff(0.f)
, x30_ooPhase(0.f)
, x34_phase(0.f)
, x38_lookupPhase(0.f)
, x3c_(sub_8012f098())
{
if (0.f < intensity && intensity < 1.f) {
static CRandom16 sRippleRandom(0xABBA);
float value1 = (intensity * (sRippleRandom.Float() - 0.5f)) * 2.f * 0.1f + intensity;
float tmp = 2.f * (0.0f < value1 ? (1.0f < value1 ? 1.0f : value1) : 0.0f);
x14_timeFalloff = 0.5f * tmp + 1.5f;
x18_distFalloff = 4.f * tmp + 8.f;
x1c_frequency = 2.f + tmp;
x20_amplitude = 0.15f * tmp + 0.1f;
x24_lookupAmplitude = x20_amplitude / 255.f;
}
x28_ooTimeFalloff = 1.f / x14_timeFalloff;
x2c_ooDistFalloff = 1.f / x18_distFalloff;
x30_ooPhase = x18_distFalloff / 2.5f;
x34_phase = 1.f / x30_ooPhase;
x38_lookupPhase = 256.f * x34_phase;
}