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); mleaf_t *Mod_PointInLeaf (const vec3_t p, model_t *model);
byte *Mod_LeafPVS (mleaf_t *leaf, model_t *model); byte *Mod_LeafPVS (mleaf_t *leaf, model_t *model);
model_t *Mod_FindName (const char *name); model_t *Mod_FindName (const char *name);
void Mod_LoadExternalSkins (model_t * mod);
int Mod_CalcFullbright (byte *in, byte *out, int pixels); int Mod_CalcFullbright (byte *in, byte *out, int pixels);
int Mod_Fullbright (byte * skin, int width, int height, char *name); 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); int extra);
void *Mod_LoadAliasGroup (void *pin, int *posenum, maliasframedesc_t *frame, void *Mod_LoadAliasGroup (void *pin, int *posenum, maliasframedesc_t *frame,
int extra); 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_SpriteLoadTexture (mspriteframe_t *pspriteframe, int framenum);
void Mod_LoadBrushModel (model_t *mod, void *buffer); 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, void (*Mod_LoadAliasModel) (model_t *mod, void *buffer,
cache_allocator_t allocator); cache_allocator_t allocator);
void (*Mod_LoadSpriteModel) (model_t *mod, void *buffer); 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_SetColormap) (struct skin_s *skin, int cmap);
struct skin_s *(*Skin_SetSkin) (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; extern vid_model_funcs_t *m_funcs;
void Mod_LoadExternalTextures (model_t *mod); void gl_Mod_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr, void *_m,
void Mod_LoadLighting (bsp_t *bsp); int _s, int extra);
void Mod_SubdivideSurface (msurface_t *fa); void *gl_Mod_LoadSkin (byte *skin, int skinsize, int snum, int gnum,
void Mod_ProcessTexture(texture_t *tx); 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, void Mod_LoadAliasModel (model_t *mod, void *buffer,
cache_allocator_t allocator); cache_allocator_t allocator);
void Mod_LoadSpriteModel (model_t *mod, void *buffer); 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 ======================================== // ALIAS MODEL DISPLAY LIST GENERATION ========================================
model_t *aliasmodel; static model_t *aliasmodel;
aliashdr_t *paliashdr; static aliashdr_t *paliashdr;
qboolean *used; static qboolean *used;
int used_size; static int used_size;
// the command list holds counts and s/t values that are valid for every frame // the command list holds counts and s/t values that are valid for every frame
int *commands; static int *commands;
int numcommands; static int numcommands;
int commands_size; static int commands_size;
// all frames will have their vertexes rearranged and expanded // all frames will have their vertexes rearranged and expanded
// so they are in the order expected by the command list // so they are in the order expected by the command list
int *vertexorder; static int *vertexorder;
int numorder; static int numorder;
int vertexorder_size; static int vertexorder_size;
int allverts, alltris; static int allverts, alltris;
int *stripverts; static int *stripverts;
int *striptris; static int *striptris;
int stripcount; static int stripcount;
int strip_size; static int strip_size;
static inline void static inline void
@ -336,7 +336,8 @@ BuildTris (void)
} }
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; dstring_t *cache, *fullpath;
unsigned char model_digest[MDFOUR_DIGEST_BYTES]; unsigned char model_digest[MDFOUR_DIGEST_BYTES];

View file

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

View file

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

View file

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

View file

@ -47,14 +47,12 @@ static __attribute__ ((used)) const char rcsid[] = "$Id$";
#include "d_iface.h" #include "d_iface.h"
#include "mod_internal.h" #include "mod_internal.h"
int alias_cache = 1;
// a pose is a single set of vertexes. a frame may be // a pose is a single set of vertexes. a frame may be
// an animating sequence of poses // an animating sequence of poses
void * 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) qboolean group, maliasskindesc_t *skindesc)
{ {
byte *pskin; byte *pskin;
@ -87,8 +85,8 @@ process_frame (maliasframedesc_t *frame, int posenum, int extra)
} }
void void
Mod_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr, void *_m, int _s, sw_Mod_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr, void *_m,
int extra) int _s, int extra)
{ {
int i, j; int i, j;
int posenum = 0; int posenum = 0;
@ -130,11 +128,11 @@ Mod_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr, void *_m, int _s,
} }
void void
Mod_FinalizeAliasModel (model_t *m, aliashdr_t *hdr) sw_Mod_FinalizeAliasModel (model_t *m, aliashdr_t *hdr)
{ {
} }
void 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 void
Mod_ProcessTexture (texture_t *tx) gl_Mod_ProcessTexture (texture_t *tx)
{ {
char name[32]; char name[32];
@ -97,7 +97,7 @@ Mod_LoadAnExternalTexture (char * tname, char *mname)
} }
void void
Mod_LoadExternalTextures (model_t *mod) gl_Mod_LoadExternalTextures (model_t *mod)
{ {
int i; int i;
tex_t *base, *luma; tex_t *base, *luma;
@ -137,7 +137,7 @@ Mod_LoadExternalTextures (model_t *mod)
} }
void void
Mod_LoadLighting (bsp_t *bsp) gl_Mod_LoadLighting (bsp_t *bsp)
{ {
byte d; byte d;
byte *in, *out, *data; byte *in, *out, *data;
@ -297,7 +297,7 @@ SubdividePolygon (int numverts, float *verts)
can be done reasonably. can be done reasonably.
*/ */
void void
Mod_SubdivideSurface (msurface_t *fa) gl_Mod_SubdivideSurface (msurface_t *fa)
{ {
float *vec; float *vec;
int lindex, numverts, i; int lindex, numverts, i;

View file

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

View file

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

View file

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

View file

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

View file

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