mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-01 23:17:56 +01:00
Rebase onto staging (after #531)
The vehicle's physics is TDynamicObject::physics now (physics::Vehicle): the wipers, the insects and the rain of the glasses, the snow of the windscreen water and the deer take it from there. The includes of staging kept in opengl46renderer.cpp; the texture check of staging first in Render_Instances_Indirect_Shadow(), then the materials with a vertex shader of their own. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BqfRrTiBDaAyQ2gT6ZrnZD
This commit is contained in:
@@ -25,8 +25,6 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "vehicle/Train.h"
|
||||
#include "physics/vehicle.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace gfx
|
||||
{
|
||||
|
||||
@@ -517,7 +515,7 @@ void windscreen_water::update(double const Seconds)
|
||||
m_bladesbefore.x < 0.f ? blades.x : m_bladesbefore.x, m_bladesbefore.y < 0.f ? blades.y : m_bladesbefore.y, m_bladesbefore.z < 0.f ? blades.z : m_bladesbefore.z, m_bladesbefore.w < 0.f ? blades.w : m_bladesbefore.w};
|
||||
block.rain = glm::vec4{LEAST_DROP, lambda, 1.f, 0.f};
|
||||
block.counts = glm::uvec4{m_step * 2654435761u, most, 0u, 0u};
|
||||
block.snow = glm::vec4{snow ? perground : 0.f, GLASS_WARMTH, static_cast<float>(std::abs(vehicle->MoverParameters->V)), static_cast<float>(m_snowmap)};
|
||||
block.snow = glm::vec4{snow ? perground : 0.f, GLASS_WARMTH, static_cast<float>(std::abs(vehicle->physics->V)), static_cast<float>(m_snowmap)};
|
||||
m_bladesbefore = blades;
|
||||
gpu_step(block, most);
|
||||
if (anysnow)
|
||||
|
||||
@@ -46,6 +46,11 @@ void scene_camera_place(gl::scene_ubs &Ubs, glm::dvec3 const &Place)
|
||||
}
|
||||
} // namespace
|
||||
|
||||
#include <algorithm>
|
||||
#include <format>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
//#define EU07_DEBUG_OPENGL
|
||||
|
||||
int constexpr EU07_PICKBUFFERSIZE{ 1024 }; // size of (square) textures bound with the pick framebuffer
|
||||
@@ -1697,7 +1702,7 @@ void opengl46_renderer::Render_pass(viewport_config &vp, rendermode const Mode)
|
||||
// were at the ends of their sweep (the drops on the glass come back from then) are kept while the camera is away, so the glass
|
||||
// looks as the blades left it when it's back in the cab. they're forgotten only for another vehicle
|
||||
TDynamicObject const *owner = Global.pCamera.m_owner;
|
||||
if ((owner == nullptr) || (owner->MoverParameters->CabActive == 0))
|
||||
if ((owner == nullptr) || (owner->physics->CabActive == 0))
|
||||
owner = (simulation::Train != nullptr) ? simulation::Train->Dynamic() : nullptr;
|
||||
if (owner != m_wipervehicle)
|
||||
{
|
||||
@@ -1728,7 +1733,7 @@ void opengl46_renderer::Render_pass(viewport_config &vp, rendermode const Mode)
|
||||
m_wiperbugs = 0.0;
|
||||
}
|
||||
else if (owner != nullptr)
|
||||
m_wiperbugs += glassstep * std::max(std::abs(owner->MoverParameters->V) * 3.6 - 20.0, 0.0) / 80.0;
|
||||
m_wiperbugs += glassstep * std::max(std::abs(owner->physics->V) * 3.6 - 20.0, 0.0) / 80.0;
|
||||
scene_ubs.rain_wind.w = static_cast<float>(m_wiperbugs);
|
||||
// the rain the glass meets (mat_rain_windscreen): counted in seconds of the heaviest rain standing still, more at speed (the
|
||||
// glass runs into it). the glass fills with it up to as many drops as it gets (a lighter rain only fills it more slowly) while
|
||||
@@ -1737,7 +1742,7 @@ void opengl46_renderer::Render_pass(viewport_config &vp, rendermode const Mode)
|
||||
constexpr double fill_rate{0.3}; // per second of the heaviest rain: 95% full in 10 s (20 s at cloud cover 1.5)
|
||||
constexpr double fill_speed{1.5}; // at 100 km/h and more the glass meets x (1 + fill_speed) as much rain
|
||||
auto const dt{glassstep};
|
||||
auto const speed{(owner != nullptr) ? std::min(std::abs(owner->MoverParameters->V) * 3.6 / 100.0, 1.0) : 0.0};
|
||||
auto const speed{(owner != nullptr) ? std::min(std::abs(owner->physics->V) * 3.6 / 100.0, 1.0) : 0.0};
|
||||
auto const meet{static_cast<double>(percipitation_intensity) * (1.0 + fill_speed * speed)};
|
||||
m_wiperrain += dt * meet;
|
||||
if ((percipitation_intensity > 0.f) && (Global.Weather == "rain:"))
|
||||
@@ -1748,7 +1753,7 @@ void opengl46_renderer::Render_pass(viewport_config &vp, rendermode const Mode)
|
||||
}
|
||||
if (owner != nullptr)
|
||||
{
|
||||
auto const cabactive{owner->MoverParameters->CabActive != 0 ? owner->MoverParameters->CabActive : 1};
|
||||
auto const cabactive{owner->physics->CabActive != 0 ? owner->physics->CabActive : 1};
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
if (i < owner->dWiperPos.size())
|
||||
@@ -4203,6 +4208,11 @@ opengl46_renderer::indirect_counts opengl46_renderer::Render_Instances_Indirect_
|
||||
for( std::size_t index = 0; index < count; ) {
|
||||
auto const &draw { m_indirectdraws[ index ] };
|
||||
auto const texture { Indirect_Shadow_Texture( draw.material ) };
|
||||
if( ( texture != null_handle ) && ( false == m_textures.mark_as_used( texture ).bind( 0 ) ) ) {
|
||||
// a texture which isn't there (yet) would leave the one bound before to the alpha test; no shadow until it is
|
||||
++index;
|
||||
continue;
|
||||
}
|
||||
// the materials with a vertex shader of their own are drawn one by one, with it (Bind_Material_Shadow())
|
||||
auto const ownvertex = [ this ]( material_handle const Material ) {
|
||||
return ( false == m_cubeshadows ) && ( Material_Shadow_Program( Material, Indirect_Shadow_Texture( Material ) != null_handle ) != nullptr ); };
|
||||
|
||||
@@ -1575,7 +1575,7 @@ void vulkan14_renderer::render_viewport(std::size_t const Index)
|
||||
// were at the ends of their sweep (the drops on the glass come back from then) are kept while the camera is away, so the glass
|
||||
// looks as the blades left it when it's back in the cab. they're forgotten only for another vehicle
|
||||
TDynamicObject const *owner = Global.pCamera.m_owner;
|
||||
if ((owner == nullptr) || (owner->MoverParameters->CabActive == 0))
|
||||
if ((owner == nullptr) || (owner->physics->CabActive == 0))
|
||||
owner = (simulation::Train != nullptr) ? simulation::Train->Dynamic() : nullptr;
|
||||
if (owner != m_wipervehicle)
|
||||
{
|
||||
@@ -1606,7 +1606,7 @@ void vulkan14_renderer::render_viewport(std::size_t const Index)
|
||||
m_wiperbugs = 0.0;
|
||||
}
|
||||
else if (owner != nullptr)
|
||||
m_wiperbugs += glassstep * std::max(std::abs(owner->MoverParameters->V) * 3.6 - 20.0, 0.0) / 80.0;
|
||||
m_wiperbugs += glassstep * std::max(std::abs(owner->physics->V) * 3.6 - 20.0, 0.0) / 80.0;
|
||||
scene_ubs.rain_wind.w = static_cast<float>(m_wiperbugs);
|
||||
// the rain the glass meets (mat_rain_windscreen): counted in seconds of the heaviest rain standing still, more at speed (the
|
||||
// glass runs into it). the glass fills with it up to as many drops as it gets (a lighter rain only fills it more slowly) while
|
||||
@@ -1615,7 +1615,7 @@ void vulkan14_renderer::render_viewport(std::size_t const Index)
|
||||
constexpr double fill_rate{0.3}; // per second of the heaviest rain: 95% full in 10 s (20 s at cloud cover 1.5)
|
||||
constexpr double fill_speed{1.5}; // at 100 km/h and more the glass meets x (1 + fill_speed) as much rain
|
||||
auto const dt{glassstep};
|
||||
auto const speed{(owner != nullptr) ? std::min(std::abs(owner->MoverParameters->V) * 3.6 / 100.0, 1.0) : 0.0};
|
||||
auto const speed{(owner != nullptr) ? std::min(std::abs(owner->physics->V) * 3.6 / 100.0, 1.0) : 0.0};
|
||||
auto const meet{static_cast<double>(percipitation_intensity) * (1.0 + fill_speed * speed)};
|
||||
m_wiperrain += dt * meet;
|
||||
if ((percipitation_intensity > 0.f) && (Global.Weather == "rain:"))
|
||||
@@ -1626,7 +1626,7 @@ void vulkan14_renderer::render_viewport(std::size_t const Index)
|
||||
}
|
||||
if (owner != nullptr)
|
||||
{
|
||||
auto const cabactive{owner->MoverParameters->CabActive != 0 ? owner->MoverParameters->CabActive : 1};
|
||||
auto const cabactive{owner->physics->CabActive != 0 ? owner->physics->CabActive : 1};
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
if (i < owner->dWiperPos.size())
|
||||
|
||||
+3
-3
@@ -27,7 +27,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "simulation/simulation.h"
|
||||
#include "rendering/renderer.h"
|
||||
#include "vehicle/DynObj.h"
|
||||
#include "McZapkie/MOVER.h"
|
||||
#include "physics/vehicle.h"
|
||||
#include "world/Track.h"
|
||||
#include "editor/editorTerrainStreamer.hpp"
|
||||
#include "scene/heightmapterrain.h"
|
||||
@@ -590,7 +590,7 @@ void simulation::deer_herd::update(double const Deltatime)
|
||||
m_travelled = 0.0;
|
||||
return;
|
||||
}
|
||||
auto const *mover{vehicle->MoverParameters};
|
||||
auto const *mover{vehicle->physics};
|
||||
m_travelled += std::abs(mover->V) * Deltatime;
|
||||
if ((Global.deer_interval > 0.0) && (m_travelled >= Global.deer_interval))
|
||||
{
|
||||
@@ -661,7 +661,7 @@ bool simulation::deer_herd::tend(deer &Animal, glm::dvec3 const &Train, double c
|
||||
bool simulation::deer_herd::spawn(TDynamicObject const &Vehicle)
|
||||
{
|
||||
// the end of the train the way it goes, or the cab occupied when it stands
|
||||
auto const *mover{Vehicle.MoverParameters};
|
||||
auto const *mover{Vehicle.physics};
|
||||
auto front{mover->V > 0.1};
|
||||
if (std::abs(mover->V) <= 0.1)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user