ModVectorElement implementations

This commit is contained in:
Phillip Stephens 2016-02-13 16:14:23 -08:00
parent e64e4b6c0b
commit 0073569512
2 changed files with 113 additions and 12 deletions

View File

@ -143,10 +143,111 @@ bool CMVEBounce::GetValue(int frame, Zeus::CVector3f& pVel, Zeus::CVector3f& pPo
return false;
}
bool CMVEConstant::GetValue(int frame, Zeus::CVector3f& pVel, Zeus::CVector3f& pPos) const
{
x4_x->GetValue(frame, pVel.x);
x8_y->GetValue(frame, pVel.y);
xc_z->GetValue(frame, pVel.z);
return false;
}
bool CMVEFastConstant::GetValue(int /*frame*/, Zeus::CVector3f& pVel, Zeus::CVector3f& /*pPos*/) const
{
pVel = x4_val;
return false;
}
bool CMVEGravity::GetValue(int frame, Zeus::CVector3f& pVel, Zeus::CVector3f& /*pPos*/) const
{
Zeus::CVector3f grav;
x4_a->GetValue(frame, grav);
pVel += grav;
return false;
}
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);
vec.normalize();
float a;
x4_a->GetValue(frame, a);
pVel = vec * a;
}
return false;
}
bool CMVESetPosition::GetValue(int frame, Zeus::CVector3f& /*pVel*/, Zeus::CVector3f& pPos) const
{
x4_a->GetValue(frame, pPos);
return false;
}
bool CMVEPulse::GetValue(int frame, Zeus::CVector3f& pVel, Zeus::CVector3f& pPos) const
{
int a, b;
x4_aDuration->GetValue(frame, a);
x8_bDuration->GetValue(frame, b);
int cv = std::max(1, a + b + 1);
if (b >= 1)
{
int cv2 = frame % cv;
if (cv2 >= a)
x10_bVal->GetValue(frame, pVel, pPos);
else
xc_aVal->GetValue(frame, pVel, pPos);
}
else
xc_aVal->GetValue(frame, pVel, pPos);
return false;
}
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;
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);
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);
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);
pVel.z = (c * ((f9 * b.z) + (d * ((b.x * (x * b.y)) - y)))) + ((1.0 - c) * pVel.x);
return false;
}
}

View File

@ -73,12 +73,12 @@ public:
class CMVEConstant : public CModVectorElement
{
std::unique_ptr<CRealElement> x4_a;
std::unique_ptr<CRealElement> x8_b;
std::unique_ptr<CRealElement> xc_c;
std::unique_ptr<CRealElement> x4_x;
std::unique_ptr<CRealElement> x8_y;
std::unique_ptr<CRealElement> xc_z;
public:
CMVEConstant(CRealElement* a, CRealElement* b, CRealElement* c)
: x4_a(a), x8_b(b), xc_c(c) {}
: x4_x(a), x8_y(b), xc_z(c) {}
bool GetValue(int frame, Zeus::CVector3f& pVel, Zeus::CVector3f& pPos) const;
};
@ -121,23 +121,23 @@ public:
class CMVEPulse : public CModVectorElement
{
std::unique_ptr<CIntElement> x4_a;
std::unique_ptr<CIntElement> x8_b;
std::unique_ptr<CModVectorElement> xc_c;
std::unique_ptr<CModVectorElement> x10_d;
std::unique_ptr<CIntElement> x4_aDuration;
std::unique_ptr<CIntElement> x8_bDuration;
std::unique_ptr<CModVectorElement> xc_aVal;
std::unique_ptr<CModVectorElement> x10_bVal;
public:
CMVEPulse(CIntElement* a, CIntElement* b, CModVectorElement* c, CModVectorElement* d)
: x4_a(a), x8_b(b), xc_c(c), x10_d(d) {}
: x4_aDuration(a), x8_bDuration(b), xc_aVal(c), x10_bVal(d) {}
bool GetValue(int frame, Zeus::CVector3f& pVel, Zeus::CVector3f& pPos) const;
};
class CMVEWind : public CModVectorElement
{
std::unique_ptr<CVectorElement> x4_a;
std::unique_ptr<CRealElement> x8_b;
std::unique_ptr<CVectorElement> x4_direction;
std::unique_ptr<CRealElement> x8_speed;
public:
CMVEWind(CVectorElement* a, CRealElement* b)
: x4_a(a), x8_b(b) {}
: x4_direction(a), x8_speed(b) {}
bool GetValue(int frame, Zeus::CVector3f& pVel, Zeus::CVector3f& pPos) const;
};