| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
#include "server.h" |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
clipHandle_t SV_ClipHandleForEntity( const sharedEntity_t *ent ) { |
| 36 |
if ( ent->r.bmodel ) { |
| 37 |
|
| 38 |
return CM_InlineModel( ent->s.modelindex ); |
| 39 |
} |
| 40 |
if ( ent->r.svFlags & SVF_CAPSULE ) { |
| 41 |
|
| 42 |
return CM_TempBoxModel( ent->r.mins, ent->r.maxs, qtrue ); |
| 43 |
} |
| 44 |
|
| 45 |
|
| 46 |
return CM_TempBoxModel( ent->r.mins, ent->r.maxs, qfalse ); |
| 47 |
} |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
typedef struct worldSector_s { |
| 65 |
int axis; |
| 66 |
float dist; |
| 67 |
struct worldSector_s *children[2]; |
| 68 |
svEntity_t *entities; |
| 69 |
} worldSector_t; |
| 70 |
|
| 71 |
#define AREA_DEPTH 4 |
| 72 |
#define AREA_NODES 64 |
| 73 |
|
| 74 |
worldSector_t sv_worldSectors[AREA_NODES]; |
| 75 |
int sv_numworldSectors; |
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
void SV_SectorList_f( void ) { |
| 84 |
int i, c; |
| 85 |
worldSector_t *sec; |
| 86 |
svEntity_t *ent; |
| 87 |
|
| 88 |
for ( i = 0 ; i < AREA_NODES ; i++ ) { |
| 89 |
sec = &sv_worldSectors[i]; |
| 90 |
|
| 91 |
c = 0; |
| 92 |
for ( ent = sec->entities ; ent ; ent = ent->nextEntityInWorldSector ) { |
| 93 |
c++; |
| 94 |
} |
| 95 |
Com_Printf( "sector %i: %i entities\n", i, c ); |
| 96 |
} |
| 97 |
} |
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
static worldSector_t *SV_CreateworldSector( int depth, vec3_t mins, vec3_t maxs ) { |
| 107 |
worldSector_t *anode; |
| 108 |
vec3_t size; |
| 109 |
vec3_t mins1, maxs1, mins2, maxs2; |
| 110 |
|
| 111 |
anode = &sv_worldSectors[sv_numworldSectors]; |
| 112 |
sv_numworldSectors++; |
| 113 |
|
| 114 |
if (depth == AREA_DEPTH) { |
| 115 |
anode->axis = -1; |
| 116 |
anode->children[0] = anode->children[1] = NULL; |
| 117 |
return anode; |
| 118 |
} |
| 119 |
|
| 120 |
VectorSubtract (maxs, mins, size); |
| 121 |
if (size[0] > size[1]) { |
| 122 |
anode->axis = 0; |
| 123 |
} else { |
| 124 |
anode->axis = 1; |
| 125 |
} |
| 126 |
|
| 127 |
anode->dist = 0.5 * (maxs[anode->axis] + mins[anode->axis]); |
| 128 |
VectorCopy (mins, mins1); |
| 129 |
VectorCopy (mins, mins2); |
| 130 |
VectorCopy (maxs, maxs1); |
| 131 |
VectorCopy (maxs, maxs2); |
| 132 |
|
| 133 |
maxs1[anode->axis] = mins2[anode->axis] = anode->dist; |
| 134 |
|
| 135 |
anode->children[0] = SV_CreateworldSector (depth+1, mins2, maxs2); |
| 136 |
anode->children[1] = SV_CreateworldSector (depth+1, mins1, maxs1); |
| 137 |
|
| 138 |
return anode; |
| 139 |
} |
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
void SV_ClearWorld( void ) { |
| 148 |
clipHandle_t h; |
| 149 |
vec3_t mins, maxs; |
| 150 |
|
| 151 |
Com_Memset( sv_worldSectors, 0, sizeof(sv_worldSectors) ); |
| 152 |
sv_numworldSectors = 0; |
| 153 |
|
| 154 |
|
| 155 |
h = CM_InlineModel( 0 ); |
| 156 |
CM_ModelBounds( h, mins, maxs ); |
| 157 |
SV_CreateworldSector( 0, mins, maxs ); |
| 158 |
} |
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
void SV_UnlinkEntity( sharedEntity_t *gEnt ) { |
| 168 |
svEntity_t *ent; |
| 169 |
svEntity_t *scan; |
| 170 |
worldSector_t *ws; |
| 171 |
|
| 172 |
ent = SV_SvEntityForGentity( gEnt ); |
| 173 |
|
| 174 |
gEnt->r.linked = qfalse; |
| 175 |
|
| 176 |
ws = ent->worldSector; |
| 177 |
if ( !ws ) { |
| 178 |
return; |
| 179 |
} |
| 180 |
ent->worldSector = NULL; |
| 181 |
|
| 182 |
if ( ws->entities == ent ) { |
| 183 |
ws->entities = ent->nextEntityInWorldSector; |
| 184 |
return; |
| 185 |
} |
| 186 |
|
| 187 |
for ( scan = ws->entities ; scan ; scan = scan->nextEntityInWorldSector ) { |
| 188 |
if ( scan->nextEntityInWorldSector == ent ) { |
| 189 |
scan->nextEntityInWorldSector = ent->nextEntityInWorldSector; |
| 190 |
return; |
| 191 |
} |
| 192 |
} |
| 193 |
|
| 194 |
Com_Printf( "WARNING: SV_UnlinkEntity: not found in worldSector\n" ); |
| 195 |
} |
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
|
| 204 |
#define MAX_TOTAL_ENT_LEAFS 128 |
| 205 |
void SV_LinkEntity( sharedEntity_t *gEnt ) { |
| 206 |
worldSector_t *node; |
| 207 |
int leafs[MAX_TOTAL_ENT_LEAFS]; |
| 208 |
int cluster; |
| 209 |
int num_leafs; |
| 210 |
int i, j, k; |
| 211 |
int area; |
| 212 |
int lastLeaf; |
| 213 |
float *origin, *angles; |
| 214 |
svEntity_t *ent; |
| 215 |
|
| 216 |
ent = SV_SvEntityForGentity( gEnt ); |
| 217 |
|
| 218 |
if ( ent->worldSector ) { |
| 219 |
SV_UnlinkEntity( gEnt ); |
| 220 |
} |
| 221 |
|
| 222 |
|
| 223 |
if ( gEnt->r.bmodel ) { |
| 224 |
gEnt->s.solid = SOLID_BMODEL; |
| 225 |
} else if ( gEnt->r.contents & ( CONTENTS_SOLID | CONTENTS_BODY ) ) { |
| 226 |
|
| 227 |
i = gEnt->r.maxs[0]; |
| 228 |
if (i<1) |
| 229 |
i = 1; |
| 230 |
if (i>255) |
| 231 |
i = 255; |
| 232 |
|
| 233 |
|
| 234 |
j = (-gEnt->r.mins[2]); |
| 235 |
if (j<1) |
| 236 |
j = 1; |
| 237 |
if (j>255) |
| 238 |
j = 255; |
| 239 |
|
| 240 |
|
| 241 |
k = (gEnt->r.maxs[2]+32); |
| 242 |
if (k<1) |
| 243 |
k = 1; |
| 244 |
if (k>255) |
| 245 |
k = 255; |
| 246 |
|
| 247 |
gEnt->s.solid = (k<<16) | (j<<8) | i; |
| 248 |
} else { |
| 249 |
gEnt->s.solid = 0; |
| 250 |
} |
| 251 |
|
| 252 |
|
| 253 |
origin = gEnt->r.currentOrigin; |
| 254 |
angles = gEnt->r.currentAngles; |
| 255 |
|
| 256 |
|
| 257 |
if ( gEnt->r.bmodel && (angles[0] || angles[1] || angles[2]) ) { |
| 258 |
|
| 259 |
float max; |
| 260 |
|
| 261 |
max = RadiusFromBounds( gEnt->r.mins, gEnt->r.maxs ); |
| 262 |
for (i=0 ; i<3 ; i++) { |
| 263 |
gEnt->r.absmin[i] = origin[i] - max; |
| 264 |
gEnt->r.absmax[i] = origin[i] + max; |
| 265 |
} |
| 266 |
} else { |
| 267 |
|
| 268 |
VectorAdd (origin, gEnt->r.mins, gEnt->r.absmin); |
| 269 |
VectorAdd (origin, gEnt->r.maxs, gEnt->r.absmax); |
| 270 |
} |
| 271 |
|
| 272 |
|
| 273 |
|
| 274 |
gEnt->r.absmin[0] -= 1; |
| 275 |
gEnt->r.absmin[1] -= 1; |
| 276 |
gEnt->r.absmin[2] -= 1; |
| 277 |
gEnt->r.absmax[0] += 1; |
| 278 |
gEnt->r.absmax[1] += 1; |
| 279 |
gEnt->r.absmax[2] += 1; |
| 280 |
|
| 281 |
|
| 282 |
ent->numClusters = 0; |
| 283 |
ent->lastCluster = 0; |
| 284 |
ent->areanum = -1; |
| 285 |
ent->areanum2 = -1; |
| 286 |
|
| 287 |
|
| 288 |
num_leafs = CM_BoxLeafnums( gEnt->r.absmin, gEnt->r.absmax, |
| 289 |
leafs, MAX_TOTAL_ENT_LEAFS, &lastLeaf ); |
| 290 |
|
| 291 |
|
| 292 |
|
| 293 |
if ( !num_leafs ) { |
| 294 |
return; |
| 295 |
} |
| 296 |
|
| 297 |
|
| 298 |
for (i=0 ; i<num_leafs ; i++) { |
| 299 |
area = CM_LeafArea (leafs[i]); |
| 300 |
if (area != -1) { |
| 301 |
|
| 302 |
|
| 303 |
if (ent->areanum != -1 && ent->areanum != area) { |
| 304 |
if (ent->areanum2 != -1 && ent->areanum2 != area && sv.state == SS_LOADING) { |
| 305 |
Com_DPrintf ("Object %i touching 3 areas at %f %f %f\n", |
| 306 |
gEnt->s.number, |
| 307 |
gEnt->r.absmin[0], gEnt->r.absmin[1], gEnt->r.absmin[2]); |
| 308 |
} |
| 309 |
ent->areanum2 = area; |
| 310 |
} else { |
| 311 |
ent->areanum = area; |
| 312 |
} |
| 313 |
} |
| 314 |
} |
| 315 |
|
| 316 |
|
| 317 |
ent->numClusters = 0; |
| 318 |
for (i=0 ; i < num_leafs ; i++) { |
| 319 |
cluster = CM_LeafCluster( leafs[i] ); |
| 320 |
if ( cluster != -1 ) { |
| 321 |
ent->clusternums[ent->numClusters++] = cluster; |
| 322 |
if ( ent->numClusters == MAX_ENT_CLUSTERS ) { |
| 323 |
break; |
| 324 |
} |
| 325 |
} |
| 326 |
} |
| 327 |
|
| 328 |
|
| 329 |
if ( i != num_leafs ) { |
| 330 |
ent->lastCluster = CM_LeafCluster( lastLeaf ); |
| 331 |
} |
| 332 |
|
| 333 |
gEnt->r.linkcount++; |
| 334 |
|
| 335 |
|
| 336 |
node = sv_worldSectors; |
| 337 |
while (1) |
| 338 |
{ |
| 339 |
if (node->axis == -1) |
| 340 |
break; |
| 341 |
if ( gEnt->r.absmin[node->axis] > node->dist) |
| 342 |
node = node->children[0]; |
| 343 |
else if ( gEnt->r.absmax[node->axis] < node->dist) |
| 344 |
node = node->children[1]; |
| 345 |
else |
| 346 |
break; |
| 347 |
} |
| 348 |
|
| 349 |
|
| 350 |
ent->worldSector = node; |
| 351 |
ent->nextEntityInWorldSector = node->entities; |
| 352 |
node->entities = ent; |
| 353 |
|
| 354 |
gEnt->r.linked = qtrue; |
| 355 |
} |
| 356 |
|
| 357 |
|
| 358 |
|
| 359 |
|
| 360 |
|
| 361 |
|
| 362 |
|
| 363 |
|
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
typedef struct { |
| 368 |
const float *mins; |
| 369 |
const float *maxs; |
| 370 |
int *list; |
| 371 |
int count, maxcount; |
| 372 |
} areaParms_t; |
| 373 |
|
| 374 |
|
| 375 |
|
| 376 |
|
| 377 |
|
| 378 |
|
| 379 |
|
| 380 |
|
| 381 |
static void SV_AreaEntities_r( worldSector_t *node, areaParms_t *ap ) { |
| 382 |
svEntity_t *check, *next; |
| 383 |
sharedEntity_t *gcheck; |
| 384 |
|
| 385 |
for ( check = node->entities ; check ; check = next ) { |
| 386 |
next = check->nextEntityInWorldSector; |
| 387 |
|
| 388 |
gcheck = SV_GEntityForSvEntity( check ); |
| 389 |
|
| 390 |
if ( gcheck->r.absmin[0] > ap->maxs[0] |
| 391 |
|| gcheck->r.absmin[1] > ap->maxs[1] |
| 392 |
|| gcheck->r.absmin[2] > ap->maxs[2] |
| 393 |
|| gcheck->r.absmax[0] < ap->mins[0] |
| 394 |
|| gcheck->r.absmax[1] < ap->mins[1] |
| 395 |
|| gcheck->r.absmax[2] < ap->mins[2]) { |
| 396 |
continue; |
| 397 |
} |
| 398 |
|
| 399 |
if ( ap->count == ap->maxcount ) { |
| 400 |
Com_Printf ("SV_AreaEntities: MAXCOUNT\n"); |
| 401 |
return; |
| 402 |
} |
| 403 |
|
| 404 |
ap->list[ap->count] = check - sv.svEntities; |
| 405 |
ap->count++; |
| 406 |
} |
| 407 |
|
| 408 |
if (node->axis == -1) { |
| 409 |
return; |
| 410 |
} |
| 411 |
|
| 412 |
|
| 413 |
if ( ap->maxs[node->axis] > node->dist ) { |
| 414 |
SV_AreaEntities_r ( node->children[0], ap ); |
| 415 |
} |
| 416 |
if ( ap->mins[node->axis] < node->dist ) { |
| 417 |
SV_AreaEntities_r ( node->children[1], ap ); |
| 418 |
} |
| 419 |
} |
| 420 |
|
| 421 |
|
| 422 |
|
| 423 |
|
| 424 |
|
| 425 |
|
| 426 |
int SV_AreaEntities( const vec3_t mins, const vec3_t maxs, int *entityList, int maxcount ) { |
| 427 |
areaParms_t ap; |
| 428 |
|
| 429 |
ap.mins = mins; |
| 430 |
ap.maxs = maxs; |
| 431 |
ap.list = entityList; |
| 432 |
ap.count = 0; |
| 433 |
ap.maxcount = maxcount; |
| 434 |
|
| 435 |
SV_AreaEntities_r( sv_worldSectors, &ap ); |
| 436 |
|
| 437 |
return ap.count; |
| 438 |
} |
| 439 |
|
| 440 |
|
| 441 |
|
| 442 |
|
| 443 |
|
| 444 |
|
| 445 |
typedef struct { |
| 446 |
vec3_t boxmins, boxmaxs; |
| 447 |
const float *mins; |
| 448 |
const float *maxs; |
| 449 |
const float *start; |
| 450 |
vec3_t end; |
| 451 |
trace_t trace; |
| 452 |
int passEntityNum; |
| 453 |
int contentmask; |
| 454 |
int capsule; |
| 455 |
} moveclip_t; |
| 456 |
|
| 457 |
|
| 458 |
|
| 459 |
|
| 460 |
|
| 461 |
|
| 462 |
|
| 463 |
|
| 464 |
void SV_ClipToEntity( trace_t *trace, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int entityNum, int contentmask, int capsule ) { |
| 465 |
sharedEntity_t *touch; |
| 466 |
clipHandle_t clipHandle; |
| 467 |
float *origin, *angles; |
| 468 |
|
| 469 |
touch = SV_GentityNum( entityNum ); |
| 470 |
|
| 471 |
Com_Memset(trace, 0, sizeof(trace_t)); |
| 472 |
|
| 473 |
|
| 474 |
|
| 475 |
if ( ! ( contentmask & touch->r.contents ) ) { |
| 476 |
trace->fraction = 1.0; |
| 477 |
return; |
| 478 |
} |
| 479 |
|
| 480 |
|
| 481 |
clipHandle = SV_ClipHandleForEntity (touch); |
| 482 |
|
| 483 |
origin = touch->r.currentOrigin; |
| 484 |
angles = touch->r.currentAngles; |
| 485 |
|
| 486 |
if ( !touch->r.bmodel ) { |
| 487 |
angles = vec3_origin; |
| 488 |
} |
| 489 |
|
| 490 |
CM_TransformedBoxTrace ( trace, (float *)start, (float *)end, |
| 491 |
(float *)mins, (float *)maxs, clipHandle, contentmask, |
| 492 |
origin, angles, capsule); |
| 493 |
|
| 494 |
if ( trace->fraction < 1 ) { |
| 495 |
trace->entityNum = touch->s.number; |
| 496 |
} |
| 497 |
} |
| 498 |
|
| 499 |
|
| 500 |
|
| 501 |
|
| 502 |
|
| 503 |
|
| 504 |
|
| 505 |
|
| 506 |
static void SV_ClipMoveToEntities( moveclip_t *clip ) { |
| 507 |
int i, num; |
| 508 |
int touchlist[MAX_GENTITIES]; |
| 509 |
sharedEntity_t *touch; |
| 510 |
int passOwnerNum; |
| 511 |
trace_t trace; |
| 512 |
clipHandle_t clipHandle; |
| 513 |
float *origin, *angles; |
| 514 |
|
| 515 |
num = SV_AreaEntities( clip->boxmins, clip->boxmaxs, touchlist, MAX_GENTITIES); |
| 516 |
|
| 517 |
if ( clip->passEntityNum != ENTITYNUM_NONE ) { |
| 518 |
passOwnerNum = ( SV_GentityNum( clip->passEntityNum ) )->r.ownerNum; |
| 519 |
if ( passOwnerNum == ENTITYNUM_NONE ) { |
| 520 |
passOwnerNum = -1; |
| 521 |
} |
| 522 |
} else { |
| 523 |
passOwnerNum = -1; |
| 524 |
} |
| 525 |
|
| 526 |
for ( i=0 ; i<num ; i++ ) { |
| 527 |
if ( clip->trace.allsolid ) { |
| 528 |
return; |
| 529 |
} |
| 530 |
touch = SV_GentityNum( touchlist[i] ); |
| 531 |
|
| 532 |
|
| 533 |
if ( clip->passEntityNum != ENTITYNUM_NONE ) { |
| 534 |
if ( touchlist[i] == clip->passEntityNum ) { |
| 535 |
continue; |
| 536 |
} |
| 537 |
if ( touch->r.ownerNum == clip->passEntityNum ) { |
| 538 |
continue; |
| 539 |
} |
| 540 |
if ( touch->r.ownerNum == passOwnerNum ) { |
| 541 |
continue; |
| 542 |
} |
| 543 |
} |
| 544 |
|
| 545 |
|
| 546 |
|
| 547 |
if ( ! ( clip->contentmask & touch->r.contents ) ) { |
| 548 |
continue; |
| 549 |
} |
| 550 |
|
| 551 |
|
| 552 |
clipHandle = SV_ClipHandleForEntity (touch); |
| 553 |
|
| 554 |
origin = touch->r.currentOrigin; |
| 555 |
angles = touch->r.currentAngles; |
| 556 |
|
| 557 |
|
| 558 |
if ( !touch->r.bmodel ) { |
| 559 |
angles = vec3_origin; |
| 560 |
} |
| 561 |
|
| 562 |
CM_TransformedBoxTrace ( &trace, (float *)clip->start, (float *)clip->end, |
| 563 |
(float *)clip->mins, (float *)clip->maxs, clipHandle, clip->contentmask, |
| 564 |
origin, angles, clip->capsule); |
| 565 |
|
| 566 |
if ( trace.allsolid ) { |
| 567 |
clip->trace.allsolid = qtrue; |
| 568 |
trace.entityNum = touch->s.number; |
| 569 |
} else if ( trace.startsolid ) { |
| 570 |
clip->trace.startsolid = qtrue; |
| 571 |
trace.entityNum = touch->s.number; |
| 572 |
} |
| 573 |
|
| 574 |
if ( trace.fraction < clip->trace.fraction ) { |
| 575 |
qboolean oldStart; |
| 576 |
|
| 577 |
|
| 578 |
oldStart = clip->trace.startsolid; |
| 579 |
|
| 580 |
trace.entityNum = touch->s.number; |
| 581 |
clip->trace = trace; |
| 582 |
clip->trace.startsolid |= oldStart; |
| 583 |
} |
| 584 |
} |
| 585 |
} |
| 586 |
|
| 587 |
|
| 588 |
|
| 589 |
|
| 590 |
|
| 591 |
|
| 592 |
|
| 593 |
|
| 594 |
|
| 595 |
|
| 596 |
void SV_Trace( trace_t *results, const vec3_t start, vec3_t mins, vec3_t maxs, const vec3_t end, int passEntityNum, int contentmask, int capsule ) { |
| 597 |
moveclip_t clip; |
| 598 |
int i; |
| 599 |
|
| 600 |
if ( !mins ) { |
| 601 |
mins = vec3_origin; |
| 602 |
} |
| 603 |
if ( !maxs ) { |
| 604 |
maxs = vec3_origin; |
| 605 |
} |
| 606 |
|
| 607 |
Com_Memset ( &clip, 0, sizeof ( moveclip_t ) ); |
| 608 |
|
| 609 |
|
| 610 |
CM_BoxTrace( &clip.trace, start, end, mins, maxs, 0, contentmask, capsule ); |
| 611 |
clip.trace.entityNum = clip.trace.fraction != 1.0 ? ENTITYNUM_WORLD : ENTITYNUM_NONE; |
| 612 |
if ( clip.trace.fraction == 0 ) { |
| 613 |
*results = clip.trace; |
| 614 |
return; |
| 615 |
} |
| 616 |
|
| 617 |
clip.contentmask = contentmask; |
| 618 |
clip.start = start; |
| 619 |
|
| 620 |
VectorCopy( end, clip.end ); |
| 621 |
clip.mins = mins; |
| 622 |
clip.maxs = maxs; |
| 623 |
clip.passEntityNum = passEntityNum; |
| 624 |
clip.capsule = capsule; |
| 625 |
|
| 626 |
|
| 627 |
|
| 628 |
|
| 629 |
|
| 630 |
for ( i=0 ; i<3 ; i++ ) { |
| 631 |
if ( end[i] > start[i] ) { |
| 632 |
clip.boxmins[i] = clip.start[i] + clip.mins[i] - 1; |
| 633 |
clip.boxmaxs[i] = clip.end[i] + clip.maxs[i] + 1; |
| 634 |
} else { |
| 635 |
clip.boxmins[i] = clip.end[i] + clip.mins[i] - 1; |
| 636 |
clip.boxmaxs[i] = clip.start[i] + clip.maxs[i] + 1; |
| 637 |
} |
| 638 |
} |
| 639 |
|
| 640 |
|
| 641 |
SV_ClipMoveToEntities ( &clip ); |
| 642 |
|
| 643 |
*results = clip.trace; |
| 644 |
} |
| 645 |
|
| 646 |
|
| 647 |
|
| 648 |
|
| 649 |
|
| 650 |
|
| 651 |
|
| 652 |
|
| 653 |
int SV_PointContents( const vec3_t p, int passEntityNum ) { |
| 654 |
int touch[MAX_GENTITIES]; |
| 655 |
sharedEntity_t *hit; |
| 656 |
int i, num; |
| 657 |
int contents, c2; |
| 658 |
clipHandle_t clipHandle; |
| 659 |
float *angles; |
| 660 |
|
| 661 |
|
| 662 |
contents = CM_PointContents( p, 0 ); |
| 663 |
|
| 664 |
|
| 665 |
num = SV_AreaEntities( p, p, touch, MAX_GENTITIES ); |
| 666 |
|
| 667 |
for ( i=0 ; i<num ; i++ ) { |
| 668 |
if ( touch[i] == passEntityNum ) { |
| 669 |
continue; |
| 670 |
} |
| 671 |
hit = SV_GentityNum( touch[i] ); |
| 672 |
|
| 673 |
clipHandle = SV_ClipHandleForEntity( hit ); |
| 674 |
angles = hit->r.currentAngles; |
| 675 |
if ( !hit->r.bmodel ) { |
| 676 |
angles = vec3_origin; |
| 677 |
} |
| 678 |
|
| 679 |
c2 = CM_TransformedPointContents (p, clipHandle, hit->r.currentOrigin, angles); |
| 680 |
|
| 681 |
contents |= c2; |
| 682 |
} |
| 683 |
|
| 684 |
return contents; |
| 685 |
} |
| 686 |
|
| 687 |
|