Exemple #1
0
        public static trace_t SV_Trace(float[] start, float[] mins, float[] maxs, float[] end, edict_t passedict, int contentmask)
        {
            moveclip_t clip = new moveclip_t();

            if (mins == null)
            {
                mins = Globals.vec3_origin;
            }
            if (maxs == null)
            {
                maxs = Globals.vec3_origin;
            }
            clip.trace     = CM.BoxTrace(start, end, mins, maxs, 0, contentmask);
            clip.trace.ent = GameBase.g_edicts[0];
            if (clip.trace.fraction == 0)
            {
                return(clip.trace);
            }
            clip.contentmask = contentmask;
            clip.start       = start;
            clip.end         = end;
            clip.mins        = mins;
            clip.maxs        = maxs;
            clip.passedict   = passedict;
            Math3D.VectorCopy(mins, clip.mins2);
            Math3D.VectorCopy(maxs, clip.maxs2);
            SV_TraceBounds(start, clip.mins2, clip.maxs2, end, clip.boxmins, clip.boxmaxs);
            SV_ClipMoveToEntities(clip);
            return(clip.trace);
        }
Exemple #2
0
        public static void SV_ClipMoveToEntities(moveclip_t clip)
        {
            int     i, num;
            edict_t touch;
            trace_t trace;
            int     headnode;

            float[] angles;
            num = SV_AreaEdicts(clip.boxmins, clip.boxmaxs, SV_WORLD.touchlist, Defines.MAX_EDICTS, Defines.AREA_SOLID);
            for (i = 0; i < num; i++)
            {
                touch = SV_WORLD.touchlist[i];
                if (touch.solid == Defines.SOLID_NOT)
                {
                    continue;
                }
                if (touch == clip.passedict)
                {
                    continue;
                }
                if (clip.trace.allsolid)
                {
                    return;
                }
                if (clip.passedict != null)
                {
                    if (touch.owner == clip.passedict)
                    {
                        continue;
                    }
                    if (clip.passedict.owner == touch)
                    {
                        continue;
                    }
                }

                if (0 == (clip.contentmask & Defines.CONTENTS_DEADMONSTER) && 0 != (touch.svflags & Defines.SVF_DEADMONSTER))
                {
                    continue;
                }
                headnode = SV_HullForEntity(touch);
                angles   = touch.s.angles;
                if (touch.solid != Defines.SOLID_BSP)
                {
                    angles = Globals.vec3_origin;
                }
                if ((touch.svflags & Defines.SVF_MONSTER) != 0)
                {
                    trace = CM.TransformedBoxTrace(clip.start, clip.end, clip.mins2, clip.maxs2, headnode, clip.contentmask, touch.s.origin, angles);
                }
                else
                {
                    trace = CM.TransformedBoxTrace(clip.start, clip.end, clip.mins, clip.maxs, headnode, clip.contentmask, touch.s.origin, angles);
                }
                if (trace.allsolid || trace.startsolid || trace.fraction < clip.trace.fraction)
                {
                    trace.ent = touch;
                    if (clip.trace.startsolid)
                    {
                        clip.trace            = trace;
                        clip.trace.startsolid = true;
                    }
                    else
                    {
                        clip.trace.Set(trace);
                    }
                }
                else if (trace.startsolid)
                {
                    clip.trace.startsolid = true;
                }
            }
        }