Fix CScriptEffect translation set

This commit is contained in:
Jack Andersen 2018-06-12 16:32:02 -10:00
parent 00a4cbdac7
commit 941c4d793c
4 changed files with 14 additions and 23 deletions

View File

@ -774,7 +774,7 @@ struct MVESwirl : IModVectorElement
AT_DECL_DNA_YAML AT_DECL_DNA_YAML
VectorElementFactory helixPoint; VectorElementFactory helixPoint;
VectorElementFactory curveBinormal; VectorElementFactory curveBinormal;
RealElementFactory targetRadius; RealElementFactory filterGain;
RealElementFactory tangentialVelocity; RealElementFactory tangentialVelocity;
const char* ClassID() const {return "SWRL";} const char* ClassID() const {return "SWRL";}
}; };

View File

@ -249,22 +249,13 @@ bool CMVESwirl::GetValue(int frame, zeus::CVector3f& pVel, zeus::CVector3f& pPos
x4_helixPoint->GetValue(frame, a); x4_helixPoint->GetValue(frame, a);
x8_curveBinormal->GetValue(frame, b); x8_curveBinormal->GetValue(frame, b);
/* Compute FrenetSerret normal const zeus::CVector3f posToOrigin = a - pPos;
* https://en.wikipedia.org/wiki/FrenetSerret_formulas */ const zeus::CVector3f posToHelix = posToOrigin - posToOrigin.dot(b) * 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; float c = 0.0f, d = 0.0f;
xc_targetRadius->GetValue(frame, c); xc_filterGain->GetValue(frame, c);
x10_tangentialVelocity->GetValue(frame, d); x10_tangentialVelocity->GetValue(frame, d);
const zeus::CVector3f wetVel = (posToHelix.cross(b) * d + b * b.dot(pVel));
/* Integrate tangential velocity by crossing particle normal with binormal, pVel = c * wetVel + (1.f - c) * pVel;
* 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);
pVel.z = (c * ((f9 * b.z) + (d * ((b.x * (x * b.y)) - y)))) + ((1.0 - c) * pVel.x);
return false; return false;
} }

View File

@ -157,13 +157,13 @@ class CMVESwirl : public CModVectorElement
{ {
std::unique_ptr<CVectorElement> x4_helixPoint; std::unique_ptr<CVectorElement> x4_helixPoint;
std::unique_ptr<CVectorElement> x8_curveBinormal; std::unique_ptr<CVectorElement> x8_curveBinormal;
std::unique_ptr<CRealElement> xc_targetRadius; std::unique_ptr<CRealElement> xc_filterGain;
std::unique_ptr<CRealElement> x10_tangentialVelocity; std::unique_ptr<CRealElement> x10_tangentialVelocity;
public: public:
CMVESwirl(std::unique_ptr<CVectorElement>&& a, std::unique_ptr<CVectorElement>&& b, CMVESwirl(std::unique_ptr<CVectorElement>&& a, std::unique_ptr<CVectorElement>&& b,
std::unique_ptr<CRealElement>&& c, std::unique_ptr<CRealElement>&& d) std::unique_ptr<CRealElement>&& c, std::unique_ptr<CRealElement>&& d)
: x4_helixPoint(std::move(a)), x8_curveBinormal(std::move(b)), : x4_helixPoint(std::move(a)), x8_curveBinormal(std::move(b)),
xc_targetRadius(std::move(c)), x10_tangentialVelocity(std::move(d)) {} xc_filterGain(std::move(c)), x10_tangentialVelocity(std::move(d)) {}
bool GetValue(int frame, zeus::CVector3f& pVel, zeus::CVector3f& pPos) const; bool GetValue(int frame, zeus::CVector3f& pVel, zeus::CVector3f& pPos) const;
}; };

View File

@ -62,7 +62,7 @@ CScriptEffect::CScriptEffect(TUniqueId uid, std::string_view name, const CEntity
zeus::CTransform newXf = xf; zeus::CTransform newXf = xf;
newXf.origin = zeus::CVector3f::skZero; newXf.origin = zeus::CVector3f::skZero;
x104_particleSystem->SetOrientation(newXf); x104_particleSystem->SetOrientation(newXf);
x104_particleSystem->SetTranslation(xf.origin); x104_particleSystem->SetGlobalTranslation(xf.origin);
x104_particleSystem->SetLocalScale(scale); x104_particleSystem->SetLocalScale(scale);
x104_particleSystem->SetParticleEmission(active); x104_particleSystem->SetParticleEmission(active);
x104_particleSystem->SetModulationColor(lParms.GetNoLightsAmbient()); x104_particleSystem->SetModulationColor(lParms.GetNoLightsAmbient());
@ -77,7 +77,7 @@ CScriptEffect::CScriptEffect(TUniqueId uid, std::string_view name, const CEntity
zeus::CTransform newXf = xf; zeus::CTransform newXf = xf;
newXf.origin = zeus::CVector3f::skZero; newXf.origin = zeus::CVector3f::skZero;
xf4_electric->SetOrientation(newXf); xf4_electric->SetOrientation(newXf);
xf4_electric->SetTranslation(xf.origin); xf4_electric->SetGlobalTranslation(xf.origin);
xf4_electric->SetLocalScale(scale); xf4_electric->SetLocalScale(scale);
xf4_electric->SetParticleEmission(active); xf4_electric->SetParticleEmission(active);
} }
@ -106,7 +106,7 @@ void CScriptEffect::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CSt
zeus::CTransform newXf = GetTransform(); zeus::CTransform newXf = GetTransform();
newXf.origin = zeus::CVector3f::skZero; newXf.origin = zeus::CVector3f::skZero;
x104_particleSystem->SetOrientation(newXf); x104_particleSystem->SetOrientation(newXf);
x104_particleSystem->SetTranslation(GetTranslation()); x104_particleSystem->SetGlobalTranslation(GetTranslation());
x104_particleSystem->SetLocalScale(scale); x104_particleSystem->SetLocalScale(scale);
x104_particleSystem->SetParticleEmission(oldActive); x104_particleSystem->SetParticleEmission(oldActive);
x104_particleSystem->SetModulationColor(color); x104_particleSystem->SetModulationColor(color);
@ -121,7 +121,7 @@ void CScriptEffect::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CSt
zeus::CTransform newXf = GetTransform(); zeus::CTransform newXf = GetTransform();
newXf.origin = zeus::CVector3f::skZero; newXf.origin = zeus::CVector3f::skZero;
xf4_electric->SetOrientation(newXf); xf4_electric->SetOrientation(newXf);
xf4_electric->SetTranslation(GetTranslation()); xf4_electric->SetGlobalTranslation(GetTranslation());
xf4_electric->SetLocalScale(scale); xf4_electric->SetLocalScale(scale);
xf4_electric->SetParticleEmission(oldActive); xf4_electric->SetParticleEmission(oldActive);
xf4_electric->SetModulationColor(color); xf4_electric->SetModulationColor(color);
@ -291,14 +291,14 @@ void CScriptEffect::Think(float dt, CStateManager& mgr)
zeus::CTransform newXf = x34_transform; zeus::CTransform newXf = x34_transform;
newXf.origin = zeus::CVector3f::skZero; newXf.origin = zeus::CVector3f::skZero;
x104_particleSystem->SetOrientation(newXf); x104_particleSystem->SetOrientation(newXf);
x104_particleSystem->SetTranslation(x34_transform.origin); x104_particleSystem->SetGlobalTranslation(x34_transform.origin);
} }
if (xf4_electric) if (xf4_electric)
{ {
zeus::CTransform newXf = x34_transform; zeus::CTransform newXf = x34_transform;
newXf.origin = zeus::CVector3f::skZero; newXf.origin = zeus::CVector3f::skZero;
xf4_electric->SetOrientation(newXf); xf4_electric->SetOrientation(newXf);
xf4_electric->SetTranslation(x34_transform.origin); xf4_electric->SetGlobalTranslation(x34_transform.origin);
} }
if (TCastToPtr<CActor> act = mgr.ObjectById(x108_lightId)) if (TCastToPtr<CActor> act = mgr.ObjectById(x108_lightId))