From c1af78e7ed7593848c853605b132d6b314e19d97 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Sun, 28 Feb 2016 17:03:11 -1000 Subject: [PATCH] Parameter renaming and minor bug fixes --- Runtime/Particle/CColorElement.cpp | 2 +- Runtime/Particle/CColorElement.hpp | 4 +-- Runtime/Particle/CEmitterElement.cpp | 22 ++++++------- Runtime/Particle/CEmitterElement.hpp | 24 +++++++------- Runtime/Particle/CModVectorElement.cpp | 43 +++++++++++++------------- Runtime/Particle/CModVectorElement.hpp | 16 +++++----- Runtime/Particle/CUVElement.cpp | 4 +-- Runtime/Particle/CUVElement.hpp | 2 +- 8 files changed, 58 insertions(+), 59 deletions(-) diff --git a/Runtime/Particle/CColorElement.cpp b/Runtime/Particle/CColorElement.cpp index 92fa57f3d..e5597f429 100644 --- a/Runtime/Particle/CColorElement.cpp +++ b/Runtime/Particle/CColorElement.cpp @@ -114,7 +114,7 @@ bool CCEFadeEnd::GetValue(int frame, Zeus::CColor& valOut) const bool CCEFade::GetValue(int frame, Zeus::CColor& valOut) const { float c; - xc_startFrame->GetValue(frame, c); + xc_endFrame->GetValue(frame, c); float t = frame / c; if (t > 1.f) diff --git a/Runtime/Particle/CColorElement.hpp b/Runtime/Particle/CColorElement.hpp index 024d54ce8..4aa1bc324 100644 --- a/Runtime/Particle/CColorElement.hpp +++ b/Runtime/Particle/CColorElement.hpp @@ -70,10 +70,10 @@ class CCEFade : public CColorElement { std::unique_ptr x4_a; std::unique_ptr x8_b; - std::unique_ptr xc_startFrame; + std::unique_ptr xc_endFrame; public: CCEFade(CColorElement* a, CColorElement* b, CRealElement* c) - : x4_a(a), x8_b(b), xc_startFrame(c) {} + : x4_a(a), x8_b(b), xc_endFrame(c) {} bool GetValue(int frame, Zeus::CColor& colorOut) const; }; diff --git a/Runtime/Particle/CEmitterElement.cpp b/Runtime/Particle/CEmitterElement.cpp index 1c3dea82b..2d0deefc8 100644 --- a/Runtime/Particle/CEmitterElement.cpp +++ b/Runtime/Particle/CEmitterElement.cpp @@ -21,9 +21,9 @@ bool CEESimpleEmitter::GetValue(int frame, Zeus::CVector3f& pPos, Zeus::CVector3 bool CVESphere::GetValue(int frame, Zeus::CVector3f& pPos, Zeus::CVector3f& pVel) const { Zeus::CVector3f a; - x4_a->GetValue(frame, a); + x4_sphereOrigin->GetValue(frame, a); float b; - x8_b->GetValue(frame, b); + x8_sphereRadius->GetValue(frame, b); CRandom16* rand = CRandom16::GetRandomNumber(); int rand1 = rand->Range(-100, 100); int rand2 = rand->Range(-100, 100); @@ -42,7 +42,7 @@ bool CVESphere::GetValue(int frame, Zeus::CVector3f& pPos, Zeus::CVector3f& pVel normVec2.normalize(); float c; - xc_c->GetValue(frame, c); + xc_velocityMag->GetValue(frame, c); pVel = c * normVec2; return false; @@ -51,17 +51,17 @@ bool CVESphere::GetValue(int frame, Zeus::CVector3f& pPos, Zeus::CVector3f& pVel bool CVEAngleSphere::GetValue(int frame, Zeus::CVector3f& pPos, Zeus::CVector3f& pVel) const { Zeus::CVector3f a; - x4_a->GetValue(frame, a); + x4_sphereOrigin->GetValue(frame, a); float b, d, e, f, g; - x8_b->GetValue(frame, b); - x10_d->GetValue(frame, d); - x14_e->GetValue(frame, e); - x18_f->GetValue(frame, f); - x1c_g->GetValue(frame, g); + x8_sphereRadius->GetValue(frame, b); + x10_angleXBias->GetValue(frame, d); + x14_angleYBias->GetValue(frame, e); + x18_angleXRange->GetValue(frame, f); + x1c_angleYRange->GetValue(frame, g); CRandom16* rand = CRandom16::GetRandomNumber(); d = (d + ((0.5f * (f * rand->Float())) - f)) * M_PI / 180.f; - e = (e + ((0.5f * (f * rand->Float())) - f)) * M_PI / 180.f; + e = (e + ((0.5f * (g * rand->Float())) - g)) * M_PI / 180.f; float cosD = Zeus::Math::fastCosR(d); pPos.x = a.x + (b * (-Zeus::Math::fastSinR(e) * cosD)); @@ -70,7 +70,7 @@ bool CVEAngleSphere::GetValue(int frame, Zeus::CVector3f& pPos, Zeus::CVector3f& Zeus::CVector3f normVec = (pPos - a).normalized(); float c; - xc_c->GetValue(frame, c); + xc_velocityMag->GetValue(frame, c); pVel = c * normVec; return false; } diff --git a/Runtime/Particle/CEmitterElement.hpp b/Runtime/Particle/CEmitterElement.hpp index 97a6165d3..7cdfc5539 100644 --- a/Runtime/Particle/CEmitterElement.hpp +++ b/Runtime/Particle/CEmitterElement.hpp @@ -20,28 +20,28 @@ public: class CVESphere : public CEmitterElement { - std::unique_ptr x4_a; - std::unique_ptr x8_b; - std::unique_ptr xc_c; + std::unique_ptr x4_sphereOrigin; + std::unique_ptr x8_sphereRadius; + std::unique_ptr xc_velocityMag; public: CVESphere(CVectorElement* a, CRealElement* b, CRealElement* c) - : x4_a(a), x8_b(b), xc_c(c) {} + : x4_sphereOrigin(a), x8_sphereRadius(b), xc_velocityMag(c) {} bool GetValue(int frame, Zeus::CVector3f& pPos, Zeus::CVector3f& pVel) const; }; class CVEAngleSphere : public CEmitterElement { - std::unique_ptr x4_a; - std::unique_ptr x8_b; - std::unique_ptr xc_c; - std::unique_ptr x10_d; - std::unique_ptr x14_e; - std::unique_ptr x18_f; - std::unique_ptr x1c_g; + std::unique_ptr x4_sphereOrigin; + std::unique_ptr x8_sphereRadius; + std::unique_ptr xc_velocityMag; + std::unique_ptr x10_angleXBias; + std::unique_ptr x14_angleYBias; + std::unique_ptr x18_angleXRange; + std::unique_ptr x1c_angleYRange; public: CVEAngleSphere(CVectorElement* a, CRealElement* b, CRealElement* c, CRealElement* d, CRealElement* e, CRealElement* f, CRealElement* g) - : x4_a(a), x8_b(b), xc_c(c), x10_d(d), x14_e(e), x18_f(f), x1c_g(g) {} + : x4_sphereOrigin(a), x8_sphereRadius(b), xc_velocityMag(c), x10_angleXBias(d), x14_angleYBias(e), x18_angleXRange(f), x1c_angleYRange(g) {} bool GetValue(int frame, Zeus::CVector3f& pPos, Zeus::CVector3f& pVel) const; }; diff --git a/Runtime/Particle/CModVectorElement.cpp b/Runtime/Particle/CModVectorElement.cpp index 460933d80..12dd9c63b 100644 --- a/Runtime/Particle/CModVectorElement.cpp +++ b/Runtime/Particle/CModVectorElement.cpp @@ -186,26 +186,20 @@ bool CMVEGravity::GetValue(int frame, Zeus::CVector3f& pVel, Zeus::CVector3f& /* bool CMVEExplode::GetValue(int frame, Zeus::CVector3f& pVel, Zeus::CVector3f& /*pPos*/) const { if (frame == 0) - { - float b; - x8_b->GetValue(frame, b); - pVel *= b; - } - else { CRandom16* rand = CRandom16::GetRandomNumber(); - Zeus::CVector3f vec; - do - { - vec = {rand->Float() - 0.5f, rand->Float() - 0.5f, rand->Float() - 0.5f}; - } - while (vec.magSquared() > 1.0); - + Zeus::CVector3f vec = {rand->Float() - 0.5f, rand->Float() - 0.5f, rand->Float() - 0.5f}; vec.normalize(); float a; x4_a->GetValue(frame, a); pVel = vec * a; } + else + { + float b; + x8_b->GetValue(frame, b); + pVel *= b; + } return false; } @@ -239,27 +233,32 @@ bool CMVEPulse::GetValue(int frame, Zeus::CVector3f& pVel, Zeus::CVector3f& pPos bool CMVEWind::GetValue(int frame, Zeus::CVector3f& pVel, Zeus::CVector3f& /*pPos*/) const { - Zeus::CVector3f direction; - x4_direction->GetValue(frame, direction); - float speed; - x8_speed->GetValue(frame, speed); - pVel += (direction - pVel) * speed; + Zeus::CVector3f wVel; + x4_velocity->GetValue(frame, wVel); + float factor; + x8_factor->GetValue(frame, factor); + pVel += (wVel - pVel) * factor; return false; } bool CMVESwirl::GetValue(int frame, Zeus::CVector3f& pVel, Zeus::CVector3f& pPos) const { Zeus::CVector3f a, b; - x4_a->GetValue(frame, a); - x8_b->GetValue(frame, b); + x4_helixPoint->GetValue(frame, a); + x8_curveBinormal->GetValue(frame, b); + + /* Compute Frenet–Serret normal + * https://en.wikipedia.org/wiki/Frenet–Serret_formulas */ const Zeus::CVector3f diff = a - pPos; float x = (diff.x - (((diff.z * ((diff.x * (diff.y * b.y)) + b.x)) + b.z) * b.x)); float y = (diff.y - (((diff.z * ((diff.x * (diff.y * b.y)) + b.x)) + b.z) * b.y)); float z = (diff.z - (((diff.z * ((diff.x * (diff.y * b.y)) + b.x)) + b.z) * b.z)); float c = 0.0f, d = 0.0f; - xc_c->GetValue(frame, c); - x10_d->GetValue(frame, d); + xc_targetRadius->GetValue(frame, c); + x10_tangentialVelocity->GetValue(frame, d); + /* Integrate tangential velocity by crossing particle normal with binormal, + * also "homing" towards the target radius */ const float f9 = (b.z * ((b.x * (b.y * pVel.y)) + pVel.x)) + pVel.x; pVel.x = (c * ((f9 * b.x) + (d * ((b.y * (y * b.z)) - z)))) + ((1.0 - c) * pVel.x); pVel.y = (c * ((f9 * b.y) + (d * ((b.z * x) - (z * b.x))))) + ((1.0 - c) * pVel.y); diff --git a/Runtime/Particle/CModVectorElement.hpp b/Runtime/Particle/CModVectorElement.hpp index e195b7618..64aea32eb 100644 --- a/Runtime/Particle/CModVectorElement.hpp +++ b/Runtime/Particle/CModVectorElement.hpp @@ -135,23 +135,23 @@ public: class CMVEWind : public CModVectorElement { - std::unique_ptr x4_direction; - std::unique_ptr x8_speed; + std::unique_ptr x4_velocity; + std::unique_ptr x8_factor; public: CMVEWind(CVectorElement* a, CRealElement* b) - : x4_direction(a), x8_speed(b) {} + : x4_velocity(a), x8_factor(b) {} bool GetValue(int frame, Zeus::CVector3f& pVel, Zeus::CVector3f& pPos) const; }; class CMVESwirl : public CModVectorElement { - std::unique_ptr x4_a; - std::unique_ptr x8_b; - std::unique_ptr xc_c; - std::unique_ptr x10_d; + std::unique_ptr x4_helixPoint; + std::unique_ptr x8_curveBinormal; + std::unique_ptr xc_targetRadius; + std::unique_ptr x10_tangentialVelocity; public: CMVESwirl(CVectorElement* a, CVectorElement* b, CRealElement* c, CRealElement* d) - : x4_a(a), x8_b(b), xc_c(c), x10_d(d) {} + : x4_helixPoint(a), x8_curveBinormal(b), xc_targetRadius(c), x10_tangentialVelocity(d) {} bool GetValue(int frame, Zeus::CVector3f& pVel, Zeus::CVector3f& pPos) const; }; diff --git a/Runtime/Particle/CUVElement.cpp b/Runtime/Particle/CUVElement.cpp index c9f236306..7e3efe112 100644 --- a/Runtime/Particle/CUVElement.cpp +++ b/Runtime/Particle/CUVElement.cpp @@ -7,7 +7,7 @@ namespace pshag CUVEAnimTexture::CUVEAnimTexture(TToken&& tex, CIntElement* a, CIntElement* b, CIntElement* c, CIntElement* d, CIntElement* e, bool f) -: x4_tex(std::move(tex)), x24_loop(f), x28_cycleFrameRate(e) +: x4_tex(std::move(tex)), x24_loop(f), x28_cycleFrames(e) { a->GetValue(0, x10_tileW); delete a; @@ -42,7 +42,7 @@ CUVEAnimTexture::CUVEAnimTexture(TToken&& tex, CIntElement* a, CIntEle void CUVEAnimTexture::GetValueUV(int frame, SUVElementSet& valOut) const { int cv; - x28_cycleFrameRate->GetValue(frame, cv); + x28_cycleFrames->GetValue(frame, cv); float cvf = cv / float(x20_tiles); cvf = frame / cvf; diff --git a/Runtime/Particle/CUVElement.hpp b/Runtime/Particle/CUVElement.hpp index 85b74c5f4..d03749191 100644 --- a/Runtime/Particle/CUVElement.hpp +++ b/Runtime/Particle/CUVElement.hpp @@ -49,7 +49,7 @@ struct CUVEAnimTexture : public CUVElement int x10_tileW, x14_tileH, x18_strideW, x1c_strideH; int x20_tiles; bool x24_loop; - std::unique_ptr x28_cycleFrameRate; + std::unique_ptr x28_cycleFrames; std::vector x2c_uvElems; public: CUVEAnimTexture(TToken&& tex, CIntElement* a, CIntElement* b,