/* * ============= SV_PointContents ============= */ public static int SV_PointContents(float[] p) { edict_t hit; int i, num; int contents, c2; int headnode; // get base contents from world contents = CM.PointContents(p, SV_INIT.sv.models[1].headnode); // or in contents from all the other entities num = SV_WORLD.SV_AreaEdicts(p, p, SV_WORLD.touch, Defines.MAX_EDICTS, Defines.AREA_SOLID); for (i = 0; i < num; i++) { hit = SV_WORLD.touch[i]; // might intersect, so do an exact clip headnode = SV_WORLD.SV_HullForEntity(hit); if (hit.solid != Defines.SOLID_BSP) { } c2 = CM.TransformedPointContents(p, headnode, hit.s.origin, hit.s.angles); contents |= c2; } return(contents); }
public static void SV_ClipMoveToEntities(moveclip_t clip) { int i, num; edict_t touch; trace_t trace; int headnode; float[] angles; num = SV_WORLD.SV_AreaEdicts(clip.boxmins, clip.boxmaxs, SV_WORLD.touchlist, Defines.MAX_EDICTS, Defines.AREA_SOLID); // be careful, it is possible to have an entity in this // list removed before we get to it (killtriggered) 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; // don't clip against own missiles } if (clip.passedict.owner == touch) { continue; // don't clip against owner } } if (0 == (clip.contentmask & Defines.CONTENTS_DEADMONSTER) && 0 != (touch.svflags & Defines.SVF_DEADMONSTER)) { continue; } // might intersect, so do an exact clip headnode = SV_WORLD.SV_HullForEntity(touch); angles = touch.s.angles; if (touch.solid != Defines.SOLID_BSP) { angles = Globals.vec3_origin; // boxes don't rotate } 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; } } }