]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
Added an unreal-esque feature: snd_spatialization_occlusion, which when enabled uses...
authorechon <echon@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 6 Sep 2009 17:31:47 +0000 (17:31 +0000)
committerechon <echon@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 6 Sep 2009 17:31:47 +0000 (17:31 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9168 d7cf8633-e32d-0410-b094-e92efae38249

snd_main.c

index 0bd242cc0940090cdae61851fcb5ece2383b1993..236bb5e0ae80994d88dd7523c3c4d7328adea07d 100644 (file)
@@ -166,6 +166,7 @@ cvar_t snd_spatialization_min = {CVAR_SAVE, "snd_spatialization_min", "0.70", "m
 cvar_t snd_spatialization_max = {CVAR_SAVE, "snd_spatialization_max", "0.95", "maximum spatialization of sounds"};
 cvar_t snd_spatialization_power = {CVAR_SAVE, "snd_spatialization_power", "0", "exponent of the spatialization falloff curve (0: logarithmic)"};
 cvar_t snd_spatialization_control = {CVAR_SAVE, "snd_spatialization_control", "0", "enable spatialization control (headphone friendly mode)"};
+cvar_t snd_spatialization_occlusion = {CVAR_SAVE, "snd_spatialization_occlusion", "1", "enable occlusion testing on spatialized sounds, which simply quiets sounds that are blocked by the world"};
 
 // Cvars declared in snd_main.h (shared with other snd_*.c files)
 cvar_t _snd_mixahead = {CVAR_SAVE, "_snd_mixahead", "0.11", "how much sound to mix ahead of time"};
@@ -809,6 +810,7 @@ void S_Init(void)
        Cvar_RegisterVariable(&snd_spatialization_max);
        Cvar_RegisterVariable(&snd_spatialization_power);
        Cvar_RegisterVariable(&snd_spatialization_control);
+       Cvar_RegisterVariable(&snd_spatialization_occlusion);
 
        Cvar_RegisterVariable(&snd_speed);
        Cvar_RegisterVariable(&snd_width);
@@ -1370,6 +1372,17 @@ void SND_Spatialize(channel_t *ch, qboolean isstatic)
                                }
 
                                vol = intensity * max(0, source_vec[0] * snd_speakerlayout.listeners[i].dotscale + snd_speakerlayout.listeners[i].dotbias);
+
+                               if (snd_spatialization_occlusion.integer)
+                               {
+                                       if (cl.worldmodel
+                                       && cl.worldmodel->brush.TraceLineOfSight
+                                       && !cl.worldmodel->brush.TraceLineOfSight(cl.worldmodel, listener_origin, source_vec))
+                                       {
+                                               vol *= 0.5f;
+                                       }
+                               }
+
                                ch->listener_volume[i] = (int)bound(0, vol, 255);
                        }
                }