61 vec3_t mins1, maxs1, mins2, maxs2;
75 VectorSubtract(maxs, mins, size);
76 if (size[0] > size[1])
81 anode->
dist = 0.5 * (maxs[anode->
axis] + mins[anode->
axis]);
82 VectorCopy(mins, mins1);
83 VectorCopy(mins, mins2);
84 VectorCopy(maxs, maxs1);
85 VectorCopy(maxs, maxs2);
111 cm = &
sv.
cm.cache->models[0];
116 for (i = 0; i <
ge->max_edicts; i++) {
118 ent->area.prev = ent->area.next = NULL;
133 if (ent->num_clusters == -1) {
139 for (i = 0; i < ent->num_clusters; i++) {
140 if (Q_IsBitSet(mask, ent->clusternums[i])) {
166 VectorSubtract(ent->maxs, ent->mins, ent->size);
169 if (ent->solid == SOLID_BSP &&
170 (ent->s.angles[0] || ent->s.angles[1] || ent->s.angles[2])) {
176 for (i = 0; i < 3; i++) {
177 v = Q_fabs(ent->mins[i]);
180 v = Q_fabs(ent->maxs[i]);
184 for (i = 0; i < 3; i++) {
185 ent->absmin[i] = ent->s.origin[i] - max;
186 ent->absmax[i] = ent->s.origin[i] + max;
190 VectorAdd(ent->s.origin, ent->mins, ent->absmin);
191 VectorAdd(ent->s.origin, ent->maxs, ent->absmax);
204 ent->num_clusters = 0;
209 num_leafs =
CM_BoxLeafs(cm, ent->absmin, ent->absmax,
213 for (i = 0; i < num_leafs; i++) {
214 clusters[i] = CM_LeafCluster(leafs[i]);
215 area = CM_LeafArea(leafs[i]);
219 if (ent->areanum && ent->areanum != area) {
220 if (ent->areanum2 && ent->areanum2 != area &&
sv.
state == ss_loading) {
221 Com_DPrintf(
"Object touching 3 areas at %f %f %f\n",
222 ent->absmin[0], ent->absmin[1], ent->absmin[2]);
224 ent->areanum2 = area;
232 ent->num_clusters = -1;
233 ent->headnode = CM_NumNode(cm, topnode);
235 ent->num_clusters = 0;
236 for (i = 0; i < num_leafs; i++) {
237 if (clusters[i] == -1)
239 for (j = 0; j < i; j++)
240 if (clusters[j] == clusters[i])
243 if (ent->num_clusters == MAX_ENT_CLUSTERS) {
245 ent->num_clusters = -1;
246 ent->headnode = CM_NumNode(cm, topnode);
250 ent->clusternums[ent->num_clusters++] = clusters[i];
260 List_Remove(&ent->area);
261 ent->area.prev = ent->area.next = NULL;
276 if (ent ==
ge->edicts)
280 Com_DPrintf(
"%s: entity %d is not in use\n", __func__,
NUM_FOR_EDICT(ent));
292 switch (ent->solid) {
294 if ((ent->svflags & SVF_DEADMONSTER) || VectorCompare(ent->mins, ent->maxs)) {
298 ent->s.solid = MSG_PackSolid16(ent->mins, ent->maxs);
299 sent->
solid32 = MSG_PackSolid32(ent->mins, ent->maxs);
303 ent->s.solid = PACKED_BSP;
315 if (!ent->linkcount) {
316 VectorCopy(ent->s.origin, ent->s.old_origin);
318 VectorCopy(ent->s.origin, sent->create_origin);
327 VectorCopy(ent->s.origin, sent->history[i].origin);
331 if (ent->solid == SOLID_NOT)
337 if (node->
axis == -1)
339 if (ent->absmin[node->
axis] > node->
dist)
341 else if (ent->absmax[node->
axis] < node->
dist)
348 if (ent->solid == SOLID_TRIGGER)
372 LIST_FOR_EACH(edict_t, check, start, area) {
373 if (check->solid == SOLID_NOT)
384 Com_WPrintf(
"SV_AreaEdicts: MAXCOUNT\n");
392 if (node->
axis == -1)
408 int maxcount,
int areatype)
435 if (ent->solid == SOLID_BSP) {
436 int i = ent->s.modelindex - 1;
439 if (i <= 0 || i >=
sv.
cm.cache->nummodels)
440 Com_Error(ERR_DROP,
"%s: inline model %d out of range", __func__, i);
442 return sv.
cm.cache->models[i].headnode;
456 edict_t *touch[MAX_EDICTS], *hit;
461 Com_Error(ERR_DROP,
"%s: no map loaded", __func__);
470 for (i = 0; i < num; i++) {
475 hit->s.origin, hit->s.angles);
488 edict_t *passedict,
int contentmask, trace_t *tr)
490 vec3_t boxmins, boxmaxs;
492 edict_t *touchlist[MAX_EDICTS], *touch;
496 for (i = 0; i < 3; i++) {
497 if (end[i] > start[i]) {
498 boxmins[i] = start[i] + mins[i] - 1;
499 boxmaxs[i] = end[i] + maxs[i] + 1;
501 boxmins[i] = end[i] + mins[i] - 1;
502 boxmaxs[i] = start[i] + maxs[i] + 1;
506 num =
SV_AreaEdicts(boxmins, boxmaxs, touchlist, MAX_EDICTS, AREA_SOLID);
510 for (i = 0; i < num; i++) {
511 touch = touchlist[i];
512 if (touch->solid == SOLID_NOT)
514 if (touch == passedict)
519 if (touch->owner == passedict)
521 if (passedict->owner == touch)
525 if (!(contentmask & CONTENTS_DEADMONSTER)
526 && (touch->svflags & SVF_DEADMONSTER))
532 touch->s.origin, touch->s.angles);
546 trace_t q_gameabi
SV_Trace(vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end,
547 edict_t *passedict,
int contentmask)
552 Com_Error(ERR_DROP,
"%s: no map loaded", __func__);
557 Com_EPrintf(
"%s: runaway loop avoided\n", __func__);
558 memset(&trace, 0,
sizeof(trace));
560 trace.ent =
ge->edicts;
561 VectorCopy(end, trace.endpos);
572 CM_BoxTrace(&trace, start, end, mins, maxs,
sv.
cm.cache->nodes, contentmask);
573 trace.ent =
ge->edicts;
574 if (trace.fraction == 0) {