BNCE variable names and some doc-links

This commit is contained in:
Jack Andersen 2016-02-27 20:55:05 -10:00
parent 4405af9925
commit accc593102
14 changed files with 71 additions and 37 deletions

View File

@ -4,6 +4,8 @@
#include "CRandom16.hpp" #include "CRandom16.hpp"
#include <math.h> #include <math.h>
/* Documentation at: http://www.metroid2002.com/retromodding/wiki/Particle_Script#Color_Elements */
namespace pshag namespace pshag
{ {

View File

@ -3,6 +3,8 @@
#include "IElement.hpp" #include "IElement.hpp"
/* Documentation at: http://www.metroid2002.com/retromodding/wiki/Particle_Script#Color_Elements */
namespace pshag namespace pshag
{ {

View File

@ -1,6 +1,8 @@
#include "CEmitterElement.hpp" #include "CEmitterElement.hpp"
#include "CRandom16.hpp" #include "CRandom16.hpp"
/* Documentation at: http://www.metroid2002.com/retromodding/wiki/Particle_Script#Emitter_Elements */
namespace pshag namespace pshag
{ {

View File

@ -3,6 +3,8 @@
#include "IElement.hpp" #include "IElement.hpp"
/* Documentation at: http://www.metroid2002.com/retromodding/wiki/Particle_Script#Emitter_Elements */
namespace pshag namespace pshag
{ {

View File

@ -2,6 +2,8 @@
#include "CParticleGlobals.hpp" #include "CParticleGlobals.hpp"
#include "CRandom16.hpp" #include "CRandom16.hpp"
/* Documentation at: http://www.metroid2002.com/retromodding/wiki/Particle_Script#Int_Elements */
namespace pshag namespace pshag
{ {

View File

@ -3,6 +3,8 @@
#include "IElement.hpp" #include "IElement.hpp"
/* Documentation at: http://www.metroid2002.com/retromodding/wiki/Particle_Script#Int_Elements */
namespace pshag namespace pshag
{ {

View File

@ -3,6 +3,8 @@
#include "CRandom16.hpp" #include "CRandom16.hpp"
#include <math.h> #include <math.h>
/* Documentation at: http://www.metroid2002.com/retromodding/wiki/Particle_Script#Mod_Vector_Elements */
namespace pshag namespace pshag
{ {
@ -98,59 +100,64 @@ bool CMVETimeChain::GetValue(int frame, Zeus::CVector3f& pVel, Zeus::CVector3f&
} }
CMVEBounce::CMVEBounce(CVectorElement* a, CVectorElement* b, CRealElement* c, CRealElement* d, bool f) CMVEBounce::CMVEBounce(CVectorElement* a, CVectorElement* b, CRealElement* c, CRealElement* d, bool f)
: x4_a(a), x8_b(b), xc_c(c), x10_d(d), x14_e(false), x15_f(f), x24_j(0.0) : x4_planePoint(a), x8_planeNormal(b), xc_friction(c), x10_restitution(d), x14_planePrecomputed(false), x15_dieOnPenetrate(f), x24_planeD(0.0)
{ {
if (x4_a && x8_b && x4_a->IsFastConstant() && x8_b->IsFastConstant()) if (x4_planePoint && x8_planeNormal && x4_planePoint->IsFastConstant() && x8_planeNormal->IsFastConstant())
{ {
x14_e = true; /* Precompute Hesse normal form of plane (for penetration testing)
x8_b->GetValue(0, x18_g); * https://en.wikipedia.org/wiki/Hesse_normal_form */
x14_planePrecomputed = true;
x8_planeNormal->GetValue(0, x18_planeValidatedNormal);
if (x18_g.magSquared() > 0.0) if (x18_planeValidatedNormal.magSquared() > 0.0)
x18_g.normalize(); x18_planeValidatedNormal.normalize();
Zeus::CVector3f a; Zeus::CVector3f a;
x4_a->GetValue(0, a); x4_planePoint->GetValue(0, a);
x24_j = x18_g.dot(a); x24_planeD = x18_planeValidatedNormal.dot(a);
} }
} }
bool CMVEBounce::GetValue(int frame, Zeus::CVector3f& pVel, Zeus::CVector3f& pPos) const bool CMVEBounce::GetValue(int frame, Zeus::CVector3f& pVel, Zeus::CVector3f& pPos) const
{ {
if (!x14_e) if (!x14_planePrecomputed)
{ {
x8_b->GetValue(frame, ((Zeus::CVector3f&)x18_g)); /* Compute Hesse normal form of plane (for penetration testing) */
((Zeus::CVector3f&)x18_g).normalize(); x8_planeNormal->GetValue(frame, ((Zeus::CVector3f&)x18_planeValidatedNormal));
((Zeus::CVector3f&)x18_planeValidatedNormal).normalize();
Zeus::CVector3f a; Zeus::CVector3f a;
x4_a->GetValue(frame, a); x4_planePoint->GetValue(frame, a);
(float&)(x24_j) = x18_g.dot(a); (float&)(x24_planeD) = x18_planeValidatedNormal.dot(a);
} }
float dot = x18_g.dot(pPos); float dot = x18_planeValidatedNormal.dot(pPos);
if ((dot - x24_j) <= 0.0f) if ((dot - x24_planeD) <= 0.0f)
{ {
if (x15_f) if (x15_dieOnPenetrate)
return true; return true;
} }
else else
return false; return false;
/* Deflection event */
if (pVel.magSquared() > 0.0f) if (pVel.magSquared() > 0.0f)
return false; return false;
Zeus::CVector3f delta = pPos - pVel; Zeus::CVector3f delta = pPos - pVel;
pPos += Zeus::CVector3f{(-((((delta.z * ((delta.x * (delta.y * x18_g.y)) pPos += Zeus::CVector3f{(-((((delta.z * ((delta.x * (delta.y * x18_planeValidatedNormal.y))
+ ((pVel.x * (x18_g.y * pVel.y)) + x18_g.x))) + x18_g.z) - x24_j)) / + ((pVel.x * (x18_planeValidatedNormal.y * pVel.y)) + x18_planeValidatedNormal.x))) + x18_planeValidatedNormal.z) - x24_planeD)) /
((pVel.z * ((pVel.x * (x18_g.y * pVel.y)) + x18_g.x)) + x18_g.z)) - ( ((pVel.z * ((pVel.x * (x18_planeValidatedNormal.y * pVel.y)) + x18_planeValidatedNormal.x)) + x18_planeValidatedNormal.z)) - (
(x18_g.z * ((x18_g.x * (x18_g.y * pVel.y)) + pVel.x)) + pVel.z)} * pVel; (x18_planeValidatedNormal.z * ((x18_planeValidatedNormal.x * (x18_planeValidatedNormal.y * pVel.y)) + pVel.x)) + pVel.z)} * pVel;
float d = 0.0f; float d = 0.0f;
x10_d->GetValue(frame, d); x10_restitution->GetValue(frame, d);
pVel -= d * pVel; pVel -= d * pVel;
float c = 0.0f; float c = 0.0f;
xc_c->GetValue(frame, c); xc_friction->GetValue(frame, c);
pVel -= Zeus::CVector3f{(1.0f + c) * ((x18_g.z * (x18_g.x * (x18_g.y * pVel.y)) + pVel.x) + pVel.x)} * x18_g; pVel -= Zeus::CVector3f{(1.0f + c) * ((x18_planeValidatedNormal.z * (x18_planeValidatedNormal.x * (x18_planeValidatedNormal.y * pVel.y)) + pVel.x) + pVel.x)} * x18_planeValidatedNormal;
return false; return false;
} }

View File

@ -3,6 +3,8 @@
#include "IElement.hpp" #include "IElement.hpp"
/* Documentation at: http://www.metroid2002.com/retromodding/wiki/Particle_Script#Mod_Vector_Elements */
namespace pshag namespace pshag
{ {
@ -58,14 +60,14 @@ public:
class CMVEBounce : public CModVectorElement class CMVEBounce : public CModVectorElement
{ {
std::unique_ptr<CVectorElement> x4_a; std::unique_ptr<CVectorElement> x4_planePoint;
std::unique_ptr<CVectorElement> x8_b; std::unique_ptr<CVectorElement> x8_planeNormal;
std::unique_ptr<CRealElement> xc_c; std::unique_ptr<CRealElement> xc_friction;
std::unique_ptr<CRealElement> x10_d; std::unique_ptr<CRealElement> x10_restitution;
bool x14_e; bool x14_planePrecomputed;
bool x15_f; bool x15_dieOnPenetrate;
Zeus::CVector3f x18_g; Zeus::CVector3f x18_planeValidatedNormal;
float x24_j; float x24_planeD;
public: public:
CMVEBounce(CVectorElement* a, CVectorElement* b, CRealElement* c, CRealElement* d, bool e); CMVEBounce(CVectorElement* a, CVectorElement* b, CRealElement* c, CRealElement* d, bool e);
bool GetValue(int frame, Zeus::CVector3f& pVel, Zeus::CVector3f& pPos) const; bool GetValue(int frame, Zeus::CVector3f& pVel, Zeus::CVector3f& pPos) const;

View File

@ -1,8 +1,11 @@
#include "CRealElement.hpp" #include "CRealElement.hpp"
#include "CParticleGlobals.hpp" #include "CParticleGlobals.hpp"
#include "CRandom16.hpp" #include "CRandom16.hpp"
#include "CElementGen.hpp"
#include <math.h> #include <math.h>
/* Documentation at: http://www.metroid2002.com/retromodding/wiki/Particle_Script#Real_Elements */
namespace pshag namespace pshag
{ {
@ -278,13 +281,13 @@ bool CREParticleAccessParam8::GetValue(int frame, float& valOut) const
bool CREPSLL::GetValue(int frame, float& valOut) const bool CREPSLL::GetValue(int frame, float& valOut) const
{ {
//valOut = CParticleGlobals::g_particleMetrics->x2c_psll; valOut = CElementGen::g_currentParticle->x2c_lineLengthOrSize;
return false; return false;
} }
bool CREPRLW::GetValue(int frame, float& valOut) const bool CREPRLW::GetValue(int frame, float& valOut) const
{ {
//valOut = CParticleGlobals::g_particleMetrics->x30_prlw; valOut = CElementGen::g_currentParticle->x30_lineWidthOrRota;
return false; return false;
} }

View File

@ -3,6 +3,8 @@
#include "IElement.hpp" #include "IElement.hpp"
/* Documentation at: http://www.metroid2002.com/retromodding/wiki/Particle_Script#Real_Elements */
namespace pshag namespace pshag
{ {

View File

@ -1,5 +1,7 @@
#include "CUVElement.hpp" #include "CUVElement.hpp"
/* Documentation at: http://www.metroid2002.com/retromodding/wiki/Particle_Script#UV_Elements */
namespace pshag namespace pshag
{ {

View File

@ -5,6 +5,8 @@
#include "CToken.hpp" #include "CToken.hpp"
#include "CTexture.hpp" #include "CTexture.hpp"
/* Documentation at: http://www.metroid2002.com/retromodding/wiki/Particle_Script#UV_Elements */
namespace pshag namespace pshag
{ {
class CToken; class CToken;

View File

@ -4,6 +4,8 @@
#include "CElementGen.hpp" #include "CElementGen.hpp"
#include <math.h> #include <math.h>
/* Documentation at: http://www.metroid2002.com/retromodding/wiki/Particle_Script#Vector_Elements */
namespace pshag namespace pshag
{ {
@ -192,7 +194,7 @@ bool CVEFastConstant::GetValue(int frame, Zeus::CVector3f& valOut) const
} }
CVECircle::CVECircle(CVectorElement* a, CVectorElement* b, CRealElement* c, CRealElement* d, CRealElement* e) CVECircle::CVECircle(CVectorElement* a, CVectorElement* b, CRealElement* c, CRealElement* d, CRealElement* e)
: x4_direction(a), x20_angleConstant(c), x24_angleLinear(d), x28_magnitude(e) : x4_direction(a), x20_angleConstant(c), x24_angleLinear(d), x28_radius(e)
{ {
Zeus::CVector3f bv; Zeus::CVector3f bv;
b->GetValue(0, bv); b->GetValue(0, bv);
@ -210,7 +212,7 @@ bool CVECircle::GetValue(int frame, Zeus::CVector3f& valOut) const
float c, d, e; float c, d, e;
x20_angleConstant->GetValue(frame, c); x20_angleConstant->GetValue(frame, c);
x24_angleLinear->GetValue(frame, d); x24_angleLinear->GetValue(frame, d);
x28_magnitude->GetValue(frame, e); x28_radius->GetValue(frame, e);
float curAngle = (d * frame + c) * M_PI / 180.f; float curAngle = (d * frame + c) * M_PI / 180.f;

View File

@ -3,6 +3,8 @@
#include "IElement.hpp" #include "IElement.hpp"
/* Documentation at: http://www.metroid2002.com/retromodding/wiki/Particle_Script#Vector_Elements */
namespace pshag namespace pshag
{ {
@ -104,7 +106,7 @@ class CVECircle : public CVectorElement
Zeus::CVector3f x14_yVec; Zeus::CVector3f x14_yVec;
std::unique_ptr<CRealElement> x20_angleConstant; std::unique_ptr<CRealElement> x20_angleConstant;
std::unique_ptr<CRealElement> x24_angleLinear; std::unique_ptr<CRealElement> x24_angleLinear;
std::unique_ptr<CRealElement> x28_magnitude; std::unique_ptr<CRealElement> x28_radius;
public: public:
CVECircle(CVectorElement* a, CVectorElement* b, CRealElement* c, CRealElement* d, CRealElement* e); CVECircle(CVectorElement* a, CVectorElement* b, CRealElement* c, CRealElement* d, CRealElement* e);
bool GetValue(int frame, Zeus::CVector3f& valOut) const; bool GetValue(int frame, Zeus::CVector3f& valOut) const;