mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-18 04:19:19 +02:00
Merge branch 'tmj-dev' into milek-dev
This commit is contained in:
19
scene.cpp
19
scene.cpp
@@ -12,6 +12,10 @@ http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#include "simulation.h"
|
||||
#include "Globals.h"
|
||||
#include "Camera.h"
|
||||
#include "AnimModel.h"
|
||||
#include "Event.h"
|
||||
#include "EvLaunch.h"
|
||||
#include "Timer.h"
|
||||
#include "Logs.h"
|
||||
#include "sn_utils.h"
|
||||
@@ -20,6 +24,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
namespace scene {
|
||||
|
||||
std::string const EU07_FILEEXTENSION_REGION { ".sbt" };
|
||||
std::uint32_t const EU07_FILEHEADER { MAKE_ID4( 'E','U','0','7' ) };
|
||||
std::uint32_t const EU07_FILEVERSION_REGION { MAKE_ID4( 'S', 'B', 'T', 1 ) };
|
||||
|
||||
// potentially activates event handler with the same name as provided node, and within handler activation range
|
||||
@@ -119,7 +124,7 @@ basic_cell::update_events() {
|
||||
// event launchers
|
||||
for( auto *launcher : m_eventlaunchers ) {
|
||||
if( ( true == ( launcher->check_activation() && launcher->check_conditions() ) )
|
||||
&& ( SquareMagnitude( launcher->location() - Global.pCameraPosition ) < launcher->dRadius ) ) {
|
||||
&& ( SquareMagnitude( launcher->location() - Global.pCamera.Pos ) < launcher->dRadius ) ) {
|
||||
|
||||
launch_event( launcher );
|
||||
}
|
||||
@@ -945,9 +950,9 @@ void
|
||||
basic_region::update_events() {
|
||||
// render events and sounds from sectors near enough to the viewer
|
||||
auto const range = EU07_SECTIONSIZE; // arbitrary range
|
||||
auto const §ionlist = sections( Global.pCameraPosition, range );
|
||||
auto const §ionlist = sections( Global.pCamera.Pos, range );
|
||||
for( auto *section : sectionlist ) {
|
||||
section->update_events( Global.pCameraPosition, range );
|
||||
section->update_events( Global.pCamera.Pos, range );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -956,9 +961,9 @@ void
|
||||
basic_region::update_sounds() {
|
||||
// render events and sounds from sectors near enough to the viewer
|
||||
auto const range = 2750.f; // audible range of 100 db sound
|
||||
auto const §ionlist = sections( Global.pCameraPosition, range );
|
||||
auto const §ionlist = sections( Global.pCamera.Pos, range );
|
||||
for( auto *section : sectionlist ) {
|
||||
section->update_sounds( Global.pCameraPosition, range );
|
||||
section->update_sounds( Global.pCamera.Pos, range );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -998,7 +1003,7 @@ basic_region::serialize( std::string const &Scenariofile ) const {
|
||||
|
||||
// region file version 1
|
||||
// header: EU07SBT + version (0-255)
|
||||
sn_utils::ls_uint32( output, MAKE_ID4( 'E', 'U', '0', '7' ) );
|
||||
sn_utils::ls_uint32( output, EU07_FILEHEADER );
|
||||
sn_utils::ls_uint32( output, EU07_FILEVERSION_REGION );
|
||||
// sections
|
||||
// TBD, TODO: build table of sections and file offsets, if we postpone section loading until they're within range
|
||||
@@ -1043,7 +1048,7 @@ basic_region::deserialize( std::string const &Scenariofile ) {
|
||||
uint32_t headermain { sn_utils::ld_uint32( input ) };
|
||||
uint32_t headertype { sn_utils::ld_uint32( input ) };
|
||||
|
||||
if( ( headermain != MAKE_ID4( 'E', 'U', '0', '7' )
|
||||
if( ( headermain != EU07_FILEHEADER
|
||||
|| ( headertype != EU07_FILEVERSION_REGION ) ) ) {
|
||||
// wrong file type
|
||||
WriteLog( "Bad file: \"" + filename + "\" is of either unrecognized type or version" );
|
||||
|
||||
Reference in New Issue
Block a user