MCPcopy Create free account
hub / github.com/OGSR/OGSR-Engine / Update

Method Update

ogsr_engine/xrGame/level_sounds.cpp:63–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61extern XRSOUND_API float SoundRenderGetOcculution(Fvector& P, float R, Fvector* occ);
62
63void SStaticSound::Update(u32 game_time, u32 global_time)
64{
65 Fvector occ[3];
66 float occluder_volume = SoundRenderGetOcculution(m_Position, .2f, occ);
67 float vol = m_Volume * occluder_volume;
68
69 if (ShouldPlay(static_cast<int>(game_time), m_ActiveTime))
70 {
71 if (0 == m_Source._feedback())
72 {
73 if ((0 == m_PauseTime.x) && (0 == m_PauseTime.y))
74 {
75 m_Source.play_at_pos(0, m_Position, sm_Looped);
76 m_Source.set_volume(vol);
77 m_Source.set_frequency(m_Freq);
78 m_StopTime = 0xFFFFFFFF;
79 }
80 else
81 {
82 if (global_time >= m_NextTime)
83 {
84 bool bFullPlay = (0 == m_PlayTime.x) && (0 == m_PlayTime.y);
85 m_Source.play_at_pos(0, m_Position, bFullPlay ? 0 : sm_Looped);
86 m_Source.set_volume(vol);
87 m_Source.set_frequency(m_Freq);
88 if (bFullPlay)
89 {
90 m_StopTime = 0xFFFFFFFF;
91 m_NextTime = global_time + iFloor(m_Source.get_length_sec() * 1000.0f) + Random.randI(m_PauseTime.x, m_PauseTime.y);
92 }
93 else
94 {
95 m_StopTime = bFullPlay ? 0 : global_time + Random.randI(m_PlayTime.x, m_PlayTime.y);
96 m_NextTime = m_StopTime + Random.randI(m_PauseTime.x, m_PauseTime.y);
97 }
98 }
99 }
100 }
101 else
102 {
103 if (Device.dwTimeGlobal >= m_StopTime)
104 m_Source.stop_deffered();
105 }
106 }
107 else
108 {
109 if (0 != m_Source._feedback())
110 m_Source.stop_deffered();
111 }
112}
113//-----------------------------------------------------------------------------
114// music tracks
115//-----------------------------------------------------------------------------

Callers

nothing calls this directly

Calls 15

SoundRenderGetOcculutionFunction · 0.85
ShouldPlayFunction · 0.85
LogFunction · 0.85
_feedbackMethod · 0.80
randIMethod · 0.80
stop_defferedMethod · 0.80
PausedMethod · 0.80
GetGameDayTimeMSMethod · 0.80
play_at_posMethod · 0.45
set_volumeMethod · 0.45
set_frequencyMethod · 0.45
get_length_secMethod · 0.45

Tested by

no test coverage detected