Quake II RTX doxygen
1.0 dev
|
|
#include "shared/shared.h"
#include "common/bsp.h"
#include "common/cmd.h"
#include "common/cmodel.h"
#include "common/common.h"
#include "common/cvar.h"
#include "common/math.h"
#include "common/zone.h"
#include "system/hunk.h"
Go to the source code of this file.
|
static void | FloodAreaConnections (cm_t *cm) |
|
void | CM_FreeMap (cm_t *cm) |
|
qerror_t | CM_LoadMap (cm_t *cm, const char *name) |
|
mnode_t * | CM_NodeNum (cm_t *cm, int number) |
|
mleaf_t * | CM_LeafNum (cm_t *cm, int number) |
|
static void | CM_InitBoxHull (void) |
|
mnode_t * | CM_HeadnodeForBox (vec3_t mins, vec3_t maxs) |
|
mleaf_t * | CM_PointLeaf (cm_t *cm, vec3_t p) |
|
static void | CM_BoxLeafs_r (mnode_t *node) |
|
static int | CM_BoxLeafs_headnode (vec3_t mins, vec3_t maxs, mleaf_t **list, int listsize, mnode_t *headnode, mnode_t **topnode) |
|
int | CM_BoxLeafs (cm_t *cm, vec3_t mins, vec3_t maxs, mleaf_t **list, int listsize, mnode_t **topnode) |
|
int | CM_PointContents (vec3_t p, mnode_t *headnode) |
|
int | CM_TransformedPointContents (vec3_t p, mnode_t *headnode, vec3_t origin, vec3_t angles) |
|
static void | CM_ClipBoxToBrush (vec3_t mins, vec3_t maxs, vec3_t p1, vec3_t p2, trace_t *trace, mbrush_t *brush) |
|
static void | CM_TestBoxInBrush (vec3_t mins, vec3_t maxs, vec3_t p1, trace_t *trace, mbrush_t *brush) |
|
static void | CM_TraceToLeaf (mleaf_t *leaf) |
|
static void | CM_TestInLeaf (mleaf_t *leaf) |
|
static void | CM_RecursiveHullCheck (mnode_t *node, float p1f, float p2f, vec3_t p1, vec3_t p2) |
|
void | CM_BoxTrace (trace_t *trace, vec3_t start, vec3_t end, vec3_t mins, vec3_t maxs, mnode_t *headnode, int brushmask) |
|
void | CM_TransformedBoxTrace (trace_t *trace, vec3_t start, vec3_t end, vec3_t mins, vec3_t maxs, mnode_t *headnode, int brushmask, vec3_t origin, vec3_t angles) |
|
void | CM_ClipEntity (trace_t *dst, const trace_t *src, struct edict_s *ent) |
|
static void | FloodArea_r (cm_t *cm, int number, int floodnum) |
|
void | CM_SetAreaPortalState (cm_t *cm, int portalnum, qboolean open) |
|
qboolean | CM_AreasConnected (cm_t *cm, int area1, int area2) |
|
int | CM_WriteAreaBits (cm_t *cm, byte *buffer, int area) |
|
int | CM_WritePortalBits (cm_t *cm, byte *buffer) |
|
void | CM_SetPortalStates (cm_t *cm, byte *buffer, int bytes) |
|
qboolean | CM_HeadnodeVisible (mnode_t *node, byte *visbits) |
|
byte * | CM_FatPVS (cm_t *cm, byte *mask, const vec3_t org, int vis) |
|
void | CM_Init (void) |
|
◆ DIST_EPSILON
#define DIST_EPSILON (0.03125) |
◆ CM_AreasConnected()
qboolean CM_AreasConnected |
( |
cm_t * |
cm, |
|
|
int |
area1, |
|
|
int |
area2 |
|
) |
| |
◆ CM_BoxLeafs()
int CM_BoxLeafs |
( |
cm_t * |
cm, |
|
|
vec3_t |
mins, |
|
|
vec3_t |
maxs, |
|
|
mleaf_t ** |
list, |
|
|
int |
listsize, |
|
|
mnode_t ** |
topnode |
|
) |
| |
◆ CM_BoxLeafs_headnode()
static int CM_BoxLeafs_headnode |
( |
vec3_t |
mins, |
|
|
vec3_t |
maxs, |
|
|
mleaf_t ** |
list, |
|
|
int |
listsize, |
|
|
mnode_t * |
headnode, |
|
|
mnode_t ** |
topnode |
|
) |
| |
|
static |
◆ CM_BoxLeafs_r()
static void CM_BoxLeafs_r |
( |
mnode_t * |
node | ) |
|
|
static |
Definition at line 229 of file cmodel.c.
233 while (node->plane) {
236 node = node->children[0];
238 node = node->children[1];
245 node = node->children[1];
Referenced by CM_BoxLeafs_headnode().
◆ CM_BoxTrace()
void CM_BoxTrace |
( |
trace_t * |
trace, |
|
|
vec3_t |
start, |
|
|
vec3_t |
end, |
|
|
vec3_t |
mins, |
|
|
vec3_t |
maxs, |
|
|
mnode_t * |
headnode, |
|
|
int |
brushmask |
|
) |
| |
Definition at line 683 of file cmodel.c.
708 if (start[0] == end[0] && start[1] == end[1] && start[2] == end[2]) {
709 mleaf_t *leafs[1024];
713 VectorAdd(start, mins, c1);
714 VectorAdd(start, maxs, c2);
715 for (i = 0; i < 3; i++) {
721 for (i = 0; i < numleafs; i++) {
733 if (mins[0] == 0 && mins[1] == 0 && mins[2] == 0
734 && maxs[0] == 0 && maxs[1] == 0 && maxs[2] == 0) {
Referenced by CL_AddViewWeapon(), CL_SetupThirdPersionView(), CL_Trace(), CM_TransformedBoxTrace(), LOC_FindClosest(), LOC_There_m(), MVD_HitPlayer(), and SV_Trace().
◆ CM_ClipBoxToBrush()
static void CM_ClipBoxToBrush |
( |
vec3_t |
mins, |
|
|
vec3_t |
maxs, |
|
|
vec3_t |
p1, |
|
|
vec3_t |
p2, |
|
|
trace_t * |
trace, |
|
|
mbrush_t * |
brush |
|
) |
| |
|
static |
Definition at line 365 of file cmodel.c.
369 cplane_t *plane, *clipplane;
371 float enterfrac, leavefrac;
374 qboolean getout, startout;
376 mbrushside_t *side, *leadside;
382 if (!brush->numsides)
389 side = brush->firstbrushside;
390 for (i = 0; i < brush->numsides; i++, side++) {
401 for (j = 0; j < 3; j++) {
402 if (plane->normal[j] < 0)
407 dist = DotProduct(ofs, plane->normal);
408 dist = plane->dist - dist;
414 d1 = DotProduct(p1, plane->normal) - dist;
415 d2 = DotProduct(p2, plane->normal) - dist;
423 if (d1 > 0 && d2 >= d1)
426 if (d1 <= 0 && d2 <= 0)
448 trace->startsolid = qtrue;
450 trace->allsolid = qtrue;
454 trace->contents = brush->contents;
459 if (enterfrac < leavefrac) {
460 if (enterfrac > -1 && enterfrac < trace->fraction) {
463 trace->fraction = enterfrac;
464 trace->plane = *clipplane;
465 trace->surface = &(leadside->texinfo->c);
466 trace->contents = brush->contents;
Referenced by CM_TraceToLeaf().
◆ CM_ClipEntity()
void CM_ClipEntity |
( |
trace_t * |
dst, |
|
|
const trace_t * |
src, |
|
|
struct edict_s * |
ent |
|
) |
| |
Definition at line 804 of file cmodel.c.
806 dst->allsolid |= src->allsolid;
807 dst->startsolid |= src->startsolid;
808 if (src->fraction < dst->fraction) {
809 dst->fraction = src->fraction;
810 VectorCopy(src->endpos, dst->endpos);
811 dst->plane = src->plane;
812 dst->surface = src->surface;
813 dst->contents |= src->contents;
Referenced by CL_ClipMoveToEntities(), and SV_ClipMoveToEntities().
◆ CM_FatPVS()
byte* CM_FatPVS |
( |
cm_t * |
cm, |
|
|
byte * |
mask, |
|
|
const vec3_t |
org, |
|
|
int |
vis |
|
) |
| |
Definition at line 1045 of file cmodel.c.
1047 byte temp[VIS_MAX_BYTES];
1050 int i, j, count, longs;
1051 uint_fast32_t *src, *dst;
1055 return memset(mask, 0, VIS_MAX_BYTES);
1057 if (!cm->cache->vis) {
1058 return memset(mask, 0xff, VIS_MAX_BYTES);
1061 for (i = 0; i < 3; i++) {
1062 mins[i] = org[i] - 8;
1063 maxs[i] = org[i] + 8;
1066 count =
CM_BoxLeafs(cm, mins, maxs, leafs, 64, NULL);
1068 Com_Error(ERR_DROP,
"CM_FatPVS: leaf count < 1");
1069 longs = VIS_FAST_LONGS(cm->cache);
1072 for (i = 0; i < count; i++) {
1073 clusters[i] = leafs[i]->cluster;
1079 for (i = 1; i < count; i++) {
1080 for (j = 0; j < i; j++) {
1081 if (clusters[i] == clusters[j]) {
1085 src = (uint_fast32_t *)
BSP_ClusterVis(cm->cache, temp, clusters[i], vis);
1086 dst = (uint_fast32_t *)mask;
1087 for (j = 0; j < longs; j++) {
Referenced by SV_BuildClientFrame().
◆ CM_FreeMap()
void CM_FreeMap |
( |
cm_t * |
cm | ) |
|
◆ CM_HeadnodeForBox()
mnode_t* CM_HeadnodeForBox |
( |
vec3_t |
mins, |
|
|
vec3_t |
maxs |
|
) |
| |
◆ CM_HeadnodeVisible()
qboolean CM_HeadnodeVisible |
( |
mnode_t * |
node, |
|
|
byte * |
visbits |
|
) |
| |
Definition at line 1016 of file cmodel.c.
1021 while (node->plane) {
1024 node = node->children[1];
1027 leaf = (mleaf_t *)node;
1028 cluster = leaf->cluster;
1031 if (Q_IsBitSet(visbits, cluster))
Referenced by SV_EdictIsVisible().
◆ CM_Init()
◆ CM_InitBoxHull()
Definition at line 129 of file cmodel.c.
143 box_leaf.contents = CONTENTS_MONSTER;
149 for (i = 0; i < 6; i++) {
164 c->children[side ^ 1] = (mnode_t *)&
box_leaf;
170 VectorClear(p->normal);
171 p->normal[i >> 1] = 1;
174 p->type = 3 + (i >> 1);
176 VectorClear(p->normal);
177 p->normal[i >> 1] = -1;
Referenced by CM_Init().
◆ CM_LeafNum()
mleaf_t* CM_LeafNum |
( |
cm_t * |
cm, |
|
|
int |
number |
|
) |
| |
Definition at line 98 of file cmodel.c.
103 if (number < 0 || number >= cm->cache->numleafs) {
104 Com_EPrintf(
"%s: bad number: %d\n", __func__, number);
107 return cm->cache->leafs + number;
Referenced by MVD_ParseMulticast().
◆ CM_LoadMap()
qerror_t CM_LoadMap |
( |
cm_t * |
cm, |
|
|
const char * |
name |
|
) |
| |
Definition at line 64 of file cmodel.c.
75 cm->floodnums =
Z_TagMallocz(
sizeof(
int) * cm->cache->numareas +
76 sizeof(qboolean) * (cm->cache->lastareaportal + 1), TAG_CMODEL);
77 cm->portalopen = (qboolean *)(cm->floodnums + cm->cache->numareas);
Referenced by MVD_ParseServerData(), and SV_ParseMapCmd().
◆ CM_NodeNum()
mnode_t* CM_NodeNum |
( |
cm_t * |
cm, |
|
|
int |
number |
|
) |
| |
Definition at line 83 of file cmodel.c.
89 return (mnode_t *)cm->cache->leafs;
91 if (number < 0 || number >= cm->cache->numnodes) {
92 Com_EPrintf(
"%s: bad number: %d\n", __func__, number);
95 return cm->cache->nodes + number;
Referenced by SV_EdictIsVisible().
◆ CM_PointContents()
int CM_PointContents |
( |
vec3_t |
p, |
|
|
mnode_t * |
headnode |
|
) |
| |
◆ CM_PointLeaf()
mleaf_t* CM_PointLeaf |
( |
cm_t * |
cm, |
|
|
vec3_t |
p |
|
) |
| |
◆ CM_RecursiveHullCheck()
static void CM_RecursiveHullCheck |
( |
mnode_t * |
node, |
|
|
float |
p1f, |
|
|
float |
p2f, |
|
|
vec3_t |
p1, |
|
|
vec3_t |
p2 |
|
) |
| |
|
static |
Definition at line 590 of file cmodel.c.
593 float t1, t2, offset;
615 if (plane->type < 3) {
616 t1 = p1[plane->type] - plane->dist;
617 t2 = p2[plane->type] - plane->dist;
620 t1 = PlaneDiff(p1, plane);
621 t2 = PlaneDiff(p2, plane);
631 if (t1 >= offset && t2 >= offset) {
632 node = node->children[0];
635 if (t1 < -offset && t2 < -offset) {
636 node = node->children[1];
642 idist = 1.0 / (t1 - t2);
646 }
else if (t1 > t2) {
647 idist = 1.0 / (t1 - t2);
660 midf = p1f + (p2f - p1f) * frac;
661 LerpVector(p1, p2, frac, mid);
668 midf = p1f + (p2f - p1f) * frac2;
669 LerpVector(p1, p2, frac2, mid);
Referenced by CM_BoxTrace().
◆ CM_SetAreaPortalState()
void CM_SetAreaPortalState |
( |
cm_t * |
cm, |
|
|
int |
portalnum, |
|
|
qboolean |
open |
|
) |
| |
Definition at line 869 of file cmodel.c.
875 if (portalnum < 0 || portalnum >= MAX_MAP_AREAPORTALS) {
876 Com_EPrintf(
"%s: portalnum %d is out of range\n", __func__, portalnum);
881 if (portalnum > cm->cache->lastareaportal) {
882 Com_DPrintf(
"%s: portalnum %d is not in use\n", __func__, portalnum);
886 cm->portalopen[portalnum] = open;
Referenced by PF_SetAreaPortalState().
◆ CM_SetPortalStates()
void CM_SetPortalStates |
( |
cm_t * |
cm, |
|
|
byte * |
buffer, |
|
|
int |
bytes |
|
) |
| |
Definition at line 982 of file cmodel.c.
991 for (i = 0; i <= cm->cache->lastareaportal; i++) {
992 cm->portalopen[i] = qtrue;
995 numportals = bytes << 3;
996 if (numportals > cm->cache->lastareaportal + 1) {
997 numportals = cm->cache->lastareaportal + 1;
999 for (i = 0; i < numportals; i++) {
1000 cm->portalopen[i] = Q_IsBitSet(buffer, i);
Referenced by MVD_ParseFrame(), MVD_Seek_f(), and read_level_file().
◆ CM_TestBoxInBrush()
static void CM_TestBoxInBrush |
( |
vec3_t |
mins, |
|
|
vec3_t |
maxs, |
|
|
vec3_t |
p1, |
|
|
trace_t * |
trace, |
|
|
mbrush_t * |
brush |
|
) |
| |
|
static |
Definition at line 476 of file cmodel.c.
486 if (!brush->numsides)
489 side = brush->firstbrushside;
490 for (i = 0; i < brush->numsides; i++, side++) {
500 for (j = 0; j < 3; j++) {
501 if (plane->normal[j] < 0)
506 dist = DotProduct(ofs, plane->normal);
507 dist = plane->dist - dist;
509 d1 = DotProduct(p1, plane->normal) - dist;
518 trace->startsolid = trace->allsolid = qtrue;
520 trace->contents = brush->contents;
Referenced by CM_TestInLeaf().
◆ CM_TestInLeaf()
static void CM_TestInLeaf |
( |
mleaf_t * |
leaf | ) |
|
|
static |
Definition at line 559 of file cmodel.c.
562 mbrush_t *b, **leafbrush;
567 leafbrush = leaf->firstleafbrush;
568 for (k = 0; k < leaf->numleafbrushes; k++, leafbrush++) {
Referenced by CM_BoxTrace().
◆ CM_TraceToLeaf()
static void CM_TraceToLeaf |
( |
mleaf_t * |
leaf | ) |
|
|
static |
Definition at line 529 of file cmodel.c.
532 mbrush_t *b, **leafbrush;
537 leafbrush = leaf->firstleafbrush;
538 for (k = 0; k < leaf->numleafbrushes; k++, leafbrush++) {
Referenced by CM_RecursiveHullCheck().
◆ CM_TransformedBoxTrace()
void CM_TransformedBoxTrace |
( |
trace_t * |
trace, |
|
|
vec3_t |
start, |
|
|
vec3_t |
end, |
|
|
vec3_t |
mins, |
|
|
vec3_t |
maxs, |
|
|
mnode_t * |
headnode, |
|
|
int |
brushmask, |
|
|
vec3_t |
origin, |
|
|
vec3_t |
angles |
|
) |
| |
Definition at line 764 of file cmodel.c.
769 vec3_t start_l, end_l;
774 VectorSubtract(start,
origin, start_l);
775 VectorSubtract(end,
origin, end_l);
779 (angles[0] || angles[1] || angles[2]))
785 AnglesToAxis(angles, axis);
786 RotatePoint(start_l, axis);
787 RotatePoint(end_l, axis);
791 CM_BoxTrace(trace, start_l, end_l, mins, maxs, headnode, brushmask);
794 if (rotated && trace->fraction != 1.0) {
796 RotatePoint(trace->plane.normal, axis);
801 LerpVector(start, end, trace->fraction, trace->endpos);
Referenced by CL_ClipMoveToEntities(), MVD_HitPlayer(), and SV_ClipMoveToEntities().
◆ CM_TransformedPointContents()
int CM_TransformedPointContents |
( |
vec3_t |
p, |
|
|
mnode_t * |
headnode, |
|
|
vec3_t |
origin, |
|
|
vec3_t |
angles |
|
) |
| |
Definition at line 310 of file cmodel.c.
322 VectorSubtract(p,
origin, p_l);
326 (angles[0] || angles[1] || angles[2])) {
329 VectorCopy(p_l, temp);
330 p_l[0] = DotProduct(temp,
forward);
331 p_l[1] = -DotProduct(temp,
right);
332 p_l[2] = DotProduct(temp,
up);
337 return leaf->contents;
Referenced by CL_PointContents(), and SV_PointContents().
◆ CM_WriteAreaBits()
int CM_WriteAreaBits |
( |
cm_t * |
cm, |
|
|
byte * |
buffer, |
|
|
int |
area |
|
) |
| |
Definition at line 925 of file cmodel.c.
927 bsp_t *cache = cm->cache;
936 bytes = (cache->numareas + 7) >> 3;
940 memset(buffer, 255, bytes);
942 memset(buffer, 0, bytes);
944 floodnum = cm->floodnums[area];
945 for (i = 0; i < cache->numareas; i++) {
946 if (cm->floodnums[i] == floodnum) {
Referenced by SV_BuildClientFrame().
◆ CM_WritePortalBits()
int CM_WritePortalBits |
( |
cm_t * |
cm, |
|
|
byte * |
buffer |
|
) |
| |
Definition at line 955 of file cmodel.c.
957 int i, bytes, numportals;
963 numportals = cm->cache->lastareaportal + 1;
964 if (numportals > MAX_MAP_AREAS) {
967 Com_WPrintf(
"%s: too many areaportals\n", __func__);
968 numportals = MAX_MAP_AREAS;
971 bytes = (numportals + 7) >> 3;
972 memset(buffer, 0, bytes);
973 for (i = 0; i < numportals; i++) {
974 if (cm->portalopen[i]) {
Referenced by emit_base_frame(), emit_frame(), emit_gamestate(), and write_level_file().
◆ FloodArea_r()
static void FloodArea_r |
( |
cm_t * |
cm, |
|
|
int |
number, |
|
|
int |
floodnum |
|
) |
| |
|
static |
Definition at line 827 of file cmodel.c.
833 area = &cm->cache->areas[number];
835 if (cm->floodnums[number] == floodnum)
837 Com_Error(ERR_DROP,
"FloodArea_r: reflooded");
840 cm->floodnums[number] = floodnum;
842 p = area->firstareaportal;
843 for (i = 0; i < area->numareaportals; i++, p++) {
844 if (cm->portalopen[p->portalnum])
Referenced by FloodAreaConnections().
◆ FloodAreaConnections()
static void FloodAreaConnections |
( |
cm_t * |
cm | ) |
|
|
static |
◆ box_brush
◆ box_brushsides
mbrushside_t box_brushsides[6] |
|
static |
◆ box_emptyleaf
◆ box_headnode
◆ box_leaf
◆ box_leafbrush
◆ box_nodes
◆ box_planes
◆ checkcount
◆ floodvalid
◆ leaf_count
◆ leaf_list
◆ leaf_maxcount
◆ leaf_maxs
◆ leaf_mins
◆ leaf_topnode
◆ map_allsolid_bug
◆ map_noareas
◆ nullleaf
◆ nulltexinfo
◆ trace_contents
◆ trace_end
◆ trace_extents
◆ trace_ispoint
◆ trace_maxs
◆ trace_mins
◆ trace_start
◆ trace_trace
void CM_BoxTrace(trace_t *trace, vec3_t start, vec3_t end, vec3_t mins, vec3_t maxs, mnode_t *headnode, int brushmask)
qboolean CM_HeadnodeVisible(mnode_t *node, byte *visbits)
static vec3_t trace_start
static void CM_TestBoxInBrush(vec3_t mins, vec3_t maxs, vec3_t p1, trace_t *trace, mbrush_t *brush)
static mleaf_t ** leaf_list
static void CM_ClipBoxToBrush(vec3_t mins, vec3_t maxs, vec3_t p1, vec3_t p2, trace_t *trace, mbrush_t *brush)
cvar_t * Cvar_Get(const char *var_name, const char *var_value, int flags)
byte * BSP_ClusterVis(bsp_t *bsp, byte *mask, int cluster, int vis)
static mbrush_t box_brush
static mleaf_t box_emptyleaf
static void CM_RecursiveHullCheck(mnode_t *node, float p1f, float p2f, vec3_t p1, vec3_t p2)
int CM_BoxLeafs(cm_t *cm, vec3_t mins, vec3_t maxs, mleaf_t **list, int listsize, mnode_t **topnode)
static vec3_t trace_extents
mleaf_t * BSP_PointLeaf(mnode_t *node, vec3_t p)
static void FloodArea_r(cm_t *cm, int number, int floodnum)
static qboolean trace_ispoint
void Com_Error(error_type_t type, const char *fmt,...)
void BSP_Free(bsp_t *bsp)
static void FloodAreaConnections(cm_t *cm)
void * Z_TagMallocz(size_t size, memtag_t tag)
static int CM_BoxLeafs_headnode(vec3_t mins, vec3_t maxs, mleaf_t **list, int listsize, mnode_t *headnode, mnode_t **topnode)
void AngleVectors(vec3_t angles, vec3_t forward, vec3_t right, vec3_t up)
static cvar_t * map_allsolid_bug
static void CM_InitBoxHull(void)
static cvar_t * map_noareas
static void CM_TestInLeaf(mleaf_t *leaf)
static int trace_contents
static mnode_t box_nodes[6]
static void CM_BoxLeafs_r(mnode_t *node)
static cplane_t box_planes[12]
qerror_t BSP_Load(const char *name, bsp_t **bsp_p)
static mbrush_t * box_leafbrush
static mbrushside_t box_brushsides[6]
static trace_t * trace_trace
static void CM_TraceToLeaf(mleaf_t *leaf)
static mnode_t * box_headnode
static mnode_t * leaf_topnode