1#include "Game/Map/WaterPoint.hpp"
2#include "Game/Util.hpp"
4WaterPoint::WaterPoint(
const TVec3f &rPos,
const TVec3f &rUpVec, f32 coordAcrossRail, f32 coordOnRail, f32 height, f32 flowSpeedRate) :
5 mPosition(rPos), mOrigPos(rPos), mCoordAcrossRail(coordAcrossRail), mCoordOnRail(coordOnRail), mUpVec(rUpVec), mHeight(height), mFlowSpeedRate(flowSpeedRate), mAlpha(-1) {
9void WaterPoint::initAfterPlacement() {
10 if (mHeight != 0.0f) {
11 TVec3f v9(mPosition.x, (200.0f + mPosition.y), mPosition.z);
12 TVec3f v8(0.0f, 0.0f, 0.0f);
14 if (MR::calcMapGround(v9, &v8, 400.0f)) {
15 f32 v2 = ((v8.y - mPosition.y) / 200.0f);
16 f32 v3 = MR::clamp((0.1f + __fabsf(v2)), 0.1f, 1.0f);
17 f32 v6 = MR::clamp((30.0f + (255.0f * -v2)), 30.0f, 255.0f);
20 mHeight = (v3 >= v7) ? v7 : v3;
25void WaterPoint::updatePos(f32 waveTheta1, f32 waveTheta2, f32 waveHeight1, f32 waveHeight2, f32 a5) {
26 f32 height = calcHeight(waveTheta1, waveTheta2, waveHeight1, waveHeight2, mCoordAcrossRail, mCoordOnRail);
28 mPosition.x = mUpVec.x * v9;
29 mPosition.y = mUpVec.y * (a5 * height);
30 mPosition.z = mUpVec.z * v9;
31 mPosition.addInline_4(mOrigPos);
35f32 WaterPoint::calcHeight(f32 waveTheta1, f32 waveTheta2, f32 waveHeight1, f32 waveHeight2, f32 coordAcrossRail, f32 coordOnRail)
const {
37 f32 actualWaveHeight2 = (waveHeight2 * MR::sin(waveTheta2 + (0.0024999999f * coordOnRail)));
40 f32 wave1PerpendicularComponent = 0.003f * coordAcrossRail;
41 f32 wave1ThetaPlusPerpendicularComponent = waveTheta1 + wave1PerpendicularComponent;
42 f32 normalizedWaveHeight1 = MR::sin(wave1ThetaPlusPerpendicularComponent + 0.00030000001f * coordOnRail);
43 f32 actualWaveHeight1 = waveHeight1 * normalizedWaveHeight1;
45 f32 finalHeight = mHeight * (actualWaveHeight2 + actualWaveHeight1);