-// set the abs box
-
- if (ent->v->solid == SOLID_BSP)
- {
- if (ent->v->modelindex < 0 || ent->v->modelindex > MAX_MODELS)
- Host_Error("SOLID_BSP with invalid modelindex!\n");
- model = sv.models[(int) ent->v->modelindex];
- if (model != NULL)
- {
- if (model->type != mod_brush)
- Host_Error("SOLID_BSP with non-BSP model\n");
-
- if (ent->v->angles[0] || ent->v->angles[2] || ent->v->avelocity[0] || ent->v->avelocity[2])
- {
- VectorAdd(ent->v->origin, model->rotatedmins, ent->v->absmin);
- VectorAdd(ent->v->origin, model->rotatedmaxs, ent->v->absmax);
- }
- else if (ent->v->angles[1] || ent->v->avelocity[1])
- {
- VectorAdd(ent->v->origin, model->yawmins, ent->v->absmin);
- VectorAdd(ent->v->origin, model->yawmaxs, ent->v->absmax);
- }
- else
- {
- VectorAdd(ent->v->origin, model->normalmins, ent->v->absmin);
- VectorAdd(ent->v->origin, model->normalmaxs, ent->v->absmax);
- }
- }
- else
- {
- // SOLID_BSP with no model is valid, mainly because some QC setup code does so temporarily
- VectorAdd(ent->v->origin, ent->v->mins, ent->v->absmin);
- VectorAdd(ent->v->origin, ent->v->maxs, ent->v->absmax);
- }
- }
- else
- {
- VectorAdd(ent->v->origin, ent->v->mins, ent->v->absmin);
- VectorAdd(ent->v->origin, ent->v->maxs, ent->v->absmax);
- }
-
-//
-// to make items easier to pick up and allow them to be grabbed off
-// of shelves, the abs sizes are expanded
-//
- if ((int)ent->v->flags & FL_ITEM)
- {
- ent->v->absmin[0] -= 15;
- ent->v->absmin[1] -= 15;
- ent->v->absmin[2] -= 1;
- ent->v->absmax[0] += 15;
- ent->v->absmax[1] += 15;
- ent->v->absmax[2] += 1;
- }
- else
- {
- // because movement is clipped an epsilon away from an actual edge,
- // we must fully check even when bounding boxes don't quite touch
- ent->v->absmin[0] -= 1;
- ent->v->absmin[1] -= 1;
- ent->v->absmin[2] -= 1;
- ent->v->absmax[0] += 1;
- ent->v->absmax[1] += 1;
- ent->v->absmax[2] += 1;
- }
-
- if (ent->v->solid == SOLID_NOT)
- return;
-
- SV_LinkEdict_AreaGrid(ent);
-
-// if touch_triggers, touch all entities at this node and descend for more
- if (touch_triggers)
- SV_TouchAreaGrid(ent);
-}
-
-
-
-/*
-===============================================================================
-
-POINT TESTING IN HULLS
-
-===============================================================================
-*/
-
-/*
-============
-SV_TestEntityPosition
-
-This could be a lot more efficient...
-============
-*/
-int SV_TestEntityPosition (edict_t *ent)
-{
- return SV_Move (ent->v->origin, ent->v->mins, ent->v->maxs, ent->v->origin, MOVE_NORMAL, ent).startsolid;
-}
-
-
-/*
-===============================================================================
-
-LINE TESTING IN HULLS
-
-===============================================================================
-*/
-
-/*
-==================
-SV_ClipMoveToEntity
-
-Handles selection or creation of a clipping hull, and offseting (and
-eventually rotation) of the end points
-==================
-*/
-trace_t SV_ClipMoveToEntity (edict_t *ent, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end)
-{
- int i;
- trace_t trace;
- model_t *model;
-
- i = ent->v->modelindex;
- if ((unsigned int) i >= MAX_MODELS)
- Host_Error("SV_ClipMoveToEntity: invalid modelindex\n");
- model = sv.models[i];
- if (i != 0 && model == NULL)
- Host_Error("SV_ClipMoveToEntity: invalid modelindex\n");
-
- if ((int) ent->v->solid == SOLID_BSP)
- {
- Mod_CheckLoaded(model);
- if (model->type != mod_brush)
- {
- Con_Printf ("SV_ClipMoveToEntity: SOLID_BSP with a non bsp model, entity dump:\n");
- ED_Print (ent);
- Host_Error ("SV_ClipMoveToEntity: SOLID_BSP with a non bsp model\n");
- }
- if (ent->v->movetype != MOVETYPE_PUSH)
- Host_Error ("SV_ClipMoveToEntity: SOLID_BSP without MOVETYPE_PUSH");
- }
-
- if (sv_polygoncollisions.integer && (mins[0] != maxs[0] || mins[1] != maxs[1] || mins[2] != maxs[2]))
- Collision_PolygonClipTrace(&trace, ent, model, ent->v->origin, ent->v->angles, ent->v->mins, ent->v->maxs, start, mins, maxs, end);
- else
- Collision_ClipTrace(&trace, ent, model, ent->v->origin, ent->v->angles, ent->v->mins, ent->v->maxs, start, mins, maxs, end);
-
- return trace;
-}
-
-//===========================================================================
-
-void SV_ClipToNode(moveclip_t *clip, link_t *list)
-{
- link_t *l, *next;
- edict_t *touch;
- trace_t trace;
-
- sv_areagrid_stats_nodechecks++;
- for (l = list->next;l != list;l = next)
- {
- next = l->next;
- touch = EDICT_NUM(l->entitynumber);
- if (touch->e->areagridmarknumber == sv_areagrid_marknumber)
- continue;
- touch->e->areagridmarknumber = sv_areagrid_marknumber;
- sv_areagrid_stats_entitychecks++;
-
- if (clip->boxmins[0] > touch->v->absmax[0]
- || clip->boxmaxs[0] < touch->v->absmin[0]
- || clip->boxmins[1] > touch->v->absmax[1]
- || clip->boxmaxs[1] < touch->v->absmin[1]
- || clip->boxmins[2] > touch->v->absmax[2]
- || clip->boxmaxs[2] < touch->v->absmin[2])
- continue;
-
- if (clip->type == MOVE_NOMONSTERS && touch->v->solid != SOLID_BSP)
- continue;
-
- if (touch->v->solid == SOLID_NOT)
- continue;
-
- if (clip->passedict)
- {
- if (clip->passedict->v->size[0] && !touch->v->size[0])
- continue; // points never interact
- if (PROG_TO_EDICT(touch->v->owner) == clip->passedict)
- continue; // don't clip against own missiles
- if (PROG_TO_EDICT(clip->passedict->v->owner) == touch)
- continue; // don't clip against owner
- // LordHavoc: corpse code
- if (clip->passedict->v->solid == SOLID_CORPSE && (touch->v->solid == SOLID_SLIDEBOX || touch->v->solid == SOLID_CORPSE))
- continue;
- if (clip->passedict->v->solid == SOLID_SLIDEBOX && touch->v->solid == SOLID_CORPSE)
- continue;
- }
-
- if (touch == clip->passedict)
- continue;
- if (touch->v->solid == SOLID_TRIGGER)
- {
- ED_Print(touch);
- Host_Error ("Trigger in clipping list");
- }
-
- // might interact, so do an exact clip
- if (touch->v->solid == SOLID_BSP)
- trace = SV_ClipMoveToEntity (touch, clip->start, clip->hullmins, clip->hullmaxs, clip->end);
- else if ((int)touch->v->flags & FL_MONSTER)
- trace = SV_ClipMoveToEntity (touch, clip->start, clip->mins2, clip->maxs2, clip->end);
- else
- trace = SV_ClipMoveToEntity (touch, clip->start, clip->mins, clip->maxs, clip->end);
- // LordHavoc: take the 'best' answers from the new trace and combine with existing data
- if (trace.allsolid)
- clip->trace.allsolid = true;
- if (trace.startsolid)
- {
- clip->trace.startsolid = true;
- if (!clip->trace.ent)
- clip->trace.ent = trace.ent;
- }
- if (trace.inopen)
- clip->trace.inopen = true;
- if (trace.inwater)
- clip->trace.inwater = true;
- if (trace.fraction < clip->trace.fraction)
- {
- clip->trace.fraction = trace.fraction;
- VectorCopy(trace.endpos, clip->trace.endpos);
- clip->trace.plane = trace.plane;
- clip->trace.endcontents = trace.endcontents;
- clip->trace.ent = trace.ent;
- }
- if (clip->trace.allsolid)
- return;
- }
-}
-
-/*
-====================
-SV_ClipToAreaGrid
-
-Mins and maxs enclose the entire area swept by the move
-====================
-*/
-void SV_ClipToAreaGrid(moveclip_t *clip)
-{
- areagrid_t *grid;
- int igrid[3], igridmins[3], igridmaxs[3];
-
- if (clip->trace.allsolid)