summaryrefslogtreecommitdiff
path: root/src/renderergl1
diff options
context:
space:
mode:
authorSmileTheory <SmileTheory@gmail.com>2013-11-29 16:13:47 -0800
committerTim Angus <tim@ngus.net>2014-06-17 17:43:37 +0100
commit9a6d6431b8e111428e47839b726830ed86713bfe (patch)
tree3552ff0e3873aabfe5471ff2cca4a523bb24d3d9 /src/renderergl1
parent7209797fa22f60d8464bc29e517655ad898effae (diff)
#6069: Remove md4 model support.
Diffstat (limited to 'src/renderergl1')
-rw-r--r--src/renderergl1/tr_animation.c140
-rw-r--r--src/renderergl1/tr_local.h7
-rw-r--r--src/renderergl1/tr_main.c3
-rw-r--r--src/renderergl1/tr_model.c182
-rw-r--r--src/renderergl1/tr_surface.c1
5 files changed, 9 insertions, 324 deletions
diff --git a/src/renderergl1/tr_animation.c b/src/renderergl1/tr_animation.c
index 53d2f4c6..5f401370 100644
--- a/src/renderergl1/tr_animation.c
+++ b/src/renderergl1/tr_animation.c
@@ -34,140 +34,6 @@ frame.
*/
-/*
-==============
-R_AddAnimSurfaces
-==============
-*/
-void R_AddAnimSurfaces( trRefEntity_t *ent ) {
- md4Header_t *header;
- md4Surface_t *surface;
- md4LOD_t *lod;
- shader_t *shader;
- int i;
-
- header = (md4Header_t *) tr.currentModel->modelData;
- lod = (md4LOD_t *)( (byte *)header + header->ofsLODs );
-
- surface = (md4Surface_t *)( (byte *)lod + lod->ofsSurfaces );
- for ( i = 0 ; i < lod->numSurfaces ; i++ ) {
- shader = R_GetShaderByHandle( surface->shaderIndex );
- R_AddDrawSurf( (void *)surface, shader, 0 /*fogNum*/, qfalse );
- surface = (md4Surface_t *)( (byte *)surface + surface->ofsEnd );
- }
-}
-
-/*
-==============
-RB_SurfaceAnim
-==============
-*/
-void RB_SurfaceAnim( md4Surface_t *surface ) {
- int i, j, k;
- float frontlerp, backlerp;
- int *triangles;
- int indexes;
- int baseIndex, baseVertex;
- int numVerts;
- md4Vertex_t *v;
- md4Bone_t bones[MD4_MAX_BONES];
- md4Bone_t *bonePtr, *bone;
- md4Header_t *header;
- md4Frame_t *frame;
- md4Frame_t *oldFrame;
- int frameSize;
-
-
- if ( backEnd.currentEntity->e.oldframe == backEnd.currentEntity->e.frame ) {
- backlerp = 0;
- frontlerp = 1;
- } else {
- backlerp = backEnd.currentEntity->e.backlerp;
- frontlerp = 1.0f - backlerp;
- }
- header = (md4Header_t *)((byte *)surface + surface->ofsHeader);
-
- frameSize = (size_t)( &((md4Frame_t *)0)->bones[ header->numBones ] );
-
- frame = (md4Frame_t *)((byte *)header + header->ofsFrames +
- backEnd.currentEntity->e.frame * frameSize );
- oldFrame = (md4Frame_t *)((byte *)header + header->ofsFrames +
- backEnd.currentEntity->e.oldframe * frameSize );
-
- RB_CheckOverflow( surface->numVerts, surface->numTriangles * 3 );
-
- triangles = (int *) ((byte *)surface + surface->ofsTriangles);
- indexes = surface->numTriangles * 3;
- baseIndex = tess.numIndexes;
- baseVertex = tess.numVertexes;
- for (j = 0 ; j < indexes ; j++) {
- tess.indexes[baseIndex + j] = baseIndex + triangles[j];
- }
- tess.numIndexes += indexes;
-
- //
- // lerp all the needed bones
- //
- if ( !backlerp ) {
- // no lerping needed
- bonePtr = frame->bones;
- } else {
- bonePtr = bones;
- for ( i = 0 ; i < header->numBones*12 ; i++ ) {
- ((float *)bonePtr)[i] = frontlerp * ((float *)frame->bones)[i]
- + backlerp * ((float *)oldFrame->bones)[i];
- }
- }
-
- //
- // deform the vertexes by the lerped bones
- //
- numVerts = surface->numVerts;
- // FIXME
- // This makes TFC's skeletons work. Shouldn't be necessary anymore, but left
- // in for reference.
- //v = (md4Vertex_t *) ((byte *)surface + surface->ofsVerts + 12);
- v = (md4Vertex_t *) ((byte *)surface + surface->ofsVerts);
- for ( j = 0; j < numVerts; j++ ) {
- vec3_t tempVert, tempNormal;
- md4Weight_t *w;
-
- VectorClear( tempVert );
- VectorClear( tempNormal );
- w = v->weights;
- for ( k = 0 ; k < v->numWeights ; k++, w++ ) {
- bone = bonePtr + w->boneIndex;
-
- tempVert[0] += w->boneWeight * ( DotProduct( bone->matrix[0], w->offset ) + bone->matrix[0][3] );
- tempVert[1] += w->boneWeight * ( DotProduct( bone->matrix[1], w->offset ) + bone->matrix[1][3] );
- tempVert[2] += w->boneWeight * ( DotProduct( bone->matrix[2], w->offset ) + bone->matrix[2][3] );
-
- tempNormal[0] += w->boneWeight * DotProduct( bone->matrix[0], v->normal );
- tempNormal[1] += w->boneWeight * DotProduct( bone->matrix[1], v->normal );
- tempNormal[2] += w->boneWeight * DotProduct( bone->matrix[2], v->normal );
- }
-
- tess.xyz[baseVertex + j][0] = tempVert[0];
- tess.xyz[baseVertex + j][1] = tempVert[1];
- tess.xyz[baseVertex + j][2] = tempVert[2];
-
- tess.normal[baseVertex + j][0] = tempNormal[0];
- tess.normal[baseVertex + j][1] = tempNormal[1];
- tess.normal[baseVertex + j][2] = tempNormal[2];
-
- tess.texCoords[baseVertex + j][0][0] = v->texCoords[0];
- tess.texCoords[baseVertex + j][0][1] = v->texCoords[1];
-
- // FIXME
- // This makes TFC's skeletons work. Shouldn't be necessary anymore, but left
- // in for reference.
- //v = (md4Vertex_t *)( ( byte * )&v->weights[v->numWeights] + 12 );
- v = (md4Vertex_t *)&v->weights[v->numWeights];
- }
-
- tess.numVertexes += surface->numVerts;
-}
-
// copied and adapted from tr_mesh.c
@@ -196,7 +62,7 @@ static int R_MDRCullModel( mdrHeader_t *header, trRefEntity_t *ent ) {
switch ( R_CullLocalPointAndRadius( newFrame->localOrigin, newFrame->radius ) )
{
// Ummm... yeah yeah I know we don't really have an md3 here.. but we pretend
- // we do. After all, the purpose of md4s are not that different, are they?
+ // we do. After all, the purpose of mdrs are not that different, are they?
case CULL_OUT:
tr.pc.c_sphere_cull_md3_out++;
@@ -443,7 +309,7 @@ void R_MDRAddAnimSurfaces( trRefEntity_t *ent ) {
RB_MDRSurfaceAnim
==============
*/
-void RB_MDRSurfaceAnim( md4Surface_t *surface )
+void RB_MDRSurfaceAnim( mdrSurface_t *surface )
{
int i, j, k;
float frontlerp, backlerp;
@@ -455,7 +321,7 @@ void RB_MDRSurfaceAnim( md4Surface_t *surface )
mdrHeader_t *header;
mdrFrame_t *frame;
mdrFrame_t *oldFrame;
- mdrBone_t bones[MD4_MAX_BONES], *bonePtr, *bone;
+ mdrBone_t bones[MDR_MAX_BONES], *bonePtr, *bone;
int frameSize;
diff --git a/src/renderergl1/tr_local.h b/src/renderergl1/tr_local.h
index 0cba2dfe..3b024ec2 100644
--- a/src/renderergl1/tr_local.h
+++ b/src/renderergl1/tr_local.h
@@ -474,7 +474,6 @@ typedef enum {
SF_TRIANGLES,
SF_POLY,
SF_MD3,
- SF_MD4,
SF_MDR,
SF_IQM,
SF_FLARE,
@@ -733,7 +732,6 @@ typedef enum {
MOD_BAD,
MOD_BRUSH,
MOD_MESH,
- MOD_MD4,
MOD_MDR,
MOD_IQM
} modtype_t;
@@ -746,7 +744,7 @@ typedef struct model_s {
int dataSize; // just for listing purposes
bmodel_t *bmodel; // only if type == MOD_BRUSH
md3Header_t *md3[MD3_MAX_LODS]; // only if type == MOD_MESH
- void *modelData; // only if type == (MOD_MD4 | MOD_MDR | MOD_IQM)
+ void *modelData; // only if type == (MOD_MDR | MOD_IQM)
int numLods;
} model_t;
@@ -1394,9 +1392,8 @@ ANIMATED MODELS
// void R_MakeAnimModel( model_t *model ); haven't seen this one really, so not needed I guess.
void R_AddAnimSurfaces( trRefEntity_t *ent );
-void RB_SurfaceAnim( md4Surface_t *surfType );
void R_MDRAddAnimSurfaces( trRefEntity_t *ent );
-void RB_MDRSurfaceAnim( md4Surface_t *surface );
+void RB_MDRSurfaceAnim( mdrSurface_t *surface );
qboolean R_LoadIQM (model_t *mod, void *buffer, int filesize, const char *name );
void R_AddIQMSurfaces( trRefEntity_t *ent );
void RB_IQMSurfaceAnim( surfaceType_t *surface );
diff --git a/src/renderergl1/tr_main.c b/src/renderergl1/tr_main.c
index c2e32c94..500bb788 100644
--- a/src/renderergl1/tr_main.c
+++ b/src/renderergl1/tr_main.c
@@ -1243,9 +1243,6 @@ void R_AddEntitySurfaces (void) {
case MOD_MESH:
R_AddMD3Surfaces( ent );
break;
- case MOD_MD4:
- R_AddAnimSurfaces( ent );
- break;
case MOD_MDR:
R_MDRAddAnimSurfaces( ent );
break;
diff --git a/src/renderergl1/tr_model.c b/src/renderergl1/tr_model.c
index 2a677be7..bbc8e437 100644
--- a/src/renderergl1/tr_model.c
+++ b/src/renderergl1/tr_model.c
@@ -27,7 +27,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#define LL(x) x=LittleLong(x)
static qboolean R_LoadMD3(model_t *mod, int lod, void *buffer, const char *name );
-static qboolean R_LoadMD4(model_t *mod, void *buffer, const char *name );
static qboolean R_LoadMDR(model_t *mod, void *buffer, int filesize, const char *name );
/*
@@ -73,15 +72,10 @@ qhandle_t R_RegisterMD3(const char *name, model_t *mod)
continue;
ident = LittleLong(* (unsigned *) buf.u);
- if (ident == MD4_IDENT)
- loaded = R_LoadMD4(mod, buf.u, name);
+ if (ident == MD3_IDENT)
+ loaded = R_LoadMD3(mod, lod, buf.u, name);
else
- {
- if (ident == MD3_IDENT)
- loaded = R_LoadMD3(mod, lod, buf.u, name);
- else
- ri.Printf(PRINT_WARNING,"R_RegisterMD3: unknown fileid for %s\n", name);
- }
+ ri.Printf(PRINT_WARNING,"R_RegisterMD3: unknown fileid for %s\n", name);
ri.FS_FreeFile(buf.v);
@@ -201,7 +195,6 @@ static modelExtToLoaderMap_t modelLoaders[ ] =
{
{ "iqm", R_RegisterIQM },
{ "mdr", R_RegisterMDR },
- { "md4", R_RegisterMD3 },
{ "md3", R_RegisterMD3 }
};
@@ -577,7 +570,7 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char
LL(pinmodel->ofsFrames);
// This is a model that uses some type of compressed Bones. We don't want to uncompress every bone for each rendered frame
- // over and over again, we'll uncompress it in this function already, so we must adjust the size of the target md4.
+ // over and over again, we'll uncompress it in this function already, so we must adjust the size of the target mdr.
if(pinmodel->ofsFrames < 0)
{
// mdrFrame_t is larger than mdrCompFrame_t:
@@ -874,162 +867,6 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char
return qtrue;
}
-/*
-=================
-R_LoadMD4
-=================
-*/
-
-static qboolean R_LoadMD4( model_t *mod, void *buffer, const char *mod_name ) {
- int i, j, k, lodindex;
- md4Header_t *pinmodel, *md4;
- md4Frame_t *frame;
- md4LOD_t *lod;
- md4Surface_t *surf;
- md4Triangle_t *tri;
- md4Vertex_t *v;
- int version;
- int size;
- shader_t *sh;
- int frameSize;
-
- pinmodel = (md4Header_t *)buffer;
-
- version = LittleLong (pinmodel->version);
- if (version != MD4_VERSION) {
- ri.Printf( PRINT_WARNING, "R_LoadMD4: %s has wrong version (%i should be %i)\n",
- mod_name, version, MD4_VERSION);
- return qfalse;
- }
-
- mod->type = MOD_MD4;
- size = LittleLong(pinmodel->ofsEnd);
- mod->dataSize += size;
- mod->modelData = md4 = ri.Hunk_Alloc( size, h_low );
-
- Com_Memcpy(md4, buffer, size);
-
- LL(md4->ident);
- LL(md4->version);
- LL(md4->numFrames);
- LL(md4->numBones);
- LL(md4->numLODs);
- LL(md4->ofsFrames);
- LL(md4->ofsLODs);
- md4->ofsEnd = size;
-
- if ( md4->numFrames < 1 ) {
- ri.Printf( PRINT_WARNING, "R_LoadMD4: %s has no frames\n", mod_name );
- return qfalse;
- }
-
- // we don't need to swap tags in the renderer, they aren't used
-
- // swap all the frames
- frameSize = (size_t)( &((md4Frame_t *)0)->bones[ md4->numBones ] );
- for ( i = 0 ; i < md4->numFrames ; i++) {
- frame = (md4Frame_t *) ( (byte *)md4 + md4->ofsFrames + i * frameSize );
- frame->radius = LittleFloat( frame->radius );
- for ( j = 0 ; j < 3 ; j++ ) {
- frame->bounds[0][j] = LittleFloat( frame->bounds[0][j] );
- frame->bounds[1][j] = LittleFloat( frame->bounds[1][j] );
- frame->localOrigin[j] = LittleFloat( frame->localOrigin[j] );
- }
- for ( j = 0 ; j < md4->numBones * sizeof( md4Bone_t ) / 4 ; j++ ) {
- ((float *)frame->bones)[j] = LittleFloat( ((float *)frame->bones)[j] );
- }
- }
-
- // swap all the LOD's
- lod = (md4LOD_t *) ( (byte *)md4 + md4->ofsLODs );
- for ( lodindex = 0 ; lodindex < md4->numLODs ; lodindex++ ) {
-
- // swap all the surfaces
- surf = (md4Surface_t *) ( (byte *)lod + lod->ofsSurfaces );
- for ( i = 0 ; i < lod->numSurfaces ; i++) {
- LL(surf->ident);
- LL(surf->numTriangles);
- LL(surf->ofsTriangles);
- LL(surf->numVerts);
- LL(surf->ofsVerts);
- LL(surf->ofsEnd);
-
- if ( surf->numVerts >= SHADER_MAX_VERTEXES ) {
- ri.Printf(PRINT_WARNING, "R_LoadMD4: %s has more than %i verts on %s (%i).\n",
- mod_name, SHADER_MAX_VERTEXES - 1, surf->name[0] ? surf->name : "a surface",
- surf->numVerts );
- return qfalse;
- }
- if ( surf->numTriangles*3 >= SHADER_MAX_INDEXES ) {
- ri.Printf(PRINT_WARNING, "R_LoadMD4: %s has more than %i triangles on %s (%i).\n",
- mod_name, ( SHADER_MAX_INDEXES / 3 ) - 1, surf->name[0] ? surf->name : "a surface",
- surf->numTriangles );
- return qfalse;
- }
-
- // change to surface identifier
- surf->ident = SF_MD4;
-
- // lowercase the surface name so skin compares are faster
- Q_strlwr( surf->name );
-
- // register the shaders
- sh = R_FindShader( surf->shader, LIGHTMAP_NONE, qtrue );
- if ( sh->defaultShader ) {
- surf->shaderIndex = 0;
- } else {
- surf->shaderIndex = sh->index;
- }
-
- // swap all the triangles
- tri = (md4Triangle_t *) ( (byte *)surf + surf->ofsTriangles );
- for ( j = 0 ; j < surf->numTriangles ; j++, tri++ ) {
- LL(tri->indexes[0]);
- LL(tri->indexes[1]);
- LL(tri->indexes[2]);
- }
-
- // swap all the vertexes
- // FIXME
- // This makes TFC's skeletons work. Shouldn't be necessary anymore, but left
- // in for reference.
- //v = (md4Vertex_t *) ( (byte *)surf + surf->ofsVerts + 12);
- v = (md4Vertex_t *) ( (byte *)surf + surf->ofsVerts);
- for ( j = 0 ; j < surf->numVerts ; j++ ) {
- v->normal[0] = LittleFloat( v->normal[0] );
- v->normal[1] = LittleFloat( v->normal[1] );
- v->normal[2] = LittleFloat( v->normal[2] );
-
- v->texCoords[0] = LittleFloat( v->texCoords[0] );
- v->texCoords[1] = LittleFloat( v->texCoords[1] );
-
- v->numWeights = LittleLong( v->numWeights );
-
- for ( k = 0 ; k < v->numWeights ; k++ ) {
- v->weights[k].boneIndex = LittleLong( v->weights[k].boneIndex );
- v->weights[k].boneWeight = LittleFloat( v->weights[k].boneWeight );
- v->weights[k].offset[0] = LittleFloat( v->weights[k].offset[0] );
- v->weights[k].offset[1] = LittleFloat( v->weights[k].offset[1] );
- v->weights[k].offset[2] = LittleFloat( v->weights[k].offset[2] );
- }
- // FIXME
- // This makes TFC's skeletons work. Shouldn't be necessary anymore, but left
- // in for reference.
- //v = (md4Vertex_t *)( ( byte * )&v->weights[v->numWeights] + 12 );
- v = (md4Vertex_t *)( ( byte * )&v->weights[v->numWeights]);
- }
-
- // find the next surface
- surf = (md4Surface_t *)( (byte *)surf + surf->ofsEnd );
- }
-
- // find the next LOD
- lod = (md4LOD_t *)( (byte *)lod + lod->ofsEnd );
- }
-
- return qtrue;
-}
-
//=============================================================================
@@ -1267,17 +1104,6 @@ void R_ModelBounds( qhandle_t handle, vec3_t mins, vec3_t maxs ) {
VectorCopy( frame->bounds[1], maxs );
return;
- } else if (model->type == MOD_MD4) {
- md4Header_t *header;
- md4Frame_t *frame;
-
- header = (md4Header_t *)model->modelData;
- frame = (md4Frame_t *) ((byte *)header + header->ofsFrames);
-
- VectorCopy( frame->bounds[0], mins );
- VectorCopy( frame->bounds[1], maxs );
-
- return;
} else if (model->type == MOD_MDR) {
mdrHeader_t *header;
mdrFrame_t *frame;
diff --git a/src/renderergl1/tr_surface.c b/src/renderergl1/tr_surface.c
index d357d9cd..8f0905e7 100644
--- a/src/renderergl1/tr_surface.c
+++ b/src/renderergl1/tr_surface.c
@@ -1234,7 +1234,6 @@ void (*rb_surfaceTable[SF_NUM_SURFACE_TYPES])( void *) = {
(void(*)(void*))RB_SurfaceTriangles, // SF_TRIANGLES,
(void(*)(void*))RB_SurfacePolychain, // SF_POLY,
(void(*)(void*))RB_SurfaceMesh, // SF_MD3,
- (void(*)(void*))RB_SurfaceAnim, // SF_MD4,
(void(*)(void*))RB_MDRSurfaceAnim, // SF_MDR,
(void(*)(void*))RB_IQMSurfaceAnim, // SF_IQM,
(void(*)(void*))RB_SurfaceFlare, // SF_FLARE,