]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
do sound occlusion only once per sound, not once per listener channel
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 9 Sep 2010 07:37:50 +0000 (07:37 +0000)
committerRudolf Polzer <divverent@alientrap.org>
Thu, 9 Sep 2010 07:32:00 +0000 (09:32 +0200)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10451 d7cf8633-e32d-0410-b094-e92efae38249
::stable-branch::merge=1c4c36dd5a6587988ac63db25c246c96fba749f4

snd_main.c

index b9fe66027f69fed7fbd63c894e6088916e1e965b..ea8a154802a5f7368137545ab2ee480e65690174 100644 (file)
@@ -1376,6 +1376,25 @@ void SND_Spatialize(channel_t *ch, qboolean isstatic)
                intensity = mastervol * (1.0 - dist * ch->dist_mult);
                if (intensity > 0)
                {
+                       qboolean occluded = false;
+                       if (snd_spatialization_occlusion.integer)
+                       {
+                               if(snd_spatialization_occlusion.integer & 1)
+                                       if(listener_pvs)
+                                       {
+                                               int cluster = cl.worldmodel->brush.PointInLeaf(cl.worldmodel, ch->origin)->clusterindex;
+                                               if(cluster >= 0 && cluster < 8 * listener_pvsbytes && !CHECKPVSBIT(listener_pvs, cluster))
+                                                       occluded = true;
+                                       }
+
+                               if(snd_spatialization_occlusion.integer & 2)
+                                       if(!occluded)
+                                               if(cl.worldmodel && cl.worldmodel->brush.TraceLineOfSight && !cl.worldmodel->brush.TraceLineOfSight(cl.worldmodel, listener_origin, ch->origin))
+                                                       occluded = true;
+                       }
+                       if(occluded)
+                               intensity *= 0.5;
+
                        for (i = 0;i < SND_LISTENERS;i++)
                        {
                                Matrix4x4_Transform(&listener_matrix[i], ch->origin, source_vec);
@@ -1406,29 +1425,6 @@ 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)
-                               {
-                                       qboolean occluded = false;
-
-                                       if(snd_spatialization_occlusion.integer & 1)
-                                       if(listener_pvs)
-                                       {
-                                               int cluster = cl.worldmodel->brush.PointInLeaf(cl.worldmodel, ch->origin)->clusterindex;
-                                               if(cluster >= 0 && cluster < 8 * listener_pvsbytes && !CHECKPVSBIT(listener_pvs, cluster))
-                                                       occluded = true;
-                                       }
-
-                                       if(snd_spatialization_occlusion.integer & 2)
-                                       if(!occluded)
-                                       if(cl.worldmodel && cl.worldmodel->brush.TraceLineOfSight && !cl.worldmodel->brush.TraceLineOfSight(cl.worldmodel, listener_origin, ch->origin))
-                                       {
-                                               occluded = true;
-                                       }
-
-                                       if(occluded)
-                                               vol *= 0.5f;
-                               }
-
                                ch->listener_volume[i] = (int)bound(0, vol, 255);
                        }
                }