mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-18 03:09:18 +02:00
Merge branch 'milek-dev' into gfx-work
This commit is contained in:
@@ -11,6 +11,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "simulationenvironment.h"
|
||||
|
||||
#include "Globals.h"
|
||||
#include "Timer.h"
|
||||
|
||||
namespace simulation {
|
||||
|
||||
@@ -79,8 +80,14 @@ world_environment::init() {
|
||||
m_stars.init();
|
||||
m_clouds.Init();
|
||||
m_precipitation.init();
|
||||
|
||||
m_precipitationsound.deserialize( "rain-sound-loop", sound_type::single );
|
||||
m_wind = basic_wind{
|
||||
static_cast<float>( Random( 0, 360 ) ),
|
||||
static_cast<float>( Random( -5, 5 ) ),
|
||||
static_cast<float>( Random( -2, 4 ) ),
|
||||
static_cast<float>( Random( -1, 1 ) ),
|
||||
static_cast<float>( Random( 5, 20 ) ),
|
||||
{} };
|
||||
}
|
||||
|
||||
void
|
||||
@@ -176,6 +183,8 @@ world_environment::update() {
|
||||
else {
|
||||
m_precipitationsound.stop();
|
||||
}
|
||||
|
||||
update_wind();
|
||||
}
|
||||
|
||||
void
|
||||
@@ -184,6 +193,33 @@ world_environment::update_precipitation() {
|
||||
m_precipitation.update();
|
||||
}
|
||||
|
||||
void
|
||||
world_environment::update_wind() {
|
||||
|
||||
auto const timedelta{ static_cast<float>( Timer::GetDeltaTime() ) };
|
||||
|
||||
m_wind.change_time -= timedelta;
|
||||
if( m_wind.change_time < 0 ) {
|
||||
m_wind.change_time = Random( 5, 30 );
|
||||
m_wind.azimuth_change = Random( -5, 5 );
|
||||
m_wind.velocity_change = Random( -1, 1 );
|
||||
}
|
||||
// TBD, TODO: wind configuration
|
||||
m_wind.azimuth = clamp_circular( m_wind.azimuth + m_wind.azimuth_change * timedelta );
|
||||
// HACK: negative part of range allows for some quiet periods, without active wind
|
||||
m_wind.velocity = clamp<float>( m_wind.velocity + m_wind.velocity_change * timedelta, -2, 4 );
|
||||
// convert to force vector
|
||||
auto const polarangle { glm::radians( 90.f ) }; // theta
|
||||
auto const azimuthalangle{ glm::radians( m_wind.azimuth ) }; // phi
|
||||
// convert spherical coordinates to opengl coordinates
|
||||
m_wind.vector =
|
||||
std::max( 0.f, m_wind.velocity )
|
||||
* glm::vec3(
|
||||
std::sin( polarangle ) * std::sin( azimuthalangle ),
|
||||
std::cos( polarangle ),
|
||||
std::sin( polarangle ) * std::cos( azimuthalangle ) * -1 );
|
||||
}
|
||||
|
||||
void
|
||||
world_environment::time( int const Hour, int const Minute, int const Second ) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user