vkQuake2 doxygen  1.0 dev
gl_model.c File Reference
#include "gl_local.h"

Go to the source code of this file.

Macros

#define MAX_MOD_KNOWN   512
 

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)
 
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_Modellist_f (void)
 
void Mod_Init (void)
 
model_tMod_ForName (char *name, qboolean crash)
 
void Mod_LoadLighting (lump_t *l)
 
void Mod_LoadVisibility (lump_t *l)
 
void Mod_LoadVertexes (lump_t *l)
 
float RadiusFromBounds (vec3_t mins, vec3_t maxs)
 
void Mod_LoadSubmodels (lump_t *l)
 
void Mod_LoadEdges (lump_t *l)
 
void Mod_LoadTexinfo (lump_t *l)
 
void CalcSurfaceExtents (msurface_t *s)
 
void GL_BuildPolygonFromSurface (msurface_t *fa)
 
void GL_CreateSurfaceLightmap (msurface_t *surf)
 
void GL_EndBuildingLightmaps (void)
 
void GL_BeginBuildingLightmaps (model_t *m)
 
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
 
int modfilelen
 
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
 
bytemod_base
 

Macro Definition Documentation

◆ MAX_MOD_KNOWN

#define MAX_MOD_KNOWN   512

Definition at line 34 of file gl_model.c.

Function Documentation

◆ CalcSurfaceExtents()

void CalcSurfaceExtents ( msurface_t s)

Definition at line 500 of file gl_model.c.

501 {
502  float mins[2], maxs[2], val;
503  int i,j, e;
504  mvertex_t *v;
505  mtexinfo_t *tex;
506  int bmins[2], bmaxs[2];
507 
508  mins[0] = mins[1] = 999999;
509  maxs[0] = maxs[1] = -99999;
510 
511  tex = s->texinfo;
512 
513  for (i=0 ; i<s->numedges ; i++)
514  {
515  e = loadmodel->surfedges[s->firstedge+i];
516  if (e >= 0)
517  v = &loadmodel->vertexes[loadmodel->edges[e].v[0]];
518  else
519  v = &loadmodel->vertexes[loadmodel->edges[-e].v[1]];
520 
521  for (j=0 ; j<2 ; j++)
522  {
523  val = v->position[0] * tex->vecs[j][0] +
524  v->position[1] * tex->vecs[j][1] +
525  v->position[2] * tex->vecs[j][2] +
526  tex->vecs[j][3];
527  if (val < mins[j])
528  mins[j] = val;
529  if (val > maxs[j])
530  maxs[j] = val;
531  }
532  }
533 
534  for (i=0 ; i<2 ; i++)
535  {
536  bmins[i] = floor(mins[i]/16);
537  bmaxs[i] = ceil(maxs[i]/16);
538 
539  s->texturemins[i] = bmins[i] * 16;
540  s->extents[i] = (bmaxs[i] - bmins[i]) * 16;
541 
542 // if ( !(tex->flags & TEX_SPECIAL) && s->extents[i] > 512 /* 256 */ )
543 // ri.Sys_Error (ERR_DROP, "Bad surface extents");
544  }
545 }

Referenced by Mod_LoadFaces().

◆ GL_BeginBuildingLightmaps()

void GL_BeginBuildingLightmaps ( model_t m)

Definition at line 1565 of file gl_rsurf.c.

1566 {
1567  static lightstyle_t lightstyles[MAX_LIGHTSTYLES];
1568  int i;
1569  unsigned dummy[128*128];
1570 
1571  memset( gl_lms.allocated, 0, sizeof(gl_lms.allocated) );
1572 
1573  r_framecount = 1; // no dlightcache
1574 
1575  GL_EnableMultitexture( true );
1577 
1578  /*
1579  ** setup the base lightstyles so the lightmaps won't have to be regenerated
1580  ** the first time they're seen
1581  */
1582  for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
1583  {
1584  lightstyles[i].rgb[0] = 1;
1585  lightstyles[i].rgb[1] = 1;
1586  lightstyles[i].rgb[2] = 1;
1587  lightstyles[i].white = 3;
1588  }
1589  r_newrefdef.lightstyles = lightstyles;
1590 
1592  {
1594 // gl_state.lightmap_textures = gl_state.texture_extension_number;
1595 // gl_state.texture_extension_number = gl_state.lightmap_textures + MAX_LIGHTMAPS;
1596  }
1597 
1599 
1600  /*
1601  ** if mono lightmaps are enabled and we want to use alpha
1602  ** blending (a,1-a) then we're likely running on a 3DLabs
1603  ** Permedia2. In a perfect world we'd use a GL_ALPHA lightmap
1604  ** in order to conserve space and maximize bandwidth, however
1605  ** this isn't a perfect world.
1606  **
1607  ** So we have to use alpha lightmaps, but stored in GL_RGBA format,
1608  ** which means we only get 1/16th the color resolution we should when
1609  ** using alpha lightmaps. If we find another board that supports
1610  ** only alpha lightmaps but that can at least support the GL_ALPHA
1611  ** format then we should change this code to use real alpha maps.
1612  */
1613  if ( toupper( gl_monolightmap->string[0] ) == 'A' )
1614  {
1616  }
1617  /*
1618  ** try to do hacked colored lighting with a blended texture
1619  */
1620  else if ( toupper( gl_monolightmap->string[0] ) == 'C' )
1621  {
1623  }
1624  else if ( toupper( gl_monolightmap->string[0] ) == 'I' )
1625  {
1626  gl_lms.internal_format = GL_INTENSITY8;
1627  }
1628  else if ( toupper( gl_monolightmap->string[0] ) == 'L' )
1629  {
1630  gl_lms.internal_format = GL_LUMINANCE8;
1631  }
1632  else
1633  {
1635  }
1636 
1637  /*
1638  ** initialize the dynamic lightmap texture
1639  */
1641  qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
1642  qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
1643  qglTexImage2D( GL_TEXTURE_2D,
1644  0,
1647  0,
1649  GL_UNSIGNED_BYTE,
1650  dummy );
1651 }

Referenced by Mod_LoadFaces().

◆ GL_BuildPolygonFromSurface()

void GL_BuildPolygonFromSurface ( msurface_t fa)

Definition at line 1450 of file gl_rsurf.c.

1451 {
1452  int i, lindex, lnumverts;
1453  medge_t *pedges, *r_pedge;
1454  int vertpage;
1455  float *vec;
1456  float s, t;
1457  glpoly_t *poly;
1458  vec3_t total;
1459 
1460 // reconstruct the polygon
1461  pedges = currentmodel->edges;
1462  lnumverts = fa->numedges;
1463  vertpage = 0;
1464 
1465  VectorClear (total);
1466  //
1467  // draw texture
1468  //
1469  poly = Hunk_Alloc (sizeof(glpoly_t) + (lnumverts-4) * VERTEXSIZE*sizeof(float));
1470  poly->next = fa->polys;
1471  poly->flags = fa->flags;
1472  fa->polys = poly;
1473  poly->numverts = lnumverts;
1474 
1475  for (i=0 ; i<lnumverts ; i++)
1476  {
1477  lindex = currentmodel->surfedges[fa->firstedge + i];
1478 
1479  if (lindex > 0)
1480  {
1481  r_pedge = &pedges[lindex];
1482  vec = currentmodel->vertexes[r_pedge->v[0]].position;
1483  }
1484  else
1485  {
1486  r_pedge = &pedges[-lindex];
1487  vec = currentmodel->vertexes[r_pedge->v[1]].position;
1488  }
1489  s = DotProduct (vec, fa->texinfo->vecs[0]) + fa->texinfo->vecs[0][3];
1490  s /= fa->texinfo->image->width;
1491 
1492  t = DotProduct (vec, fa->texinfo->vecs[1]) + fa->texinfo->vecs[1][3];
1493  t /= fa->texinfo->image->height;
1494 
1495  VectorAdd (total, vec, total);
1496  VectorCopy (vec, poly->verts[i]);
1497  poly->verts[i][3] = s;
1498  poly->verts[i][4] = t;
1499 
1500  //
1501  // lightmap texture coordinates
1502  //
1503  s = DotProduct (vec, fa->texinfo->vecs[0]) + fa->texinfo->vecs[0][3];
1504  s -= fa->texturemins[0];
1505  s += fa->light_s*16;
1506  s += 8;
1507  s /= BLOCK_WIDTH*16; //fa->texinfo->texture->width;
1508 
1509  t = DotProduct (vec, fa->texinfo->vecs[1]) + fa->texinfo->vecs[1][3];
1510  t -= fa->texturemins[1];
1511  t += fa->light_t*16;
1512  t += 8;
1513  t /= BLOCK_HEIGHT*16; //fa->texinfo->texture->height;
1514 
1515  poly->verts[i][5] = s;
1516  poly->verts[i][6] = t;
1517  }
1518 
1519  poly->numverts = lnumverts;
1520 
1521 }

Referenced by Mod_LoadFaces().

◆ GL_CreateSurfaceLightmap()

void GL_CreateSurfaceLightmap ( msurface_t surf)

Definition at line 1528 of file gl_rsurf.c.

1529 {
1530  int smax, tmax;
1531  byte *base;
1532 
1533  if (surf->flags & (SURF_DRAWSKY|SURF_DRAWTURB))
1534  return;
1535 
1536  smax = (surf->extents[0]>>4)+1;
1537  tmax = (surf->extents[1]>>4)+1;
1538 
1539  if ( !LM_AllocBlock( smax, tmax, &surf->light_s, &surf->light_t ) )
1540  {
1541  LM_UploadBlock( false );
1542  LM_InitBlock();
1543  if ( !LM_AllocBlock( smax, tmax, &surf->light_s, &surf->light_t ) )
1544  {
1545  ri.Sys_Error( ERR_FATAL, "Consecutive calls to LM_AllocBlock(%d,%d) failed\n", smax, tmax );
1546  }
1547  }
1548 
1550 
1551  base = gl_lms.lightmap_buffer;
1552  base += (surf->light_t * BLOCK_WIDTH + surf->light_s) * LIGHTMAP_BYTES;
1553 
1554  R_SetCacheState( surf );
1556 }

Referenced by Mod_LoadFaces().

◆ GL_EndBuildingLightmaps()

void GL_EndBuildingLightmaps ( void  )

Definition at line 1658 of file gl_rsurf.c.

1659 {
1660  LM_UploadBlock( false );
1661  GL_EnableMultitexture( false );
1662 }

Referenced by Mod_LoadFaces().

◆ Mod_ClusterPVS()

byte* Mod_ClusterPVS ( int  cluster,
model_t model 
)

Definition at line 124 of file gl_model.c.

125 {
126  if (cluster == -1 || !model->vis)
127  return mod_novis;
128  return Mod_DecompressVis ( (byte *)model->vis + model->vis->bitofs[cluster][DVIS_PVS],
129  model);
130 }

◆ Mod_DecompressVis()

byte* Mod_DecompressVis ( byte in,
model_t model 
)

Definition at line 79 of file gl_model.c.

80 {
81  static byte decompressed[MAX_MAP_LEAFS/8];
82  int c;
83  byte *out;
84  int row;
85 
86  row = (model->vis->numclusters+7)>>3;
87  out = decompressed;
88 
89  if (!in)
90  { // no vis info, so make all visible
91  while (row)
92  {
93  *out++ = 0xff;
94  row--;
95  }
96  return decompressed;
97  }
98 
99  do
100  {
101  if (*in)
102  {
103  *out++ = *in++;
104  continue;
105  }
106 
107  c = in[1];
108  in += 2;
109  while (c)
110  {
111  *out++ = 0;
112  c--;
113  }
114  } while (out - decompressed < row);
115 
116  return decompressed;
117 }

Referenced by Mod_ClusterPVS().

◆ Mod_ForName()

model_t* Mod_ForName ( char *  name,
qboolean  crash 
)

Definition at line 177 of file gl_model.c.

178 {
179  model_t *mod;
180  unsigned *buf;
181  int i;
182 
183  if (!name[0])
184  ri.Sys_Error (ERR_DROP, "Mod_ForName: NULL name");
185 
186  //
187  // inline models are grabbed only from worldmodel
188  //
189  if (name[0] == '*')
190  {
191  i = atoi(name+1);
192  if (i < 1 || !r_worldmodel || i >= r_worldmodel->numsubmodels)
193  ri.Sys_Error (ERR_DROP, "bad inline model number");
194  return &mod_inline[i];
195  }
196 
197  //
198  // search the currently loaded models
199  //
200  for (i=0 , mod=mod_known ; i<mod_numknown ; i++, mod++)
201  {
202  if (!mod->name[0])
203  continue;
204  if (!strcmp (mod->name, name) )
205  return mod;
206  }
207 
208  //
209  // find a free model slot spot
210  //
211  for (i=0 , mod=mod_known ; i<mod_numknown ; i++, mod++)
212  {
213  if (!mod->name[0])
214  break; // free spot
215  }
216  if (i == mod_numknown)
217  {
219  ri.Sys_Error (ERR_DROP, "mod_numknown == MAX_MOD_KNOWN");
220  mod_numknown++;
221  }
222  strcpy (mod->name, name);
223 
224  //
225  // load the file
226  //
227  modfilelen = ri.FS_LoadFile (mod->name, (void **)&buf);
228  if (!buf)
229  {
230  if (crash)
231  ri.Sys_Error (ERR_DROP, "Mod_NumForName: %s not found", mod->name);
232  memset (mod->name, 0, sizeof(mod->name));
233  return NULL;
234  }
235 
236  loadmodel = mod;
237 
238  //
239  // fill it in
240  //
241 
242 
243  // call the apropriate loader
244 
245  switch (LittleLong(*(unsigned *)buf))
246  {
247  case IDALIASHEADER:
248  loadmodel->extradata = Hunk_Begin (0x200000);
249  Mod_LoadAliasModel (mod, buf);
250  break;
251 
252  case IDSPRITEHEADER:
253  loadmodel->extradata = Hunk_Begin (0x10000);
254  Mod_LoadSpriteModel (mod, buf);
255  break;
256 
257  case IDBSPHEADER:
258  loadmodel->extradata = Hunk_Begin (0x1000000);
259  Mod_LoadBrushModel (mod, buf);
260  break;
261 
262  default:
263  ri.Sys_Error (ERR_DROP,"Mod_NumForName: unknown fileid for %s", mod->name);
264  break;
265  }
266 
268 
269  ri.FS_FreeFile (buf);
270 
271  return mod;
272 }

Referenced by R_BeginRegistration(), and R_RegisterModel().

◆ Mod_Free()

void Mod_Free ( model_t mod)

Definition at line 1206 of file gl_model.c.

1207 {
1208  Hunk_Free (mod->extradata);
1209  memset (mod, 0, sizeof(*mod));
1210 }

Referenced by Mod_FreeAll(), R_BeginRegistration(), and R_EndRegistration().

◆ Mod_FreeAll()

void Mod_FreeAll ( void  )

Definition at line 1217 of file gl_model.c.

1218 {
1219  int i;
1220 
1221  for (i=0 ; i<mod_numknown ; i++)
1222  {
1223  if (mod_known[i].extradatasize)
1224  Mod_Free (&mod_known[i]);
1225  }
1226 }

◆ Mod_Init()

void Mod_Init ( void  )

Definition at line 163 of file gl_model.c.

164 {
165  memset (mod_novis, 0xff, sizeof(mod_novis));
166 }

◆ Mod_LoadAliasModel()

void Mod_LoadAliasModel ( model_t mod,
void buffer 
)

Definition at line 932 of file gl_model.c.

933 {
934  int i, j;
935  dmdl_t *pinmodel, *pheader;
936  dstvert_t *pinst, *poutst;
937  dtriangle_t *pintri, *pouttri;
938  daliasframe_t *pinframe, *poutframe;
939  int *pincmd, *poutcmd;
940  int version;
941 
942  pinmodel = (dmdl_t *)buffer;
943 
944  version = LittleLong (pinmodel->version);
945  if (version != ALIAS_VERSION)
946  ri.Sys_Error (ERR_DROP, "%s has wrong version number (%i should be %i)",
947  mod->name, version, ALIAS_VERSION);
948 
949  pheader = Hunk_Alloc (LittleLong(pinmodel->ofs_end));
950 
951  // byte swap the header fields and sanity check
952  for (i=0 ; i<sizeof(dmdl_t)/4 ; i++)
953  ((int *)pheader)[i] = LittleLong (((int *)buffer)[i]);
954 
955  if (pheader->skinheight > MAX_LBM_HEIGHT)
956  ri.Sys_Error (ERR_DROP, "model %s has a skin taller than %d", mod->name,
958 
959  if (pheader->num_xyz <= 0)
960  ri.Sys_Error (ERR_DROP, "model %s has no vertices", mod->name);
961 
962  if (pheader->num_xyz > MAX_VERTS)
963  ri.Sys_Error (ERR_DROP, "model %s has too many vertices", mod->name);
964 
965  if (pheader->num_st <= 0)
966  ri.Sys_Error (ERR_DROP, "model %s has no st vertices", mod->name);
967 
968  if (pheader->num_tris <= 0)
969  ri.Sys_Error (ERR_DROP, "model %s has no triangles", mod->name);
970 
971  if (pheader->num_frames <= 0)
972  ri.Sys_Error (ERR_DROP, "model %s has no frames", mod->name);
973 
974 //
975 // load base s and t vertices (not used in gl version)
976 //
977  pinst = (dstvert_t *) ((byte *)pinmodel + pheader->ofs_st);
978  poutst = (dstvert_t *) ((byte *)pheader + pheader->ofs_st);
979 
980  for (i=0 ; i<pheader->num_st ; i++)
981  {
982  poutst[i].s = LittleShort (pinst[i].s);
983  poutst[i].t = LittleShort (pinst[i].t);
984  }
985 
986 //
987 // load triangle lists
988 //
989  pintri = (dtriangle_t *) ((byte *)pinmodel + pheader->ofs_tris);
990  pouttri = (dtriangle_t *) ((byte *)pheader + pheader->ofs_tris);
991 
992  for (i=0 ; i<pheader->num_tris ; i++)
993  {
994  for (j=0 ; j<3 ; j++)
995  {
996  pouttri[i].index_xyz[j] = LittleShort (pintri[i].index_xyz[j]);
997  pouttri[i].index_st[j] = LittleShort (pintri[i].index_st[j]);
998  }
999  }
1000 
1001 //
1002 // load the frames
1003 //
1004  for (i=0 ; i<pheader->num_frames ; i++)
1005  {
1006  pinframe = (daliasframe_t *) ((byte *)pinmodel
1007  + pheader->ofs_frames + i * pheader->framesize);
1008  poutframe = (daliasframe_t *) ((byte *)pheader
1009  + pheader->ofs_frames + i * pheader->framesize);
1010 
1011  memcpy (poutframe->name, pinframe->name, sizeof(poutframe->name));
1012  for (j=0 ; j<3 ; j++)
1013  {
1014  poutframe->scale[j] = LittleFloat (pinframe->scale[j]);
1015  poutframe->translate[j] = LittleFloat (pinframe->translate[j]);
1016  }
1017  // verts are all 8 bit, so no swapping needed
1018  memcpy (poutframe->verts, pinframe->verts,
1019  pheader->num_xyz*sizeof(dtrivertx_t));
1020 
1021  }
1022 
1023  mod->type = mod_alias;
1024 
1025  //
1026  // load the glcmds
1027  //
1028  pincmd = (int *) ((byte *)pinmodel + pheader->ofs_glcmds);
1029  poutcmd = (int *) ((byte *)pheader + pheader->ofs_glcmds);
1030  for (i=0 ; i<pheader->num_glcmds ; i++)
1031  poutcmd[i] = LittleLong (pincmd[i]);
1032 
1033 
1034  // register all skins
1035  memcpy ((char *)pheader + pheader->ofs_skins, (char *)pinmodel + pheader->ofs_skins,
1036  pheader->num_skins*MAX_SKINNAME);
1037  for (i=0 ; i<pheader->num_skins ; i++)
1038  {
1039  mod->skins[i] = GL_FindImage ((char *)pheader + pheader->ofs_skins + i*MAX_SKINNAME
1040  , it_skin);
1041  }
1042 
1043  mod->mins[0] = -32;
1044  mod->mins[1] = -32;
1045  mod->mins[2] = -32;
1046  mod->maxs[0] = 32;
1047  mod->maxs[1] = 32;
1048  mod->maxs[2] = 32;
1049 }

Referenced by Mod_ForName().

◆ Mod_LoadBrushModel()

void Mod_LoadBrushModel ( model_t mod,
void buffer 
)

Definition at line 852 of file gl_model.c.

853 {
854  int i;
855  dheader_t *header;
856  mmodel_t *bm;
857 
859  if (loadmodel != mod_known)
860  ri.Sys_Error (ERR_DROP, "Loaded a brush model after the world");
861 
862  header = (dheader_t *)buffer;
863 
864  i = LittleLong (header->version);
865  if (i != BSPVERSION)
866  ri.Sys_Error (ERR_DROP, "Mod_LoadBrushModel: %s has wrong version number (%i should be %i)", mod->name, i, BSPVERSION);
867 
868 // swap all the lumps
869  mod_base = (byte *)header;
870 
871  for (i=0 ; i<sizeof(dheader_t)/4 ; i++)
872  ((int *)header)[i] = LittleLong ( ((int *)header)[i]);
873 
874 // load into heap
875 
877  Mod_LoadEdges (&header->lumps[LUMP_EDGES]);
880  Mod_LoadPlanes (&header->lumps[LUMP_PLANES]);
881  Mod_LoadTexinfo (&header->lumps[LUMP_TEXINFO]);
882  Mod_LoadFaces (&header->lumps[LUMP_FACES]);
885  Mod_LoadLeafs (&header->lumps[LUMP_LEAFS]);
886  Mod_LoadNodes (&header->lumps[LUMP_NODES]);
887  Mod_LoadSubmodels (&header->lumps[LUMP_MODELS]);
888  mod->numframes = 2; // regular and alternate animation
889 
890 //
891 // set up the submodels
892 //
893  for (i=0 ; i<mod->numsubmodels ; i++)
894  {
895  model_t *starmod;
896 
897  bm = &mod->submodels[i];
898  starmod = &mod_inline[i];
899 
900  *starmod = *loadmodel;
901 
902  starmod->firstmodelsurface = bm->firstface;
903  starmod->nummodelsurfaces = bm->numfaces;
904  starmod->firstnode = bm->headnode;
905  if (starmod->firstnode >= loadmodel->numnodes)
906  ri.Sys_Error (ERR_DROP, "Inline model %i has bad firstnode", i);
907 
908  VectorCopy (bm->maxs, starmod->maxs);
909  VectorCopy (bm->mins, starmod->mins);
910  starmod->radius = bm->radius;
911 
912  if (i == 0)
913  *loadmodel = *starmod;
914 
915  starmod->numleafs = bm->visleafs;
916  }
917 }

Referenced by Mod_ForName().

◆ Mod_LoadEdges()

void Mod_LoadEdges ( lump_t l)

Definition at line 415 of file gl_model.c.

416 {
417  dedge_t *in;
418  medge_t *out;
419  int i, count;
420 
421  in = (void *)(mod_base + l->fileofs);
422  if (l->filelen % sizeof(*in))
423  ri.Sys_Error (ERR_DROP, "MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
424  count = l->filelen / sizeof(*in);
425  out = Hunk_Alloc ( (count + 1) * sizeof(*out));
426 
427  loadmodel->edges = out;
429 
430  for ( i=0 ; i<count ; i++, in++, out++)
431  {
432  out->v[0] = (unsigned short)LittleShort(in->v[0]);
433  out->v[1] = (unsigned short)LittleShort(in->v[1]);
434  }
435 }

Referenced by Mod_LoadBrushModel().

◆ Mod_LoadFaces()

void Mod_LoadFaces ( lump_t l)

Definition at line 558 of file gl_model.c.

559 {
560  dface_t *in;
561  msurface_t *out;
562  int i, count, surfnum;
563  int planenum, side;
564  int ti;
565 
566  in = (void *)(mod_base + l->fileofs);
567  if (l->filelen % sizeof(*in))
568  ri.Sys_Error (ERR_DROP, "MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
569  count = l->filelen / sizeof(*in);
570  out = Hunk_Alloc ( count*sizeof(*out));
571 
572  loadmodel->surfaces = out;
574 
576 
578 
579  for ( surfnum=0 ; surfnum<count ; surfnum++, in++, out++)
580  {
581  out->firstedge = LittleLong(in->firstedge);
582  out->numedges = LittleShort(in->numedges);
583  out->flags = 0;
584  out->polys = NULL;
585 
586  planenum = LittleShort(in->planenum);
587  side = LittleShort(in->side);
588  if (side)
589  out->flags |= SURF_PLANEBACK;
590 
591  out->plane = loadmodel->planes + planenum;
592 
593  ti = LittleShort (in->texinfo);
594  if (ti < 0 || ti >= loadmodel->numtexinfo)
595  ri.Sys_Error (ERR_DROP, "MOD_LoadBmodel: bad texinfo number");
596  out->texinfo = loadmodel->texinfo + ti;
597 
598  CalcSurfaceExtents (out);
599 
600  // lighting info
601 
602  for (i=0 ; i<MAXLIGHTMAPS ; i++)
603  out->styles[i] = in->styles[i];
604  i = LittleLong(in->lightofs);
605  if (i == -1)
606  out->samples = NULL;
607  else
608  out->samples = loadmodel->lightdata + i;
609 
610  // set the drawing flags
611 
612  if (out->texinfo->flags & SURF_WARP)
613  {
614  out->flags |= SURF_DRAWTURB;
615  for (i=0 ; i<2 ; i++)
616  {
617  out->extents[i] = 16384;
618  out->texturemins[i] = -8192;
619  }
620  GL_SubdivideSurface (out); // cut up polygon for warps
621  }
622 
623  // create lightmaps and polygons
626 
627  if (! (out->texinfo->flags & SURF_WARP) )
629 
630  }
631 
633 }

Referenced by Mod_LoadBrushModel().

◆ Mod_LoadLeafs()

void Mod_LoadLeafs ( lump_t l)

Definition at line 703 of file gl_model.c.

704 {
705  dleaf_t *in;
706  mleaf_t *out;
707  int i, j, count, p;
708 // glpoly_t *poly;
709 
710  in = (void *)(mod_base + l->fileofs);
711  if (l->filelen % sizeof(*in))
712  ri.Sys_Error (ERR_DROP, "MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
713  count = l->filelen / sizeof(*in);
714  out = Hunk_Alloc ( count*sizeof(*out));
715 
716  loadmodel->leafs = out;
718 
719  for ( i=0 ; i<count ; i++, in++, out++)
720  {
721  for (j=0 ; j<3 ; j++)
722  {
723  out->minmaxs[j] = LittleShort (in->mins[j]);
724  out->minmaxs[3+j] = LittleShort (in->maxs[j]);
725  }
726 
727  p = LittleLong(in->contents);
728  out->contents = p;
729 
730  out->cluster = LittleShort(in->cluster);
731  out->area = LittleShort(in->area);
732 
734  LittleShort(in->firstleafface);
735  out->nummarksurfaces = LittleShort(in->numleaffaces);
736 
737  // gl underwater warp
738 #if 0
739  if (out->contents & (CONTENTS_WATER|CONTENTS_SLIME|CONTENTS_LAVA|CONTENTS_THINWATER) )
740  {
741  for (j=0 ; j<out->nummarksurfaces ; j++)
742  {
744  for (poly = out->firstmarksurface[j]->polys ; poly ; poly=poly->next)
745  poly->flags |= SURF_UNDERWATER;
746  }
747  }
748 #endif
749  }
750 }

Referenced by Mod_LoadBrushModel().

◆ Mod_LoadLighting()

void Mod_LoadLighting ( lump_t l)

Definition at line 290 of file gl_model.c.

291 {
292  if (!l->filelen)
293  {
295  return;
296  }
298  memcpy (loadmodel->lightdata, mod_base + l->fileofs, l->filelen);
299 }

Referenced by Mod_LoadBrushModel().

◆ Mod_LoadMarksurfaces()

void Mod_LoadMarksurfaces ( lump_t l)

Definition at line 757 of file gl_model.c.

758 {
759  int i, j, count;
760  short *in;
761  msurface_t **out;
762 
763  in = (void *)(mod_base + l->fileofs);
764  if (l->filelen % sizeof(*in))
765  ri.Sys_Error (ERR_DROP, "MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
766  count = l->filelen / sizeof(*in);
767  out = Hunk_Alloc ( count*sizeof(*out));
768 
769  loadmodel->marksurfaces = out;
771 
772  for ( i=0 ; i<count ; i++)
773  {
774  j = LittleShort(in[i]);
775  if (j < 0 || j >= loadmodel->numsurfaces)
776  ri.Sys_Error (ERR_DROP, "Mod_ParseMarksurfaces: bad surface number");
777  out[i] = loadmodel->surfaces + j;
778  }
779 }

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 655 of file gl_model.c.

656 {
657  int i, j, count, p;
658  dnode_t *in;
659  mnode_t *out;
660 
661  in = (void *)(mod_base + l->fileofs);
662  if (l->filelen % sizeof(*in))
663  ri.Sys_Error (ERR_DROP, "MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
664  count = l->filelen / sizeof(*in);
665  out = Hunk_Alloc ( count*sizeof(*out));
666 
667  loadmodel->nodes = out;
669 
670  for ( i=0 ; i<count ; i++, in++, out++)
671  {
672  for (j=0 ; j<3 ; j++)
673  {
674  out->minmaxs[j] = LittleShort (in->mins[j]);
675  out->minmaxs[3+j] = LittleShort (in->maxs[j]);
676  }
677 
678  p = LittleLong(in->planenum);
679  out->plane = loadmodel->planes + p;
680 
681  out->firstsurface = LittleShort (in->firstface);
682  out->numsurfaces = LittleShort (in->numfaces);
683  out->contents = -1; // differentiate from leafs
684 
685  for (j=0 ; j<2 ; j++)
686  {
687  p = LittleLong (in->children[j]);
688  if (p >= 0)
689  out->children[j] = loadmodel->nodes + p;
690  else
691  out->children[j] = (mnode_t *)(loadmodel->leafs + (-1 - p));
692  }
693  }
694 
695  Mod_SetParent (loadmodel->nodes, NULL); // sets nodes and leafs
696 }

Referenced by Mod_LoadBrushModel().

◆ Mod_LoadPlanes()

void Mod_LoadPlanes ( lump_t l)

Definition at line 814 of file gl_model.c.

815 {
816  int i, j;
817  cplane_t *out;
818  dplane_t *in;
819  int count;
820  int bits;
821 
822  in = (void *)(mod_base + l->fileofs);
823  if (l->filelen % sizeof(*in))
824  ri.Sys_Error (ERR_DROP, "MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
825  count = l->filelen / sizeof(*in);
826  out = Hunk_Alloc ( count*2*sizeof(*out));
827 
828  loadmodel->planes = out;
830 
831  for ( i=0 ; i<count ; i++, in++, out++)
832  {
833  bits = 0;
834  for (j=0 ; j<3 ; j++)
835  {
836  out->normal[j] = LittleFloat (in->normal[j]);
837  if (out->normal[j] < 0)
838  bits |= 1<<j;
839  }
840 
841  out->dist = LittleFloat (in->dist);
842  out->type = LittleLong (in->type);
843  out->signbits = bits;
844  }
845 }

Referenced by Mod_LoadBrushModel().

◆ Mod_LoadSpriteModel()

void Mod_LoadSpriteModel ( model_t mod,
void buffer 
)

Definition at line 1064 of file gl_model.c.

1065 {
1066  dsprite_t *sprin, *sprout;
1067  int i;
1068 
1069  sprin = (dsprite_t *)buffer;
1070  sprout = Hunk_Alloc (modfilelen);
1071 
1072  sprout->ident = LittleLong (sprin->ident);
1073  sprout->version = LittleLong (sprin->version);
1074  sprout->numframes = LittleLong (sprin->numframes);
1075 
1076  if (sprout->version != SPRITE_VERSION)
1077  ri.Sys_Error (ERR_DROP, "%s has wrong version number (%i should be %i)",
1078  mod->name, sprout->version, SPRITE_VERSION);
1079 
1080  if (sprout->numframes > MAX_MD2SKINS)
1081  ri.Sys_Error (ERR_DROP, "%s has too many frames (%i > %i)",
1082  mod->name, sprout->numframes, MAX_MD2SKINS);
1083 
1084  // byte swap everything
1085  for (i=0 ; i<sprout->numframes ; i++)
1086  {
1087  sprout->frames[i].width = LittleLong (sprin->frames[i].width);
1088  sprout->frames[i].height = LittleLong (sprin->frames[i].height);
1089  sprout->frames[i].origin_x = LittleLong (sprin->frames[i].origin_x);
1090  sprout->frames[i].origin_y = LittleLong (sprin->frames[i].origin_y);
1091  memcpy (sprout->frames[i].name, sprin->frames[i].name, MAX_SKINNAME);
1092  mod->skins[i] = GL_FindImage (sprout->frames[i].name,
1093  it_sprite);
1094  }
1095 
1096  mod->type = mod_sprite;
1097 }

Referenced by Mod_ForName().

◆ Mod_LoadSubmodels()

void Mod_LoadSubmodels ( lump_t l)

Definition at line 380 of file gl_model.c.

381 {
382  dmodel_t *in;
383  mmodel_t *out;
384  int i, j, count;
385 
386  in = (void *)(mod_base + l->fileofs);
387  if (l->filelen % sizeof(*in))
388  ri.Sys_Error (ERR_DROP, "MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
389  count = l->filelen / sizeof(*in);
390  out = Hunk_Alloc ( count*sizeof(*out));
391 
392  loadmodel->submodels = out;
394 
395  for ( i=0 ; i<count ; i++, in++, out++)
396  {
397  for (j=0 ; j<3 ; j++)
398  { // spread the mins / maxs by a pixel
399  out->mins[j] = LittleFloat (in->mins[j]) - 1;
400  out->maxs[j] = LittleFloat (in->maxs[j]) + 1;
401  out->origin[j] = LittleFloat (in->origin[j]);
402  }
403  out->radius = RadiusFromBounds (out->mins, out->maxs);
404  out->headnode = LittleLong (in->headnode);
405  out->firstface = LittleLong (in->firstface);
406  out->numfaces = LittleLong (in->numfaces);
407  }
408 }

Referenced by Mod_LoadBrushModel().

◆ Mod_LoadSurfedges()

void Mod_LoadSurfedges ( lump_t l)

Definition at line 786 of file gl_model.c.

787 {
788  int i, count;
789  int *in, *out;
790 
791  in = (void *)(mod_base + l->fileofs);
792  if (l->filelen % sizeof(*in))
793  ri.Sys_Error (ERR_DROP, "MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
794  count = l->filelen / sizeof(*in);
795  if (count < 1 || count >= MAX_MAP_SURFEDGES)
796  ri.Sys_Error (ERR_DROP, "MOD_LoadBmodel: bad surfedges count in %s: %i",
797  loadmodel->name, count);
798 
799  out = Hunk_Alloc ( count*sizeof(*out));
800 
801  loadmodel->surfedges = out;
803 
804  for ( i=0 ; i<count ; i++)
805  out[i] = LittleLong (in[i]);
806 }

Referenced by Mod_LoadBrushModel().

◆ Mod_LoadTexinfo()

void Mod_LoadTexinfo ( lump_t l)

Definition at line 442 of file gl_model.c.

443 {
444  texinfo_t *in;
445  mtexinfo_t *out, *step;
446  int i, j, count;
447  char name[MAX_QPATH];
448  int next;
449 
450  in = (void *)(mod_base + l->fileofs);
451  if (l->filelen % sizeof(*in))
452  ri.Sys_Error (ERR_DROP, "MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
453  count = l->filelen / sizeof(*in);
454  out = Hunk_Alloc ( count*sizeof(*out));
455 
456  loadmodel->texinfo = out;
458 
459  for ( i=0 ; i<count ; i++, in++, out++)
460  {
461  for (j=0 ; j<4 ; j++)
462  {
463  out->vecs[0][j] = LittleFloat (in->vecs[0][j]);
464  out->vecs[1][j] = LittleFloat (in->vecs[1][j]);
465  }
466 
467  out->flags = LittleLong (in->flags);
468  next = LittleLong (in->nexttexinfo);
469  if (next > 0)
470  out->next = loadmodel->texinfo + next;
471  else
472  out->next = NULL;
473  Com_sprintf (name, sizeof(name), "textures/%s.wal", in->texture);
474 
475  out->image = GL_FindImage (name, it_wall);
476  if (!out->image)
477  {
478  ri.Con_Printf (PRINT_ALL, "Couldn't load %s\n", name);
479  out->image = r_notexture;
480  }
481  }
482 
483  // count animation frames
484  for (i=0 ; i<count ; i++)
485  {
486  out = &loadmodel->texinfo[i];
487  out->numframes = 1;
488  for (step = out->next ; step && step != out ; step=step->next)
489  out->numframes++;
490  }
491 }

Referenced by Mod_LoadBrushModel().

◆ Mod_LoadVertexes()

void Mod_LoadVertexes ( lump_t l)

Definition at line 333 of file gl_model.c.

334 {
335  dvertex_t *in;
336  mvertex_t *out;
337  int i, count;
338 
339  in = (void *)(mod_base + l->fileofs);
340  if (l->filelen % sizeof(*in))
341  ri.Sys_Error (ERR_DROP, "MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
342  count = l->filelen / sizeof(*in);
343  out = Hunk_Alloc ( count*sizeof(*out));
344 
345  loadmodel->vertexes = out;
347 
348  for ( i=0 ; i<count ; i++, in++, out++)
349  {
350  out->position[0] = LittleFloat (in->point[0]);
351  out->position[1] = LittleFloat (in->point[1]);
352  out->position[2] = LittleFloat (in->point[2]);
353  }
354 }

Referenced by Mod_LoadBrushModel().

◆ Mod_LoadVisibility()

void Mod_LoadVisibility ( lump_t l)

Definition at line 307 of file gl_model.c.

308 {
309  int i;
310 
311  if (!l->filelen)
312  {
313  loadmodel->vis = NULL;
314  return;
315  }
316  loadmodel->vis = Hunk_Alloc ( l->filelen);
317  memcpy (loadmodel->vis, mod_base + l->fileofs, l->filelen);
318 
320  for (i=0 ; i<loadmodel->vis->numclusters ; i++)
321  {
322  loadmodel->vis->bitofs[i][0] = LittleLong (loadmodel->vis->bitofs[i][0]);
323  loadmodel->vis->bitofs[i][1] = LittleLong (loadmodel->vis->bitofs[i][1]);
324  }
325 }

Referenced by Mod_LoadBrushModel().

◆ Mod_Modellist_f()

void Mod_Modellist_f ( void  )

Definition at line 140 of file gl_model.c.

141 {
142  int i;
143  model_t *mod;
144  int total;
145 
146  total = 0;
147  ri.Con_Printf (PRINT_ALL,"Loaded models:\n");
148  for (i=0, mod=mod_known ; i < mod_numknown ; i++, mod++)
149  {
150  if (!mod->name[0])
151  continue;
152  ri.Con_Printf (PRINT_ALL, "%8i : %s\n",mod->extradatasize, mod->name);
153  total += mod->extradatasize;
154  }
155  ri.Con_Printf (PRINT_ALL, "Total resident: %i\n", total);
156 }

◆ Mod_PointInLeaf()

mleaf_t* Mod_PointInLeaf ( vec3_t  p,
model_t model 
)

Definition at line 48 of file gl_model.c.

49 {
50  mnode_t *node;
51  float d;
52  cplane_t *plane;
53 
54  if (!model || !model->nodes)
55  ri.Sys_Error (ERR_DROP, "Mod_PointInLeaf: bad model");
56 
57  node = model->nodes;
58  while (1)
59  {
60  if (node->contents != -1)
61  return (mleaf_t *)node;
62  plane = node->plane;
63  d = DotProduct (p,plane->normal) - plane->dist;
64  if (d > 0)
65  node = node->children[0];
66  else
67  node = node->children[1];
68  }
69 
70  return NULL; // never reached
71 }

◆ Mod_SetParent()

void Mod_SetParent ( mnode_t node,
mnode_t parent 
)

Definition at line 641 of file gl_model.c.

642 {
643  node->parent = parent;
644  if (node->contents != -1)
645  return;
646  Mod_SetParent (node->children[0], node);
647  Mod_SetParent (node->children[1], node);
648 }

Referenced by Mod_LoadNodes().

◆ R_BeginRegistration()

void R_BeginRegistration ( char *  model)

Definition at line 1108 of file gl_model.c.

1109 {
1110  char fullname[MAX_QPATH];
1111  cvar_t *flushmap;
1112 
1114  r_oldviewcluster = -1; // force markleafs
1115 
1116  Com_sprintf (fullname, sizeof(fullname), "maps/%s.bsp", model);
1117 
1118  // explicitly free the old map if different
1119  // this guarantees that mod_known[0] is the world map
1120  flushmap = ri.Cvar_Get ("flushmap", "0", 0);
1121  if ( strcmp(mod_known[0].name, fullname) || flushmap->value)
1122  Mod_Free (&mod_known[0]);
1123  r_worldmodel = Mod_ForName(fullname, true);
1124 
1125  r_viewcluster = -1;
1126 }

◆ R_EndRegistration()

void R_EndRegistration ( void  )

Definition at line 1179 of file gl_model.c.

1180 {
1181  int i;
1182  model_t *mod;
1183 
1184  for (i=0, mod=mod_known ; i<mod_numknown ; i++, mod++)
1185  {
1186  if (!mod->name[0])
1187  continue;
1189  { // don't need this model
1190  Mod_Free (mod);
1191  }
1192  }
1193 
1195 }

◆ R_RegisterModel()

struct model_s* R_RegisterModel ( char *  name)

Definition at line 1135 of file gl_model.c.

1136 {
1137  model_t *mod;
1138  int i;
1139  dsprite_t *sprout;
1140  dmdl_t *pheader;
1141 
1142  mod = Mod_ForName (name, false);
1143  if (mod)
1144  {
1146 
1147  // register any images used by the models
1148  if (mod->type == mod_sprite)
1149  {
1150  sprout = (dsprite_t *)mod->extradata;
1151  for (i=0 ; i<sprout->numframes ; i++)
1152  mod->skins[i] = GL_FindImage (sprout->frames[i].name, it_sprite);
1153  }
1154  else if (mod->type == mod_alias)
1155  {
1156  pheader = (dmdl_t *)mod->extradata;
1157  for (i=0 ; i<pheader->num_skins ; i++)
1158  mod->skins[i] = GL_FindImage ((char *)pheader + pheader->ofs_skins + i*MAX_SKINNAME, it_skin);
1159 //PGM
1160  mod->numframes = pheader->num_frames;
1161 //PGM
1162  }
1163  else if (mod->type == mod_brush)
1164  {
1165  for (i=0 ; i<mod->numtexinfo ; i++)
1167  }
1168  }
1169  return mod;
1170 }

◆ RadiusFromBounds()

float RadiusFromBounds ( vec3_t  mins,
vec3_t  maxs 
)

Definition at line 361 of file gl_model.c.

362 {
363  int i;
364  vec3_t corner;
365 
366  for (i=0 ; i<3 ; i++)
367  {
368  corner[i] = fabs(mins[i]) > fabs(maxs[i]) ? fabs(mins[i]) : fabs(maxs[i]);
369  }
370 
371  return VectorLength (corner);
372 }

Referenced by Mod_LoadSubmodels().

Variable Documentation

◆ loadmodel

◆ mod_base

◆ mod_inline

model_t mod_inline[MAX_MOD_KNOWN]

Definition at line 39 of file gl_model.c.

Referenced by Mod_ForName(), and Mod_LoadBrushModel().

◆ mod_known

◆ mod_novis

byte mod_novis[MAX_MAP_LEAFS/8]

Definition at line 32 of file gl_model.c.

Referenced by Mod_ClusterPVS(), and Mod_Init().

◆ mod_numknown

int mod_numknown

Definition at line 36 of file gl_model.c.

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

◆ modfilelen

int modfilelen

Definition at line 25 of file gl_model.c.

Referenced by Mod_ForName(), and Mod_LoadSpriteModel().

◆ registration_sequence

int registration_sequence

Definition at line 41 of file gl_model.c.

Referenced by R_BeginRegistration(), R_EndRegistration(), and R_RegisterModel().

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
cplane_s::normal
vec3_t normal
Definition: q_shared.h:415
LUMP_EDGES
#define LUMP_EDGES
Definition: qfiles.h:273
Mod_LoadNodes
void Mod_LoadNodes(lump_t *l)
Definition: gl_model.c:655
dmdl_t::ofs_glcmds
int ofs_glcmds
Definition: qfiles.h:157
cplane_s::type
byte type
Definition: q_shared.h:417
currentmodel
model_t * currentmodel
Definition: r_main.c:39
dheader_t
Definition: qfiles.h:283
r_framecount
int r_framecount
Definition: r_main.c:97
msurface_s::plane
mplane_t * plane
Definition: r_model.h:100
msurface_s::styles
byte styles[MAXLIGHTMAPS]
Definition: r_model.h:115
Hunk_Begin
void * Hunk_Begin(int maxsize)
Definition: q_shwin.c:41
MAX_MOD_KNOWN
#define MAX_MOD_KNOWN
Definition: gl_model.c:34
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
lightstyle_t::rgb
float rgb[3]
Definition: ref.h:98
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
Mod_LoadLeafs
void Mod_LoadLeafs(lump_t *l)
Definition: gl_model.c:703
lump_t::filelen
int filelen
Definition: qfiles.h:259
r_notexture
image_t * r_notexture
Definition: gl_rmain.c:44
CONTENTS_WATER
#define CONTENTS_WATER
Definition: qfiles.h:338
mvertex_t
Definition: r_model.h:45
model_s::nummodelsurfaces
int nummodelsurfaces
Definition: r_model.h:196
mmodel_t::numfaces
int numfaces
Definition: gl_model.h:53
gl_state
glstate_t gl_state
Definition: gl_rmain.c:42
dplane_t
Definition: qfiles.h:318
msurface_s::light_t
int light_t
Definition: gl_model.h:108
Hunk_Free
void Hunk_Free(void *base)
Definition: q_shwin.c:99
ri
refimport_t ri
Definition: r_main.c:25
BLOCK_HEIGHT
#define BLOCK_HEIGHT
Definition: gl_rsurf.c:36
Mod_LoadVisibility
void Mod_LoadVisibility(lump_t *l)
Definition: gl_model.c:307
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
mmodel_t::visleafs
int visleafs
Definition: gl_model.h:52
dmdl_t::num_tris
int num_tris
Definition: qfiles.h:149
gl_texture1
int gl_texture1
Definition: gl_rmain.c:35
cplane_s::signbits
byte signbits
Definition: q_shared.h:418
glpoly_s::verts
float verts[4][VERTEXSIZE]
Definition: gl_model.h:92
dsprframe_t::height
int height
Definition: qfiles.h:176
model_s::edges
medge_t * edges
Definition: r_model.h:211
mtexinfo_s
Definition: r_model.h:83
refimport_t::FS_LoadFile
int(* FS_LoadFile)(char *name, void **buf)
Definition: ref.h:209
VERTEXSIZE
#define VERTEXSIZE
Definition: gl_model.h:84
refimport_t::Cvar_Get
cvar_t *(* Cvar_Get)(char *name, char *value, int flags)
Definition: ref.h:216
cvar_s::string
char * string
Definition: q_shared.h:327
VectorClear
#define VectorClear(a)
Definition: q_shared.h:166
i
int i
Definition: q_shared.c:305
msurface_s::numedges
int numedges
Definition: r_model.h:104
model_s::firstnode
int firstnode
Definition: r_model.h:214
LUMP_LEAFS
#define LUMP_LEAFS
Definition: qfiles.h:270
GL_FreeUnusedImages
void GL_FreeUnusedImages(void)
Definition: gl_image.c:1442
mnode_s::parent
struct mnode_s * parent
Definition: r_model.h:131
dstvert_t::s
short s
Definition: qfiles.h:97
MAX_MAP_SURFEDGES
#define MAX_MAP_SURFEDGES
Definition: qfiles.h:246
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
Mod_LoadEdges
void Mod_LoadEdges(lump_t *l)
Definition: gl_model.c:415
glpoly_s::next
struct glpoly_s * next
Definition: gl_model.h:88
mleaf_s::firstmarksurface
msurface_t ** firstmarksurface
Definition: r_model.h:157
dtrivertx_t
Definition: qfiles.h:107
Mod_DecompressVis
byte * Mod_DecompressVis(byte *in, model_t *model)
Definition: gl_model.c:79
r_oldviewcluster
int r_oldviewcluster
Definition: r_local.h:791
model_s::marksurfaces
msurface_t ** marksurfaces
Definition: r_model.h:227
msurface_s::samples
byte * samples
Definition: r_model.h:116
mmodel_t
Definition: gl_model.h:46
mnode_s::children
struct mnode_s * children[2]
Definition: r_model.h:135
GL_CreateSurfaceLightmap
void GL_CreateSurfaceLightmap(msurface_t *surf)
Definition: gl_rsurf.c:1528
mod_base
byte * mod_base
Definition: gl_model.c:282
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
Mod_LoadVertexes
void Mod_LoadVertexes(lump_t *l)
Definition: gl_model.c:333
mod_inline
model_t mod_inline[MAX_MOD_KNOWN]
Definition: gl_model.c:39
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
SURF_TRANS66
#define SURF_TRANS66
Definition: qfiles.h:374
model_s::extradata
void * extradata
Definition: r_model.h:235
Mod_LoadTexinfo
void Mod_LoadTexinfo(lump_t *l)
Definition: gl_model.c:442
dvertex_t
Definition: qfiles.h:300
refimport_t::FS_FreeFile
void(* FS_FreeFile)(void *buf)
Definition: ref.h:210
r_viewcluster
int r_viewcluster
Definition: r_main.c:108
j
GLint j
Definition: qgl_win.c:150
IDBSPHEADER
#define IDBSPHEADER
Definition: qfiles.h:219
Mod_LoadSpriteModel
void Mod_LoadSpriteModel(model_t *mod, void *buffer)
Definition: gl_model.c:1064
Mod_LoadSurfedges
void Mod_LoadSurfedges(lump_t *l)
Definition: gl_model.c:786
model_s::numsubmodels
int numsubmodels
Definition: r_model.h:198
mvertex_t::position
vec3_t position
Definition: r_model.h:47
gl_tex_alpha_format
int gl_tex_alpha_format
Definition: gl_image.c:43
dsprite_t
Definition: qfiles.h:181
model_s::numedges
int numedges
Definition: r_model.h:210
glpoly_s::numverts
int numverts
Definition: gl_model.h:90
SURF_PLANEBACK
#define SURF_PLANEBACK
Definition: r_model.h:68
dtriangle_t::index_st
short index_st[3]
Definition: qfiles.h:104
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
GL_FindImage
image_t * GL_FindImage(char *name, imagetype_t type)
Definition: gl_image.c:1363
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
dmdl_t::ofs_end
int ofs_end
Definition: qfiles.h:158
GL_EnableMultitexture
void GL_EnableMultitexture(qboolean enable)
Definition: gl_image.c:71
LM_InitBlock
static void LM_InitBlock(void)
Definition: gl_rsurf.c:1354
model_s::numframes
int numframes
Definition: r_model.h:178
LittleFloat
float LittleFloat(float l)
Definition: q_shared.c:950
SPRITE_VERSION
#define SPRITE_VERSION
Definition: qfiles.h:172
model_s::texinfo
mtexinfo_t * texinfo
Definition: r_model.h:218
dmdl_t::ofs_frames
int ofs_frames
Definition: qfiles.h:156
Mod_LoadLighting
void Mod_LoadLighting(lump_t *l)
Definition: gl_model.c:290
dvis_t::numclusters
int numclusters
Definition: qfiles.h:465
medge_t
Definition: r_model.h:77
LittleLong
int LittleLong(int l)
Definition: q_shared.c:948
image_s::height
int height
Definition: r_local.h:75
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
RadiusFromBounds
float RadiusFromBounds(vec3_t mins, vec3_t maxs)
Definition: gl_model.c:361
LIGHTMAP_BYTES
#define LIGHTMAP_BYTES
Definition: gl_rsurf.c:33
loadmodel
model_t * loadmodel
Definition: gl_model.c:24
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
mmodel_t::headnode
int headnode
Definition: gl_model.h:51
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
GL_BuildPolygonFromSurface
void GL_BuildPolygonFromSurface(msurface_t *fa)
Definition: gl_rsurf.c:1450
model_s::mins
vec3_t mins
Definition: r_model.h:185
mleaf_s::cluster
int cluster
Definition: r_model.h:154
LM_AllocBlock
static qboolean LM_AllocBlock(int w, int h, int *x, int *y)
Definition: gl_rsurf.c:1411
GL_EndBuildingLightmaps
void GL_EndBuildingLightmaps(void)
Definition: gl_rsurf.c:1658
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
GL_Bind
void GL_Bind(int texnum)
Definition: gl_image.c:137
modfilelen
int modfilelen
Definition: gl_model.c:25
r_newrefdef
refdef_t r_newrefdef
Definition: r_main.c:38
DotProduct
#define DotProduct(x, y)
Definition: q_shared.h:162
dmdl_t::num_xyz
int num_xyz
Definition: qfiles.h:147
SURF_TRANS33
#define SURF_TRANS33
Definition: qfiles.h:373
r_worldmodel
model_t * r_worldmodel
Definition: r_main.c:41
mmodel_t::radius
float radius
Definition: gl_model.h:50
cvar_s::value
float value
Definition: q_shared.h:331
cplane_s::dist
float dist
Definition: q_shared.h:416
BLOCK_WIDTH
#define BLOCK_WIDTH
Definition: gl_rsurf.c:35
Mod_SetParent
void Mod_SetParent(mnode_t *node, mnode_t *parent)
Definition: gl_model.c:641
model_s::lightdata
byte * lightdata
Definition: r_model.h:231
TEXNUM_LIGHTMAPS
#define TEXNUM_LIGHTMAPS
Definition: gl_local.h:103
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
gllightmapstate_t::lightmap_buffer
byte lightmap_buffer[4 *BLOCK_WIDTH *BLOCK_HEIGHT]
Definition: gl_rsurf.c:56
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
image_s::width
int width
Definition: r_local.h:75
GL_SubdivideSurface
void GL_SubdivideSurface(msurface_t *fa)
Definition: gl_warp.c:164
daliasframe_t::translate
float translate[3]
Definition: qfiles.h:122
gllightmapstate_t::current_lightmap_texture
int current_lightmap_texture
Definition: gl_rsurf.c:48
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
it_skin
@ it_skin
Definition: r_local.h:64
dsprframe_t::width
int width
Definition: qfiles.h:176
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
ERR_FATAL
#define ERR_FATAL
Definition: qcommon.h:743
mod_numknown
int mod_numknown
Definition: gl_model.c:36
msurface_s::flags
int flags
Definition: r_model.h:101
mod_sprite
@ mod_sprite
Definition: r_model.h:169
lightstyle_t
Definition: ref.h:96
CalcSurfaceExtents
void CalcSurfaceExtents(msurface_t *s)
Definition: gl_model.c:500
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
VectorAdd
#define VectorAdd(a, b, c)
Definition: q_shared.h:164
model_s::maxs
vec3_t maxs
Definition: r_model.h:185
s
static fixed16_t s
Definition: r_scan.c:30
model_s::radius
float radius
Definition: gl_model.h:189
CONTENTS_SLIME
#define CONTENTS_SLIME
Definition: qfiles.h:337
mtexinfo_s::next
struct mtexinfo_s * next
Definition: r_model.h:90
r_pedge
medge_t * r_pedge
Definition: r_rast.c:41
mmodel_t::origin
vec3_t origin
Definition: gl_model.h:49
dsprite_t::ident
int ident
Definition: qfiles.h:182
msurface_s::polys
glpoly_t * polys
Definition: gl_model.h:111
gl_lms
static gllightmapstate_t gl_lms
Definition: gl_rsurf.c:59
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
model_s::skins
image_t * skins[MAX_MD2SKINS]
Definition: r_model.h:234
gl_tex_solid_format
int gl_tex_solid_format
Definition: gl_image.c:42
refdef_t::lightstyles
lightstyle_t * lightstyles
Definition: ref.h:114
mtexinfo_s::vecs
float vecs[2][4]
Definition: r_model.h:85
Mod_ForName
model_t * Mod_ForName(char *name, qboolean crash)
Definition: gl_model.c:177
BSPVERSION
#define BSPVERSION
Definition: qfiles.h:222
MAX_VERTS
#define MAX_VERTS
Definition: qfiles.h:90
model_s::name
char name[MAX_QPATH]
Definition: r_model.h:173
msurface_s::light_s
int light_s
Definition: gl_model.h:108
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
GL_BeginBuildingLightmaps
void GL_BeginBuildingLightmaps(model_t *m)
Definition: gl_rsurf.c:1565
dsprite_t::numframes
int numframes
Definition: qfiles.h:184
dsprframe_t::origin_y
int origin_y
Definition: qfiles.h:177
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
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
CONTENTS_LAVA
#define CONTENTS_LAVA
Definition: qfiles.h:336
model_s::numleafs
int numleafs
Definition: r_model.h:204
msurface_s::lightmaptexturenum
int lightmaptexturenum
Definition: gl_model.h:121
mmodel_t::mins
vec3_t mins
Definition: gl_model.h:48
MAX_SKINNAME
#define MAX_SKINNAME
Definition: qfiles.h:93
daliasframe_t::name
char name[16]
Definition: qfiles.h:123
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
Mod_Free
void Mod_Free(model_t *mod)
Definition: gl_model.c:1206
mtexinfo_s::flags
int flags
Definition: r_model.h:88
model_s::numnodes
int numnodes
Definition: r_model.h:213
glstate_t::lightmap_textures
int lightmap_textures
Definition: gl_local.h:416
registration_sequence
int registration_sequence
Definition: gl_model.c:41
msurface_s::texturemins
short texturemins[2]
Definition: r_model.h:109
ALIAS_VERSION
#define ALIAS_VERSION
Definition: qfiles.h:87
Mod_LoadFaces
void Mod_LoadFaces(lump_t *l)
Definition: gl_model.c:558
model_s::planes
mplane_t * planes
Definition: r_model.h:202
lightstyle_t::white
float white
Definition: ref.h:99
dsprframe_t::origin_x
int origin_x
Definition: qfiles.h:177
mod_novis
byte mod_novis[MAX_MAP_LEAFS/8]
Definition: gl_model.c:32
dsprite_t::version
int version
Definition: qfiles.h:183
dmdl_t::ofs_st
int ofs_st
Definition: qfiles.h:154
dmdl_t::num_st
int num_st
Definition: qfiles.h:148
dmdl_t::ofs_tris
int ofs_tris
Definition: qfiles.h:155
GL_LIGHTMAP_FORMAT
#define GL_LIGHTMAP_FORMAT
Definition: gl_rsurf.c:43
glpoly_s::flags
int flags
Definition: gl_model.h:91
IDALIASHEADER
#define IDALIASHEADER
Definition: qfiles.h:86
Mod_LoadAliasModel
void Mod_LoadAliasModel(model_t *mod, void *buffer)
Definition: gl_model.c:932
cplane_s
Definition: q_shared.h:413
R_BuildLightMap
void R_BuildLightMap(msurface_t *surf, byte *dest, int stride)
Definition: gl_light.c:455
R_SetCacheState
void R_SetCacheState(msurface_t *surf)
Definition: gl_light.c:437
mnode_s::numsurfaces
unsigned short numsurfaces
Definition: r_model.h:138
model_s::vertexes
mvertex_t * vertexes
Definition: r_model.h:208
SURF_UNDERWATER
#define SURF_UNDERWATER
Definition: gl_model.h:66
GL_SelectTexture
void GL_SelectTexture(GLenum texture)
Definition: gl_image.c:92
Mod_LoadSubmodels
void Mod_LoadSubmodels(lump_t *l)
Definition: gl_model.c:380
gllightmapstate_t::internal_format
int internal_format
Definition: gl_rsurf.c:47
MAX_LIGHTSTYLES
#define MAX_LIGHTSTYLES
Definition: q_shared.h:88
Mod_LoadBrushModel
void Mod_LoadBrushModel(model_t *mod, void *buffer)
Definition: gl_model.c:852
dtriangle_t
Definition: qfiles.h:101
Mod_LoadPlanes
void Mod_LoadPlanes(lump_t *l)
Definition: gl_model.c:814
gl_monolightmap
cvar_t * gl_monolightmap
Definition: gl_rmain.c:117
model_s::nummarksurfaces
int nummarksurfaces
Definition: r_model.h:226
mmodel_t::firstface
int firstface
Definition: gl_model.h:53
vec3_t
vec_t vec3_t[3]
Definition: q_shared.h:134
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
LM_UploadBlock
static void LM_UploadBlock(qboolean dynamic)
Definition: gl_rsurf.c:1359
mmodel_t::maxs
vec3_t maxs
Definition: gl_model.h:48
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
gllightmapstate_t::allocated
int allocated[BLOCK_WIDTH]
Definition: gl_rsurf.c:52
model_s::extradatasize
int extradatasize
Definition: r_model.h:236
mod_known
model_t mod_known[MAX_MOD_KNOWN]
Definition: gl_model.c:35
model_s::numsurfaces
int numsurfaces
Definition: r_model.h:220
Mod_LoadMarksurfaces
void Mod_LoadMarksurfaces(lump_t *l)
Definition: gl_model.c:757
glpoly_s
Definition: gl_model.h:86