mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-01 03:37:09 +01:00
refactor(render): the renderer reads a vehicle through TDynamicObject, not its physics
No file of rendering/ includes physics/vehicle.h any more. What the renderers read of a vehicle comes through a few queries of TDynamicObject (vehicle/dynamic/lights.cpp): its dimensions, its speed, its active cab, the light of its compartments, the adapters of its couplers, the lights switched on at an end, the low voltage for them, and the multiplier and the colour of its headlights. The shares of the speed and the opacity of the exhaust smoke (ExhaustScales()) move out of the particles into the vehicle, as they are. The headlights pick their multiplier once, by the dimming and the high beam switches, where the light array repeated the same four branches twice; the light of a switched off end still goes to zero as before.
This commit is contained in:
@@ -16,7 +16,6 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "stdafx.h"
|
||||
#include "rendering/lightarray.h"
|
||||
#include "vehicle/DynObj.h"
|
||||
#include "physics/vehicle.h"
|
||||
|
||||
void
|
||||
light_array::insert( TDynamicObject const *Owner ) {
|
||||
@@ -52,11 +51,10 @@ light_array::update() {
|
||||
light.direction.z = -light.direction.z;
|
||||
}
|
||||
// determine intensity of this light set
|
||||
if( ( true == light.owner->physics->lowVoltage.Is24vAvailable() )
|
||||
|| ( true == light.owner->physics->lowVoltage.Is110vAvailable() ) ) {
|
||||
if( true == light.owner->LowVoltagePowered() ) {
|
||||
// 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->physics->iLights[ light.index ] & light.owner->LightList( static_cast<VehicleEnd>( light.index ) ) };
|
||||
auto const lights { light.owner->LightsSwitchedOn( static_cast<VehicleEnd>( light.index ) ) & light.owner->LightList( static_cast<VehicleEnd>( light.index ) ) };
|
||||
// ...then check their individual state
|
||||
light.count = 0
|
||||
+ ( ( lights & light::headlight_left ) ? 1 : 0 )
|
||||
@@ -70,18 +68,11 @@ light_array::update() {
|
||||
bool isEnabled = EndOf( light.index ) == VehicleEnd::front ? !light.owner->HeadlightsAoff : !light.owner->HeadlightsBoff;
|
||||
|
||||
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->physics->dimMultiplier);
|
||||
else if (!light.owner->DimHeadlights && !light.owner->HighBeamLights && isEnabled) // normalne
|
||||
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->physics->highDimMultiplier);
|
||||
else if (!light.owner->DimHeadlights && light.owner->HighBeamLights && isEnabled) // dlugie zwykle
|
||||
light.intensity *= static_cast<float>(light.owner->physics->highMultiplier);
|
||||
else if (!isEnabled)
|
||||
{
|
||||
auto const multiplier{light.owner->HeadlightsMultiplier()};
|
||||
if (isEnabled)
|
||||
light.intensity *= static_cast<float>(multiplier);
|
||||
else
|
||||
light.intensity = 0.0f;
|
||||
}
|
||||
|
||||
// TBD, TODO: intensity can be affected further by other factors
|
||||
light.state = {
|
||||
@@ -89,24 +80,9 @@ light_array::update() {
|
||||
( ( lights & light::headlight_upper ) ? 1.f : 0.f ),
|
||||
( ( lights & light::headlight_right | light::highbeamlight_right) ? 1.f : 0.f ) };
|
||||
|
||||
light.color = {
|
||||
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
|
||||
};
|
||||
light.color = light.owner->HeadlightsColor();
|
||||
|
||||
if (light.owner->DimHeadlights && !light.owner->HighBeamLights) // tylko przyciemnione
|
||||
light.state *= light.owner->physics->dimMultiplier;
|
||||
else if (!light.owner->DimHeadlights && !light.owner->HighBeamLights) // normalne
|
||||
light.state *= light.owner->physics->normMultiplier;
|
||||
else if (light.owner->DimHeadlights && light.owner->HighBeamLights) // przyciemnione dlugie
|
||||
light.state *= light.owner->physics->highDimMultiplier;
|
||||
else if (!light.owner->DimHeadlights && light.owner->HighBeamLights) // dlugie zwykle
|
||||
light.state *= light.owner->physics->highMultiplier;
|
||||
else if (!isEnabled)
|
||||
{
|
||||
light.state = glm::vec3{0.f};
|
||||
}
|
||||
light.state *= multiplier;
|
||||
}
|
||||
else {
|
||||
light.intensity = 0.0f;
|
||||
|
||||
Reference in New Issue
Block a user