diff --git a/source/src/md2.h b/source/src/md2.h index 67b725d3..390e76b4 100644 --- a/source/src/md2.h +++ b/source/src/md2.h @@ -235,13 +235,12 @@ struct md2 : vertmodel } }; -void md2anim(char *anim, char *frame, char *range, char *s) +void md2anim(char *anim, char *frame, char *range, char *speed) { if(!loadingmd2 || loadingmd2->parts.empty()) { conoutf("not loading an md2"); return; } int num = findanim(anim); if(num<0) { conoutf("could not find animation %s", anim); return; } - float speed = s[0] ? atof(s) : 100.0f; - loadingmd2->parts.last()->setanim(num, atoi(frame), atoi(range), speed); + loadingmd2->parts.last()->setanim(num, atoi(frame), atoi(range), atof(speed)); } COMMAND(md2anim, ARG_4STR); diff --git a/source/src/md3.h b/source/src/md3.h index 701fa7b9..d8413b3b 100644 --- a/source/src/md3.h +++ b/source/src/md3.h @@ -240,13 +240,12 @@ void md3skin(char *objname, char *skin) } } -void md3anim(char *anim, char *startframe, char *range, char *s) +void md3anim(char *anim, char *startframe, char *range, char *speed) { if(!loadingmd3 || loadingmd3->parts.empty()) { conoutf("not loading an md3"); return; }; - float speed = s[0] ? atof(s) : 100.0f; int num = findanim(anim); if(num<0) { conoutf("could not find animation %s", anim); return; }; - loadingmd3->parts.last()->setanim(num, atoi(startframe), atoi(range), speed); + loadingmd3->parts.last()->setanim(num, atoi(startframe), atoi(range), atof(speed)); } void md3link(char *parentno, char *childno, char *tagname) diff --git a/source/src/menus.cpp b/source/src/menus.cpp index 7a03c8f3..dacf7e36 100644 --- a/source/src/menus.cpp +++ b/source/src/menus.cpp @@ -150,7 +150,7 @@ void rendermenumdl() s_sprintfd(skin)("packages/models/%s.jpg", m.mdl); tex = -(int)textureload(skin)->id; } - rendermodel(isplayermodel ? (char *)"playermodels" : m.mdl, m.anim, tex, 0, pos.x, pos.y, pos.z, yaw, 0, 100, 0, NULL, isplayermodel ? (char*)"weapons/subgun/world" : NULL, m.scale ? m.scale/25.0f : 1.0f); + rendermodel(isplayermodel ? (char *)"playermodels" : m.mdl, m.anim, tex, 0, pos.x, pos.y, pos.z, yaw, 0, 0, 0, NULL, isplayermodel ? (char*)"weapons/subgun/world" : NULL, m.scale ? m.scale/25.0f : 1.0f); glPopMatrix(); } diff --git a/source/src/protos.h b/source/src/protos.h index 21bceba5..76363757 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -245,7 +245,7 @@ extern void music(char *name); // rendermodel extern void rendershadow(playerent *d); -extern void rendermodel(char *mdl, int anim, int tex, float rad, float x, float y, float z, float yaw, float pitch, float speed, int basetime = 0, playerent *d = NULL, char *vwepmdl = NULL, float scale = 1.0f); +extern void rendermodel(char *mdl, int anim, int tex, float rad, float x, float y, float z, float yaw, float pitch, float speed = 0, int basetime = 0, playerent *d = NULL, char *vwepmdl = NULL, float scale = 1.0f); extern mapmodelinfo &getmminfo(int i); extern int findanim(const char *name); extern void loadskin(const char *dir, const char *altdir, Texture *&skin, model *m); diff --git a/source/src/rendermodel.cpp b/source/src/rendermodel.cpp index 44c5b684..488dc84b 100644 --- a/source/src/rendermodel.cpp +++ b/source/src/rendermodel.cpp @@ -206,7 +206,7 @@ void renderclient(playerent *d, char *mdlname, char *vwepname, int tex) { int varseed = (int)(size_t)d; int anim = ANIM_IDLE|ANIM_LOOP; - float speed = 100.0f; + float speed = 0.0; float mz = d->o.z-d->eyeheight; int basetime = -((int)(size_t)d&0xFFF); if(d->state==CS_DEAD) diff --git a/source/src/vertmodel.h b/source/src/vertmodel.h index 28937719..c399986f 100644 --- a/source/src/vertmodel.h +++ b/source/src/vertmodel.h @@ -248,22 +248,21 @@ struct vertmodel : model loopv(meshes) meshes[i]->gendyn(); } - virtual void getdefaultanim(animstate &as, int anim, int varseed, float speed) + virtual void getdefaultanim(animstate &as, int anim, int varseed) { as.frame = 0; as.range = 1; - as.speed = speed; } bool calcanimstate(int anim, int varseed, float speed, int basetime, dynent *d, animstate &as) { as.anim = anim; + as.speed = speed<=0 ? 100.0f : speed; as.basetime = basetime; if((anim&ANIM_INDEX)==ANIM_ALL) { as.frame = 0; as.range = numframes; - as.speed = speed; } else if(anims) { @@ -273,16 +272,11 @@ struct vertmodel : model animinfo &ai = ais[varseed%ais.length()]; as.frame = ai.frame; as.range = ai.range; - as.speed = speed*100.0f/ai.speed; - } - else - { - as.frame = 0; - as.range = 1; - as.speed = speed; + if(ai.speed>0) as.speed = 1000.0f/ai.speed; } + else getdefaultanim(as, anim&ANIM_INDEX, varseed); } - else getdefaultanim(as, anim&ANIM_INDEX, varseed, speed); + else getdefaultanim(as, anim&ANIM_INDEX, varseed); if(anim&(ANIM_START|ANIM_END)) { if(anim&ANIM_END) as.frame += as.range-1; @@ -315,7 +309,7 @@ struct vertmodel : model void render(int anim, int varseed, float speed, int basetime, dynent *d) { - if(meshes.length() <= 0) return; + if(meshes.empty()) return; animstate as; if(!calcanimstate(anim, varseed, speed, basetime, d, as)) return; diff --git a/source/src/weapon.cpp b/source/src/weapon.cpp index c828f082..36e6f8a2 100644 --- a/source/src/weapon.cpp +++ b/source/src/weapon.cpp @@ -409,7 +409,7 @@ void renderbounceents() } } path(model); - rendermodel(model, ANIM_MAPMODEL|ANIM_LOOP, 0, 1.1f, p->o.x, p->o.y, z, p->yaw+90, p->pitch, 10.0f); + rendermodel(model, ANIM_MAPMODEL|ANIM_LOOP, 0, 1.1f, p->o.x, p->o.y, z, p->yaw+90, p->pitch); } }