fix TVec3<f32>::setLength

This commit is contained in:
LagoLunatic
2024-04-14 18:10:49 -04:00
parent 6a3ae88d95
commit 0c32a3d3c1
4 changed files with 23 additions and 26 deletions
@@ -12,13 +12,13 @@ struct J3DAnmKeyTableBase {
}; // Size = 0x6
struct J3DAnmColorKeyTable {
enum Color {
RED = 0,
GREEN = 1,
BLUE = 2,
ALPHA = 3,
};
/* 0x00 */ J3DAnmKeyTableBase mColorInfo[4];
enum Color {
RED = 0,
GREEN = 1,
BLUE = 2,
ALPHA = 3,
};
/* 0x00 */ J3DAnmKeyTableBase mColorInfo[4];
}; // Size = 0x18
struct J3DAnmColorFullTable {
+7 -4
View File
@@ -207,22 +207,25 @@ struct TVec3<f32> : public Vec {
z = a.x * b.y - a.y * b.x;
}
void setLength(f32 len) {
f32 setLength(f32 len) {
f32 sq = squared();
if (sq <= TUtil<f32>::epsilon()) {
return;
return 0.0f;
}
f32 norm = TUtil<f32>::inv_sqrt(sq);
scale(norm * len);
return sq * norm;
}
void setLength(const TVec3<f32>& b, f32 len) {
f32 setLength(const TVec3<f32>& b, f32 len) {
f32 sq = b.squared();
if (sq <= TUtil<f32>::epsilon()) {
return;
zero();
return 0.0f;
}
f32 norm = TUtil<f32>::inv_sqrt(sq);
scale(norm * len, b);
return sq * norm;
}
template<typename S>
+1 -5
View File
@@ -270,11 +270,7 @@ void JPAConvectionField::calc(JPAFieldData* data, JPABaseParticle* ptcl) {
JGeometry::TVec3<f32> newPos;
newPos.add(axisX, axisZ);
if (newPos.isZero()) {
newPos.zero();
} else {
newPos.setLength(data->mVal1);
}
newPos.setLength(newPos, data->mVal1);
JGeometry::TVec3<f32> delta, axisY;
delta.sub(ptcl->mLocalPosition, newPos);
+8 -10
View File
@@ -28,13 +28,15 @@ void JPABaseParticle::initParticle() {
mGlobalPosition.set(emtrInfo.mEmitterGlobalCenter);
velOmni.zero();
if (emtr->mInitialVelOmni != 0.0f && !emtrInfo.mVelOmni.isZero())
if (emtr->mInitialVelOmni)
velOmni.setLength(emtrInfo.mVelOmni, emtr->mInitialVelOmni);
else
velOmni.zero();
velAxis.zero();
if (emtr->mInitialVelAxis != 0.0f && !emtrInfo.mVelAxis.isZero())
if (emtr->mInitialVelAxis)
velAxis.setLength(emtrInfo.mVelAxis, emtr->mInitialVelAxis);
else
velAxis.zero();
velDir.zero();
if (emtr->mInitialVelDir != 0.0f) {
@@ -63,12 +65,8 @@ void JPABaseParticle::initParticle() {
MTXMultVec(emtrInfo.mEmitterGlobalRot, mBaseVel, mBaseVel);
if (mBaseVel.isZero()) {
mAccel.zero();
} else {
f32 accel = emtr->mAccel * (1.0f + emtr->getRandomRF() * emtr->mAccelRndm);
mAccel.setLength(mBaseVel, accel);
}
f32 accel = emtr->mAccel * (1.0f + emtr->getRandomRF() * emtr->mAccelRndm);
mAccel.setLength(mBaseVel, accel);
mAirResist = emtr->mAirResist + emtr->mAirResistRndm * emtr->getRandomSF();
if (mAirResist > 1.0f)