mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-08 10:31:01 +01:00
The spawn count of the smoke source of a vehicle moves out of smoke_source::update() into smoke::vehicle_spawn_count() (vehicle/smoke.h), a free function on the mover state, which joins the core library so the unit tests can call it the way the source does. The rates are the same as before, the steady rate of the source still counted in before the share of the engine. Tests: tests/unit/test_smoke.cpp. A vehicle taken off the tracks spawns no smoke and drops the pending particles, with the engine starting, idling or under load; a road vehicle back from the pool puffs again; the engine adds to the steady rate; the pending count stays within the room of the source. Two of the four fail without the fix. Checked again on td.scn with the SM42 driven into a portal: the smoke source keeps puffing on the run and drops to 0 particles once the vehicle is taken off the tracks.
31 lines
1.2 KiB
C++
31 lines
1.2 KiB
C++
/*
|
|
This Source Code Form is subject to the
|
|
terms of the Mozilla Public License, v.
|
|
2.0. If a copy of the MPL was not
|
|
distributed with this file, You can
|
|
obtain one at
|
|
http://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
class TMoverParameters;
|
|
|
|
// the smoke of a vehicle's engine, let out by the smoke sources of its model (rendering/particles.h)
|
|
namespace smoke {
|
|
|
|
// what a smoke source spawns, before the engine of its vehicle is taken into account
|
|
struct spawn_rate {
|
|
float pending{0.f}; // particles left to spawn from the previous updates
|
|
float rate{0.f}; // particles per second
|
|
float fidelity{1.f}; // multiplier of the smoke settings
|
|
float limit{0.f}; // most particles the source can have
|
|
};
|
|
|
|
// number of particles the smoke source of a vehicle has to spawn after Timedelta seconds: the steady rate of the
|
|
// source, plus a share which grows with the work of its engine. a vehicle taken off the tracks (Ontracks false: gone through a portal, or waiting in the pool of the road
|
|
// traffic) puffs no more, the particles it already let out fade away as usual
|
|
float vehicle_spawn_count(TMoverParameters const &Mover, bool Ontracks, spawn_rate const &Rate, double Timedelta);
|
|
|
|
} // namespace smoke
|