icculus quake2 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 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 556 of file r_model.c.

557 {
558  float mins[2], maxs[2], val;
559  int i,j, e;
560  mvertex_t *v;
561  mtexinfo_t *tex;
562  int bmins[2], bmaxs[2];
563 
564  mins[0] = mins[1] = 999999;
565  maxs[0] = maxs[1] = -99999;
566 
567  tex = s->texinfo;
568 
569  for (i=0 ; i<s->numedges ; i++)
570  {
571  e = loadmodel->surfedges[s->firstedge+i];
572  if (e >= 0)
573  v = &loadmodel->vertexes[loadmodel->edges[e].v[0]];
574  else
575  v = &loadmodel->vertexes[loadmodel->edges[-e].v[1]];
576 
577  for (j=0 ; j<2 ; j++)
578  {
579  val = v->position[0] * tex->vecs[j][0] +
580  v->position[1] * tex->vecs[j][1] +
581  v->position[2] * tex->vecs[j][2] +
582  tex->vecs[j][3];
583  if (val < mins[j])
584  mins[j] = val;
585  if (val > maxs[j])
586  maxs[j] = val;
587  }
588  }
589 
590  for (i=0 ; i<2 ; i++)
591  {
592  bmins[i] = floor(mins[i]/16);
593  bmaxs[i] = ceil(maxs[i]/16);
594 
595  s->texturemins[i] = bmins[i] * 16;
596  s->extents[i] = (bmaxs[i] - bmins[i]) * 16;
597  if (s->extents[i] < 16)
598  s->extents[i] = 16; // take at least one cache block
599  if ( !(tex->flags & (SURF_WARP|SURF_SKY)) && s->extents[i] > 256)
600  ri.Sys_Error (ERR_DROP,"Bad surface extents");
601  }
602 }

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 1239 of file r_model.c.

1240 {
1241  Hunk_Free (mod->extradata);
1242  memset (mod, 0, sizeof(*mod));
1243 }

Referenced by Mod_FreeAll(), and R_BeginRegistration().

◆ Mod_FreeAll()

void Mod_FreeAll ( void  )

Definition at line 1250 of file r_model.c.

1251 {
1252  int i;
1253 
1254  for (i=0 ; i<mod_numknown ; i++)
1255  {
1256  if (mod_known[i].extradatasize)
1257  Mod_Free (&mod_known[i]);
1258  }
1259 }

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 972 of file r_model.c.

973 {
974  int i, j;
975  dmdl_t *pinmodel, *pheader;
976  dstvert_t *pinst, *poutst;
977  dtriangle_t *pintri, *pouttri;
978  daliasframe_t *pinframe, *poutframe;
979  int *pincmd, *poutcmd;
980  int version;
981 
982  pinmodel = (dmdl_t *)buffer;
983 
984  version = LittleLong (pinmodel->version);
985  if (version != ALIAS_VERSION)
986  ri.Sys_Error (ERR_DROP, "%s has wrong version number (%i should be %i)",
987  mod->name, version, ALIAS_VERSION);
988 
989  pheader = Hunk_Alloc (LittleLong(pinmodel->ofs_end));
990 
991  // byte swap the header fields and sanity check
992  for (i=0 ; i<sizeof(dmdl_t)/4 ; i++)
993  ((int *)pheader)[i] = LittleLong (((int *)buffer)[i]);
994 
995  if (pheader->skinheight > MAX_LBM_HEIGHT)
996  ri.Sys_Error (ERR_DROP, "model %s has a skin taller than %d", mod->name,
998 
999  if (pheader->num_xyz <= 0)
1000  ri.Sys_Error (ERR_DROP, "model %s has no vertices", mod->name);
1001 
1002  if (pheader->num_xyz > MAX_VERTS)
1003  ri.Sys_Error (ERR_DROP, "model %s has too many vertices", mod->name);
1004 
1005  if (pheader->num_st <= 0)
1006  ri.Sys_Error (ERR_DROP, "model %s has no st vertices", mod->name);
1007 
1008  if (pheader->num_tris <= 0)
1009  ri.Sys_Error (ERR_DROP, "model %s has no triangles", mod->name);
1010 
1011  if (pheader->num_frames <= 0)
1012  ri.Sys_Error (ERR_DROP, "model %s has no frames", mod->name);
1013 
1014 //
1015 // load base s and t vertices (not used in gl version)
1016 //
1017  pinst = (dstvert_t *) ((byte *)pinmodel + pheader->ofs_st);
1018  poutst = (dstvert_t *) ((byte *)pheader + pheader->ofs_st);
1019 
1020  for (i=0 ; i<pheader->num_st ; i++)
1021  {
1022  poutst[i].s = LittleShort (pinst[i].s);
1023  poutst[i].t = LittleShort (pinst[i].t);
1024  }
1025 
1026 //
1027 // load triangle lists
1028 //
1029  pintri = (dtriangle_t *) ((byte *)pinmodel + pheader->ofs_tris);
1030  pouttri = (dtriangle_t *) ((byte *)pheader + pheader->ofs_tris);
1031 
1032  for (i=0 ; i<pheader->num_tris ; i++)
1033  {
1034  for (j=0 ; j<3 ; j++)
1035  {
1036  pouttri[i].index_xyz[j] = LittleShort (pintri[i].index_xyz[j]);
1037  pouttri[i].index_st[j] = LittleShort (pintri[i].index_st[j]);
1038  }
1039  }
1040 
1041 //
1042 // load the frames
1043 //
1044  for (i=0 ; i<pheader->num_frames ; i++)
1045  {
1046  pinframe = (daliasframe_t *) ((byte *)pinmodel
1047  + pheader->ofs_frames + i * pheader->framesize);
1048  poutframe = (daliasframe_t *) ((byte *)pheader
1049  + pheader->ofs_frames + i * pheader->framesize);
1050 
1051  memcpy (poutframe->name, pinframe->name, sizeof(poutframe->name));
1052  for (j=0 ; j<3 ; j++)
1053  {
1054  poutframe->scale[j] = LittleFloat (pinframe->scale[j]);
1055  poutframe->translate[j] = LittleFloat (pinframe->translate[j]);
1056  }
1057  // verts are all 8 bit, so no swapping needed
1058  memcpy (poutframe->verts, pinframe->verts,
1059  pheader->num_xyz*sizeof(dtrivertx_t));
1060 
1061  }
1062 
1063  mod->type = mod_alias;
1064 
1065  //
1066  // load the glcmds
1067  //
1068  pincmd = (int *) ((byte *)pinmodel + pheader->ofs_glcmds);
1069  poutcmd = (int *) ((byte *)pheader + pheader->ofs_glcmds);
1070  for (i=0 ; i<pheader->num_glcmds ; i++)
1071  poutcmd[i] = LittleLong (pincmd[i]);
1072 
1073 
1074  // register all skins
1075  memcpy ((char *)pheader + pheader->ofs_skins, (char *)pinmodel + pheader->ofs_skins,
1076  pheader->num_skins*MAX_SKINNAME);
1077  for (i=0 ; i<pheader->num_skins ; i++)
1078  {
1079  mod->skins[i] = R_FindImage ((char *)pheader + pheader->ofs_skins + i*MAX_SKINNAME, it_skin);
1080  }
1081 }

Referenced by Mod_ForName().

◆ Mod_LoadBrushModel()

void Mod_LoadBrushModel ( model_t mod,
void buffer 
)

Definition at line 892 of file r_model.c.

893 {
894  int i;
895  dheader_t *header;
896  dmodel_t *bm;
897 
899  if (loadmodel != mod_known)
900  ri.Sys_Error (ERR_DROP, "Loaded a brush model after the world");
901 
902  header = (dheader_t *)buffer;
903 
904  i = LittleLong (header->version);
905  if (i != BSPVERSION)
906  ri.Sys_Error (ERR_DROP,"Mod_LoadBrushModel: %s has wrong version number (%i should be %i)", mod->name, i, BSPVERSION);
907 
908 // swap all the lumps
909  mod_base = (byte *)header;
910 
911  for (i=0 ; i<sizeof(dheader_t)/4 ; i++)
912  ((int *)header)[i] = LittleLong ( ((int *)header)[i]);
913 
914 // load into heap
915 
917  Mod_LoadEdges (&header->lumps[LUMP_EDGES]);
920  Mod_LoadPlanes (&header->lumps[LUMP_PLANES]);
921  Mod_LoadTexinfo (&header->lumps[LUMP_TEXINFO]);
922  Mod_LoadFaces (&header->lumps[LUMP_FACES]);
925  Mod_LoadLeafs (&header->lumps[LUMP_LEAFS]);
926  Mod_LoadNodes (&header->lumps[LUMP_NODES]);
927  Mod_LoadSubmodels (&header->lumps[LUMP_MODELS]);
928  r_numvisleafs = 0;
930 
931 //
932 // set up the submodels
933 //
934  for (i=0 ; i<mod->numsubmodels ; i++)
935  {
936  model_t *starmod;
937 
938  bm = &mod->submodels[i];
939  starmod = &mod_inline[i];
940 
941  *starmod = *loadmodel;
942 
943  starmod->firstmodelsurface = bm->firstface;
944  starmod->nummodelsurfaces = bm->numfaces;
945  starmod->firstnode = bm->headnode;
946  if (starmod->firstnode >= loadmodel->numnodes)
947  ri.Sys_Error (ERR_DROP, "Inline model %i has bad firstnode", i);
948 
949  VectorCopy (bm->maxs, starmod->maxs);
950  VectorCopy (bm->mins, starmod->mins);
951 
952  if (i == 0)
953  *loadmodel = *starmod;
954  }
955 
956  R_InitSkyBox ();
957 }

Referenced by Mod_ForName().

◆ Mod_LoadEdges()

void Mod_LoadEdges ( lump_t l)

Definition at line 447 of file r_model.c.

448 {
449  dedge_t *in;
450  medge_t *out;
451  int i, count;
452 
453  in = (void *)(mod_base + l->fileofs);
454  if (l->filelen % sizeof(*in))
455  ri.Sys_Error (ERR_DROP,"MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
456  count = l->filelen / sizeof(*in);
457  out = Hunk_Alloc ( (count + 13) * sizeof(*out)); // extra for skybox
458 
459  loadmodel->edges = out;
461 
462  for ( i=0 ; i<count ; i++, in++, out++)
463  {
464  out->v[0] = (unsigned short)LittleShort(in->v[0]);
465  out->v[1] = (unsigned short)LittleShort(in->v[1]);
466  }
467 }

Referenced by Mod_LoadBrushModel().

◆ Mod_LoadFaces()

void Mod_LoadFaces ( lump_t l)

Definition at line 610 of file r_model.c.

611 {
612  dface_t *in;
613  msurface_t *out;
614  int i, count, surfnum;
615  int planenum, side;
616 
617  in = (void *)(mod_base + l->fileofs);
618  if (l->filelen % sizeof(*in))
619  ri.Sys_Error (ERR_DROP,"MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
620  count = l->filelen / sizeof(*in);
621  out = Hunk_Alloc ( (count+6)*sizeof(*out)); // extra for skybox
622 
623  loadmodel->surfaces = out;
625 
626  for ( surfnum=0 ; surfnum<count ; surfnum++, in++, out++)
627  {
628  out->firstedge = LittleLong(in->firstedge);
629  out->numedges = LittleShort(in->numedges);
630  if (out->numedges < 3)
631  ri.Sys_Error (ERR_DROP,"Surface with %s edges", out->numedges);
632  out->flags = 0;
633 
634  planenum = LittleShort(in->planenum);
635  side = LittleShort(in->side);
636  if (side)
637  out->flags |= SURF_PLANEBACK;
638 
639  out->plane = loadmodel->planes + planenum;
640 
641  out->texinfo = loadmodel->texinfo + LittleShort (in->texinfo);
642 
643  CalcSurfaceExtents (out);
644 
645  // lighting info is converted from 24 bit on disk to 8 bit
646 
647  for (i=0 ; i<MAXLIGHTMAPS ; i++)
648  out->styles[i] = in->styles[i];
649  i = LittleLong(in->lightofs);
650  if (i == -1)
651  out->samples = NULL;
652  else
653  out->samples = loadmodel->lightdata + i/3;
654 
655  // set the drawing flags flag
656 
657  if (!out->texinfo->image)
658  continue;
659  if (out->texinfo->flags & SURF_SKY)
660  {
661  out->flags |= SURF_DRAWSKY;
662  continue;
663  }
664 
665  if (out->texinfo->flags & SURF_WARP)
666  {
667  out->flags |= SURF_DRAWTURB;
668  for (i=0 ; i<2 ; i++)
669  {
670  out->extents[i] = 16384;
671  out->texturemins[i] = -8192;
672  }
673  continue;
674  }
675 //==============
676 //PGM
677  // this marks flowing surfaces as turbulent, but with the new
678  // SURF_FLOW flag.
679  if (out->texinfo->flags & SURF_FLOWING)
680  {
681  out->flags |= SURF_DRAWTURB | SURF_FLOW;
682  for (i=0 ; i<2 ; i++)
683  {
684  out->extents[i] = 16384;
685  out->texturemins[i] = -8192;
686  }
687  continue;
688  }
689 //PGM
690 //==============
691  }
692 }

Referenced by Mod_LoadBrushModel().

◆ Mod_LoadLeafs()

void Mod_LoadLeafs ( lump_t l)

Definition at line 762 of file r_model.c.

763 {
764  dleaf_t *in;
765  mleaf_t *out;
766  int i, j, count;
767 
768  in = (void *)(mod_base + l->fileofs);
769  if (l->filelen % sizeof(*in))
770  ri.Sys_Error (ERR_DROP,"MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
771  count = l->filelen / sizeof(*in);
772  out = Hunk_Alloc ( count*sizeof(*out));
773 
774  loadmodel->leafs = out;
776 
777  for ( i=0 ; i<count ; i++, in++, out++)
778  {
779  for (j=0 ; j<3 ; j++)
780  {
781  out->minmaxs[j] = LittleShort (in->mins[j]);
782  out->minmaxs[3+j] = LittleShort (in->maxs[j]);
783  }
784 
785  out->contents = LittleLong(in->contents);
786  out->cluster = LittleShort(in->cluster);
787  out->area = LittleShort(in->area);
788 
790  LittleShort(in->firstleafface);
791  out->nummarksurfaces = LittleShort(in->numleaffaces);
792  }
793 }

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 801 of file r_model.c.

802 {
803  int i, j, count;
804  short *in;
805  msurface_t **out;
806 
807  in = (void *)(mod_base + l->fileofs);
808  if (l->filelen % sizeof(*in))
809  ri.Sys_Error (ERR_DROP,"MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
810  count = l->filelen / sizeof(*in);
811  out = Hunk_Alloc ( count*sizeof(*out));
812 
813  loadmodel->marksurfaces = out;
815 
816  for ( i=0 ; i<count ; i++)
817  {
818  j = LittleShort(in[i]);
819  if (j >= loadmodel->numsurfaces)
820  ri.Sys_Error (ERR_DROP,"Mod_ParseMarksurfaces: bad surface number");
821  out[i] = loadmodel->surfaces + j;
822  }
823 }

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 714 of file r_model.c.

715 {
716  int i, j, count, p;
717  dnode_t *in;
718  mnode_t *out;
719 
720  in = (void *)(mod_base + l->fileofs);
721  if (l->filelen % sizeof(*in))
722  ri.Sys_Error (ERR_DROP,"MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
723  count = l->filelen / sizeof(*in);
724  out = Hunk_Alloc ( count*sizeof(*out));
725 
726  loadmodel->nodes = out;
728 
729  for ( i=0 ; i<count ; i++, in++, out++)
730  {
731  for (j=0 ; j<3 ; j++)
732  {
733  out->minmaxs[j] = LittleShort (in->mins[j]);
734  out->minmaxs[3+j] = LittleShort (in->maxs[j]);
735  }
736 
737  p = LittleLong(in->planenum);
738  out->plane = loadmodel->planes + p;
739 
740  out->firstsurface = LittleShort (in->firstface);
741  out->numsurfaces = LittleShort (in->numfaces);
742  out->contents = CONTENTS_NODE; // differentiate from leafs
743 
744  for (j=0 ; j<2 ; j++)
745  {
746  p = LittleLong (in->children[j]);
747  if (p >= 0)
748  out->children[j] = loadmodel->nodes + p;
749  else
750  out->children[j] = (mnode_t *)(loadmodel->leafs + (-1 - p));
751  }
752  }
753 
754  Mod_SetParent (loadmodel->nodes, NULL); // sets nodes and leafs
755 }

Referenced by Mod_LoadBrushModel().

◆ Mod_LoadPlanes()

void Mod_LoadPlanes ( lump_t l)

Definition at line 853 of file r_model.c.

854 {
855  int i, j;
856  mplane_t *out;
857  dplane_t *in;
858  int count;
859  int bits;
860 
861  in = (void *)(mod_base + l->fileofs);
862  if (l->filelen % sizeof(*in))
863  ri.Sys_Error (ERR_DROP,"MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
864  count = l->filelen / sizeof(*in);
865  out = Hunk_Alloc ( (count+6)*sizeof(*out)); // extra for skybox
866 
867  loadmodel->planes = out;
869 
870  for ( i=0 ; i<count ; i++, in++, out++)
871  {
872  bits = 0;
873  for (j=0 ; j<3 ; j++)
874  {
875  out->normal[j] = LittleFloat (in->normal[j]);
876  if (out->normal[j] < 0)
877  bits |= 1<<j;
878  }
879 
880  out->dist = LittleFloat (in->dist);
881  out->type = LittleLong (in->type);
882  out->signbits = bits;
883  }
884 }

Referenced by Mod_LoadBrushModel().

◆ Mod_LoadSpriteModel()

void Mod_LoadSpriteModel ( model_t mod,
void buffer 
)

Definition at line 1096 of file r_model.c.

1097 {
1098  dsprite_t *sprin, *sprout;
1099  int i;
1100 
1101  sprin = (dsprite_t *)buffer;
1102  sprout = Hunk_Alloc (modfilelen);
1103 
1104  sprout->ident = LittleLong (sprin->ident);
1105  sprout->version = LittleLong (sprin->version);
1106  sprout->numframes = LittleLong (sprin->numframes);
1107 
1108  if (sprout->version != SPRITE_VERSION)
1109  ri.Sys_Error (ERR_DROP, "%s has wrong version number (%i should be %i)",
1110  mod->name, sprout->version, SPRITE_VERSION);
1111 
1112  if (sprout->numframes > MAX_MD2SKINS)
1113  ri.Sys_Error (ERR_DROP, "%s has too many frames (%i > %i)",
1114  mod->name, sprout->numframes, MAX_MD2SKINS);
1115 
1116  // byte swap everything
1117  for (i=0 ; i<sprout->numframes ; i++)
1118  {
1119  sprout->frames[i].width = LittleLong (sprin->frames[i].width);
1120  sprout->frames[i].height = LittleLong (sprin->frames[i].height);
1121  sprout->frames[i].origin_x = LittleLong (sprin->frames[i].origin_x);
1122  sprout->frames[i].origin_y = LittleLong (sprin->frames[i].origin_y);
1123  memcpy (sprout->frames[i].name, sprin->frames[i].name, MAX_SKINNAME);
1124  mod->skins[i] = R_FindImage (sprout->frames[i].name, it_sprite);
1125  }
1126 
1127  mod->type = mod_sprite;
1128 }

Referenced by Mod_ForName().

◆ Mod_LoadSubmodels()

void Mod_LoadSubmodels ( lump_t l)

Definition at line 413 of file r_model.c.

414 {
415  dmodel_t *in;
416  dmodel_t *out;
417  int i, j, count;
418 
419  in = (void *)(mod_base + l->fileofs);
420  if (l->filelen % sizeof(*in))
421  ri.Sys_Error (ERR_DROP,"MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
422  count = l->filelen / sizeof(*in);
423  out = Hunk_Alloc ( count*sizeof(*out));
424 
425  loadmodel->submodels = out;
427 
428  for ( i=0 ; i<count ; i++, in++, out++)
429  {
430  for (j=0 ; j<3 ; j++)
431  { // spread the mins / maxs by a pixel
432  out->mins[j] = LittleFloat (in->mins[j]) - 1;
433  out->maxs[j] = LittleFloat (in->maxs[j]) + 1;
434  out->origin[j] = LittleFloat (in->origin[j]);
435  }
436  out->headnode = LittleLong (in->headnode);
437  out->firstface = LittleLong (in->firstface);
438  out->numfaces = LittleLong (in->numfaces);
439  }
440 }

Referenced by Mod_LoadBrushModel().

◆ Mod_LoadSurfedges()

void Mod_LoadSurfedges ( lump_t l)

Definition at line 830 of file r_model.c.

831 {
832  int i, count;
833  int *in, *out;
834 
835  in = (void *)(mod_base + l->fileofs);
836  if (l->filelen % sizeof(*in))
837  ri.Sys_Error (ERR_DROP,"MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
838  count = l->filelen / sizeof(*in);
839  out = Hunk_Alloc ( (count+24)*sizeof(*out)); // extra for skybox
840 
841  loadmodel->surfedges = out;
843 
844  for ( i=0 ; i<count ; i++)
845  out[i] = LittleLong (in[i]);
846 }

Referenced by Mod_LoadBrushModel().

◆ Mod_LoadTexinfo()

void Mod_LoadTexinfo ( lump_t l)

Definition at line 474 of file r_model.c.

475 {
476  texinfo_t *in;
477  mtexinfo_t *out, *step;
478  int i, j, count;
479  float len1, len2;
480  char name[MAX_QPATH];
481  int next;
482 
483  in = (void *)(mod_base + l->fileofs);
484  if (l->filelen % sizeof(*in))
485  ri.Sys_Error (ERR_DROP,"MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
486  count = l->filelen / sizeof(*in);
487  out = Hunk_Alloc ( (count+6)*sizeof(*out)); // extra for skybox
488 
489  loadmodel->texinfo = out;
491 
492  for ( i=0 ; i<count ; i++, in++, out++)
493  {
494  for (j=0 ; j<8 ; j++)
495  out->vecs[0][j] = LittleFloat (in->vecs[0][j]);
496  len1 = VectorLength (out->vecs[0]);
497  len2 = VectorLength (out->vecs[1]);
498  len1 = (len1 + len2)/2;
499  if (len1 < 0.32)
500  out->mipadjust = 4;
501  else if (len1 < 0.49)
502  out->mipadjust = 3;
503  else if (len1 < 0.99)
504  out->mipadjust = 2;
505  else
506  out->mipadjust = 1;
507 #if 0
508  if (len1 + len2 < 0.001)
509  out->mipadjust = 1; // don't crash
510  else
511  out->mipadjust = 1 / floor( (len1+len2)/2 + 0.1 );
512 #endif
513 
514  out->flags = LittleLong (in->flags);
515 
516  next = LittleLong (in->nexttexinfo);
517  if (next > 0)
518  out->next = loadmodel->texinfo + next;
519  /*
520  * PATCH: eliasm
521  *
522  * This patch fixes the problem where the game
523  * domed core when loading a new level.
524  */
525  else {
526  out->next = NULL;
527  }
528  /* END OF PATCH */
529 
530  Com_sprintf (name, sizeof(name), "textures/%s.wal", in->texture);
531  out->image = R_FindImage (name, it_wall);
532  if (!out->image)
533  {
534  out->image = r_notexture_mip; // texture not found
535  out->flags = 0;
536  }
537  }
538 
539  // count animation frames
540  for (i=0 ; i<count ; i++)
541  {
542  out = &loadmodel->texinfo[i];
543  out->numframes = 1;
544  for (step = out->next ; step && step != out ; step=step->next)
545  out->numframes++;
546  }
547 }

Referenced by Mod_LoadBrushModel().

◆ Mod_LoadVertexes()

void Mod_LoadVertexes ( lump_t l)

Definition at line 377 of file r_model.c.

378 {
379  dvertex_t *in;
380  mvertex_t *out;
381  int i, count;
382 
383  in = (void *)(mod_base + l->fileofs);
384  if (l->filelen % sizeof(*in))
385  ri.Sys_Error (ERR_DROP,"MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
386  count = l->filelen / sizeof(*in);
387  out = Hunk_Alloc ( (count+8)*sizeof(*out)); // extra for skybox
388  /*
389  * PATCH: eliasm
390  *
391  * This patch fixes the problem where the games dumped core
392  * when changing levels.
393  */
394  memset( out, 0, (count + 6) * sizeof( *out ) );
395  /* END OF PATCH */
396 
397  loadmodel->vertexes = out;
399 
400  for ( i=0 ; i<count ; i++, in++, out++)
401  {
402  out->position[0] = LittleFloat (in->point[0]);
403  out->position[1] = LittleFloat (in->point[1]);
404  out->position[2] = LittleFloat (in->point[2]);
405  }
406 }

Referenced by Mod_LoadBrushModel().

◆ Mod_LoadVisibility()

void Mod_LoadVisibility ( lump_t l)

Definition at line 351 of file r_model.c.

352 {
353  int i;
354 
355  if (!l->filelen)
356  {
357  loadmodel->vis = NULL;
358  return;
359  }
360  loadmodel->vis = Hunk_Alloc ( l->filelen);
361  memcpy (loadmodel->vis, mod_base + l->fileofs, l->filelen);
362 
364  for (i=0 ; i<loadmodel->vis->numclusters ; i++)
365  {
366  loadmodel->vis->bitofs[i][0] = LittleLong (loadmodel->vis->bitofs[i][0]);
367  loadmodel->vis->bitofs[i][1] = LittleLong (loadmodel->vis->bitofs[i][1]);
368  }
369 }

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 700 of file r_model.c.

701 {
702  node->parent = parent;
703  if (node->contents != -1)
704  return;
705  Mod_SetParent (node->children[0], node);
706  Mod_SetParent (node->children[1], node);
707 }

Referenced by Mod_LoadNodes().

◆ R_BeginRegistration()

void R_BeginRegistration ( char *  model)

Definition at line 1139 of file r_model.c.

1140 {
1141  char fullname[MAX_QPATH];
1142  cvar_t *flushmap;
1143 
1145  r_oldviewcluster = -1; // force markleafs
1146  Com_sprintf (fullname, sizeof(fullname), "maps/%s.bsp", model);
1147 
1148  D_FlushCaches ();
1149  // explicitly free the old map if different
1150  // this guarantees that mod_known[0] is the world map
1151  flushmap = ri.Cvar_Get ("flushmap", "0", 0);
1152  if ( strcmp(mod_known[0].name, fullname) || flushmap->value)
1153  Mod_Free (&mod_known[0]);
1154  r_worldmodel = R_RegisterModel (fullname);
1155  R_NewMap ();
1156 }

◆ R_EndRegistration()

void R_EndRegistration ( void  )

Definition at line 1208 of file r_model.c.

1209 {
1210  int i;
1211  model_t *mod;
1212 
1213  for (i=0, mod=mod_known ; i<mod_numknown ; i++, mod++)
1214  {
1215  if (!mod->name[0])
1216  continue;
1218  { // don't need this model
1219  Hunk_Free (mod->extradata);
1220  memset (mod, 0, sizeof(*mod));
1221  }
1222  else
1223  { // make sure it is paged in
1225  }
1226  }
1227 
1228  R_FreeUnusedImages ();
1229 }

◆ R_NumberLeafs()

void R_NumberLeafs ( mnode_t node)

Definition at line 324 of file r_model.c.

325 {
326  mleaf_t *leaf;
327  int leafnum;
328 
329  if (node->contents != -1)
330  {
331  leaf = (mleaf_t *)node;
332  leafnum = leaf - loadmodel->leafs;
333  if (leaf->contents & CONTENTS_SOLID)
334  return;
335  r_leaftovis[leafnum] = r_numvisleafs;
336  r_vistoleaf[r_numvisleafs] = leafnum;
337  r_numvisleafs++;
338  return;
339  }
340 
341  R_NumberLeafs (node->children[0]);
342  R_NumberLeafs (node->children[1]);
343 }

Referenced by Mod_LoadBrushModel().

◆ R_RegisterModel()

struct model_s* R_RegisterModel ( char *  name)

Definition at line 1165 of file r_model.c.

1166 {
1167  model_t *mod;
1168  int i;
1169  dsprite_t *sprout;
1170  dmdl_t *pheader;
1171 
1172  mod = Mod_ForName (name, false);
1173  if (mod)
1174  {
1176 
1177  // register any images used by the models
1178  if (mod->type == mod_sprite)
1179  {
1180  sprout = (dsprite_t *)mod->extradata;
1181  for (i=0 ; i<sprout->numframes ; i++)
1182  mod->skins[i] = R_FindImage (sprout->frames[i].name, it_sprite);
1183  }
1184  else if (mod->type == mod_alias)
1185  {
1186  pheader = (dmdl_t *)mod->extradata;
1187  for (i=0 ; i<pheader->num_skins ; i++)
1188  mod->skins[i] = R_FindImage ((char *)pheader + pheader->ofs_skins + i*MAX_SKINNAME, it_skin);
1189 //PGM
1190  mod->numframes = pheader->num_frames;
1191 //PGM
1192  }
1193  else if (mod->type == mod_brush)
1194  {
1195  for (i=0 ; i<mod->numtexinfo ; i++)
1197  }
1198  }
1199  return mod;
1200 }

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 320 of file r_model.c.

Referenced by R_NumberLeafs().

◆ r_numvisleafs

int r_numvisleafs

Definition at line 322 of file r_model.c.

Referenced by Mod_LoadBrushModel(), and R_NumberLeafs().

◆ r_vistoleaf

int r_vistoleaf[MAX_MAP_LEAFS]

Definition at line 321 of file r_model.c.

Referenced by R_NumberLeafs().

◆ registration_sequence

Mod_LoadSurfedges
void Mod_LoadSurfedges(lump_t *l)
Definition: r_model.c:830
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:59
dsprframe_t::name
char name[MAX_SKINNAME]
Definition: qfiles.h:178
Mod_LoadTexinfo
void Mod_LoadTexinfo(lump_t *l)
Definition: r_model.c:474
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::styles
byte styles[MAXLIGHTMAPS]
Definition: r_model.h:115
Mod_LoadSpriteModel
void Mod_LoadSpriteModel(model_t *mod, void *buffer)
Definition: r_model.c:1096
Hunk_Begin
void * Hunk_Begin(int maxsize)
Definition: q_shwin.c:41
MAX_QPATH
#define MAX_QPATH
Definition: q_shared.h:73
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:377
LittleShort
short LittleShort(short l)
Definition: q_shared.c:946
model_s::vis
dvis_t * vis
Definition: r_model.h:229
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:801
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:60
r_numvisleafs
int r_numvisleafs
Definition: r_model.c:322
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:235
refimport_t::Cvar_Get
cvar_t *(* Cvar_Get)(char *name, char *value, int flags)
Definition: ref.h:242
R_FindImage
image_t * R_FindImage(char *name, imagetype_t type)
Definition: r_image.c:497
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:104
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:731
Mod_LoadLeafs
void Mod_LoadLeafs(lump_t *l)
Definition: r_model.c:762
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:71
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:317
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:236
Mod_LoadBrushModel
void Mod_LoadBrushModel(model_t *mod, void *buffer)
Definition: r_model.c:892
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
msurface_s::plane
mplane_t * plane
Definition: r_model.h:100
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:578
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:324
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:228
PRINT_ALL
#define PRINT_ALL
Definition: qcommon.h:743
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:1165
Mod_LoadSubmodels
void Mod_LoadSubmodels(lump_t *l)
Definition: r_model.c:413
dmdl_t::ofs_end
int ofs_end
Definition: qfiles.h:158
mnode_s::plane
mplane_t * plane
Definition: r_model.h:134
Mod_LoadEdges
void Mod_LoadEdges(lump_t *l)
Definition: r_model.c:447
model_s::numframes
int numframes
Definition: r_model.h:178
D_FlushCaches
void D_FlushCaches(void)
Definition: r_surf.c:418
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:853
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
dstvert_t
Definition: qfiles.h:95
R_NewMap
void R_NewMap(void)
Definition: r_main.c:380
VectorLength
vec_t VectorLength(vec3_t v)
Definition: q_shared.c:762
model_s::submodels
dmodel_t * submodels
Definition: r_model.h:199
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:320
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:220
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:155
dmdl_t::num_xyz
int num_xyz
Definition: qfiles.h:147
r_worldmodel
model_t * r_worldmodel
Definition: r_main.c:39
cvar_s::value
float value
Definition: q_shared.h:324
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:60
dheader_t::lumps
lump_t lumps[HEADER_LUMPS]
Definition: qfiles.h:287
model_s::surfedges
int * surfedges
Definition: r_model.h:224
mleaf_s::nummarksurfaces
int nummarksurfaces
Definition: r_model.h:158
r_vistoleaf
int r_vistoleaf[MAX_MAP_LEAFS]
Definition: r_model.c:321
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:736
dsprite_t::frames
dsprframe_t frames[1]
Definition: qfiles.h:185
Mod_LoadFaces
void Mod_LoadFaces(lump_t *l)
Definition: r_model.c:610
it_skin
@ it_skin
Definition: r_local.h:58
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:94
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:177
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
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:158
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:556
Mod_LoadNodes
void Mod_LoadNodes(lump_t *l)
Definition: r_model.c:714
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
mleaf_s::minmaxs
short minmaxs[6]
Definition: r_model.h:149
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
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:351
daliasframe_t::verts
dtrivertx_t verts[1]
Definition: qfiles.h:124
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
model_s::planes
mplane_t * planes
Definition: r_model.h:202
mtexinfo_s::flags
int flags
Definition: r_model.h:88
model_s::numnodes
int numnodes
Definition: r_model.h:213
mnode_s::minmaxs
short minmaxs[6]
Definition: r_model.h:129
msurface_s::texturemins
short texturemins[2]
Definition: r_model.h:109
ALIAS_VERSION
#define ALIAS_VERSION
Definition: qfiles.h:87
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:700
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:1239
Mod_LoadAliasModel
void Mod_LoadAliasModel(model_t *mod, void *buffer)
Definition: r_model.c:972
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:1236
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