CFlameWarp: Dehardcode container sizes

Same behavior, less magic numbers.
This commit is contained in:
Lioncash 2020-04-03 01:04:53 -04:00
parent ad30f0c61c
commit eb1209b492
2 changed files with 14 additions and 11 deletions

View File

@ -1,5 +1,7 @@
#include "Runtime/Particle/CFlameWarp.hpp" #include "Runtime/Particle/CFlameWarp.hpp"
#include <algorithm>
#include "Runtime/CStateManager.hpp" #include "Runtime/CStateManager.hpp"
namespace urde { namespace urde {
@ -65,22 +67,28 @@ void CFlameWarp::ModifyParticles(std::vector<CParticle>& particles) {
std::sort(vec.begin(), vec.end(), [](auto& a, auto& b) { return a.first < b.first; }); std::sort(vec.begin(), vec.end(), [](auto& a, auto& b) { return a.first < b.first; });
int pitch = particles.size() / 9; const size_t pitch = particles.size() / 9;
for (int i = 0; i < 9; ++i) { for (size_t i = 0; i < x4_collisionPoints.size(); ++i) {
CParticle& part = particles[vec[i * pitch].second]; const CParticle& part = particles[vec[i * pitch].second];
x4_collisionPoints[i] = part.x4_pos; x4_collisionPoints[i] = part.x4_pos;
if (i > 0) { if (i > 0) {
zeus::CVector3f delta = x4_collisionPoints[i] - x4_collisionPoints[i - 1]; const zeus::CVector3f delta = x4_collisionPoints[i] - x4_collisionPoints[i - 1];
if (delta.magnitude() < 0.0011920929f) if (delta.magnitude() < 0.0011920929f) {
x4_collisionPoints[i] += delta.normalized() * 0.0011920929f; x4_collisionPoints[i] += delta.normalized() * 0.0011920929f;
} }
} }
}
x4_collisionPoints[0] = x74_warpPoint; x4_collisionPoints[0] = x74_warpPoint;
x80_floatingPoint = x4_collisionPoints[8]; x80_floatingPoint = x4_collisionPoints[8];
xa0_26_processed = true; xa0_26_processed = true;
} }
void CFlameWarp::ResetPosition(const zeus::CVector3f& pos) {
std::fill(x4_collisionPoints.begin(), x4_collisionPoints.end(), pos);
xa0_26_processed = false;
}
zeus::CAABox CFlameWarp::CalculateBounds() const { zeus::CAABox CFlameWarp::CalculateBounds() const {
zeus::CAABox ret; zeus::CAABox ret;
for (const auto& v : x4_collisionPoints) for (const auto& v : x4_collisionPoints)

View File

@ -47,12 +47,7 @@ public:
bool IsActivated() override { return xa0_24_activated; } bool IsActivated() override { return xa0_24_activated; }
bool IsProcessed() const { return xa0_26_processed; } bool IsProcessed() const { return xa0_26_processed; }
FourCC Get4CharID() override { return FOURCC('FWRP'); } FourCC Get4CharID() override { return FOURCC('FWRP'); }
void ResetPosition(const zeus::CVector3f& pos) { void ResetPosition(const zeus::CVector3f& pos);
for (auto& vec : x4_collisionPoints) {
vec = pos;
}
xa0_26_processed = false;
}
zeus::CAABox CalculateBounds() const; zeus::CAABox CalculateBounds() const;
}; };
} // namespace urde } // namespace urde