mirror of https://github.com/AxioDL/metaforce.git
CFlameWarp: Dehardcode container sizes
Same behavior, less magic numbers.
This commit is contained in:
parent
ad30f0c61c
commit
eb1209b492
|
@ -1,5 +1,7 @@
|
|||
#include "Runtime/Particle/CFlameWarp.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "Runtime/CStateManager.hpp"
|
||||
|
||||
namespace urde {
|
||||
|
@ -65,14 +67,15 @@ void CFlameWarp::ModifyParticles(std::vector<CParticle>& particles) {
|
|||
|
||||
std::sort(vec.begin(), vec.end(), [](auto& a, auto& b) { return a.first < b.first; });
|
||||
|
||||
int pitch = particles.size() / 9;
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
CParticle& part = particles[vec[i * pitch].second];
|
||||
const size_t pitch = particles.size() / 9;
|
||||
for (size_t i = 0; i < x4_collisionPoints.size(); ++i) {
|
||||
const CParticle& part = particles[vec[i * pitch].second];
|
||||
x4_collisionPoints[i] = part.x4_pos;
|
||||
if (i > 0) {
|
||||
zeus::CVector3f delta = x4_collisionPoints[i] - x4_collisionPoints[i - 1];
|
||||
if (delta.magnitude() < 0.0011920929f)
|
||||
const zeus::CVector3f delta = x4_collisionPoints[i] - x4_collisionPoints[i - 1];
|
||||
if (delta.magnitude() < 0.0011920929f) {
|
||||
x4_collisionPoints[i] += delta.normalized() * 0.0011920929f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,6 +84,11 @@ void CFlameWarp::ModifyParticles(std::vector<CParticle>& particles) {
|
|||
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 ret;
|
||||
for (const auto& v : x4_collisionPoints)
|
||||
|
|
|
@ -47,12 +47,7 @@ public:
|
|||
bool IsActivated() override { return xa0_24_activated; }
|
||||
bool IsProcessed() const { return xa0_26_processed; }
|
||||
FourCC Get4CharID() override { return FOURCC('FWRP'); }
|
||||
void ResetPosition(const zeus::CVector3f& pos) {
|
||||
for (auto& vec : x4_collisionPoints) {
|
||||
vec = pos;
|
||||
}
|
||||
xa0_26_processed = false;
|
||||
}
|
||||
void ResetPosition(const zeus::CVector3f& pos);
|
||||
zeus::CAABox CalculateBounds() const;
|
||||
};
|
||||
} // namespace urde
|
||||
|
|
Loading…
Reference in New Issue