mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-03 10:05:23 +01:00
6373b49447
Brings in staging up to 6f566c075 (PR #468, the GL 4.6 / Vulkan renderers, the weather model,
the dual-mode traction commands and the motion of a vehicle off the track).
Conflicts:
- application/application.cpp: staging takes a -seed only when seed_given() reads one and marks it
with Global.random_seed_given; the branch remembered a seed from the command line so the snapshot's
seed doesn't replace it. Kept staging's parsing and set seedfromcommandline inside it; the seed taken
from the snapshot now also sets Global.random_seed_given, or init() would draw a random one over it
(it used to check only for a seed of 0) and the test mode would put its "test" seed over it.
- input/command.h, input/command.cpp: both added commands after genericset29. Staging's
tractionmode*/genset* first, then snapshotsave, in the same order in the enum, the descriptions
and the name map.
- simulation/simulationenvironment.h: the old opengl_renderer/opengl33_renderer forward declarations
are gone with #468, opengl46_renderer kept, <array> of the branch kept; wind_state() of the branch
and weather() of staging both kept.
- vehicle/DynObj.h: the snapshot methods of the branch in the public part, followed by staging's
off-track members and methods with their own private:/public: switch.
116 lines
3.0 KiB
C++
116 lines
3.0 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
|
|
|
|
#include "environment/sky.h"
|
|
#include "environment/sun.h"
|
|
#include "environment/moon.h"
|
|
#include "environment/stars.h"
|
|
#include "environment/skydome.h"
|
|
#include "environment/weather.h"
|
|
#include "rendering/precipitation.h"
|
|
#include "audio/sound.h"
|
|
|
|
#include <array>
|
|
|
|
class opengl46_renderer;
|
|
|
|
// wrapper for environment elements -- sky, sun, stars, clouds etc
|
|
class world_environment {
|
|
|
|
friend opengl46_renderer;
|
|
|
|
public:
|
|
// methods
|
|
void init();
|
|
void update();
|
|
void update_precipitation();
|
|
void update_moon();
|
|
void time( int const Hour = -1, int const Minute = -1, int const Second = -1 );
|
|
// switches between static and dynamic daylight calculation
|
|
void on_daylight_change();
|
|
// calculates current season of the year based on set simulation date
|
|
void compute_season( int const Yearday );
|
|
// calculates current weather
|
|
void compute_weather() const;
|
|
// data access
|
|
inline auto const &
|
|
sun() const {
|
|
return m_sun; }
|
|
inline auto const &
|
|
moon() const {
|
|
return m_moon; }
|
|
inline auto const &
|
|
light_intensity() const {
|
|
return m_lightintensity; }
|
|
inline auto const &
|
|
skydome() const {
|
|
return m_skydome; }
|
|
inline auto &
|
|
skydome() {
|
|
return m_skydome; }
|
|
inline auto const &
|
|
precipitation() const {
|
|
return m_precipitation; }
|
|
inline auto const &
|
|
wind() const {
|
|
return m_wind.vector; }
|
|
inline auto const &
|
|
wind_azimuth() const {
|
|
return m_wind.azimuth; }
|
|
// the wind as it blows and as it is about to change, for a snapshot of the simulation, which puts it back:
|
|
// azimuth and its change, velocity and its change, the time to the next change, the vector
|
|
std::array<float, 8>
|
|
wind_state() const;
|
|
void
|
|
wind_state( std::array<float, 8> const &State );
|
|
// clouds, fog and precipitation of the scenery, see environment/weather.h
|
|
inline auto const &
|
|
weather() const {
|
|
return m_weather; }
|
|
inline auto &
|
|
weather() {
|
|
return m_weather; }
|
|
|
|
private:
|
|
// types
|
|
struct basic_wind {
|
|
// internal state data
|
|
float azimuth;
|
|
float azimuth_change;
|
|
float velocity;
|
|
float velocity_change;
|
|
float change_time;
|
|
// output
|
|
glm::vec3 vector;
|
|
};
|
|
// methods
|
|
void update_wind();
|
|
// members
|
|
CSkyDome m_skydome;
|
|
cStars m_stars;
|
|
cSun m_sun;
|
|
cMoon m_moon;
|
|
float m_lightintensity { 1.f };
|
|
TSky m_clouds;
|
|
basic_precipitation m_precipitation;
|
|
sound_source m_rainsound { sound_placement::external, -1 };
|
|
basic_wind m_wind;
|
|
world_weather m_weather;
|
|
};
|
|
|
|
namespace simulation {
|
|
|
|
extern world_environment Environment;
|
|
|
|
} // simulation
|
|
|
|
//---------------------------------------------------------------------------
|