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)
- Host_Error("SV_ClipMoveToEntity: invalid modelindex\n");
+ {
+ 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)
- Host_Error("SV_ClipMoveToEntity: invalid modelindex\n");
+ {
+ 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: SOLID_BSP with a non-collidable model, entity dump:\n");
- ED_Print(ent);
- Host_Error("SV_ClipMoveToEntity: SOLID_BSP with a non-collidable model\n");
+ 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)
- Host_Error("SV_ClipMoveToEntity: SOLID_BSP without 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_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);
Matrix4x4_Invert_Simple(&imatrix, &matrix);
Matrix4x4_Transform(&imatrix, start, starttransformed);
Matrix4x4_Transform(&imatrix, end, endtransformed);
-#ifdef COLLISIONPARANOID
+#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
else
Collision_ClipTrace_Box(&trace, ent->v->mins, ent->v->maxs, starttransformed, mins, maxs, endtransformed, SUPERCONTENTS_SOLID, SUPERCONTENTS_SOLID);
- if (trace.fraction < 1 || trace.startsolid)
+ if (trace.fraction < 1)
{
- trace.ent = ent;
VectorLerp(start, trace.fraction, end, trace.endpos);
VectorCopy(trace.plane.normal, tempnormal);
Matrix4x4_Transform3x3(&matrix, tempnormal, trace.plane.normal);
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->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 (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;
}
- if (touch == clip->passedict)
- continue;
if (touch->v->solid == SOLID_TRIGGER)
{
ED_Print(touch);
}
// might interact, so do an exact clip
- if (touch->v->solid == SOLID_BSP)
- trace = SV_ClipMoveToEntity(touch, clip->start, clip->mins, clip->maxs, clip->end, clip->type);
- else if ((int)touch->v->flags & FL_MONSTER)
+ 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);
if (trace.startsolid)
{
clip->trace.startsolid = true;
- //if (!clip->trace.ent)
- // clip->trace.ent = trace.ent;
+ 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.fraction < clip->trace.fraction)
+ 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;
- //if (clip->trace.allsolid)
- // return;
}
}
SV_Move
==================
*/
+#if COLLISIONPARANOID >= 1
+trace_t SV_Move_(const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int type, edict_t *passedict)
+#else
trace_t SV_Move(const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int type, edict_t *passedict)
+#endif
{
moveclip_t clip;
vec3_t hullmins, hullmaxs;
VectorCopy(maxs, clip.maxs2);
clip.type = type;
clip.passedict = passedict;
-#ifdef COLLISIONPARANOID
+#if COLLISIONPARANOID >= 3
Con_Printf("move(%f %f %f,%f %f %f)", clip.start[0], clip.start[1], clip.start[2], clip.end[0], clip.end[1], clip.end[2]);
#endif
// clip to world
clip.trace = SV_ClipMoveToEntity(sv.edicts, clip.start, clip.mins, clip.maxs, clip.end, clip.type);
+ if (clip.trace.startsolid || clip.trace.fraction < 1)
+ clip.trace.ent = sv.edicts;
if (clip.type == MOVE_WORLDONLY)
- //if (clip.trace.allsolid)
return clip.trace;
if (clip.type == MOVE_MISSILE)
return clip.trace;
}
+#if COLLISIONPARANOID >= 1
+trace_t SV_Move(const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int type, edict_t *passedict)
+{
+ int endstuck;
+ trace_t trace;
+ vec3_t temp;
+ trace = SV_Move_(start, mins, maxs, end, type, passedict);
+ if (passedict)
+ {
+ VectorCopy(trace.endpos, temp);
+ endstuck = SV_Move_(temp, mins, maxs, temp, type, passedict).startsolid;
+#if COLLISIONPARANOID < 3
+ if (trace.startsolid || endstuck)
+#endif
+ Con_Printf("%s{e%i:%f %f %f:%f %f %f:%f:%f %f %f%s%s}\n", (trace.startsolid || endstuck) ? "\002" : "", passedict ? passedict - sv.edicts : -1, passedict->v->origin[0], passedict->v->origin[1], passedict->v->origin[2], end[0] - passedict->v->origin[0], end[1] - passedict->v->origin[1], end[2] - passedict->v->origin[2], trace.fraction, trace.endpos[0] - passedict->v->origin[0], trace.endpos[1] - passedict->v->origin[1], trace.endpos[2] - passedict->v->origin[2], trace.startsolid ? " startstuck" : "", endstuck ? " endstuck" : "");
+ }
+ return trace;
+}
+#endif
+
int SV_PointSuperContents(const vec3_t point)
{
return SV_Move(point, vec3_origin, vec3_origin, point, MOVE_NOMONSTERS, NULL).startsupercontents;