From 3281966a44c6eb94fe3e3c08198aa2a8ca802d9e Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Tue, 18 Oct 2022 20:51:49 -0700 Subject: [PATCH] Remove fake destructor definitions Former-commit-id: 8281bd5424d79065293d3a0483ee28de05390f88 --- include/Kyoto/Particles/CVectorElement.hpp | 44 +++++++++--- src/Kyoto/Particles/CVectorElement.cpp | 81 +++++++++++++++++----- 2 files changed, 99 insertions(+), 26 deletions(-) diff --git a/include/Kyoto/Particles/CVectorElement.hpp b/include/Kyoto/Particles/CVectorElement.hpp index 84a37c3d..77b4f92e 100644 --- a/include/Kyoto/Particles/CVectorElement.hpp +++ b/include/Kyoto/Particles/CVectorElement.hpp @@ -11,9 +11,9 @@ class CVEFastConstant : public CVectorElement { public: CVEFastConstant(float x, float y, float z); - ~CVEFastConstant(); + ~CVEFastConstant() override; bool GetValue(int frame, CVector3f& valOut) const override; - bool IsFastConstant() const; + bool IsFastConstant() const override { return true; } private: CVector3f x4_val; @@ -21,43 +21,43 @@ private: class CVEParticleLocation : public CVectorElement { public: - ~CVEParticleLocation(); + ~CVEParticleLocation() override {} bool GetValue(int frame, CVector3f& valOut) const; }; class CVEParticleColor : public CVectorElement { public: - ~CVEParticleColor(); + ~CVEParticleColor() override {} bool GetValue(int frame, CVector3f& valOut) const; }; class CVEParticleVelocity : public CVectorElement { public: - ~CVEParticleVelocity(); + ~CVEParticleVelocity() override {} bool GetValue(int frame, CVector3f& valOut) const; }; class CVEParticleSystemOrientationFront : public CVectorElement { public: - ~CVEParticleSystemOrientationFront(); + ~CVEParticleSystemOrientationFront() override {} bool GetValue(int frame, CVector3f& valOut) const override; }; class CVEParticleSystemOrientationUp : public CVectorElement { public: - ~CVEParticleSystemOrientationUp(); + ~CVEParticleSystemOrientationUp() override {} bool GetValue(int frame, CVector3f& valOut) const override; }; class CVEParticleSystemOrientationRight : public CVectorElement { public: - ~CVEParticleSystemOrientationRight(); + ~CVEParticleSystemOrientationRight() override {} bool GetValue(int frame, CVector3f& valOut) const override; }; class CVEParticleSystemTranslation : public CVectorElement { public: - ~CVEParticleSystemTranslation(); + ~CVEParticleSystemTranslation() override {} bool GetValue(int frame, CVector3f& valOut) const override; }; @@ -73,4 +73,30 @@ public: CRealElement* xc_z; }; +class CVECone : public CVectorElement { + CVectorElement* x4_direction; + CRealElement* x8_magnitude; + CVector3f xc_xVec; + CVector3f x18_yVec; + +public: + CVECone(CVectorElement* direction, CRealElement* magnitude); + ~CVECone(); + bool GetValue(int frame, CVector3f& valOut) const override; +}; + +class CVEAngleCone : public CVectorElement { + CRealElement* x4_angleXConstant; + CRealElement* x8_angleYConstant; + CRealElement* xc_angleXRange; + CRealElement* x10_angleYRange; + CRealElement* x14_magnitude; + +public: + CVEAngleCone(CRealElement* angleXConstant, CRealElement* angleYConstant, + CRealElement* angleXRange, CRealElement* angleYRange, CRealElement* magnitude); + ~CVEAngleCone(); + bool GetValue(int frame, CVector3f& valOut) const override; +}; + #endif // _CVECTORELEMENT diff --git a/src/Kyoto/Particles/CVectorElement.cpp b/src/Kyoto/Particles/CVectorElement.cpp index e381f807..5a4f5625 100644 --- a/src/Kyoto/Particles/CVectorElement.cpp +++ b/src/Kyoto/Particles/CVectorElement.cpp @@ -1,21 +1,9 @@ #include "Kyoto/Particles/CVectorElement.hpp" -bool CVEFastConstant::IsFastConstant() const { return true; } - -CVEParticleLocation::~CVEParticleLocation() {} - -CVEParticleColor::~CVEParticleColor() {} - -CVEParticleVelocity::~CVEParticleVelocity() {} - -CVEParticleSystemOrientationFront::~CVEParticleSystemOrientationFront() {} - -CVEParticleSystemOrientationUp::~CVEParticleSystemOrientationUp() {} - -CVEParticleSystemOrientationRight::~CVEParticleSystemOrientationRight() {} - -CVEParticleSystemTranslation::~CVEParticleSystemTranslation() {} +#include "Kyoto/CRandom16.hpp" +#include "Kyoto/Math/CMath.hpp" +#include "rstl/math.hpp" CVEConstant::CVEConstant(CRealElement* x, CRealElement* y, CRealElement* z) : x4_x(x), x8_y(y), xc_z(z) {} @@ -35,8 +23,7 @@ bool CVEConstant::GetValue(int frame, CVector3f& valOut) const { return false; } -CVEFastConstant::CVEFastConstant(float x, float y, float z) -: x4_val(x, y, z) {} +CVEFastConstant::CVEFastConstant(float x, float y, float z) : x4_val(x, y, z) {} CVEFastConstant::~CVEFastConstant() {} @@ -44,3 +31,63 @@ bool CVEFastConstant::GetValue(int frame, CVector3f& valOut) const { valOut = x4_val; return false; } + +CVECone::CVECone(CVectorElement* direction, CRealElement* magnitude) +: x4_direction(direction) +, x8_magnitude(magnitude) +, xc_xVec(CVector3f::Zero()) +, x18_yVec(CVector3f::Zero()) { + CVector3f av(0.f, 0.f, 0.f); + x4_direction->GetValue(0, av); + CVector3f avNorm = av.AsNormalized(); + if (avNorm.GetX() > 0.8f) { + xc_xVec = CVector3f::Cross(av, CVector3f(0.f, 1.f, 0.f)); + } else { + xc_xVec = CVector3f::Cross(av, CVector3f(1.f, 0.f, 0.f)); + } + x18_yVec = CVector3f::Cross(xc_xVec, avNorm); +} + +CVECone::~CVECone() { + delete x4_direction; + delete x8_magnitude; +} + +bool CVECone::GetValue(int frame, CVector3f& valOut) const { + float b; + CVector3f dir(0.f, 0.f, 0.f); + + x8_magnitude->GetValue(frame, b); + x4_direction->GetValue(frame, dir); + float b2 = rstl::min_val(1.f, b); + + float randX = 0.f, randY = 0.f; + do { + randX = 2.f * b2 * CRandom16::GetRandomNumber()->Float() - 0.5f; + randY = 2.f * b2 * CRandom16::GetRandomNumber()->Float() - 0.5f; + } while (randX * randX + randY * randY > 1.f); + + valOut = xc_xVec * randX + x18_yVec * randY + dir; + return false; +} + +CVEAngleCone::CVEAngleCone(CRealElement* angleXConstant, CRealElement* angleYConstant, + CRealElement* angleXRange, CRealElement* angleYRange, + CRealElement* magnitude) +: x4_angleXConstant(angleXConstant) +, x8_angleYConstant(angleYConstant) +, xc_angleXRange(angleXRange) +, x10_angleYRange(angleYRange) +, x14_magnitude(magnitude) {} + +CVEAngleCone::~CVEAngleCone() { + delete x4_angleXConstant; + delete x8_angleYConstant; + delete xc_angleXRange; + delete x10_angleYRange; + delete x14_magnitude; +} + +bool CVEAngleCone::GetValue(int frame, CVector3f& valOut) const { + return false; +}