mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-05-30 08:20:40 +00:00
big protototype cleanup. Now, except for a few cases, all non-static
prototypes are in headers files.
This commit is contained in:
parent
43fa6a4002
commit
ca4b3acd6c
102 changed files with 826 additions and 946 deletions
|
@ -40,6 +40,7 @@ static const char rcsid[] =
|
|||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
#include "QF/cvar.h"
|
||||
#include "QF/model.h"
|
||||
#include "QF/qendian.h"
|
||||
#include "QF/quakefs.h"
|
||||
|
@ -158,3 +159,133 @@ Mod_LoadLighting (lump_t *l)
|
|||
for (i = 0; i < l->filelen ; i++)
|
||||
*out++ = gammatable[*in++];
|
||||
}
|
||||
|
||||
msurface_t *warpface;
|
||||
|
||||
|
||||
void
|
||||
BoundPoly (int numverts, float *verts, vec3_t mins, vec3_t maxs)
|
||||
{
|
||||
float *v;
|
||||
int i, j;
|
||||
|
||||
mins[0] = mins[1] = mins[2] = 9999;
|
||||
maxs[0] = maxs[1] = maxs[2] = -9999;
|
||||
v = verts;
|
||||
for (i = 0; i < numverts; i++)
|
||||
for (j = 0; j < 3; j++, v++) {
|
||||
if (*v < mins[j])
|
||||
mins[j] = *v;
|
||||
if (*v > maxs[j])
|
||||
maxs[j] = *v;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SubdividePolygon (int numverts, float *verts)
|
||||
{
|
||||
float frac, m, s, t;
|
||||
float dist[64];
|
||||
float *v;
|
||||
int b, f, i, j, k;
|
||||
glpoly_t *poly;
|
||||
vec3_t mins, maxs;
|
||||
vec3_t front[64], back[64];
|
||||
|
||||
if (numverts > 60)
|
||||
Sys_Error ("numverts = %i", numverts);
|
||||
|
||||
BoundPoly (numverts, verts, mins, maxs);
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
m = (mins[i] + maxs[i]) * 0.5;
|
||||
m = gl_subdivide_size->value * floor (m / gl_subdivide_size->value +
|
||||
0.5);
|
||||
if (maxs[i] - m < 8)
|
||||
continue;
|
||||
if (m - mins[i] < 8)
|
||||
continue;
|
||||
|
||||
// cut it
|
||||
v = verts + i;
|
||||
for (j = 0; j < numverts; j++, v += 3)
|
||||
dist[j] = *v - m;
|
||||
|
||||
// wrap cases
|
||||
dist[j] = dist[0];
|
||||
v -= i;
|
||||
VectorCopy (verts, v);
|
||||
|
||||
f = b = 0;
|
||||
v = verts;
|
||||
for (j = 0; j < numverts; j++, v += 3) {
|
||||
if (dist[j] >= 0) {
|
||||
VectorCopy (v, front[f]);
|
||||
f++;
|
||||
}
|
||||
if (dist[j] <= 0) {
|
||||
VectorCopy (v, back[b]);
|
||||
b++;
|
||||
}
|
||||
if (dist[j] == 0 || dist[j + 1] == 0)
|
||||
continue;
|
||||
if ((dist[j] > 0) != (dist[j + 1] > 0)) {
|
||||
// clip point
|
||||
frac = dist[j] / (dist[j] - dist[j + 1]);
|
||||
for (k = 0; k < 3; k++)
|
||||
front[f][k] = back[b][k] = v[k] + frac * (v[3 + k] - v[k]);
|
||||
f++;
|
||||
b++;
|
||||
}
|
||||
}
|
||||
|
||||
SubdividePolygon (f, front[0]);
|
||||
SubdividePolygon (b, back[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
poly = Hunk_Alloc (sizeof (glpoly_t) + (numverts - 4) * VERTEXSIZE *
|
||||
sizeof (float));
|
||||
poly->next = warpface->polys;
|
||||
warpface->polys = poly;
|
||||
poly->numverts = numverts;
|
||||
for (i = 0; i < numverts; i++, verts += 3) {
|
||||
VectorCopy (verts, poly->verts[i]);
|
||||
s = DotProduct (verts, warpface->texinfo->vecs[0]);
|
||||
t = DotProduct (verts, warpface->texinfo->vecs[1]);
|
||||
poly->verts[i][3] = s;
|
||||
poly->verts[i][4] = t;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Mod_SubdivideSurface
|
||||
|
||||
Breaks a polygon up along axial 64 unit
|
||||
boundaries so that turbulent and sky warps
|
||||
can be done reasonably.
|
||||
*/
|
||||
void
|
||||
Mod_SubdivideSurface (msurface_t *fa)
|
||||
{
|
||||
float *vec;
|
||||
int lindex, numverts, i;
|
||||
vec3_t verts[64];
|
||||
|
||||
warpface = fa;
|
||||
|
||||
// convert edges back to a normal polygon
|
||||
numverts = 0;
|
||||
for (i = 0; i < fa->numedges; i++) {
|
||||
lindex = loadmodel->surfedges[fa->firstedge + i];
|
||||
|
||||
if (lindex > 0)
|
||||
vec = loadmodel->vertexes[loadmodel->edges[lindex].v[0]].position;
|
||||
else
|
||||
vec = loadmodel->vertexes[loadmodel->edges[-lindex].v[1]].position;
|
||||
VectorCopy (vec, verts[numverts]);
|
||||
numverts++;
|
||||
}
|
||||
|
||||
SubdividePolygon (numverts, verts[0]);
|
||||
}
|
||||
|
|
|
@ -55,10 +55,6 @@ byte mod_novis[MAX_MAP_LEAFS / 8];
|
|||
|
||||
cvar_t *gl_sky_divide;
|
||||
|
||||
void GL_SubdivideSurface (msurface_t *fa);
|
||||
void R_InitSky (struct texture_s *mt);
|
||||
|
||||
|
||||
mleaf_t *
|
||||
Mod_PointInLeaf (const vec3_t p, model_t *model)
|
||||
{
|
||||
|
@ -300,7 +296,7 @@ Mod_LoadVertexes (lump_t *l)
|
|||
|
||||
in = (void *) (mod_base + l->fileofs);
|
||||
if (l->filelen % sizeof (*in))
|
||||
Sys_Error ("MOD_LoadBmodel: funny lump size in %s", loadmodel->name);
|
||||
Sys_Error ("Mod_LoadBmodel: funny lump size in %s", loadmodel->name);
|
||||
count = l->filelen / sizeof (*in);
|
||||
out = Hunk_AllocName (count * sizeof (*out), loadname);
|
||||
|
||||
|
@ -322,7 +318,7 @@ Mod_LoadSubmodels (lump_t *l)
|
|||
|
||||
in = (void *) (mod_base + l->fileofs);
|
||||
if (l->filelen % sizeof (*in))
|
||||
Sys_Error ("MOD_LoadBmodel: funny lump size in %s", loadmodel->name);
|
||||
Sys_Error ("Mod_LoadBmodel: funny lump size in %s", loadmodel->name);
|
||||
count = l->filelen / sizeof (*in);
|
||||
out = Hunk_AllocName (count * sizeof (*out), loadname);
|
||||
|
||||
|
@ -352,7 +348,7 @@ Mod_LoadEdges (lump_t *l)
|
|||
|
||||
in = (void *) (mod_base + l->fileofs);
|
||||
if (l->filelen % sizeof (*in))
|
||||
Sys_Error ("MOD_LoadBmodel: funny lump size in %s", loadmodel->name);
|
||||
Sys_Error ("Mod_LoadBmodel: funny lump size in %s", loadmodel->name);
|
||||
count = l->filelen / sizeof (*in);
|
||||
out = Hunk_AllocName ((count + 1) * sizeof (*out), loadname);
|
||||
|
||||
|
@ -375,7 +371,7 @@ Mod_LoadTexinfo (lump_t *l)
|
|||
|
||||
in = (void *) (mod_base + l->fileofs);
|
||||
if (l->filelen % sizeof (*in))
|
||||
Sys_Error ("MOD_LoadBmodel: funny lump size in %s", loadmodel->name);
|
||||
Sys_Error ("Mod_LoadBmodel: funny lump size in %s", loadmodel->name);
|
||||
count = l->filelen / sizeof (*in);
|
||||
out = Hunk_AllocName (count * sizeof (*out), loadname);
|
||||
|
||||
|
@ -477,7 +473,7 @@ Mod_LoadFaces (lump_t *l)
|
|||
|
||||
in = (void *) (mod_base + l->fileofs);
|
||||
if (l->filelen % sizeof (*in))
|
||||
Sys_Error ("MOD_LoadBmodel: funny lump size in %s", loadmodel->name);
|
||||
Sys_Error ("Mod_LoadBmodel: funny lump size in %s", loadmodel->name);
|
||||
count = l->filelen / sizeof (*in);
|
||||
out = Hunk_AllocName (count * sizeof (*out), loadname);
|
||||
|
||||
|
@ -517,7 +513,7 @@ Mod_LoadFaces (lump_t *l)
|
|||
if (!strncmp (out->texinfo->texture->name, "sky", 3)) { // sky
|
||||
out->flags |= (SURF_DRAWSKY | SURF_DRAWTILED);
|
||||
if (gl_sky_divide && gl_sky_divide->int_val)
|
||||
GL_SubdivideSurface (out);
|
||||
Mod_SubdivideSurface (out);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -529,7 +525,7 @@ Mod_LoadFaces (lump_t *l)
|
|||
out->extents[i] = 16384;
|
||||
out->texturemins[i] = -8192;
|
||||
}
|
||||
GL_SubdivideSurface (out); // cut up polygon for warps
|
||||
Mod_SubdivideSurface (out); // cut up polygon for warps
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -554,7 +550,7 @@ Mod_LoadNodes (lump_t *l)
|
|||
|
||||
in = (void *) (mod_base + l->fileofs);
|
||||
if (l->filelen % sizeof (*in))
|
||||
Sys_Error ("MOD_LoadBmodel: funny lump size in %s", loadmodel->name);
|
||||
Sys_Error ("Mod_LoadBmodel: funny lump size in %s", loadmodel->name);
|
||||
count = l->filelen / sizeof (*in);
|
||||
out = Hunk_AllocName (count * sizeof (*out), loadname);
|
||||
|
||||
|
@ -595,7 +591,7 @@ Mod_LoadLeafs (lump_t *l)
|
|||
|
||||
in = (void *) (mod_base + l->fileofs);
|
||||
if (l->filelen % sizeof (*in))
|
||||
Sys_Error ("MOD_LoadBmodel: funny lump size in %s", loadmodel->name);
|
||||
Sys_Error ("Mod_LoadBmodel: funny lump size in %s", loadmodel->name);
|
||||
count = l->filelen / sizeof (*in);
|
||||
out = Hunk_AllocName (count * sizeof (*out), loadname);
|
||||
|
||||
|
@ -649,7 +645,7 @@ Mod_LoadClipnodes (lump_t *l)
|
|||
|
||||
in = (void *) (mod_base + l->fileofs);
|
||||
if (l->filelen % sizeof (*in))
|
||||
Sys_Error ("MOD_LoadBmodel: funny lump size in %s", loadmodel->name);
|
||||
Sys_Error ("Mod_LoadBmodel: funny lump size in %s", loadmodel->name);
|
||||
count = l->filelen / sizeof (*in);
|
||||
out = Hunk_AllocName (count * sizeof (*out), loadname);
|
||||
|
||||
|
@ -739,7 +735,7 @@ Mod_LoadMarksurfaces (lump_t *l)
|
|||
|
||||
in = (void *) (mod_base + l->fileofs);
|
||||
if (l->filelen % sizeof (*in))
|
||||
Sys_Error ("MOD_LoadBmodel: funny lump size in %s", loadmodel->name);
|
||||
Sys_Error ("Mod_LoadBmodel: funny lump size in %s", loadmodel->name);
|
||||
count = l->filelen / sizeof (*in);
|
||||
out = Hunk_AllocName (count * sizeof (*out), loadname);
|
||||
|
||||
|
@ -762,7 +758,7 @@ Mod_LoadSurfedges (lump_t *l)
|
|||
|
||||
in = (void *) (mod_base + l->fileofs);
|
||||
if (l->filelen % sizeof (*in))
|
||||
Sys_Error ("MOD_LoadBmodel: funny lump size in %s", loadmodel->name);
|
||||
Sys_Error ("Mod_LoadBmodel: funny lump size in %s", loadmodel->name);
|
||||
count = l->filelen / sizeof (*in);
|
||||
out = Hunk_AllocName (count * sizeof (*out), loadname);
|
||||
|
||||
|
@ -782,7 +778,7 @@ Mod_LoadPlanes (lump_t *l)
|
|||
|
||||
in = (void *) (mod_base + l->fileofs);
|
||||
if (l->filelen % sizeof (*in))
|
||||
Sys_Error ("MOD_LoadBmodel: funny lump size in %s", loadmodel->name);
|
||||
Sys_Error ("Mod_LoadBmodel: funny lump size in %s", loadmodel->name);
|
||||
count = l->filelen / sizeof (*in);
|
||||
out = Hunk_AllocName (count * 2 * sizeof (*out), loadname);
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ int mod_lightmap_bytes = 1;
|
|||
|
||||
|
||||
void
|
||||
GL_SubdivideSurface (msurface_t *fa)
|
||||
Mod_SubdivideSurface (msurface_t *fa)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -48,14 +48,6 @@ static const char rcsid[] =
|
|||
|
||||
#include "compat.h"
|
||||
|
||||
void Mod_LoadAliasModel (model_t *mod, void *buf,
|
||||
cache_allocator_t allocator);
|
||||
void Mod_LoadSpriteModel (model_t *mod, void *buf);
|
||||
void Mod_LoadBrushModel (model_t *mod, void *buf);
|
||||
model_t * Mod_RealLoadModel (model_t *mod, qboolean crash,
|
||||
cache_allocator_t allocator);
|
||||
void Mod_CallbackLoad (void *object, cache_allocator_t allocator);
|
||||
|
||||
model_t *loadmodel;
|
||||
char loadname[32]; // for hunk tags
|
||||
|
||||
|
@ -68,6 +60,7 @@ texture_t *r_notexture_mip;
|
|||
cvar_t *gl_mesh_cache;
|
||||
cvar_t *gl_subdivide_size;
|
||||
|
||||
static void Mod_CallbackLoad (void *object, cache_allocator_t allocator);
|
||||
|
||||
void
|
||||
Mod_Init (void)
|
||||
|
@ -147,24 +140,6 @@ Mod_FindName (const char *name)
|
|||
return mod;
|
||||
}
|
||||
|
||||
/*
|
||||
Mod_LoadModel
|
||||
|
||||
Loads a model into the cache
|
||||
*/
|
||||
model_t *
|
||||
Mod_LoadModel (model_t *mod, qboolean crash)
|
||||
{
|
||||
if (!mod->needload) {
|
||||
if (mod->type == mod_alias) {
|
||||
if (Cache_Check (&mod->cache))
|
||||
return mod;
|
||||
} else
|
||||
return mod; // not cached at all
|
||||
}
|
||||
return Mod_RealLoadModel (mod, crash, Cache_Alloc);
|
||||
}
|
||||
|
||||
model_t *
|
||||
Mod_RealLoadModel (model_t *mod, qboolean crash, cache_allocator_t allocator)
|
||||
{
|
||||
|
@ -231,12 +206,30 @@ Mod_RealLoadModel (model_t *mod, qboolean crash, cache_allocator_t allocator)
|
|||
return mod;
|
||||
}
|
||||
|
||||
/*
|
||||
Mod_LoadModel
|
||||
|
||||
Loads a model into the cache
|
||||
*/
|
||||
model_t *
|
||||
Mod_LoadModel (model_t *mod, qboolean crash)
|
||||
{
|
||||
if (!mod->needload) {
|
||||
if (mod->type == mod_alias) {
|
||||
if (Cache_Check (&mod->cache))
|
||||
return mod;
|
||||
} else
|
||||
return mod; // not cached at all
|
||||
}
|
||||
return Mod_RealLoadModel (mod, crash, Cache_Alloc);
|
||||
}
|
||||
|
||||
/*
|
||||
Mod_CallbackLoad
|
||||
|
||||
Callback used to load model automatically
|
||||
*/
|
||||
void
|
||||
static void
|
||||
Mod_CallbackLoad (void *object, cache_allocator_t allocator)
|
||||
{
|
||||
if (((model_t *)object)->type != mod_alias)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue