Fix the alias model loader for plugins.

This commit is contained in:
Bill Currie 2012-02-23 12:55:50 +09:00
parent 52e518bb1b
commit cbdbfdd12f
15 changed files with 141 additions and 85 deletions

View file

@ -440,7 +440,6 @@ void Mod_TouchModel (const char *name);
mleaf_t *Mod_PointInLeaf (const vec3_t p, model_t *model);
byte *Mod_LeafPVS (mleaf_t *leaf, model_t *model);
model_t *Mod_FindName (const char *name);
void Mod_LoadExternalSkins (model_t * mod);
int Mod_CalcFullbright (byte *in, byte *out, int pixels);
int Mod_Fullbright (byte * skin, int width, int height, char *name);
@ -448,11 +447,6 @@ void *Mod_LoadAliasFrame (void *pin, int *posenum, maliasframedesc_t *frame,
int extra);
void *Mod_LoadAliasGroup (void *pin, int *posenum, maliasframedesc_t *frame,
int extra);
void *Mod_LoadSkin (byte *skin, int skinsize, int snum, int gnum,
qboolean group, maliasskindesc_t *skindesc);
void Mod_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr, void *_m,
int _s, int extra);
void Mod_FinalizeAliasModel (model_t *m, aliashdr_t *hdr);
void Mod_SpriteLoadTexture (mspriteframe_t *pspriteframe, int framenum);
void Mod_LoadBrushModel (model_t *mod, void *buffer);

View file

@ -88,6 +88,13 @@ typedef struct vid_model_funcs_s {
void (*Mod_LoadAliasModel) (model_t *mod, void *buffer,
cache_allocator_t allocator);
void (*Mod_LoadSpriteModel) (model_t *mod, void *buffer);
void (*Mod_MakeAliasModelDisplayLists) (model_t *m, aliashdr_t *hdr,
void *_m, int _s, int extra);
void *(*Mod_LoadSkin) (byte *skin, int skinsize, int snum, int gnum,
qboolean group, maliasskindesc_t *skindesc);
void (*Mod_FinalizeAliasModel) (model_t *m, aliashdr_t *hdr);
void (*Mod_LoadExternalSkins) (model_t * mod);
int alias_cache;
struct skin_s *(*Skin_SetColormap) (struct skin_s *skin, int cmap);
struct skin_s *(*Skin_SetSkin) (struct skin_s *skin, int cmap,

View file

@ -7,10 +7,42 @@
extern vid_model_funcs_t *m_funcs;
void Mod_LoadExternalTextures (model_t *mod);
void Mod_LoadLighting (bsp_t *bsp);
void Mod_SubdivideSurface (msurface_t *fa);
void Mod_ProcessTexture(texture_t *tx);
void gl_Mod_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr, void *_m,
int _s, int extra);
void *gl_Mod_LoadSkin (byte *skin, int skinsize, int snum, int gnum,
qboolean group, maliasskindesc_t *skindesc);
void gl_Mod_FinalizeAliasModel (model_t *m, aliashdr_t *hdr);
void gl_Mod_LoadExternalSkins (model_t * mod);
void glsl_Mod_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr,
void *_m, int _s, int extra);
void *glsl_Mod_LoadSkin (byte *skin, int skinsize, int snum, int gnum,
qboolean group, maliasskindesc_t *skindesc);
void glsl_Mod_FinalizeAliasModel (model_t *m, aliashdr_t *hdr);
void glsl_Mod_LoadExternalSkins (model_t * mod);
void sw_Mod_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr, void *_m,
int _s, int extra);
void *sw_Mod_LoadSkin (byte *skin, int skinsize, int snum, int gnum,
qboolean group, maliasskindesc_t *skindesc);
void sw_Mod_FinalizeAliasModel (model_t *m, aliashdr_t *hdr);
void sw_Mod_LoadExternalSkins (model_t * mod);
void gl_Mod_LoadExternalTextures (model_t *mod);
void gl_Mod_LoadLighting (bsp_t *bsp);
void gl_Mod_SubdivideSurface (msurface_t *fa);
void gl_Mod_ProcessTexture(texture_t *tx);
void glsl_Mod_LoadExternalTextures (model_t *mod);
void glsl_Mod_LoadLighting (bsp_t *bsp);
void glsl_Mod_SubdivideSurface (msurface_t *fa);
void glsl_Mod_ProcessTexture(texture_t *tx);
void sw_Mod_LoadExternalTextures (model_t *mod);
void sw_Mod_LoadLighting (bsp_t *bsp);
void sw_Mod_SubdivideSurface (msurface_t *fa);
void sw_Mod_ProcessTexture(texture_t *tx);
void Mod_LoadAliasModel (model_t *mod, void *buffer,
cache_allocator_t allocator);
void Mod_LoadSpriteModel (model_t *mod, void *buffer);

View file

@ -52,29 +52,29 @@ static __attribute__ ((used)) const char rcsid[] =
// ALIAS MODEL DISPLAY LIST GENERATION ========================================
model_t *aliasmodel;
aliashdr_t *paliashdr;
static model_t *aliasmodel;
static aliashdr_t *paliashdr;
qboolean *used;
int used_size;
static qboolean *used;
static int used_size;
// the command list holds counts and s/t values that are valid for every frame
int *commands;
int numcommands;
int commands_size;
static int *commands;
static int numcommands;
static int commands_size;
// all frames will have their vertexes rearranged and expanded
// so they are in the order expected by the command list
int *vertexorder;
int numorder;
int vertexorder_size;
static int *vertexorder;
static int numorder;
static int vertexorder_size;
int allverts, alltris;
static int allverts, alltris;
int *stripverts;
int *striptris;
int stripcount;
int strip_size;
static int *stripverts;
static int *striptris;
static int stripcount;
static int strip_size;
static inline void
@ -336,7 +336,8 @@ BuildTris (void)
}
void
Mod_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr, void *_m, int _s, int extra)
gl_Mod_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr, void *_m,
int _s, int extra)
{
dstring_t *cache, *fullpath;
unsigned char model_digest[MDFOUR_DIGEST_BYTES];

View file

@ -53,10 +53,8 @@ static __attribute__ ((used)) const char rcsid[] = "$Id$";
#include "compat.h"
int alias_cache = 1;
void *
Mod_LoadSkin (byte * skin, int skinsize, int snum, int gnum, qboolean group,
gl_Mod_LoadSkin (byte * skin, int skinsize, int snum, int gnum, qboolean group,
maliasskindesc_t *skindesc)
{
byte *pskin;
@ -105,7 +103,7 @@ Mod_LoadSkin (byte * skin, int skinsize, int snum, int gnum, qboolean group,
}
void
Mod_FinalizeAliasModel (model_t *m, aliashdr_t *hdr)
gl_Mod_FinalizeAliasModel (model_t *m, aliashdr_t *hdr)
{
if (strequal (m->name, "progs/eyes.mdl")) {
hdr->mdl.scale_origin[2] -= (22 + 8);
@ -153,7 +151,7 @@ Mod_LoadExternalSkin (maliasskindesc_t *pskindesc, char *filename)
}
void
Mod_LoadExternalSkins (model_t *mod)
gl_Mod_LoadExternalSkins (model_t *mod)
{
char filename[MAX_QPATH + 4], modname[MAX_QPATH + 4];
int i, j;

View file

@ -52,8 +52,6 @@ static __attribute__ ((used)) const char rcsid[] = "$Id$";
#include "mod_internal.h"
#include "r_shared.h"
int alias_cache = 0;
static vec3_t vertex_normals[NUMVERTEXNORMALS] = {
#include "anorms.h"
};
@ -95,8 +93,8 @@ glsl_alias_clear (model_t *m)
}
void *
Mod_LoadSkin (byte *skin, int skinsize, int snum, int gnum, qboolean group,
maliasskindesc_t *skindesc)
glsl_Mod_LoadSkin (byte *skin, int skinsize, int snum, int gnum,
qboolean group, maliasskindesc_t *skindesc)
{
byte *tskin;
const char *name;
@ -117,7 +115,7 @@ Mod_LoadSkin (byte *skin, int skinsize, int snum, int gnum, qboolean group,
}
void
Mod_FinalizeAliasModel (model_t *m, aliashdr_t *hdr)
glsl_Mod_FinalizeAliasModel (model_t *m, aliashdr_t *hdr)
{
if (hdr->mdl.ident == HEADER_MDL16)
VectorScale (hdr->mdl.scale, 1/256.0, hdr->mdl.scale);
@ -125,13 +123,13 @@ Mod_FinalizeAliasModel (model_t *m, aliashdr_t *hdr)
}
void
Mod_LoadExternalSkins (model_t *mod)
glsl_Mod_LoadExternalSkins (model_t *mod)
{
}
void
Mod_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr, void *_m, int _s,
int extra)
glsl_Mod_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr, void *_m,
int _s, int extra)
{
mtriangle_t *tris;
stvert_t *st;

View file

@ -52,7 +52,6 @@ static __attribute__ ((used)) const char rcsid[] =
#include "mod_internal.h"
#include "r_local.h"
extern int alias_cache; //FIXME extern
aliashdr_t *pheader;
stvert_t *stverts;
@ -91,7 +90,7 @@ Mod_LoadAllSkins (int numskins, daliasskintype_t *pskintype, int *pskinindex)
pskindesc[snum].type = pskintype->type;
if (pskintype->type == ALIAS_SKIN_SINGLE) {
skin = (byte *) (pskintype + 1);
skin = Mod_LoadSkin (skin, skinsize, snum, 0, false,
skin = m_funcs->Mod_LoadSkin (skin, skinsize, snum, 0, false,
&pskindesc[snum]);
} else {
pskintype++;
@ -123,8 +122,8 @@ Mod_LoadAllSkins (int numskins, daliasskintype_t *pskintype, int *pskinindex)
for (gnum = 0; gnum < groupskins; gnum++) {
paliasskingroup->skindescs[gnum].type = ALIAS_SKIN_SINGLE;
skin = Mod_LoadSkin (skin, skinsize, snum, gnum, true,
&paliasskingroup->skindescs[gnum]);
skin = mod_funcs->Mod_LoadSkin (skin, skinsize, snum, gnum,
true, &paliasskingroup->skindescs[gnum]);
}
}
pskintype = (daliasskintype_t *) skin;
@ -371,14 +370,15 @@ Mod_LoadAliasModel (model_t *mod, void *buffer, cache_allocator_t allocator)
mod->radius = RadiusFromBounds (mod->mins, mod->maxs);
// build the draw lists
Mod_MakeAliasModelDisplayLists (mod, pheader, buffer, qfs_filesize, extra);
m_funcs->Mod_MakeAliasModelDisplayLists (mod, pheader, buffer,
qfs_filesize, extra);
Mod_FinalizeAliasModel (mod, pheader);
m_funcs->Mod_FinalizeAliasModel (mod, pheader);
Mod_LoadExternalSkins (mod);
m_funcs->Mod_LoadExternalSkins (mod);
// move the complete, relocatable alias model to the cache
if (alias_cache) {
if (m_funcs->alias_cache) {
end = Hunk_LowMark ();
total = end - start;

View file

@ -47,14 +47,12 @@ static __attribute__ ((used)) const char rcsid[] = "$Id$";
#include "d_iface.h"
#include "mod_internal.h"
int alias_cache = 1;
// a pose is a single set of vertexes. a frame may be
// an animating sequence of poses
void *
Mod_LoadSkin (byte *skin, int skinsize, int snum, int gnum,
sw_Mod_LoadSkin (byte *skin, int skinsize, int snum, int gnum,
qboolean group, maliasskindesc_t *skindesc)
{
byte *pskin;
@ -87,8 +85,8 @@ process_frame (maliasframedesc_t *frame, int posenum, int extra)
}
void
Mod_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr, void *_m, int _s,
int extra)
sw_Mod_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr, void *_m,
int _s, int extra)
{
int i, j;
int posenum = 0;
@ -130,11 +128,11 @@ Mod_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr, void *_m, int _s,
}
void
Mod_FinalizeAliasModel (model_t *m, aliashdr_t *hdr)
sw_Mod_FinalizeAliasModel (model_t *m, aliashdr_t *hdr)
{
}
void
Mod_LoadExternalSkins (model_t *mod)
sw_Mod_LoadExternalSkins (model_t *mod)
{
}

View file

@ -56,7 +56,7 @@ static __attribute__ ((used)) const char rcsid[] =
void
Mod_ProcessTexture (texture_t *tx)
gl_Mod_ProcessTexture (texture_t *tx)
{
char name[32];
@ -97,7 +97,7 @@ Mod_LoadAnExternalTexture (char * tname, char *mname)
}
void
Mod_LoadExternalTextures (model_t *mod)
gl_Mod_LoadExternalTextures (model_t *mod)
{
int i;
tex_t *base, *luma;
@ -137,7 +137,7 @@ Mod_LoadExternalTextures (model_t *mod)
}
void
Mod_LoadLighting (bsp_t *bsp)
gl_Mod_LoadLighting (bsp_t *bsp)
{
byte d;
byte *in, *out, *data;
@ -297,7 +297,7 @@ SubdividePolygon (int numverts, float *verts)
can be done reasonably.
*/
void
Mod_SubdivideSurface (msurface_t *fa)
gl_Mod_SubdivideSurface (msurface_t *fa)
{
float *vec;
int lindex, numverts, i;

View file

@ -80,7 +80,7 @@ glsl_brush_clear (model_t *m)
}
void
Mod_ProcessTexture (texture_t *tx)
glsl_Mod_ProcessTexture (texture_t *tx)
{
if (!strncmp (tx->name, "sky", 3)) {
// sky textures need to be loaded as two separate textures to allow
@ -109,12 +109,12 @@ Mod_ProcessTexture (texture_t *tx)
}
void
Mod_LoadExternalTextures (model_t *mod)
glsl_Mod_LoadExternalTextures (model_t *mod)
{
}
void
Mod_LoadLighting (bsp_t *bsp)
glsl_Mod_LoadLighting (bsp_t *bsp)
{
// a big hacky, but it's as good a place as any
loadmodel->clear = glsl_brush_clear;
@ -128,6 +128,6 @@ Mod_LoadLighting (bsp_t *bsp)
}
void
Mod_SubdivideSurface (msurface_t *fa)
glsl_Mod_SubdivideSurface (msurface_t *fa)
{
}

View file

@ -45,22 +45,22 @@ static __attribute__ ((used)) const char rcsid[] =
void
Mod_SubdivideSurface (msurface_t *fa)
sw_Mod_SubdivideSurface (msurface_t *fa)
{
}
void
Mod_ProcessTexture (texture_t *tx)
sw_Mod_ProcessTexture (texture_t *tx)
{
}
void
Mod_LoadExternalTextures (model_t *mod)
sw_Mod_LoadExternalTextures (model_t *mod)
{
}
void
Mod_LoadLighting (bsp_t *bsp)
sw_Mod_LoadLighting (bsp_t *bsp)
{
mod_lightmap_bytes = 1;
if (!bsp->lightdatasize) {

View file

@ -40,13 +40,20 @@
#include "gl/namehack.h"
static vid_model_funcs_t model_funcs = {
Mod_LoadExternalTextures,
Mod_LoadLighting,
Mod_SubdivideSurface,
Mod_ProcessTexture,
gl_Mod_LoadExternalTextures,
gl_Mod_LoadLighting,
gl_Mod_SubdivideSurface,
gl_Mod_ProcessTexture,
Mod_LoadAliasModel,
Mod_LoadSpriteModel,
gl_Mod_MakeAliasModelDisplayLists,
gl_Mod_LoadSkin,
gl_Mod_FinalizeAliasModel,
gl_Mod_LoadExternalSkins,
1,
Skin_SetColormap,
Skin_SetSkin,
gl_Skin_SetupSkin,

View file

@ -40,13 +40,20 @@
#include "glsl/namehack.h"
static vid_model_funcs_t model_funcs = {
Mod_LoadExternalTextures,
Mod_LoadLighting,
Mod_SubdivideSurface,
Mod_ProcessTexture,
glsl_Mod_LoadExternalTextures,
glsl_Mod_LoadLighting,
glsl_Mod_SubdivideSurface,
glsl_Mod_ProcessTexture,
Mod_LoadAliasModel,
Mod_LoadSpriteModel,
glsl_Mod_MakeAliasModelDisplayLists,
glsl_Mod_LoadSkin,
glsl_Mod_FinalizeAliasModel,
glsl_Mod_LoadExternalSkins,
0,
Skin_SetColormap,
Skin_SetSkin,
glsl_Skin_SetupSkin,

View file

@ -35,13 +35,20 @@
#include "r_internal.h"
static vid_model_funcs_t model_funcs = {
Mod_LoadExternalTextures,
Mod_LoadLighting,
Mod_SubdivideSurface,
Mod_ProcessTexture,
sw_Mod_LoadExternalTextures,
sw_Mod_LoadLighting,
sw_Mod_SubdivideSurface,
sw_Mod_ProcessTexture,
Mod_LoadAliasModel,
Mod_LoadSpriteModel,
sw_Mod_MakeAliasModelDisplayLists,
sw_Mod_LoadSkin,
sw_Mod_FinalizeAliasModel,
sw_Mod_LoadExternalSkins,
1,
Skin_SetColormap,
Skin_SetSkin,
sw_Skin_SetupSkin,

View file

@ -40,13 +40,20 @@
#include "sw32/namehack.h"
static vid_model_funcs_t model_funcs = {
Mod_LoadExternalTextures,
Mod_LoadLighting,
Mod_SubdivideSurface,
Mod_ProcessTexture,
sw_Mod_LoadExternalTextures,
sw_Mod_LoadLighting,
sw_Mod_SubdivideSurface,
sw_Mod_ProcessTexture,
Mod_LoadAliasModel,
Mod_LoadSpriteModel,
sw_Mod_MakeAliasModelDisplayLists,
sw_Mod_LoadSkin,
sw_Mod_FinalizeAliasModel,
sw_Mod_LoadExternalSkins,
1,
Skin_SetColormap,
Skin_SetSkin,
sw_Skin_SetupSkin,