+ // update sound origin if we know about the entity
+ if (ch->entnum > 0 && cls.state == ca_connected && cl_entities[ch->entnum].state_current.active)
+ {
+ //Con_Printf("-- entnum %i origin %f %f %f neworigin %f %f %f\n", ch->entnum, ch->origin[0], ch->origin[1], ch->origin[2], cl_entities[ch->entnum].state_current.origin[0], cl_entities[ch->entnum].state_current.origin[1], cl_entities[ch->entnum].state_current.origin[2]);
+ VectorCopy(cl_entities[ch->entnum].state_current.origin, ch->origin);
+ if (cl_entities[ch->entnum].state_current.modelindex && cl.model_precache[cl_entities[ch->entnum].state_current.modelindex]->soundfromcenter)
+ VectorMAMAM(1.0f, ch->origin, 0.5f, cl.model_precache[cl_entities[ch->entnum].state_current.modelindex]->normalmins, 0.5f, cl.model_precache[cl_entities[ch->entnum].state_current.modelindex]->normalmaxs, ch->origin);
+ }
+
+ // calculate stereo seperation and distance attenuation
+ VectorSubtract(ch->origin, listener_vieworigin, source_vec);
+ dist = VectorNormalizeLength(source_vec);
+ // distance
+ scale = ch->master_vol * (1.0 - (dist * ch->dist_mult));
+ // panning
+ pan = scale * DotProduct(listener_viewleft, source_vec);
+ // calculate the volumes
+ ch->leftvol = (int) (scale + pan);
+ ch->rightvol = (int) (scale - pan);