- 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, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int movetype)
-{
- int i;
- trace_t trace;
- model_t *model = NULL;
- matrix4x4_t matrix, imatrix;
- float tempnormal[3], starttransformed[3], endtransformed[3];
- float starttransformedmins[3], starttransformedmaxs[3], endtransformedmins[3], endtransformedmaxs[3];
-
- if ((int) ent->v->solid == SOLID_BSP || movetype == MOVE_HITMODEL)
- {
- i = ent->v->modelindex;
- // if the modelindex is 0, it shouldn't be SOLID_BSP!
- if (i == 0)
- {
- Con_Printf("SV_ClipMoveToEntity: edict %i: SOLID_BSP with no model\n", NUM_FOR_EDICT(ent));
- memset(&trace, 0, sizeof(trace));
- return trace;
- }
- if ((unsigned int) i >= MAX_MODELS)
- {
- Con_Printf("SV_ClipMoveToEntity: edict %i: SOLID_BSP with invalid modelindex\n", NUM_FOR_EDICT(ent));
- memset(&trace, 0, sizeof(trace));
- return trace;
- }
- model = sv.models[i];
- if (i != 0 && model == NULL)
- {
- Con_Printf("SV_ClipMoveToEntity: edict %i: SOLID_BSP with invalid modelindex\n", NUM_FOR_EDICT(ent));
- memset(&trace, 0, sizeof(trace));
- return trace;
- }
-
- Mod_CheckLoaded(model);
- if ((int) ent->v->solid == SOLID_BSP)
- {
- if (!model->TraceBox)
- {
- Con_Printf("SV_ClipMoveToEntity: edict %i: SOLID_BSP with a non-collidable model\n", NUM_FOR_EDICT(ent));
- memset(&trace, 0, sizeof(trace));
- return trace;
- }
- if (ent->v->movetype != MOVETYPE_PUSH)
- {
- Con_Printf("SV_ClipMoveToEntity: edict %i: SOLID_BSP without MOVETYPE_PUSH\n", NUM_FOR_EDICT(ent));
- memset(&trace, 0, sizeof(trace));
- return trace;
- }
- }
- Matrix4x4_CreateFromQuakeEntity(&matrix, ent->v->origin[0], ent->v->origin[1], ent->v->origin[2], ent->v->angles[0], ent->v->angles[1], ent->v->angles[2], 1);
- }
- else
- Matrix4x4_CreateTranslate(&matrix, ent->v->origin[0], ent->v->origin[1], ent->v->origin[2]);
-
- Matrix4x4_Invert_Simple(&imatrix, &matrix);
- Matrix4x4_Transform(&imatrix, start, starttransformed);
- Matrix4x4_Transform(&imatrix, end, endtransformed);
-#if COLLISIONPARANOID >= 3
- Con_Printf("trans(%f %f %f -> %f %f %f, %f %f %f -> %f %f %f)", start[0], start[1], start[2], starttransformed[0], starttransformed[1], starttransformed[2], end[0], end[1], end[2], endtransformed[0], endtransformed[1], endtransformed[2]);
-#endif
-
- if (model && model->TraceBox)
- {
- int frame;
- frame = (int)ent->v->frame;
- frame = bound(0, frame, (model->numframes - 1));
- VectorAdd(starttransformed, maxs, starttransformedmaxs);
- VectorAdd(endtransformed, maxs, endtransformedmaxs);
- VectorAdd(starttransformed, mins, starttransformedmins);
- VectorAdd(endtransformed, mins, endtransformedmins);
- model->TraceBox(model, frame, &trace, starttransformedmins, starttransformedmaxs, endtransformedmins, endtransformedmaxs, SUPERCONTENTS_SOLID);
- }
- else
- Collision_ClipTrace_Box(&trace, ent->v->mins, ent->v->maxs, starttransformed, mins, maxs, endtransformed, SUPERCONTENTS_SOLID, SUPERCONTENTS_SOLID);
-
- if (trace.fraction < 1)
- {
- VectorLerp(start, trace.fraction, end, trace.endpos);
- VectorCopy(trace.plane.normal, tempnormal);
- Matrix4x4_Transform3x3(&matrix, tempnormal, trace.plane.normal);
- // FIXME: should recalc trace.plane.dist
- }
- else
- VectorCopy(end, trace.endpos);
-
- 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++;
-
- // LordHavoc: this box comparison isn't much use with the high resolution areagrid
- /*
- 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 (touch == clip->passedict)
- continue;
- 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->v->solid == SOLID_TRIGGER)
- {
- ED_Print(touch);
- Host_Error ("Trigger in clipping list");
- }
-
- // might interact, so do an exact clip
- if ((int)touch->v->flags & FL_MONSTER)
- trace = SV_ClipMoveToEntity(touch, clip->start, clip->mins2, clip->maxs2, clip->end, clip->type);
- else
- trace = SV_ClipMoveToEntity(touch, clip->start, clip->mins, clip->maxs, clip->end, clip->type);
- // 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.realfraction == 1)
- clip->trace.ent = touch;
- }
- if (trace.inopen)
- clip->trace.inopen = true;
- if (trace.inwater)
- clip->trace.inwater = true;
- if (trace.realfraction < clip->trace.realfraction)
- {
- clip->trace.fraction = trace.fraction;
- clip->trace.realfraction = trace.realfraction;
- VectorCopy(trace.endpos, clip->trace.endpos);
- clip->trace.plane = trace.plane;
- clip->trace.ent = touch;
- }
- clip->trace.startsupercontents |= trace.startsupercontents;
- }