This commit is contained in:
Nikolay Korolev 2020-02-22 15:35:46 +03:00
parent 1337a9b603
commit 3481e431c9
2 changed files with 13 additions and 14 deletions

View File

@ -9006,9 +9006,9 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command)
case COMMAND_UPDATE_BOAT_FOAM_ANIMATION: case COMMAND_UPDATE_BOAT_FOAM_ANIMATION:
{ {
CollectParameters(&m_nIp, 1); CollectParameters(&m_nIp, 1);
CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]);
assert(pVehicle->m_vehType == VEHICLE_TYPE_BOAT); assert(pObject);
CSpecialParticleStuff::UpdateBoatFoamAnimation(&pVehicle->GetMatrix()); CSpecialParticleStuff::UpdateBoatFoamAnimation(&pObject->GetMatrix());
return 0; return 0;
} }
case COMMAND_SET_MUSIC_DOES_FADE: case COMMAND_SET_MUSIC_DOES_FADE:

View File

@ -386,13 +386,15 @@ CMoneyMessages::RegisterOne(CVector vecPos, const char *pText, uint8 bRed, uint8
aMoneyMessages[nIndex].m_fOpacity = fOpacity; 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) void CSpecialParticleStuff::CreateFoamAroundObject(CMatrix* pMatrix, float innerFw, float innerRg, float innerUp, int32 particles)
{ {
int attempts = 0;
float outerFw = innerFw + 5.0f; float outerFw = innerFw + 5.0f;
float outerRg = innerRg + 5.0f; float outerRg = innerRg + 5.0f;
float outerUp = innerUp + 5.0f; float outerUp = innerUp + 5.0f;
while (particles > 0 && attempts < 1000) { for (int attempts = 0; particles > 0 && attempts < 1000; attempts++) {
CVector pos; CVector pos;
int rnd = CGeneral::GetRandomNumber(); int rnd = CGeneral::GetRandomNumber();
pos.x = (int8)(rnd - 128) / 110.0f; pos.x = (int8)(rnd - 128) / 110.0f;
@ -400,20 +402,20 @@ void CSpecialParticleStuff::CreateFoamAroundObject(CMatrix* pMatrix, float inner
pos.z = 0.0f; pos.z = 0.0f;
if (DotProduct2D(pos, TheCamera.GetForward()) >= 0) if (DotProduct2D(pos, TheCamera.GetForward()) >= 0)
continue; continue;
// was there any point in adding it here?
pos += pMatrix->GetPosition(); pos += pMatrix->GetPosition();
pos.z = 2.0f; pos.z = 2.0f;
// was there any point in adding it here? float fw = Abs(DotProduct(pMatrix->GetForward(), pos - pMatrix->GetPosition()));
float fw = DotProduct(pMatrix->GetForward(), pos - pMatrix->GetPosition());
if (fw >= outerFw) if (fw >= outerFw)
continue; continue;
float rg = DotProduct(pMatrix->GetRight(), pos - pMatrix->GetPosition()); float rg = Abs(DotProduct(pMatrix->GetRight(), pos - pMatrix->GetPosition()));
if (rg >= outerRg) if (rg >= outerRg)
continue; continue;
float up = DotProduct(pMatrix->GetUp(), pos - pMatrix->GetPosition()); float up = Abs(DotProduct(pMatrix->GetUp(), pos - pMatrix->GetPosition()));
if (up >= outerUp) if (up >= outerUp)
continue; continue;
if (fw > innerFw || rg > innerRg || up > innerUp) { 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--; particles--;
} }
} }
@ -424,9 +426,6 @@ void CSpecialParticleStuff::StartBoatFoamAnimation()
BoatFromStart = CTimer::GetTimeInMilliseconds(); BoatFromStart = CTimer::GetTimeInMilliseconds();
} }
CRGBA FoamColour(255, 255, 255, 255);
unsigned int CSpecialParticleStuff::BoatFromStart;
void CSpecialParticleStuff::UpdateBoatFoamAnimation(CMatrix* pMatrix) void CSpecialParticleStuff::UpdateBoatFoamAnimation(CMatrix* pMatrix)
{ {
static int32 FrameInAnimation = 0; static int32 FrameInAnimation = 0;
@ -441,7 +440,7 @@ void CSpecialParticleStuff::UpdateBoatFoamAnimation(CMatrix* pMatrix)
CVector pos = *pMatrix * CVector(X, Y, Z); CVector pos = *pMatrix * CVector(X, Y, Z);
CParticle::AddParticle(PARTICLE_STEAM_NY, pos, CVector(0.0f, 0.0f, 0.0f), CParticle::AddParticle(PARTICLE_STEAM_NY, pos, CVector(0.0f, 0.0f, 0.0f),
nil, FrameInAnimation * 0.5f + 2.0f, FoamColour, 1, 0, 0, 0); nil, FrameInAnimation * 0.5f + 2.0f, FoamColour, 1, 0, 0, 0);
if (++FrameInAnimation) if (++FrameInAnimation > 15)
FrameInAnimation = 0; FrameInAnimation = 0;
} }
if ((cur & 0x3FF) < (prev & 0x3FF)) { if ((cur & 0x3FF) < (prev & 0x3FF)) {