diff options
-rw-r--r-- | src/control/Script.cpp | 6 | ||||
-rw-r--r-- | src/render/SpecialFX.cpp | 21 |
2 files changed, 13 insertions, 14 deletions
diff --git a/src/control/Script.cpp b/src/control/Script.cpp index a43a86a6..d31958f3 100644 --- a/src/control/Script.cpp +++ b/src/control/Script.cpp @@ -9006,9 +9006,9 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) case COMMAND_UPDATE_BOAT_FOAM_ANIMATION: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle->m_vehType == VEHICLE_TYPE_BOAT); - CSpecialParticleStuff::UpdateBoatFoamAnimation(&pVehicle->GetMatrix()); + CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + assert(pObject); + CSpecialParticleStuff::UpdateBoatFoamAnimation(&pObject->GetMatrix()); return 0; } case COMMAND_SET_MUSIC_DOES_FADE: diff --git a/src/render/SpecialFX.cpp b/src/render/SpecialFX.cpp index 39b22671..e52222a2 100644 --- a/src/render/SpecialFX.cpp +++ b/src/render/SpecialFX.cpp @@ -386,13 +386,15 @@ CMoneyMessages::RegisterOne(CVector vecPos, const char *pText, uint8 bRed, uint8 aMoneyMessages[nIndex].m_fOpacity = fOpacity;
}
+CRGBA FoamColour(255, 255, 255, 255);
+unsigned int CSpecialParticleStuff::BoatFromStart;
+
void CSpecialParticleStuff::CreateFoamAroundObject(CMatrix* pMatrix, float innerFw, float innerRg, float innerUp, int32 particles)
{
- int attempts = 0;
float outerFw = innerFw + 5.0f;
float outerRg = innerRg + 5.0f;
float outerUp = innerUp + 5.0f;
- while (particles > 0 && attempts < 1000) {
+ for (int attempts = 0; particles > 0 && attempts < 1000; attempts++) {
CVector pos;
int rnd = CGeneral::GetRandomNumber();
pos.x = (int8)(rnd - 128) / 110.0f;
@@ -400,20 +402,20 @@ void CSpecialParticleStuff::CreateFoamAroundObject(CMatrix* pMatrix, float inner pos.z = 0.0f;
if (DotProduct2D(pos, TheCamera.GetForward()) >= 0)
continue;
+ // was there any point in adding it here?
pos += pMatrix->GetPosition();
pos.z = 2.0f;
- // was there any point in adding it here?
- float fw = DotProduct(pMatrix->GetForward(), pos - pMatrix->GetPosition());
+ float fw = Abs(DotProduct(pMatrix->GetForward(), pos - pMatrix->GetPosition()));
if (fw >= outerFw)
continue;
- float rg = DotProduct(pMatrix->GetRight(), pos - pMatrix->GetPosition());
+ float rg = Abs(DotProduct(pMatrix->GetRight(), pos - pMatrix->GetPosition()));
if (rg >= outerRg)
continue;
- float up = DotProduct(pMatrix->GetUp(), pos - pMatrix->GetPosition());
+ float up = Abs(DotProduct(pMatrix->GetUp(), pos - pMatrix->GetPosition()));
if (up >= outerUp)
continue;
if (fw > innerFw || rg > innerRg || up > innerUp) {
- CParticle::AddParticle(PARTICLE_STEAM2, pos, CVector(0.0f, 0.0f, 0.0f), nil, 4.0f, 1, 0, 0, 0);
+ CParticle::AddParticle(PARTICLE_STEAM2, pos, CVector(0.0f, 0.0f, 0.0f), nil, 4.0f, FoamColour, 1, 0, 0, 0);
particles--;
}
}
@@ -424,9 +426,6 @@ void CSpecialParticleStuff::StartBoatFoamAnimation() BoatFromStart = CTimer::GetTimeInMilliseconds();
}
-CRGBA FoamColour(255, 255, 255, 255);
-unsigned int CSpecialParticleStuff::BoatFromStart;
-
void CSpecialParticleStuff::UpdateBoatFoamAnimation(CMatrix* pMatrix)
{
static int32 FrameInAnimation = 0;
@@ -441,7 +440,7 @@ void CSpecialParticleStuff::UpdateBoatFoamAnimation(CMatrix* pMatrix) CVector pos = *pMatrix * CVector(X, Y, Z);
CParticle::AddParticle(PARTICLE_STEAM_NY, pos, CVector(0.0f, 0.0f, 0.0f),
nil, FrameInAnimation * 0.5f + 2.0f, FoamColour, 1, 0, 0, 0);
- if (++FrameInAnimation)
+ if (++FrameInAnimation > 15)
FrameInAnimation = 0;
}
if ((cur & 0x3FF) < (prev & 0x3FF)) {
|