MCPcopy Create free account
hub / github.com/TombEngine/TombEngine / Sound_EffectIsPlaying

Function Sound_EffectIsPlaying

TombEngine/Sound/sound.cpp:798–831  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

796// identify what's the source of the producing effect.
797
798int Sound_EffectIsPlaying(int effectID, Pose *position)
799{
800 for (int i = 0; i < SOUND_MAX_CHANNELS; i++)
801 {
802 if (SoundSlot[i].EffectID == effectID)
803 {
804 // Free channel.
805 if (SoundSlot[i].Channel == NULL)
806 continue;
807
808 if (BASS_ChannelIsActive(SoundSlot[i].Channel))
809 {
810 // Only check position on 3D samples. 2D samples stop immediately.
811
812 BASS_CHANNELINFO info;
813 BASS_ChannelGetInfo(SoundSlot[i].Channel, &info);
814 if (!(info.flags & BASS_SAMPLE_3D) || !position)
815 return i;
816
817 // Check if effect origin is equal OR in nearest possible hearing range.
818
819 auto origin = Vector3(position->Position.x, position->Position.y, position->Position.z);
820 if (Vector3::Distance(origin, SoundSlot[i].Origin) < SOUND_MAXVOL_RADIUS)
821 return i;
822 }
823 else
824 {
825 SoundSlot[i].Channel = NULL; // WTF, let's clean this up
826 }
827 }
828 }
829
830 return SOUND_NO_CHANNEL;
831}
832
833// Gets the distance to the source.
834float Sound_DistanceToListener(Pose *position)

Callers 2

SoundEffectFunction · 0.85
IsSoundPlayingFunction · 0.85

Calls 1

Vector3Function · 0.50

Tested by

no test coverage detected