vkQuake2 doxygen  1.0 dev
r_model.c File Reference
#include "r_local.h"

Go to the source code of this file.

Macros

#define MAX_MOD_KNOWN   256
 

Functions

void Mod_LoadSpriteModel (model_t *mod, void *buffer)
 
void Mod_LoadBrushModel (model_t *mod, void *buffer)
 
void Mod_LoadAliasModel (model_t *mod, void *buffer)
 
model_tMod_LoadModel (model_t *mod, qboolean crash)
 
void Mod_Modellist_f (void)
 
void Mod_Init (void)
 
model_tMod_ForName (char *name, qboolean crash)
 
mleaf_tMod_PointInLeaf (vec3_t p, model_t *model)
 
byteMod_DecompressVis (byte *in, model_t *model)
 
byteMod_ClusterPVS (int cluster, model_t *model)
 
void Mod_LoadLighting (lump_t *l)
 
void Mod_LoadRighting (lump_t *l)
 
void R_NumberLeafs (mnode_t *node)
 
void Mod_LoadVisibility (lump_t *l)
 
void Mod_LoadVertexes (lump_t *l)
 
void Mod_LoadSubmodels (lump_t *l)
 
void Mod_LoadEdges (lump_t *l)
 
void Mod_LoadTexinfo (lump_t *l)
 
void CalcSurfaceExtents (msurface_t *s)
 
void Mod_LoadFaces (lump_t *l)
 
void Mod_SetParent (mnode_t *node, mnode_t *parent)
 
void Mod_LoadNodes (lump_t *l)
 
void Mod_LoadLeafs (lump_t *l)
 
void Mod_LoadMarksurfaces (lump_t *l)
 
void Mod_LoadSurfedges (lump_t *l)
 
void Mod_LoadPlanes (lump_t *l)
 
void R_BeginRegistration (char *model)
 
struct model_sR_RegisterModel (char *name)
 
void R_EndRegistration (void)
 
void Mod_Free (model_t *mod)
 
void Mod_FreeAll (void)
 

Variables

model_tloadmodel
 
char loadname [32]
 
byte mod_novis [MAX_MAP_LEAFS/8]
 
model_t mod_known [MAX_MOD_KNOWN]
 
int mod_numknown
 
model_t mod_inline [MAX_MOD_KNOWN]
 
int registration_sequence
 
int modfilelen
 
bytemod_base
 
int r_leaftovis [MAX_MAP_LEAFS]
 
int r_vistoleaf [MAX_MAP_LEAFS]
 
int r_numvisleafs
 

Macro Definition Documentation

◆ MAX_MOD_KNOWN

#define MAX_MOD_KNOWN   256

Definition at line 37 of file r_model.c.

Function Documentation

◆ CalcSurfaceExtents()

void CalcSurfaceExtents ( msurface_t s)

Definition at line 590 of file r_model.c.

591 {
592  float mins[2], maxs[2], val;
593  int i, j, e;
594  mvertex_t *v;
595  mtexinfo_t *tex;
596  int bmins[2], bmaxs[2];
597 
598  mins[0] = mins[1] = 999999;
599  maxs[0] = maxs[1] = -99999;
600 
601  tex = s->texinfo;
602 
603  for (i = 0; i < s->numedges; i++)
604  {
605  e = loadmodel->surfedges[s->firstedge + i];
606  if (e >= 0)
607  v = &loadmodel->vertexes[loadmodel->edges[e].v[0]];
608  else
609  v = &loadmodel->vertexes[loadmodel->edges[-e].v[1]];
610 
611  for (j = 0; j < 2; j++)
612  {
613  val = v->position[0] * tex->vecs[j][0] +
614  v->position[1] * tex->vecs[j][1] +
615  v->position[2] * tex->vecs[j][2] +
616  tex->vecs[j][3];
617  if (val < mins[j])
618  mins[j] = val;
619  if (val > maxs[j])
620  maxs[j] = val;
621  }
622  }
623 
624  for (i = 0; i < 2; i++)
625  {
626  bmins[i] = floor(mins[i] / 16);
627  bmaxs[i] = ceil(maxs[i] / 16);
628 
629  s->texturemins[i] = bmins[i] * 16;
630  s->extents[i] = (bmaxs[i] - bmins[i]) * 16;
631  if (s->extents[i] < 16)
632  s->extents[i] = 16; // take at least one cache block
633  if (!(tex->flags & (SURF_WARP | SURF_SKY)) && s->extents[i] > 256)
634  ri.Sys_Error(ERR_DROP, "Bad surface extents");
635  }
636 }

Referenced by Mod_LoadFaces().

◆ Mod_ClusterPVS()

byte* Mod_ClusterPVS ( int  cluster,
model_t model 
)

Definition at line 268 of file r_model.c.

269 {
270  if (cluster == -1 || !model->vis)
271  return mod_novis;
272  return Mod_DecompressVis((byte *)model->vis + model->vis->bitofs[cluster][DVIS_PVS],
273  model);
274 }

Referenced by R_MarkLeaves().

◆ Mod_DecompressVis()

byte* Mod_DecompressVis ( byte in,
model_t model 
)

Definition at line 219 of file r_model.c.

220 {
221  static byte decompressed[MAX_MAP_LEAFS / 8];
222  int c;
223  byte *out;
224  int row;
225 
226  row = (model->vis->numclusters + 7) >> 3;
227  out = decompressed;
228 
229 #if 0
230  memcpy (out, in, row);
231 #else
232  if (!in)
233  { // no vis info, so make all visible
234  while (row)
235  {
236  *out++ = 0xff;
237  row--;
238  }
239  return decompressed;
240  }
241 
242  do
243  {
244  if (*in)
245  {
246  *out++ = *in++;
247  continue;
248  }
249 
250  c = in[1];
251  in += 2;
252  while (c)
253  {
254  *out++ = 0;
255  c--;
256  }
257  } while (out - decompressed < row);
258 #endif
259 
260  return decompressed;
261 }

Referenced by Mod_ClusterPVS().

◆ Mod_ForName()

model_t* Mod_ForName ( char *  name,
qboolean  crash 
)

Definition at line 90 of file r_model.c.

91 {
92  model_t *mod;
93  unsigned *buf;
94  int i;
95 
96  if (!name[0])
97  ri.Sys_Error(ERR_DROP, "Mod_ForName: NULL name");
98 
99  //
100  // inline models are grabbed only from worldmodel
101  //
102  if (name[0] == '*')
103  {
104  i = atoi(name + 1);
105  if (i < 1 || !r_worldmodel || i >= r_worldmodel->numsubmodels)
106  ri.Sys_Error(ERR_DROP, "bad inline model number");
107  return &mod_inline[i];
108  }
109 
110  //
111  // search the currently loaded models
112  //
113  for (i = 0, mod = mod_known; i < mod_numknown; i++, mod++)
114  if (!strcmp(mod->name, name))
115  return mod;
116 
117  //
118  // find a free model slot spot
119  //
120  for (i = 0, mod = mod_known; i < mod_numknown; i++, mod++)
121  {
122  if (!mod->name[0])
123  break; // free spot
124  }
125  if (i == mod_numknown)
126  {
128  ri.Sys_Error(ERR_DROP, "mod_numknown == MAX_MOD_KNOWN");
129  mod_numknown++;
130  }
131  strcpy(mod->name, name);
132 
133  //
134  // load the file
135  //
136  modfilelen = ri.FS_LoadFile(mod->name, (void **)&buf);
137  if (!buf)
138  {
139  if (crash)
140  ri.Sys_Error(ERR_DROP, "Mod_NumForName: %s not found", mod->name);
141  memset(mod->name, 0, sizeof(mod->name));
142  return NULL;
143  }
144 
145  loadmodel = mod;
146 
147  //
148  // fill it in
149  //
150 
151  // call the apropriate loader
152 
153  switch (LittleLong(*(unsigned *)buf))
154  {
155  case IDALIASHEADER:
156  loadmodel->extradata = Hunk_Begin(0x200000);
157  Mod_LoadAliasModel(mod, buf);
158  break;
159 
160  case IDSPRITEHEADER:
161  loadmodel->extradata = Hunk_Begin(0x10000);
162  Mod_LoadSpriteModel(mod, buf);
163  break;
164 
165  case IDBSPHEADER:
166  loadmodel->extradata = Hunk_Begin(0x1000000);
167  Mod_LoadBrushModel(mod, buf);
168  break;
169 
170  default:
171  ri.Sys_Error(ERR_DROP, "Mod_NumForName: unknown fileid for %s", mod->name);
172  break;
173  }
174 
176 
177  ri.FS_FreeFile(buf);
178 
179  return mod;
180 }

Referenced by R_RegisterModel().

◆ Mod_Free()

void Mod_Free ( model_t mod)

Definition at line 1313 of file r_model.c.

1314 {
1315  Hunk_Free(mod->extradata);
1316  memset(mod, 0, sizeof(*mod));
1317 }

Referenced by Mod_FreeAll(), and R_BeginRegistration().

◆ Mod_FreeAll()

void Mod_FreeAll ( void  )

Definition at line 1324 of file r_model.c.

1325 {
1326  int i;
1327 
1328  for (i = 0; i < mod_numknown; i++)
1329  {
1330  if (mod_known[i].extradatasize)
1331  Mod_Free(&mod_known[i]);
1332  }
1333 }

Referenced by R_Shutdown().

◆ Mod_Init()

void Mod_Init ( void  )

Definition at line 78 of file r_model.c.

79 {
80  memset(mod_novis, 0xff, sizeof(mod_novis));
81 }

Referenced by R_Init().

◆ Mod_LoadAliasModel()

void Mod_LoadAliasModel ( model_t mod,
void buffer 
)

Definition at line 1046 of file r_model.c.

1047 {
1048  int i, j;
1049  dmdl_t *pinmodel, *pheader;
1050  dstvert_t *pinst, *poutst;
1051  dtriangle_t *pintri, *pouttri;
1052  daliasframe_t *pinframe, *poutframe;
1053  int *pincmd, *poutcmd;
1054  int version;
1055 
1056  pinmodel = (dmdl_t *)buffer;
1057 
1058  version = LittleLong(pinmodel->version);
1059  if (version != ALIAS_VERSION)
1060  ri.Sys_Error(ERR_DROP, "%s has wrong version number (%i should be %i)",
1061  mod->name, version, ALIAS_VERSION);
1062 
1063  pheader = Hunk_Alloc(LittleLong(pinmodel->ofs_end));
1064 
1065  // byte swap the header fields and sanity check
1066  for (i = 0; i<sizeof(dmdl_t) / 4; i++)
1067  ((int *)pheader)[i] = LittleLong(((int *)buffer)[i]);
1068 
1069  if (pheader->skinheight > MAX_LBM_HEIGHT)
1070  ri.Sys_Error(ERR_DROP, "model %s has a skin taller than %d", mod->name,
1071  MAX_LBM_HEIGHT);
1072 
1073  if (pheader->num_xyz <= 0)
1074  ri.Sys_Error(ERR_DROP, "model %s has no vertices", mod->name);
1075 
1076  if (pheader->num_xyz > MAX_VERTS)
1077  ri.Sys_Error(ERR_DROP, "model %s has too many vertices", mod->name);
1078 
1079  if (pheader->num_st <= 0)
1080  ri.Sys_Error(ERR_DROP, "model %s has no st vertices", mod->name);
1081 
1082  if (pheader->num_tris <= 0)
1083  ri.Sys_Error(ERR_DROP, "model %s has no triangles", mod->name);
1084 
1085  if (pheader->num_frames <= 0)
1086  ri.Sys_Error(ERR_DROP, "model %s has no frames", mod->name);
1087 
1088  //
1089  // load base s and t vertices (not used in gl version)
1090  //
1091  pinst = (dstvert_t *)((byte *)pinmodel + pheader->ofs_st);
1092  poutst = (dstvert_t *)((byte *)pheader + pheader->ofs_st);
1093 
1094  for (i = 0; i < pheader->num_st; i++)
1095  {
1096  poutst[i].s = LittleShort(pinst[i].s);
1097  poutst[i].t = LittleShort(pinst[i].t);
1098  }
1099 
1100  //
1101  // load triangle lists
1102  //
1103  pintri = (dtriangle_t *)((byte *)pinmodel + pheader->ofs_tris);
1104  pouttri = (dtriangle_t *)((byte *)pheader + pheader->ofs_tris);
1105 
1106  for (i = 0; i < pheader->num_tris; i++)
1107  {
1108  for (j = 0; j < 3; j++)
1109  {
1110  pouttri[i].index_xyz[j] = LittleShort(pintri[i].index_xyz[j]);
1111  pouttri[i].index_st[j] = LittleShort(pintri[i].index_st[j]);
1112  }
1113  }
1114 
1115  //
1116  // load the frames
1117  //
1118  for (i = 0; i < pheader->num_frames; i++)
1119  {
1120  pinframe = (daliasframe_t *)((byte *)pinmodel
1121  + pheader->ofs_frames + i * pheader->framesize);
1122  poutframe = (daliasframe_t *)((byte *)pheader
1123  + pheader->ofs_frames + i * pheader->framesize);
1124 
1125  memcpy(poutframe->name, pinframe->name, sizeof(poutframe->name));
1126  for (j = 0; j < 3; j++)
1127  {
1128  poutframe->scale[j] = LittleFloat(pinframe->scale[j]);
1129  poutframe->translate[j] = LittleFloat(pinframe->translate[j]);
1130  }
1131  // verts are all 8 bit, so no swapping needed
1132  memcpy(poutframe->verts, pinframe->verts,
1133  pheader->num_xyz*sizeof(dtrivertx_t));
1134 
1135  }
1136 
1137  mod->type = mod_alias;
1138 
1139  //
1140  // load the glcmds
1141  //
1142  pincmd = (int *)((byte *)pinmodel + pheader->ofs_glcmds);
1143  poutcmd = (int *)((byte *)pheader + pheader->ofs_glcmds);
1144  for (i = 0; i < pheader->num_glcmds; i++)
1145  poutcmd[i] = LittleLong(pincmd[i]);
1146 
1147 
1148  // register all skins
1149  memcpy((char *)pheader + pheader->ofs_skins, (char *)pinmodel + pheader->ofs_skins,
1150  pheader->num_skins*MAX_SKINNAME);
1151  for (i = 0; i < pheader->num_skins; i++)
1152  {
1153  mod->skins[i] = R_FindImage((char *)pheader + pheader->ofs_skins + i*MAX_SKINNAME, it_skin);
1154  }
1155 }

Referenced by Mod_ForName().

◆ Mod_LoadBrushModel()

void Mod_LoadBrushModel ( model_t mod,
void buffer 
)

Definition at line 962 of file r_model.c.

963 {
964  int i;
965  dheader_t *header;
966  dmodel_t *bm;
967  coloredlights = r_coloredlights->value; // leilei - colored lights - sanity check
968 
970  if (loadmodel != mod_known)
971  ri.Sys_Error(ERR_DROP, "Loaded a brush model after the world");
972 
973  header = (dheader_t *)buffer;
974 
975  i = LittleLong(header->version);
976  if (i != BSPVERSION)
977  ri.Sys_Error(ERR_DROP, "Mod_LoadBrushModel: %s has wrong version number (%i should be %i)", mod->name, i, BSPVERSION);
978 
979  // swap all the lumps
980  mod_base = (byte *)header;
981 
982  for (i = 0; i < sizeof(dheader_t) / 4; i++)
983  ((int *)header)[i] = LittleLong(((int *)header)[i]);
984 
985  // load into heap
986 
988  Mod_LoadEdges(&header->lumps[LUMP_EDGES]);
990  if (coloredlights)
992  else
994  Mod_LoadPlanes(&header->lumps[LUMP_PLANES]);
996  Mod_LoadFaces(&header->lumps[LUMP_FACES]);
999  Mod_LoadLeafs(&header->lumps[LUMP_LEAFS]);
1000  Mod_LoadNodes(&header->lumps[LUMP_NODES]);
1001  Mod_LoadSubmodels(&header->lumps[LUMP_MODELS]);
1002  r_numvisleafs = 0;
1004 
1005  //
1006  // set up the submodels
1007  //
1008  for (i = 0; i < mod->numsubmodels; i++)
1009  {
1010  model_t *starmod;
1011 
1012  bm = &mod->submodels[i];
1013  starmod = &mod_inline[i];
1014 
1015  *starmod = *loadmodel;
1016 
1017  starmod->firstmodelsurface = bm->firstface;
1018  starmod->nummodelsurfaces = bm->numfaces;
1019  starmod->firstnode = bm->headnode;
1020  if (starmod->firstnode >= loadmodel->numnodes)
1021  ri.Sys_Error(ERR_DROP, "Inline model %i has bad firstnode", i);
1022 
1023  VectorCopy(bm->maxs, starmod->maxs);
1024  VectorCopy(bm->mins, starmod->mins);
1025 
1026  if (i == 0)
1027  *loadmodel = *starmod;
1028  }
1029 
1030  R_InitSkyBox();
1031 }

Referenced by Mod_ForName().

◆ Mod_LoadEdges()

void Mod_LoadEdges ( lump_t l)

Definition at line 474 of file r_model.c.

475 {
476  dedge_t *in;
477  medge_t *out;
478  int i, count;
479 
480  in = (void *)(mod_base + l->fileofs);
481  if (l->filelen % sizeof(*in))
482  ri.Sys_Error(ERR_DROP, "MOD_LoadBmodel: funny lump size in %s", loadmodel->name);
483  count = l->filelen / sizeof(*in);
484  out = Hunk_Alloc((count + 13) * sizeof(*out)); // extra for skybox
485 
486  loadmodel->edges = out;
488 
489  for (i = 0; i < count; i++, in++, out++)
490  {
491  out->v[0] = (unsigned short)LittleShort(in->v[0]);
492  out->v[1] = (unsigned short)LittleShort(in->v[1]);
493  // Knightmare added
494  if (out->v[0] >= loadmodel->numvertexes || out->v[1] >= loadmodel->numvertexes)
495  ri.Sys_Error(ERR_DROP, "Mod_LoadEdges: bad vertexnum");
496  }
497 }

Referenced by Mod_LoadBrushModel().

◆ Mod_LoadFaces()

void Mod_LoadFaces ( lump_t l)

Definition at line 644 of file r_model.c.

645 {
646  dface_t *in;
647  msurface_t *out;
648  int i, count, surfnum;
649  int planenum, side;
650  int ti, lastedge; // Knightmare added
651 
652  in = (void *)(mod_base + l->fileofs);
653  if (l->filelen % sizeof(*in))
654  ri.Sys_Error(ERR_DROP, "MOD_LoadBmodel: funny lump size in %s", loadmodel->name);
655  count = l->filelen / sizeof(*in);
656  out = Hunk_Alloc((count + 6)*sizeof(*out)); // extra for skybox
657 
658  loadmodel->surfaces = out;
660 
661  for (surfnum = 0; surfnum < count; surfnum++, in++, out++)
662  {
663  out->firstedge = LittleLong(in->firstedge);
664  out->numedges = LittleShort(in->numedges);
665  if (out->numedges < 3)
666  ri.Sys_Error(ERR_DROP, "Surface with %s edges", out->numedges);
667  out->flags = 0;
668  // Knightmare added
669  lastedge = out->firstedge + out->numedges;
670  if (out->numedges < 3 || lastedge < out->firstedge) // || lastedge > loadmodel->numedges)
671  ri.Sys_Error(ERR_DROP, "Mod_LoadFaces: bad surfedges");
672  // end Knightmare
673 
674  planenum = LittleShort(in->planenum);
675  if (planenum > loadmodel->numplanes) // Knightmare added
676  ri.Sys_Error(ERR_DROP, "Mod_LoadFaces: bad planenum");
677  side = LittleShort(in->side);
678  if (side)
679  out->flags |= SURF_PLANEBACK;
680 
681  out->plane = loadmodel->planes + planenum;
682 
683  // out->texinfo = loadmodel->texinfo + LittleShort (in->texinfo);
684  // Knightmare added
685  ti = LittleShort(in->texinfo);
686  if (ti < 0 || ti >= loadmodel->numtexinfo)
687  ri.Sys_Error(ERR_DROP, "Mod_LoadFaces: bad texinfo number");
688  out->texinfo = loadmodel->texinfo + ti;
689  // end Knightmare
690 
691  // Knightmare- TODO: chop surface up if extents > 256
692  CalcSurfaceExtents(out);
693 
694  // lighting info is converted from 24 bit on disk to 8 bit
695 
696  for (i = 0; i < MAXLIGHTMAPS; i++)
697  out->styles[i] = in->styles[i];
698  i = LittleLong(in->lightofs);
699  if (i == -1)
700  out->samples = NULL;
701  else
702  {
703  if (coloredlights)
704  out->samples = loadmodel->lightdata + i;
705  else
706  out->samples = loadmodel->lightdata + i / 3;
707  }
708 
709  // set the drawing flags flag
710 
711  if (!out->texinfo->image)
712  continue;
713  if (out->texinfo->flags & SURF_SKY)
714  {
715  out->flags |= SURF_DRAWSKY;
716  continue;
717  }
718 
719  if (out->texinfo->flags & SURF_WARP)
720  {
721  out->flags |= SURF_DRAWTURB;
722  for (i = 0; i < 2; i++)
723  {
724  out->extents[i] = 16384;
725  out->texturemins[i] = -8192;
726  }
727  continue;
728  }
729  //==============
730  //PGM
731  // this marks flowing surfaces as turbulent, but with the new
732  // SURF_FLOW flag.
733  if (out->texinfo->flags & SURF_FLOWING)
734  {
735  out->flags |= SURF_DRAWTURB | SURF_FLOW;
736  for (i = 0; i < 2; i++)
737  {
738  out->extents[i] = 16384;
739  out->texturemins[i] = -8192;
740  }
741  continue;
742  }
743  //PGM
744  //==============
745  }
746 }

Referenced by Mod_LoadBrushModel().

◆ Mod_LoadLeafs()

void Mod_LoadLeafs ( lump_t l)

Definition at line 818 of file r_model.c.

819 {
820  dleaf_t *in;
821  mleaf_t *out;
822  int i, j, count;
823  int lastmarksurface; // Knightmare added
824 
825  in = (void *)(mod_base + l->fileofs);
826  if (l->filelen % sizeof(*in))
827  ri.Sys_Error(ERR_DROP, "MOD_LoadBmodel: funny lump size in %s", loadmodel->name);
828  count = l->filelen / sizeof(*in);
829  out = Hunk_Alloc(count*sizeof(*out));
830 
831  loadmodel->leafs = out;
833 
834  for (i = 0; i<count; i++, in++, out++)
835  {
836  for (j = 0; j<3; j++)
837  {
838  out->minmaxs[j] = LittleShort(in->mins[j]);
839  out->minmaxs[3 + j] = LittleShort(in->maxs[j]);
840  }
841 
842  out->contents = (int)LittleLong(in->contents);
843  out->cluster = LittleShort(in->cluster);
844  out->area = LittleShort(in->area);
845  // Knightmare added
846  if (loadmodel->vis != NULL) {
847  if (out->cluster < -1 || out->cluster >= loadmodel->vis->numclusters)
848  ri.Sys_Error(ERR_DROP, "Mod_LoadLeafs: bad cluster");
849  }
850  // end Knightmare
851 
853  (unsigned short)LittleShort(in->firstleafface); // Knightmare- make sure this doesn't turn negative!
854  out->nummarksurfaces = LittleShort(in->numleaffaces);
855  // Knightmare added
856  lastmarksurface = LittleShort(in->firstleafface) + out->nummarksurfaces;
857  if (lastmarksurface > loadmodel->nummarksurfaces)
858  ri.Sys_Error(ERR_DROP, "Mod_LoadLeafs: bad leaf face index");
859  // end Knightmare
860  }
861 }

Referenced by Mod_LoadBrushModel().

◆ Mod_LoadLighting()

void Mod_LoadLighting ( lump_t l)

Definition at line 295 of file r_model.c.

296 {
297  int i, size;
298  byte *in;
299 
300  if (!l->filelen)
301  {
303  return;
304  }
305  size = l->filelen / 3;
306  loadmodel->lightdata = Hunk_Alloc(size);
307  in = (void *)(mod_base + l->fileofs);
308  for (i = 0; i<size; i++, in += 3)
309  {
310  if (in[0] > in[1] && in[0] > in[2])
311  loadmodel->lightdata[i] = in[0];
312  else if (in[1] > in[0] && in[1] > in[2])
313  loadmodel->lightdata[i] = in[1];
314  else
315  loadmodel->lightdata[i] = in[2];
316  }
317 }

Referenced by Mod_LoadBrushModel().

◆ Mod_LoadMarksurfaces()

void Mod_LoadMarksurfaces ( lump_t l)

Definition at line 869 of file r_model.c.

870 {
871  int i, j, count;
872  short *in;
873  msurface_t **out;
874 
875  in = (void *)(mod_base + l->fileofs);
876  if (l->filelen % sizeof(*in))
877  ri.Sys_Error(ERR_DROP, "MOD_LoadBmodel: funny lump size in %s", loadmodel->name);
878  count = l->filelen / sizeof(*in);
879  out = Hunk_Alloc(count*sizeof(*out));
880 
881  loadmodel->marksurfaces = out;
883 
884  for (i = 0; i < count; i++)
885  {
886  j = LittleShort(in[i]);
887  if (j >= loadmodel->numsurfaces)
888  ri.Sys_Error(ERR_DROP, "Mod_ParseMarksurfaces: bad surface number");
889  out[i] = loadmodel->surfaces + j;
890  }
891 }

Referenced by Mod_LoadBrushModel().

◆ Mod_LoadModel()

model_t* Mod_LoadModel ( model_t mod,
qboolean  crash 
)

◆ Mod_LoadNodes()

void Mod_LoadNodes ( lump_t l)

Definition at line 768 of file r_model.c.

769 {
770  int i, j, count, p;
771  dnode_t *in;
772  mnode_t *out;
773 
774  in = (void *)(mod_base + l->fileofs);
775  if (l->filelen % sizeof(*in))
776  ri.Sys_Error(ERR_DROP, "MOD_LoadBmodel: funny lump size in %s", loadmodel->name);
777  count = l->filelen / sizeof(*in);
778  out = Hunk_Alloc(count*sizeof(*out));
779 
780  loadmodel->nodes = out;
782 
783  for (i = 0; i < count; i++, in++, out++)
784  {
785  for (j = 0; j < 3; j++)
786  {
787  out->minmaxs[j] = LittleShort(in->mins[j]);
788  out->minmaxs[3 + j] = LittleShort(in->maxs[j]);
789  }
790 
791  p = LittleLong(in->planenum);
792  out->plane = loadmodel->planes + p;
793 
794  out->firstsurface = LittleShort(in->firstface);
795  out->numsurfaces = LittleShort(in->numfaces);
796  out->contents = CONTENTS_NODE; // differentiate from leafs
797  if (out->firstsurface + out->numsurfaces > loadmodel->numsurfaces) // Knightmare added
798  ri.Sys_Error(ERR_DROP, "Mod_LoadNodes: bad faces in node");
799 
800  for (j = 0; j < 2; j++)
801  {
802  p = LittleLong(in->children[j]);
803  if (p >= 0)
804  out->children[j] = loadmodel->nodes + p;
805  else
806  out->children[j] = (mnode_t *)(loadmodel->leafs + (-1 - p));
807  }
808  }
809 
810  Mod_SetParent(loadmodel->nodes, NULL); // sets nodes and leafs
811 }

Referenced by Mod_LoadBrushModel().

◆ Mod_LoadPlanes()

void Mod_LoadPlanes ( lump_t l)

Definition at line 924 of file r_model.c.

925 {
926  int i, j;
927  mplane_t *out;
928  dplane_t *in;
929  int count;
930  int bits;
931 
932  in = (void *)(mod_base + l->fileofs);
933  if (l->filelen % sizeof(*in))
934  ri.Sys_Error(ERR_DROP, "MOD_LoadBmodel: funny lump size in %s", loadmodel->name);
935  count = l->filelen / sizeof(*in);
936  out = Hunk_Alloc((count + 6)*sizeof(*out)); // extra for skybox
937 
938  loadmodel->planes = out;
940 
941  for (i = 0; i < count; i++, in++, out++)
942  {
943  bits = 0;
944  for (j = 0; j < 3; j++)
945  {
946  out->normal[j] = LittleFloat(in->normal[j]);
947  if (out->normal[j] < 0)
948  bits |= 1 << j;
949  }
950 
951  out->dist = LittleFloat(in->dist);
952  out->type = LittleLong(in->type);
953  out->signbits = bits;
954  }
955 }

Referenced by Mod_LoadBrushModel().

◆ Mod_LoadRighting()

void Mod_LoadRighting ( lump_t l)

Definition at line 328 of file r_model.c.

329 {
330  if (!l->filelen)
331  {
333  return;
334  }
336  memcpy(loadmodel->lightdata, mod_base + l->fileofs, l->filelen);
337 
338 }

Referenced by Mod_LoadBrushModel().

◆ Mod_LoadSpriteModel()

void Mod_LoadSpriteModel ( model_t mod,
void buffer 
)

Definition at line 1170 of file r_model.c.

1171 {
1172  dsprite_t *sprin, *sprout;
1173  int i;
1174 
1175  sprin = (dsprite_t *)buffer;
1176  sprout = Hunk_Alloc(modfilelen);
1177 
1178  sprout->ident = LittleLong(sprin->ident);
1179  sprout->version = LittleLong(sprin->version);
1180  sprout->numframes = LittleLong(sprin->numframes);
1181 
1182  if (sprout->version != SPRITE_VERSION)
1183  ri.Sys_Error(ERR_DROP, "%s has wrong version number (%i should be %i)",
1184  mod->name, sprout->version, SPRITE_VERSION);
1185 
1186  if (sprout->numframes > MAX_MD2SKINS)
1187  ri.Sys_Error(ERR_DROP, "%s has too many frames (%i > %i)",
1188  mod->name, sprout->numframes, MAX_MD2SKINS);
1189 
1190  // byte swap everything
1191  for (i = 0; i < sprout->numframes; i++)
1192  {
1193  sprout->frames[i].width = LittleLong(sprin->frames[i].width);
1194  sprout->frames[i].height = LittleLong(sprin->frames[i].height);
1195  sprout->frames[i].origin_x = LittleLong(sprin->frames[i].origin_x);
1196  sprout->frames[i].origin_y = LittleLong(sprin->frames[i].origin_y);
1197  memcpy(sprout->frames[i].name, sprin->frames[i].name, MAX_SKINNAME);
1198  mod->skins[i] = R_FindImage(sprout->frames[i].name, it_sprite);
1199  }
1200 
1201  mod->type = mod_sprite;
1202 }

Referenced by Mod_ForName().

◆ Mod_LoadSubmodels()

void Mod_LoadSubmodels ( lump_t l)

Definition at line 434 of file r_model.c.

435 {
436  dmodel_t *in;
437  dmodel_t *out;
438  int i, j, count;
439  int lastface; // Knightmare added
440 
441  in = (void *)(mod_base + l->fileofs);
442  if (l->filelen % sizeof(*in))
443  ri.Sys_Error(ERR_DROP, "MOD_LoadBmodel: funny lump size in %s", loadmodel->name);
444  count = l->filelen / sizeof(*in);
445  out = Hunk_Alloc(count*sizeof(*out));
446 
447  loadmodel->submodels = out;
449 
450  for (i = 0; i < count; i++, in++, out++)
451  {
452  for (j = 0; j < 3; j++)
453  { // spread the mins / maxs by a pixel
454  out->mins[j] = LittleFloat(in->mins[j]) - 1;
455  out->maxs[j] = LittleFloat(in->maxs[j]) + 1;
456  out->origin[j] = LittleFloat(in->origin[j]);
457  }
458  out->headnode = LittleLong(in->headnode);
459  out->firstface = LittleLong(in->firstface);
460  out->numfaces = LittleLong(in->numfaces);
461  // Knightmare added
462  lastface = out->firstface + out->numfaces;
463  if (lastface < out->firstface) // || lastface > loadmodel->nummodelsurfaces)
464  ri.Sys_Error(ERR_DROP, "Mod_LoadSubmodels: bad facenum");
465  // end Knightmare
466  }
467 }

Referenced by Mod_LoadBrushModel().

◆ Mod_LoadSurfedges()

void Mod_LoadSurfedges ( lump_t l)

Definition at line 898 of file r_model.c.

899 {
900  int i, count;
901  int *in, *out;
902 
903  in = (void *)(mod_base + l->fileofs);
904  if (l->filelen % sizeof(*in))
905  ri.Sys_Error(ERR_DROP, "MOD_LoadBmodel: funny lump size in %s", loadmodel->name);
906  count = l->filelen / sizeof(*in);
907  out = Hunk_Alloc((count + 24)*sizeof(*out)); // extra for skybox
908 
909  loadmodel->surfedges = out;
911 
912  for (i = 0; i < count; i++) {
913  out[i] = LittleLong(in[i]);
914  if (out[i] >= loadmodel->numedges) // Knightmare added
915  ri.Sys_Error(ERR_DROP, "Mod_LoadSurfedges: bad edge index");
916  }
917 }

Referenced by Mod_LoadBrushModel().

◆ Mod_LoadTexinfo()

void Mod_LoadTexinfo ( lump_t l)

Definition at line 504 of file r_model.c.

505 {
506  texinfo_t *in;
507  mtexinfo_t *out, *step;
508  int i, j, count;
509  float len1, len2;
510  char name[MAX_QPATH];
511  int next;
512 
513  in = (void *)(mod_base + l->fileofs);
514  if (l->filelen % sizeof(*in))
515  ri.Sys_Error(ERR_DROP, "MOD_LoadBmodel: funny lump size in %s", loadmodel->name);
516  count = l->filelen / sizeof(*in);
517  out = Hunk_Alloc((count + 6)*sizeof(*out)); // extra for skybox
518 
519  loadmodel->texinfo = out;
521 
522  for (i = 0; i < count; i++, in++, out++)
523  {
524  for (j = 0; j < 8; j++)
525  out->vecs[0][j] = LittleFloat(in->vecs[0][j]);
526  len1 = VectorLength(out->vecs[0]);
527  len2 = VectorLength(out->vecs[1]);
528  len1 = (len1 + len2) / 2;
529  if (len1 < 0.32)
530  out->mipadjust = 4;
531  else if (len1 < 0.49)
532  out->mipadjust = 3;
533  else if (len1 < 0.99)
534  out->mipadjust = 2;
535  else
536  out->mipadjust = 1;
537 #if 0
538  if (len1 + len2 < 0.001)
539  out->mipadjust = 1; // don't crash
540  else
541  out->mipadjust = 1 / floor( (len1+len2)/2 + 0.1 );
542 #endif
543 
544  out->flags = LittleLong(in->flags);
545 
546  next = LittleLong(in->nexttexinfo);
547  if (next > 0) {
548  if (next >= count) // Knightmare added
549  ri.Sys_Error(ERR_DROP, "Mod_LoadTexinfo: bad anim chain");
550  out->next = loadmodel->texinfo + next;
551  }
552  /*
553  * PATCH: eliasm
554  *
555  * This patch fixes the problem where the game
556  * domed core when loading a new level.
557  */
558 
559  else {
560  out->next = NULL;
561  }
562  /* END OF PATCH */
563 
564  Com_sprintf(name, sizeof(name), "textures/%s.wal", in->texture);
565  out->image = R_FindImage(name, it_wall);
566  if (!out->image)
567  {
568  out->image = r_notexture_mip; // texture not found
569  out->flags = 0;
570  }
571  }
572 
573  // count animation frames
574  for (i = 0; i < count; i++)
575  {
576  out = &loadmodel->texinfo[i];
577  out->numframes = 1;
578  for (step = out->next; step && step != out; step = step->next)
579  out->numframes++;
580  }
581 }

Referenced by Mod_LoadBrushModel().

◆ Mod_LoadVertexes()

void Mod_LoadVertexes ( lump_t l)

Definition at line 398 of file r_model.c.

399 {
400  dvertex_t *in;
401  mvertex_t *out;
402  int i, count;
403 
404  in = (void *)(mod_base + l->fileofs);
405  if (l->filelen % sizeof(*in))
406  ri.Sys_Error(ERR_DROP, "MOD_LoadBmodel: funny lump size in %s", loadmodel->name);
407  count = l->filelen / sizeof(*in);
408  out = Hunk_Alloc((count + 8)*sizeof(*out)); // extra for skybox
409  /*
410  * PATCH: eliasm
411  *
412  * This patch fixes the problem where the games dumped core
413  * when changing levels.
414  */
415  memset(out, 0, (count + 6) * sizeof(*out));
416  /* END OF PATCH */
417 
418  loadmodel->vertexes = out;
420 
421  for (i = 0; i < count; i++, in++, out++)
422  {
423  out->position[0] = LittleFloat(in->point[0]);
424  out->position[1] = LittleFloat(in->point[1]);
425  out->position[2] = LittleFloat(in->point[2]);
426  }
427 }

Referenced by Mod_LoadBrushModel().

◆ Mod_LoadVisibility()

void Mod_LoadVisibility ( lump_t l)

Definition at line 372 of file r_model.c.

373 {
374  int i;
375 
376  if (!l->filelen)
377  {
378  loadmodel->vis = NULL;
379  return;
380  }
382  memcpy(loadmodel->vis, mod_base + l->fileofs, l->filelen);
383 
385  for (i = 0; i < loadmodel->vis->numclusters; i++)
386  {
389  }
390 }

Referenced by Mod_LoadBrushModel().

◆ Mod_Modellist_f()

void Mod_Modellist_f ( void  )

Definition at line 55 of file r_model.c.

56 {
57  int i;
58  model_t *mod;
59  int total;
60 
61  total = 0;
62  ri.Con_Printf(PRINT_ALL, "Loaded models:\n");
63  for (i = 0, mod = mod_known; i < mod_numknown; i++, mod++)
64  {
65  if (!mod->name[0])
66  continue;
67  ri.Con_Printf(PRINT_ALL, "%8i : %s\n", mod->extradatasize, mod->name);
68  total += mod->extradatasize;
69  }
70  ri.Con_Printf(PRINT_ALL, "Total resident: %i\n", total);
71 }

Referenced by R_Register().

◆ Mod_PointInLeaf()

mleaf_t* Mod_PointInLeaf ( vec3_t  p,
model_t model 
)

Definition at line 188 of file r_model.c.

189 {
190  mnode_t *node;
191  float d;
192  mplane_t *plane;
193 
194  if (!model || !model->nodes)
195  ri.Sys_Error(ERR_DROP, "Mod_PointInLeaf: bad model");
196 
197  node = model->nodes;
198  while (1)
199  {
200  if (node->contents != -1)
201  return (mleaf_t *)node;
202  plane = node->plane;
203  d = DotProduct(p, plane->normal) - plane->dist;
204  if (d > 0)
205  node = node->children[0];
206  else
207  node = node->children[1];
208  }
209 
210  return NULL; // never reached
211 }

Referenced by R_SetupFrame().

◆ Mod_SetParent()

void Mod_SetParent ( mnode_t node,
mnode_t parent 
)

Definition at line 754 of file r_model.c.

755 {
756  node->parent = parent;
757  if (node->contents != -1)
758  return;
759  Mod_SetParent(node->children[0], node);
760  Mod_SetParent(node->children[1], node);
761 }

Referenced by Mod_LoadNodes().

◆ R_BeginRegistration()

void R_BeginRegistration ( char *  model)

Definition at line 1213 of file r_model.c.

1214 {
1215  char fullname[MAX_QPATH];
1216  cvar_t *flushmap;
1217 
1219  r_oldviewcluster = -1; // force markleafs
1220  Com_sprintf(fullname, sizeof(fullname), "maps/%s.bsp", model);
1221 
1222  D_FlushCaches();
1223  // explicitly free the old map if different
1224  // this guarantees that mod_known[0] is the world map
1225  flushmap = ri.Cvar_Get("flushmap", "0", 0);
1226  if (strcmp(mod_known[0].name, fullname) || flushmap->value)
1227  Mod_Free(&mod_known[0]);
1228  r_worldmodel = R_RegisterModel(fullname);
1229  R_NewMap();
1230 }

◆ R_EndRegistration()

void R_EndRegistration ( void  )

Definition at line 1282 of file r_model.c.

1283 {
1284  int i;
1285  model_t *mod;
1286 
1287  for (i = 0, mod = mod_known; i < mod_numknown; i++, mod++)
1288  {
1289  if (!mod->name[0])
1290  continue;
1292  { // don't need this model
1293  Hunk_Free(mod->extradata);
1294  memset(mod, 0, sizeof(*mod));
1295  }
1296  else
1297  { // make sure it is paged in
1299  }
1300  }
1301 
1303 }

◆ R_NumberLeafs()

void R_NumberLeafs ( mnode_t node)

Definition at line 345 of file r_model.c.

346 {
347  mleaf_t *leaf;
348  int leafnum;
349 
350  if (node->contents != -1)
351  {
352  leaf = (mleaf_t *)node;
353  leafnum = leaf - loadmodel->leafs;
354  if (leaf->contents & CONTENTS_SOLID)
355  return;
356  r_leaftovis[leafnum] = r_numvisleafs;
357  r_vistoleaf[r_numvisleafs] = leafnum;
358  r_numvisleafs++;
359  return;
360  }
361 
362  R_NumberLeafs(node->children[0]);
363  R_NumberLeafs(node->children[1]);
364 }

Referenced by Mod_LoadBrushModel().

◆ R_RegisterModel()

struct model_s* R_RegisterModel ( char *  name)

Definition at line 1239 of file r_model.c.

1240 {
1241  model_t *mod;
1242  int i;
1243  dsprite_t *sprout;
1244  dmdl_t *pheader;
1245 
1246  mod = Mod_ForName(name, false);
1247  if (mod)
1248  {
1250 
1251  // register any images used by the models
1252  if (mod->type == mod_sprite)
1253  {
1254  sprout = (dsprite_t *)mod->extradata;
1255  for (i = 0; i < sprout->numframes; i++)
1256  mod->skins[i] = R_FindImage(sprout->frames[i].name, it_sprite);
1257  }
1258  else if (mod->type == mod_alias)
1259  {
1260  pheader = (dmdl_t *)mod->extradata;
1261  for (i = 0; i < pheader->num_skins; i++)
1262  mod->skins[i] = R_FindImage((char *)pheader + pheader->ofs_skins + i*MAX_SKINNAME, it_skin);
1263  //PGM
1264  mod->numframes = pheader->num_frames;
1265  //PGM
1266  }
1267  else if (mod->type == mod_brush)
1268  {
1269  for (i = 0; i < mod->numtexinfo; i++)
1271  }
1272  }
1273  return mod;
1274 }

Referenced by R_BeginRegistration().

Variable Documentation

◆ loadmodel

◆ loadname

char loadname[32]

Definition at line 28 of file r_model.c.

◆ mod_base

◆ mod_inline

model_t mod_inline[MAX_MOD_KNOWN]

Definition at line 42 of file r_model.c.

Referenced by Mod_ForName(), and Mod_LoadBrushModel().

◆ mod_known

◆ mod_novis

byte mod_novis[MAX_MAP_LEAFS/8]

Definition at line 35 of file r_model.c.

Referenced by Mod_ClusterPVS(), and Mod_Init().

◆ mod_numknown

int mod_numknown

Definition at line 39 of file r_model.c.

Referenced by Mod_ForName(), Mod_FreeAll(), Mod_Modellist_f(), and R_EndRegistration().

◆ modfilelen

int modfilelen

Definition at line 45 of file r_model.c.

Referenced by Mod_ForName(), and Mod_LoadSpriteModel().

◆ r_leaftovis

int r_leaftovis[MAX_MAP_LEAFS]

Definition at line 341 of file r_model.c.

Referenced by R_NumberLeafs().

◆ r_numvisleafs

int r_numvisleafs

Definition at line 343 of file r_model.c.

Referenced by Mod_LoadBrushModel(), and R_NumberLeafs().

◆ r_vistoleaf

int r_vistoleaf[MAX_MAP_LEAFS]

Definition at line 342 of file r_model.c.

Referenced by R_NumberLeafs().

◆ registration_sequence

Mod_LoadSurfedges
void Mod_LoadSurfedges(lump_t *l)
Definition: r_model.c:898
LUMP_VISIBILITY
#define LUMP_VISIBILITY
Definition: qfiles.h:265
MAX_MAP_LEAFS
#define MAX_MAP_LEAFS
Definition: qfiles.h:239
model_s::numvertexes
int numvertexes
Definition: r_model.h:207
it_sprite
@ it_sprite
Definition: r_local.h:65
dsprframe_t::name
char name[MAX_SKINNAME]
Definition: qfiles.h:178
Mod_LoadTexinfo
void Mod_LoadTexinfo(lump_t *l)
Definition: r_model.c:504
LUMP_EDGES
#define LUMP_EDGES
Definition: qfiles.h:273
dmdl_t::ofs_glcmds
int ofs_glcmds
Definition: qfiles.h:157
dheader_t
Definition: qfiles.h:283
msurface_s::plane
mplane_t * plane
Definition: r_model.h:100
msurface_s::styles
byte styles[MAXLIGHTMAPS]
Definition: r_model.h:115
Mod_LoadSpriteModel
void Mod_LoadSpriteModel(model_t *mod, void *buffer)
Definition: r_model.c:1170
Hunk_Begin
void * Hunk_Begin(int maxsize)
Definition: q_shwin.c:41
MAX_QPATH
#define MAX_QPATH
Definition: q_shared.h:80
mtexinfo_s::numframes
int numframes
Definition: r_model.h:89
mleaf_s::area
int area
Definition: r_model.h:155
model_s::numplanes
int numplanes
Definition: r_model.h:201
daliasframe_t::scale
float scale[3]
Definition: qfiles.h:121
R_InitSkyBox
void R_InitSkyBox(void)
Definition: r_rast.c:113
CONTENTS_NODE
#define CONTENTS_NODE
Definition: r_model.h:122
Mod_LoadVertexes
void Mod_LoadVertexes(lump_t *l)
Definition: r_model.c:398
LittleShort
short LittleShort(short l)
Definition: q_shared.c:946
Mod_LoadRighting
void Mod_LoadRighting(lump_t *l)
Definition: r_model.c:328
model_s::vis
dvis_t * vis
Definition: r_model.h:229
int
CONST PIXELFORMATDESCRIPTOR int
Definition: qgl_win.c:35
dnode_t
Definition: qfiles.h:381
lump_t::filelen
int filelen
Definition: qfiles.h:259
mod_known
model_t mod_known[MAX_MOD_KNOWN]
Definition: r_model.c:38
mvertex_t
Definition: r_model.h:45
Mod_LoadMarksurfaces
void Mod_LoadMarksurfaces(lump_t *l)
Definition: r_model.c:869
model_s::nummodelsurfaces
int nummodelsurfaces
Definition: r_model.h:196
dplane_t
Definition: qfiles.h:318
Hunk_Free
void Hunk_Free(void *base)
Definition: q_shwin.c:99
ri
refimport_t ri
Definition: r_main.c:25
LUMP_MODELS
#define LUMP_MODELS
Definition: qfiles.h:275
IDSPRITEHEADER
#define IDSPRITEHEADER
Definition: qfiles.h:170
v
GLdouble v
Definition: qgl_win.c:143
it_wall
@ it_wall
Definition: r_local.h:66
r_numvisleafs
int r_numvisleafs
Definition: r_model.c:343
dmdl_t::num_tris
int num_tris
Definition: qfiles.h:149
dsprframe_t::height
int height
Definition: qfiles.h:176
dmodel_t::firstface
int firstface
Definition: qfiles.h:295
Mod_DecompressVis
byte * Mod_DecompressVis(byte *in, model_t *model)
Definition: r_model.c:219
model_s::edges
medge_t * edges
Definition: r_model.h:211
Mod_LoadLighting
void Mod_LoadLighting(lump_t *l)
Definition: r_model.c:295
mtexinfo_s
Definition: r_model.h:83
refimport_t::FS_LoadFile
int(* FS_LoadFile)(char *name, void **buf)
Definition: ref.h:209
refimport_t::Cvar_Get
cvar_t *(* Cvar_Get)(char *name, char *value, int flags)
Definition: ref.h:216
R_FindImage
image_t * R_FindImage(char *name, imagetype_t type)
Definition: r_image.c:491
i
int i
Definition: q_shared.c:305
msurface_s::numedges
int numedges
Definition: r_model.h:104
dmodel_t::headnode
int headnode
Definition: qfiles.h:294
r_notexture_mip
image_t * r_notexture_mip
Definition: r_main.c:110
model_s::firstnode
int firstnode
Definition: r_model.h:214
LUMP_LEAFS
#define LUMP_LEAFS
Definition: qfiles.h:270
mnode_s::parent
struct mnode_s * parent
Definition: r_model.h:131
dstvert_t::s
short s
Definition: qfiles.h:97
mnode_s
Definition: r_model.h:123
dmdl_t::skinheight
int skinheight
Definition: qfiles.h:143
buffer
GLenum GLfloat * buffer
Definition: qgl_win.c:151
model_s
Definition: r_model.h:171
mleaf_s::firstmarksurface
msurface_t ** firstmarksurface
Definition: r_model.h:157
dtrivertx_t
Definition: qfiles.h:107
mod_novis
byte mod_novis[MAX_MAP_LEAFS/8]
Definition: r_model.c:35
r_oldviewcluster
int r_oldviewcluster
Definition: r_local.h:791
Mod_LoadLeafs
void Mod_LoadLeafs(lump_t *l)
Definition: r_model.c:818
model_s::marksurfaces
msurface_t ** marksurfaces
Definition: r_model.h:227
msurface_s::samples
byte * samples
Definition: r_model.h:116
mnode_s::children
struct mnode_s * children[2]
Definition: r_model.h:135
CONTENTS_SOLID
#define CONTENTS_SOLID
Definition: qfiles.h:333
image_s::registration_sequence
int registration_sequence
Definition: r_local.h:77
mleaf_s::contents
int contents
Definition: r_model.h:146
SURF_WARP
#define SURF_WARP
Definition: qfiles.h:372
mplane_s::normal
vec3_t normal
Definition: r_model.h:59
msurface_s::extents
short extents[2]
Definition: r_model.h:110
DVIS_PVS
#define DVIS_PVS
Definition: qfiles.h:461
cvar_s
Definition: q_shared.h:324
mod_brush
@ mod_brush
Definition: r_model.h:169
LUMP_NODES
#define LUMP_NODES
Definition: qfiles.h:266
lump_t::fileofs
int fileofs
Definition: qfiles.h:259
LUMP_LEAFFACES
#define LUMP_LEAFFACES
Definition: qfiles.h:271
mleaf_s
Definition: r_model.h:143
model_s::extradata
void * extradata
Definition: r_model.h:235
mplane_s::signbits
byte signbits
Definition: r_model.h:62
dvertex_t
Definition: qfiles.h:300
refimport_t::FS_FreeFile
void(* FS_FreeFile)(void *buf)
Definition: ref.h:210
Mod_LoadBrushModel
void Mod_LoadBrushModel(model_t *mod, void *buffer)
Definition: r_model.c:962
dmodel_t::origin
float origin[3]
Definition: qfiles.h:293
j
GLint j
Definition: qgl_win.c:150
IDBSPHEADER
#define IDBSPHEADER
Definition: qfiles.h:219
dmodel_t::numfaces
int numfaces
Definition: qfiles.h:295
model_s::numsubmodels
int numsubmodels
Definition: r_model.h:198
mvertex_t::position
vec3_t position
Definition: r_model.h:47
mod_numknown
int mod_numknown
Definition: r_model.c:39
R_FreeUnusedImages
void R_FreeUnusedImages(void)
Definition: r_image.c:564
dsprite_t
Definition: qfiles.h:181
model_s::numedges
int numedges
Definition: r_model.h:210
SURF_PLANEBACK
#define SURF_PLANEBACK
Definition: r_model.h:68
dtriangle_t::index_st
short index_st[3]
Definition: qfiles.h:104
R_NumberLeafs
void R_NumberLeafs(mnode_t *node)
Definition: r_model.c:345
model_s::registration_sequence
int registration_sequence
Definition: r_model.h:175
refimport_t::Con_Printf
void(* Con_Printf)(int print_level, char *str,...)
Definition: ref.h:202
PRINT_ALL
#define PRINT_ALL
Definition: qcommon.h:751
mtexinfo_s::image
image_t * image
Definition: r_model.h:87
dmodel_t
Definition: qfiles.h:290
R_RegisterModel
struct model_s * R_RegisterModel(char *name)
Definition: r_model.c:1239
Mod_LoadSubmodels
void Mod_LoadSubmodels(lump_t *l)
Definition: r_model.c:434
dmdl_t::ofs_end
int ofs_end
Definition: qfiles.h:158
Mod_LoadEdges
void Mod_LoadEdges(lump_t *l)
Definition: r_model.c:474
model_s::numframes
int numframes
Definition: r_model.h:178
D_FlushCaches
void D_FlushCaches(void)
Definition: r_surf.c:481
LittleFloat
float LittleFloat(float l)
Definition: q_shared.c:950
SPRITE_VERSION
#define SPRITE_VERSION
Definition: qfiles.h:172
Mod_LoadPlanes
void Mod_LoadPlanes(lump_t *l)
Definition: r_model.c:924
mod_base
byte * mod_base
Definition: r_model.c:284
model_s::texinfo
mtexinfo_t * texinfo
Definition: r_model.h:218
dmdl_t::ofs_frames
int ofs_frames
Definition: qfiles.h:156
Mod_ForName
model_t * Mod_ForName(char *name, qboolean crash)
Definition: r_model.c:90
dvis_t::numclusters
int numclusters
Definition: qfiles.h:465
mplane_s::dist
float dist
Definition: r_model.h:60
medge_t
Definition: r_model.h:77
LittleLong
int LittleLong(int l)
Definition: q_shared.c:948
dmdl_t::num_glcmds
int num_glcmds
Definition: qfiles.h:150
model_s::type
modtype_t type
Definition: r_model.h:177
dtriangle_t::index_xyz
short index_xyz[3]
Definition: qfiles.h:103
mnode_s::minmaxs
short minmaxs[6]
Definition: r_model.h:129
dstvert_t
Definition: qfiles.h:95
R_NewMap
void R_NewMap(void)
Definition: r_main.c:415
VectorLength
vec_t VectorLength(vec3_t v)
Definition: q_shared.c:762
model_s::numsurfedges
int numsurfedges
Definition: r_model.h:223
msurface_s::texinfo
mtexinfo_t * texinfo
Definition: r_model.h:112
model_s::leafs
mleaf_t * leafs
Definition: r_model.h:205
dmdl_t::version
int version
Definition: qfiles.h:140
t
GLdouble t
Definition: qgl_win.c:328
model_s::nodes
mnode_t * nodes
Definition: r_model.h:215
dedge_t
Definition: qfiles.h:404
r_leaftovis
int r_leaftovis[MAX_MAP_LEAFS]
Definition: r_model.c:341
r_coloredlights
cvar_t * r_coloredlights
Definition: r_main.c:154
model_s::mins
vec3_t mins
Definition: r_model.h:185
mleaf_s::cluster
int cluster
Definition: r_model.h:154
dstvert_t::t
short t
Definition: qfiles.h:98
refimport_t::Sys_Error
void(* Sys_Error)(int err_level, char *str,...)
Definition: ref.h:194
SURF_DRAWSKY
#define SURF_DRAWSKY
Definition: r_model.h:69
dmdl_t::num_skins
int num_skins
Definition: qfiles.h:146
SURF_FLOWING
#define SURF_FLOWING
Definition: qfiles.h:375
dmodel_t::maxs
float maxs[3]
Definition: qfiles.h:292
DotProduct
#define DotProduct(x, y)
Definition: q_shared.h:162
dmdl_t::num_xyz
int num_xyz
Definition: qfiles.h:147
r_worldmodel
model_t * r_worldmodel
Definition: r_main.c:41
cvar_s::value
float value
Definition: q_shared.h:331
model_s::lightdata
byte * lightdata
Definition: r_model.h:231
SURF_DRAWTURB
#define SURF_DRAWTURB
Definition: r_model.h:70
dmdl_t::framesize
int framesize
Definition: qfiles.h:144
Hunk_End
int Hunk_End(void)
Definition: q_shwin.c:81
LUMP_LIGHTING
#define LUMP_LIGHTING
Definition: qfiles.h:269
NULL
#define NULL
Definition: q_shared.h:67
dheader_t::lumps
lump_t lumps[HEADER_LUMPS]
Definition: qfiles.h:287
model_s::surfedges
int * surfedges
Definition: r_model.h:224
mleaf_s::minmaxs
short minmaxs[6]
Definition: r_model.h:149
mleaf_s::nummarksurfaces
int nummarksurfaces
Definition: r_model.h:158
r_vistoleaf
int r_vistoleaf[MAX_MAP_LEAFS]
Definition: r_model.c:342
daliasframe_t::translate
float translate[3]
Definition: qfiles.h:122
LUMP_VERTEXES
#define LUMP_VERTEXES
Definition: qfiles.h:264
MAX_MD2SKINS
#define MAX_MD2SKINS
Definition: qfiles.h:92
ERR_DROP
#define ERR_DROP
Definition: qcommon.h:744
dsprite_t::frames
dsprframe_t frames[1]
Definition: qfiles.h:185
Mod_LoadFaces
void Mod_LoadFaces(lump_t *l)
Definition: r_model.c:644
it_skin
@ it_skin
Definition: r_local.h:64
coloredlights
int coloredlights
Definition: r_main.c:156
dsprframe_t::width
int width
Definition: qfiles.h:176
modfilelen
int modfilelen
Definition: r_model.c:45
name
cvar_t * name
Definition: cl_main.c:79
LUMP_FACES
#define LUMP_FACES
Definition: qfiles.h:268
MAXLIGHTMAPS
#define MAXLIGHTMAPS
Definition: qfiles.h:409
mtexinfo_s::mipadjust
float mipadjust
Definition: r_model.h:86
msurface_s::flags
int flags
Definition: r_model.h:101
mod_sprite
@ mod_sprite
Definition: r_model.h:169
MAX_LBM_HEIGHT
#define MAX_LBM_HEIGHT
Definition: r_local.h:184
dvis_t::bitofs
int bitofs[8][2]
Definition: qfiles.h:466
LUMP_SURFEDGES
#define LUMP_SURFEDGES
Definition: qfiles.h:274
model_s::maxs
vec3_t maxs
Definition: r_model.h:185
s
static fixed16_t s
Definition: r_scan.c:30
mtexinfo_s::next
struct mtexinfo_s * next
Definition: r_model.h:90
dsprite_t::ident
int ident
Definition: qfiles.h:182
dheader_t::version
int version
Definition: qfiles.h:286
texinfo_s
Definition: qfiles.h:392
VectorCopy
#define VectorCopy(a, b)
Definition: q_shared.h:165
mod_inline
model_t mod_inline[MAX_MOD_KNOWN]
Definition: r_model.c:42
model_s::skins
image_t * skins[MAX_MD2SKINS]
Definition: r_model.h:234
mtexinfo_s::vecs
float vecs[2][4]
Definition: r_model.h:85
BSPVERSION
#define BSPVERSION
Definition: qfiles.h:222
MAX_VERTS
#define MAX_VERTS
Definition: qfiles.h:90
CalcSurfaceExtents
void CalcSurfaceExtents(msurface_t *s)
Definition: r_model.c:590
Mod_LoadNodes
void Mod_LoadNodes(lump_t *l)
Definition: r_model.c:768
model_s::name
char name[MAX_QPATH]
Definition: r_model.h:173
model_s::numtexinfo
int numtexinfo
Definition: r_model.h:217
mnode_s::contents
int contents
Definition: r_model.h:126
mnode_s::firstsurface
unsigned short firstsurface
Definition: r_model.h:137
mplane_s::type
byte type
Definition: r_model.h:61
dsprite_t::numframes
int numframes
Definition: qfiles.h:184
MAX_MOD_KNOWN
#define MAX_MOD_KNOWN
Definition: r_model.c:37
dsprframe_t::origin_y
int origin_y
Definition: qfiles.h:177
SURF_FLOW
#define SURF_FLOW
Definition: r_model.h:74
model_s::firstmodelsurface
int firstmodelsurface
Definition: r_model.h:196
model_s::surfaces
msurface_t * surfaces
Definition: r_model.h:221
daliasframe_t
Definition: qfiles.h:119
Com_PageInMemory
void Com_PageInMemory(byte *buffer, int size)
Definition: q_shared.c:1161
medge_t::v
unsigned short v[2]
Definition: r_model.h:79
mnode_s::plane
mplane_t * plane
Definition: r_model.h:134
LUMP_TEXINFO
#define LUMP_TEXINFO
Definition: qfiles.h:267
dleaf_t
Definition: qfiles.h:424
dface_t
Definition: qfiles.h:410
mod_alias
@ mod_alias
Definition: r_model.h:169
model_s::numleafs
int numleafs
Definition: r_model.h:204
MAX_SKINNAME
#define MAX_SKINNAME
Definition: qfiles.h:93
daliasframe_t::name
char name[16]
Definition: qfiles.h:123
Mod_LoadVisibility
void Mod_LoadVisibility(lump_t *l)
Definition: r_model.c:372
daliasframe_t::verts
dtrivertx_t verts[1]
Definition: qfiles.h:124
model_s::submodels
dmodel_t * submodels
Definition: r_model.h:199
LUMP_PLANES
#define LUMP_PLANES
Definition: qfiles.h:263
msurface_s
Definition: r_model.h:93
dmdl_t::ofs_skins
int ofs_skins
Definition: qfiles.h:153
mplane_s
Definition: r_model.h:57
mtexinfo_s::flags
int flags
Definition: r_model.h:88
model_s::numnodes
int numnodes
Definition: r_model.h:213
msurface_s::texturemins
short texturemins[2]
Definition: r_model.h:109
ALIAS_VERSION
#define ALIAS_VERSION
Definition: qfiles.h:87
model_s::planes
mplane_t * planes
Definition: r_model.h:202
dsprframe_t::origin_x
int origin_x
Definition: qfiles.h:177
dsprite_t::version
int version
Definition: qfiles.h:183
registration_sequence
int registration_sequence
Definition: r_model.c:44
dmdl_t::ofs_st
int ofs_st
Definition: qfiles.h:154
Mod_SetParent
void Mod_SetParent(mnode_t *node, mnode_t *parent)
Definition: r_model.c:754
dmdl_t::num_st
int num_st
Definition: qfiles.h:148
dmdl_t::ofs_tris
int ofs_tris
Definition: qfiles.h:155
IDALIASHEADER
#define IDALIASHEADER
Definition: qfiles.h:86
Mod_Free
void Mod_Free(model_t *mod)
Definition: r_model.c:1313
Mod_LoadAliasModel
void Mod_LoadAliasModel(model_t *mod, void *buffer)
Definition: r_model.c:1046
mnode_s::numsurfaces
unsigned short numsurfaces
Definition: r_model.h:138
model_s::vertexes
mvertex_t * vertexes
Definition: r_model.h:208
dmodel_t::mins
float mins[3]
Definition: qfiles.h:292
dtriangle_t
Definition: qfiles.h:101
loadmodel
model_t * loadmodel
Definition: r_model.c:27
model_s::nummarksurfaces
int nummarksurfaces
Definition: r_model.h:226
Hunk_Alloc
void * Hunk_Alloc(int size)
Definition: q_shwin.c:57
Com_sprintf
void Com_sprintf(char *dest, int size, char *fmt,...)
Definition: q_shared.c:1223
dmdl_t
Definition: qfiles.h:137
count
GLint GLsizei count
Definition: qgl_win.c:128
dmdl_t::num_frames
int num_frames
Definition: qfiles.h:151
msurface_s::firstedge
int firstedge
Definition: r_model.h:103
SURF_SKY
#define SURF_SKY
Definition: qfiles.h:371
model_s::extradatasize
int extradatasize
Definition: r_model.h:236
model_s::numsurfaces
int numsurfaces
Definition: r_model.h:220