From 4e21ab0e898fbf060e4d7ba6e865df434c3392f9 Mon Sep 17 00:00:00 2001 From: Lee Salzman Date: Mon, 7 Apr 2008 11:31:03 +0000 Subject: [PATCH] simplified tag setup git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@1752 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/md2.h | 2 +- source/src/md3.h | 20 +++++--------------- source/src/menus.cpp | 5 +---- source/src/model.h | 8 ++------ source/src/rendermodel.cpp | 5 +---- 5 files changed, 10 insertions(+), 30 deletions(-) diff --git a/source/src/md2.h b/source/src/md2.h index f7e76cf5..042342b9 100644 --- a/source/src/md2.h +++ b/source/src/md2.h @@ -195,7 +195,7 @@ struct md2 : vertmodel if(!cullface) glEnable(GL_CULL_FACE); else if(anim&ANIM_MIRROR) glCullFace(GL_FRONT); - if(a) for(int i = 0; a[i].type; i++) + if(a) for(int i = 0; a[i].name; i++) { vertmodel *m = (vertmodel *)a[i].m; if(!m) continue; diff --git a/source/src/md3.h b/source/src/md3.h index 5f0be957..f57d56f0 100644 --- a/source/src/md3.h +++ b/source/src/md3.h @@ -154,17 +154,12 @@ struct md3 : vertmodel { if(!loaded) return; - if(a) for(int i = 0; a[i].type; i++) + if(a) for(int i = 0; a[i].name; i++) { vertmodel *m = (vertmodel *)a[i].m; - if(!m) continue;; + if(!m || !a[i].tag) continue; part *p = m->parts[0]; - switch(a[i].type) - { - case MDL_ATTACH_VWEP: - if(link(p, "tag_weapon")) p->index = parts.length()+i; - break; - } + if(link(p, a[i].tag)) p->index = parts.length()+i; } if(!cullface) glDisable(GL_CULL_FACE); @@ -184,14 +179,9 @@ struct md3 : vertmodel if(!cullface) glEnable(GL_CULL_FACE); else if(anim&ANIM_MIRROR) glCullFace(GL_FRONT); - if(a) for(int i = 0; a[i].type; i++) + if(a) for(int i = 0; a[i].name; i++) { - switch(a[i].type) - { - case MDL_ATTACH_VWEP: - link(NULL, "tag_weapon"); - break; - } + if(a[i].tag) link(NULL, a[i].tag); } if(d) d->lastrendered = lastmillis; diff --git a/source/src/menus.cpp b/source/src/menus.cpp index a0c1fdec..acb2db02 100644 --- a/source/src/menus.cpp +++ b/source/src/menus.cpp @@ -640,10 +640,7 @@ void rendermenumdl() if(isplayermodel) { a[0].name = "weapons/subgun/world"; - a[0].type = MDL_ATTACH_VWEP; - a[0].anim = m.anim; - a[0].basetime = 0; - a[0].speed = 0; + a[0].tag = "tag_weapon"; } rendermodel(isplayermodel ? "playermodels" : m.mdl, m.anim, tex, 0, pos, yaw, 0, 0, 0, NULL, a, m.scale ? m.scale/25.0f : 1.0f); diff --git a/source/src/model.h b/source/src/model.h index 8422f855..f347d076 100644 --- a/source/src/model.h +++ b/source/src/model.h @@ -24,17 +24,13 @@ struct animstate // used for animation blending o enum { MDL_MD2 = 1, MDL_MD3 }; -enum { MDL_ATTACH_NONE = 0, MDL_ATTACH_VWEP }; - struct model; struct modelattach { - const char *name; - int type, anim, basetime; - float speed; + const char *name, *tag; model *m; - modelattach() : name(NULL), type(MDL_ATTACH_NONE) {} + modelattach() : name(NULL), tag(NULL) {} }; struct dynent; diff --git a/source/src/rendermodel.cpp b/source/src/rendermodel.cpp index 8af90f45..7bd704f0 100644 --- a/source/src/rendermodel.cpp +++ b/source/src/rendermodel.cpp @@ -471,10 +471,7 @@ void renderclient(playerent *d, const char *mdlname, const char *vwepname, int t if(vwepname) { a[0].name = vwepname; - a[0].type = MDL_ATTACH_VWEP; - a[0].anim = anim; - a[0].basetime = basetime; - a[0].speed = speed; + a[0].tag = "tag_weapon"; } rendermodel(mdlname, anim, tex, 1.5f, o, d->yaw+90, d->pitch/4, speed, basetime, d, a); if(isteam(player1->team, d->team)) renderaboveheadicon(d);