16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-22 18:39:18 +02:00

diesel-powered vehicle startup ai tweaks, gfx renderer tweaks, crash fixes

This commit is contained in:
tmj-fstate
2017-12-26 17:17:06 +01:00
parent c780f3efbf
commit 10c5907c4d
8 changed files with 167 additions and 150 deletions

View File

@@ -56,20 +56,7 @@ struct openal_source {
// methods
template <class Iterator_>
openal_source &
bind( sound_source *Controller, uint32_sequence Sounds, Iterator_ First, Iterator_ Last ) {
controller = Controller;
sounds = Sounds;
// look up and queue assigned buffers
std::vector<ALuint> buffers;
std::for_each(
First, Last,
[&]( audio::buffer_handle const &buffer ) {
buffers.emplace_back( audio::renderer.buffer( buffer ).id ); } );
if( id != audio::null_resource ) {
::alSourceQueueBuffers( id, static_cast<ALsizei>( buffers.size() ), buffers.data() );
::alSourceRewind( id ); }
is_multipart = ( buffers.size() > 1 );
return *this; }
bind( sound_source *Controller, uint32_sequence Sounds, Iterator_ First, Iterator_ Last );
// starts playback of queued buffers
void
play();
@@ -163,6 +150,32 @@ private:
extern openal_renderer renderer;
template <class Iterator_>
openal_source &
openal_source::bind( sound_source *Controller, uint32_sequence Sounds, Iterator_ First, Iterator_ Last ) {
controller = Controller;
sounds = Sounds;
// look up and queue assigned buffers
std::vector<ALuint> buffers;
std::for_each(
First, Last,
[&]( audio::buffer_handle const &buffer ) {
buffers.emplace_back( audio::renderer.buffer( buffer ).id ); } );
if( id != audio::null_resource ) {
::alSourceQueueBuffers( id, static_cast<ALsizei>( buffers.size() ), buffers.data() );
::alSourceRewind( id );
}
is_multipart = ( buffers.size() > 1 );
return *this;
}
inline
float
amplitude_to_db( float const Amplitude ) {