mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-01 03:37:09 +01:00
refactor(physics): TMoverParameters becomes physics::Vehicle, the mover is gone
The physics of a vehicle loses the name it had from the Pascal of 2001. Done by
tools/rename/mover_to_physics.py, committed with it:
physics/mover.h physics/vehicle.h
TMoverParameters physics::Vehicle (in namespace physics)
TDynamicObject::MoverParameters physics
mvOccupied, mvControlled occupied, controlled (TTrain, TController)
mvSecond, mvThird secondUnit, thirdUnit
mvPantographUnit pantographUnit
mover, Mover, movers physics, Physics, vehicles (locals, params)
m_mover, othermover, currentMover, from_movers, renderMoverEventSounds
m_physics, otherPhysics, currentPhysics,
from_vehicles, renderPhysicsEventSounds
The code and the comments are renamed, the string literals are not: no text
the game shows, logs or looks up has changed (none had the names). The movers
of the editor, the tracks a slide moves, keep their name.
By hand: two member functions of TDynamicObject (gather_off_track_terrain,
begin_off_track) had a local mover aliasing their own MoverParameters, which
the rename made physics { *physics }; the alias is gone, they use physics->.
No other function has a renamed local meeting a renamed member (checked over
all the functions of the code before the rename).
For the branches made before it: run the script on the branch (python
tools/rename/mover_to_physics.py, from the root of the repository) before
merging it with this one, and the names don't conflict. It can be run again;
the second time it changes nothing.
The class is the same as it was; breaking it into its parts (braking,
electrics, controls, load) and making its data private are the next stages.
No change in behaviour: 1149/1149 tests, golden traces exact against staging
62f7a29b.
This commit is contained in:
+15
-15
@@ -16,7 +16,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "stdafx.h"
|
||||
#include "rendering/lightarray.h"
|
||||
#include "vehicle/DynObj.h"
|
||||
#include "physics/mover.h"
|
||||
#include "physics/vehicle.h"
|
||||
|
||||
void
|
||||
light_array::insert( TDynamicObject const *Owner ) {
|
||||
@@ -52,11 +52,11 @@ light_array::update() {
|
||||
light.direction.z = -light.direction.z;
|
||||
}
|
||||
// determine intensity of this light set
|
||||
if( ( true == light.owner->MoverParameters->Power24vIsAvailable )
|
||||
|| ( true == light.owner->MoverParameters->Power110vIsAvailable ) ) {
|
||||
if( ( true == light.owner->physics->Power24vIsAvailable )
|
||||
|| ( true == light.owner->physics->Power110vIsAvailable ) ) {
|
||||
// with power on, the intensity depends on the state of activated switches
|
||||
// first we cross-check the list of enabled lights with the lights installed in the vehicle...
|
||||
auto const lights { light.owner->MoverParameters->iLights[ light.index ] & light.owner->LightList( static_cast<VehicleEnd>( light.index ) ) };
|
||||
auto const lights { light.owner->physics->iLights[ light.index ] & light.owner->LightList( static_cast<VehicleEnd>( light.index ) ) };
|
||||
// ...then check their individual state
|
||||
light.count = 0
|
||||
+ ( ( lights & light::headlight_left ) ? 1 : 0 )
|
||||
@@ -71,13 +71,13 @@ light_array::update() {
|
||||
|
||||
light.intensity = std::max(0.0f, std::log((float)light.count + 1.0f));
|
||||
if (light.owner->DimHeadlights && !light.owner->HighBeamLights && isEnabled) // tylko przyciemnione
|
||||
light.intensity *= static_cast<float>(light.owner->MoverParameters->dimMultiplier);
|
||||
light.intensity *= static_cast<float>(light.owner->physics->dimMultiplier);
|
||||
else if (!light.owner->DimHeadlights && !light.owner->HighBeamLights && isEnabled) // normalne
|
||||
light.intensity *= static_cast<float>(light.owner->MoverParameters->normMultiplier);
|
||||
light.intensity *= static_cast<float>(light.owner->physics->normMultiplier);
|
||||
else if (light.owner->DimHeadlights && light.owner->HighBeamLights && isEnabled) // przyciemnione dlugie
|
||||
light.intensity *= static_cast<float>(light.owner->MoverParameters->highDimMultiplier);
|
||||
light.intensity *= static_cast<float>(light.owner->physics->highDimMultiplier);
|
||||
else if (!light.owner->DimHeadlights && light.owner->HighBeamLights && isEnabled) // dlugie zwykle
|
||||
light.intensity *= static_cast<float>(light.owner->MoverParameters->highMultiplier);
|
||||
light.intensity *= static_cast<float>(light.owner->physics->highMultiplier);
|
||||
else if (!isEnabled)
|
||||
{
|
||||
light.intensity = 0.0f;
|
||||
@@ -90,19 +90,19 @@ light_array::update() {
|
||||
( ( lights & light::headlight_right | light::highbeamlight_right) ? 1.f : 0.f ) };
|
||||
|
||||
light.color = {
|
||||
static_cast<float>(light.owner->MoverParameters->refR) / 255.0f,
|
||||
static_cast<float>(light.owner->MoverParameters->refG) / 255.0f,
|
||||
static_cast<float>(light.owner->MoverParameters->refB) / 255.0f
|
||||
static_cast<float>(light.owner->physics->refR) / 255.0f,
|
||||
static_cast<float>(light.owner->physics->refG) / 255.0f,
|
||||
static_cast<float>(light.owner->physics->refB) / 255.0f
|
||||
};
|
||||
|
||||
if (light.owner->DimHeadlights && !light.owner->HighBeamLights) // tylko przyciemnione
|
||||
light.state *= light.owner->MoverParameters->dimMultiplier;
|
||||
light.state *= light.owner->physics->dimMultiplier;
|
||||
else if (!light.owner->DimHeadlights && !light.owner->HighBeamLights) // normalne
|
||||
light.state *= light.owner->MoverParameters->normMultiplier;
|
||||
light.state *= light.owner->physics->normMultiplier;
|
||||
else if (light.owner->DimHeadlights && light.owner->HighBeamLights) // przyciemnione dlugie
|
||||
light.state *= light.owner->MoverParameters->highDimMultiplier;
|
||||
light.state *= light.owner->physics->highDimMultiplier;
|
||||
else if (!light.owner->DimHeadlights && light.owner->HighBeamLights) // dlugie zwykle
|
||||
light.state *= light.owner->MoverParameters->highMultiplier;
|
||||
light.state *= light.owner->physics->highMultiplier;
|
||||
else if (!isEnabled)
|
||||
{
|
||||
light.state = glm::vec3{0.f};
|
||||
|
||||
Reference in New Issue
Block a user