mirror of https://github.com/AxioDL/metaforce.git
Various fmadds related fixes (may be more)
This commit is contained in:
parent
2f2ff96965
commit
69187353b9
|
@ -43,11 +43,9 @@ public:
|
||||||
|
|
||||||
inline s32 Range(s32 min, s32 max)
|
inline s32 Range(s32 min, s32 max)
|
||||||
{
|
{
|
||||||
s32 diff = max - min;
|
s32 rnd = Next();
|
||||||
s32 rand = -1;
|
s32 diff = (max - min) + 1;
|
||||||
while (rand < 0)
|
return min + (rnd - ((rnd / diff) * diff));
|
||||||
rand = s32((Next() << 16) | Next());
|
|
||||||
return rand % diff + min;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static CRandom16* GetRandomNumber() {return g_randomNumber;}
|
static CRandom16* GetRandomNumber() {return g_randomNumber;}
|
||||||
|
|
|
@ -275,7 +275,6 @@ bool CMain::LoadAudio()
|
||||||
|
|
||||||
void CMain::EnsureWorldPaksReady()
|
void CMain::EnsureWorldPaksReady()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMain::EnsureWorldPakReady(ResId mlvl)
|
void CMain::EnsureWorldPakReady(ResId mlvl)
|
||||||
|
|
|
@ -20,38 +20,42 @@ CFluidUVMotion::CFluidUVMotion(float, float)
|
||||||
|
|
||||||
void CFluidUVMotion::CalculateFluidTextureOffset(float f31, float offsets[3][2])
|
void CFluidUVMotion::CalculateFluidTextureOffset(float f31, float offsets[3][2])
|
||||||
{
|
{
|
||||||
float f29 = f31 * x4c_;
|
float f28 = (f31 * x4c_) * zeus::fastCosF(x50_);
|
||||||
float f28 = f29 * zeus::fastCosF(x50_);
|
float f29 = (f31 * x4c_) / zeus::fastSinF(x50_);
|
||||||
f29 = f29 / zeus::fastSinF(x50_);
|
|
||||||
|
|
||||||
for (u32 i = 0 ; i<x0_fluidLayers.size() ; ++i)
|
for (u32 i = 0 ; i<x0_fluidLayers.size() ; ++i)
|
||||||
{
|
{
|
||||||
const SFluidLayerMotion& layer = x0_fluidLayers[i];
|
const SFluidLayerMotion& layer = x0_fluidLayers[i];
|
||||||
float f30 = f31 / layer.x4_a;
|
|
||||||
float f25;
|
float f30 = f31 * layer.x4_a;
|
||||||
float f26;
|
float f1 = f30 - std::floor(f30);
|
||||||
float f27;
|
float f27;
|
||||||
|
float f26;
|
||||||
switch(layer.x0_motion)
|
switch(layer.x0_motion)
|
||||||
{
|
{
|
||||||
case EFluidUVMotion::Zero:
|
|
||||||
f26 = 0.f;
|
|
||||||
f27 = 0.f;
|
|
||||||
break;
|
|
||||||
case EFluidUVMotion::One:
|
case EFluidUVMotion::One:
|
||||||
f30 = (M_PIF * 2.f) * (f30 - zeus::floorF(f30));
|
{
|
||||||
f27 = (M_PIF * 2.f) * zeus::fastSinF(f30);
|
f30 = (M_PIF * 2) * f1;
|
||||||
f26 = layer.xc_c * zeus::fastSinF(f30);
|
f27 = layer.xc_c * zeus::fastSinF(f30);
|
||||||
|
f26 = layer.xc_c * zeus::fastCosF(f30);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case EFluidUVMotion::Two:
|
case EFluidUVMotion::Two:
|
||||||
|
{
|
||||||
f27 = 0.f;
|
f27 = 0.f;
|
||||||
f26 = zeus::fastCosF((M_PIF * 2.f) * layer.xc_c);
|
f26 = layer.xc_c * zeus::fastCosF((M_PIF * 2) * f1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
f27 = f26 = 0.f;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
f25 = (f26 * ((f27 * f29) + zeus::fastCosF(layer.x8_b))) + zeus::fastSinF(layer.x8_b);
|
float x = f26 * zeus::fastSinF(layer.x8_b) + (f27 * zeus::fastCosF(layer.x8_b) + f29);
|
||||||
f26 = (f27 * ((f26 * f28) + zeus::fastCosF(layer.x8_b))) + zeus::fastSinF(layer.x8_b);
|
float y = f27 * zeus::fastSinF(layer.x8_b) + (f26 * zeus::fastCosF(layer.x8_b) + f28);
|
||||||
offsets[i][0] = f25 - zeus::floorF(f25);
|
|
||||||
offsets[i][1] = f26 - zeus::floorF(f26);
|
offsets[i][0] = float(x - floor(x));
|
||||||
|
offsets[i][1] = float(y - floor(y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,7 +141,7 @@ void CPlayerCameraBob::UpdateViewWander(float dt, CStateManager& mgr)
|
||||||
|
|
||||||
void CPlayerCameraBob::Update(float dt, CStateManager& mgr)
|
void CPlayerCameraBob::Update(float dt, CStateManager& mgr)
|
||||||
{
|
{
|
||||||
x1c_bobTime = (dt * x1c_bobTime) + x18_bobTimeScale;
|
x1c_bobTime = (dt * x18_bobTimeScale) + x1c_bobTime;
|
||||||
float landSpring = kLandingBobSpringConstant;
|
float landSpring = kLandingBobSpringConstant;
|
||||||
float landDampen = kLandingBobDamping;
|
float landDampen = kLandingBobDamping;
|
||||||
if (x28_applyLandingTrans)
|
if (x28_applyLandingTrans)
|
||||||
|
@ -150,10 +150,11 @@ void CPlayerCameraBob::Update(float dt, CStateManager& mgr)
|
||||||
landSpring = 40.f;
|
landSpring = 40.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
x6c_ = dt * x6c_ + -(landSpring * -(landDampen * x6c_) - x28_applyLandingTrans);
|
x6c_ = (dt * -((landSpring * x70_landingTranslation) + -(landDampen * x6c_))) + x6c_;
|
||||||
x70_landingTranslation = x6c_ * x70_landingTranslation + dt;
|
x70_landingTranslation = x6c_ * dt + x70_landingTranslation;
|
||||||
x74_ = dt * x74_ + -(80.f * -((6.f * zeus::sqrtF(80.f)) * x74_) - x78_);
|
x74_ = dt * (-(80.f * x78_) + -((6.f * zeus::sqrtF(80.f)) * x74_)) + x74_;
|
||||||
x78_ = x74_ * x78_ + dt;
|
x78_ = x74_ * dt + x78_;
|
||||||
|
|
||||||
if (std::fabs(x6c_) < 0.0049f && std::fabs(x70_landingTranslation) < 0.0049f && std::fabs(x78_) < 0.0049f)
|
if (std::fabs(x6c_) < 0.0049f && std::fabs(x70_landingTranslation) < 0.0049f && std::fabs(x78_) < 0.0049f)
|
||||||
{
|
{
|
||||||
x28_applyLandingTrans = false;
|
x28_applyLandingTrans = false;
|
||||||
|
@ -177,10 +178,10 @@ void CPlayerCameraBob::Update(float dt, CStateManager& mgr)
|
||||||
x104_ *= 0.4f;
|
x104_ *= 0.4f;
|
||||||
}
|
}
|
||||||
|
|
||||||
x100_ = kTargetMagnitudeTrackingRate * x100_ + (x104_ - x100_);
|
x100_ = kTargetMagnitudeTrackingRate * (x104_ - x100_) + x100_;
|
||||||
x100_ = std::max(x100_, 0.f);
|
x100_ = std::max(x100_, 0.f);
|
||||||
float tmp = x14_;
|
float tmp = x14_;
|
||||||
x14_ = kTargetMagnitudeTrackingRate * tmp + (x10_bobMagnitude - tmp);
|
x14_ = kTargetMagnitudeTrackingRate * (x10_bobMagnitude - x14_) + x14_;
|
||||||
UpdateViewWander(dt, mgr);
|
UpdateViewWander(dt, mgr);
|
||||||
x78_ = tmp;
|
x78_ = tmp;
|
||||||
|
|
||||||
|
@ -205,8 +206,8 @@ void CPlayerCameraBob::CalculateMovingTranslation(float& x, float& y) const
|
||||||
if (x0_type == ECameraBobType::Zero)
|
if (x0_type == ECameraBobType::Zero)
|
||||||
{
|
{
|
||||||
double c = ((M_PIF * 2.f) * std::fmod(x1c_bobTime, 2.0f * xc_) / xc_);
|
double c = ((M_PIF * 2.f) * std::fmod(x1c_bobTime, 2.0f * xc_) / xc_);
|
||||||
x = (x14_ * x4_vec.x) * std::sin(c);
|
x = (x14_ * x4_vec.x) * float(std::sin(c));
|
||||||
y = (x14_ * x4_vec.y) * (std::fabs(std::cos(c * .5)) * std::cos(c * .5));
|
y = (x14_ * x4_vec.y) * float(std::fabs(std::cos(c * .5)) * std::cos(c * .5));
|
||||||
}
|
}
|
||||||
else if (x0_type == ECameraBobType::One)
|
else if (x0_type == ECameraBobType::One)
|
||||||
{
|
{
|
||||||
|
@ -216,8 +217,8 @@ void CPlayerCameraBob::CalculateMovingTranslation(float& x, float& y) const
|
||||||
else
|
else
|
||||||
x = ((fX / xc_)) * (x14_ * x4_vec.x);
|
x = ((fX / xc_)) * (x14_ * x4_vec.x);
|
||||||
|
|
||||||
float sY = std::sin(std::fmod((M_PI * fX) / xc_, M_PI));
|
float sY = float(std::sin(std::fmod((M_PI * fX) / xc_, M_PI)));
|
||||||
y = (((1.f - sY) * (x14_ * x4_vec.y)) * (0.5f * (-((sY * 1.f) - sY) * (x14_ * x4_vec.y)))) + 0.5f;
|
y = (1.f - sY) * (x14_ * x4_vec.y) * 0.5f + (0.5f * -((sY * sY) - 1.f) * (x14_ * x4_vec.y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ void CScriptTimer::StartTiming(bool isTiming) { x42_isTiming = isTiming; }
|
||||||
void CScriptTimer::Reset(CStateManager& mgr)
|
void CScriptTimer::Reset(CStateManager& mgr)
|
||||||
{
|
{
|
||||||
float rDt = mgr.GetActiveRandom()->Float();
|
float rDt = mgr.GetActiveRandom()->Float();
|
||||||
x34_time = (x3c_maxRandDelay + x38_startTime) * rDt;
|
x34_time = (x3c_maxRandDelay * rDt) + x38_startTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CScriptTimer::ApplyTime(float dt, CStateManager& mgr)
|
void CScriptTimer::ApplyTime(float dt, CStateManager& mgr)
|
||||||
|
|
Loading…
Reference in New Issue