PointInLeaf() public static method

Mod_PointInLeaf
public static PointInLeaf ( Vector3 &p, model_t model ) : mleaf_t
p Vector3
model model_t
return mleaf_t
Beispiel #1
0
        // S_UpdateAmbientSounds
        private static void UpdateAmbientSounds()
        {
            if (!_Ambient)
            {
                return;
            }

            // calc ambient sound levels
            if (client.cl.worldmodel == null)
            {
                return;
            }

            mleaf_t l = Mod.PointInLeaf(ref _ListenerOrigin, client.cl.worldmodel);

            if (l == null || _AmbientLevel.Value == 0)
            {
                for (int i = 0; i < Ambients.NUM_AMBIENTS; i++)
                {
                    _Channels[i].sfx = null;
                }
                return;
            }

            for (int i = 0; i < Ambients.NUM_AMBIENTS; i++)
            {
                channel_t chan = _Channels[i];
                chan.sfx = _AmbientSfx[i];

                float vol = _AmbientLevel.Value * l.ambient_sound_level[i];
                if (vol < 8)
                {
                    vol = 0;
                }

                // don't adjust volume too fast
                if (chan.master_vol < vol)
                {
                    chan.master_vol += (int)(host.FrameTime * _AmbientFade.Value);
                    if (chan.master_vol > vol)
                    {
                        chan.master_vol = (int)vol;
                    }
                }
                else if (chan.master_vol > vol)
                {
                    chan.master_vol -= (int)(host.FrameTime * _AmbientFade.Value);
                    if (chan.master_vol < vol)
                    {
                        chan.master_vol = (int)vol;
                    }
                }

                chan.leftvol = chan.rightvol = chan.master_vol;
            }
        }
Beispiel #2
0
        static int PF_newcheckclient(int check)
        {
            // cycle to the next one

            if (check < 1)
            {
                check = 1;
            }

            if (check > Server.svs.maxclients)
            {
                check = Server.svs.maxclients;
            }

            int i = check + 1;

            if (check == Server.svs.maxclients)
            {
                i = 1;
            }

            edict_t ent;

            for (; ; i++)
            {
                if (i == Server.svs.maxclients + 1)
                {
                    i = 1;
                }

                ent = Server.EdictNum(i);

                if (i == check)
                {
                    break;  // didn't find anything else
                }

                if (ent.free)
                {
                    continue;
                }

                if (ent.v.health <= 0)
                {
                    continue;
                }

                if (((int)ent.v.flags & EdictFlags.FL_NOTARGET) != 0)
                {
                    continue;
                }

                // anything that is a client, or has a client as an enemy
                break;
            }

            // get the PVS for the entity
            Vector3 org  = Common.ToVector(ref ent.v.origin) + Common.ToVector(ref ent.v.view_ofs);
            mleaf_t leaf = Mod.PointInLeaf(ref org, Server.sv.worldmodel);

            byte[] pvs = Mod.LeafPVS(leaf, Server.sv.worldmodel);
            Buffer.BlockCopy(pvs, 0, _CheckPvs, 0, pvs.Length);

            return(i);
        }