public static int SV_HullForEntity(edict_t ent) { cmodel_t model; if (ent.solid == Defines.SOLID_BSP) { model = SV_INIT.sv.models[ent.s.modelindex]; if (null == model) { Com.Error(Defines.ERR_FATAL, "MOVETYPE_PUSH with a non bsp model"); } return(model.headnode); } return(CM.HeadnodeForBox(ent.mins, ent.maxs)); }
/* * ================ SV_HullForEntity * * Returns a headnode that can be used for testing or clipping an object of * mins/maxs size. Offset is filled in to contain the adjustment that must * be added to the testing object's origin to get a point to use with the * returned hull. ================ */ public static int SV_HullForEntity(edict_t ent) { cmodel_t model; // decide which clipping hull to use, based on the size if (ent.solid == Defines.SOLID_BSP) { // explicit hulls in the BSP model model = SV_INIT.sv.models[ent.s.modelindex]; if (null == model) { Com.Error(Defines.ERR_FATAL, "MOVETYPE_PUSH with a non bsp model"); } return(model.headnode); } // create a temp hull from bounding box sizes return(CM.HeadnodeForBox(ent.mins, ent.maxs)); }
/* * ==================== CL_ClipMoveToEntities * * ==================== */ private static void ClipMoveToEntities(float[] start, float[] mins, float[] maxs, float[] end, trace_t tr) { int i, x, zd, zu; trace_t trace; int headnode; float[] angles; entity_state_t ent; int num; cmodel_t cmodel; var bmins = new float[3]; var bmaxs = new float[3]; for (i = 0; i < Globals.cl.frame.num_entities; i++) { num = (Globals.cl.frame.parse_entities + i) & (Defines.MAX_PARSE_ENTITIES - 1); ent = Globals.cl_parse_entities[num]; if (ent.solid == 0) { continue; } if (ent.number == Globals.cl.playernum + 1) { continue; } if (ent.solid == 31) { // special value for bmodel cmodel = Globals.cl.model_clip[ent.modelindex]; if (cmodel == null) { continue; } headnode = cmodel.headnode; angles = ent.angles; } else { // encoded bbox x = 8 * (ent.solid & 31); zd = (int)(8 * (((uint)ent.solid >> 5) & 31)); zu = (int)(8 * (((uint)ent.solid >> 10) & 63) - 32); bmins[0] = bmins[1] = -x; bmaxs[0] = bmaxs[1] = x; bmins[2] = -zd; bmaxs[2] = zu; headnode = CM.HeadnodeForBox(bmins, bmaxs); angles = Globals.vec3_origin; // boxes don't rotate } if (tr.allsolid) { return; } trace = CM.TransformedBoxTrace(start, end, mins, maxs, headnode, Defines.MASK_PLAYERSOLID, ent.origin, angles); if (trace.allsolid || trace.startsolid || trace.fraction < tr.fraction) { trace.ent = ent.surrounding_ent; if (tr.startsolid) { tr.set(trace); // rst: solved the Z U P P E L - P R O B L E // M tr.startsolid = true; } else { tr.set(trace); // rst: solved the Z U P P E L - P R O B L E } // M } else if (trace.startsolid) { tr.startsolid = true; } } }