diff options
Diffstat (limited to 'src/engine/skelmodel.h')
| -rw-r--r-- | src/engine/skelmodel.h | 107 |
1 files changed, 9 insertions, 98 deletions
diff --git a/src/engine/skelmodel.h b/src/engine/skelmodel.h index 140acf8..dfa0f69 100644 --- a/src/engine/skelmodel.h +++ b/src/engine/skelmodel.h @@ -93,13 +93,9 @@ struct skelmodel : animmodel { float pitch; int millis; uchar *partmask; - ragdolldata *ragdoll; - animcacheentry() : ragdoll(NULL) { - loopk(MAXANIMPARTS) as[k].cur.fr1 = as[k].prev.fr1 = -1; - } bool operator==(const animcacheentry &c) const { loopi(MAXANIMPARTS) if(as[i]!=c.as[i]) return false; - return pitch==c.pitch && partmask==c.partmask && ragdoll==c.ragdoll && (!ragdoll || min(millis, c.millis) >= ragdoll->lastmove); + return pitch==c.pitch && partmask==c.partmask; } }; struct vbocacheentry : animcacheentry { @@ -160,14 +156,6 @@ struct skelmodel : animmodel { } } } - void genBIH(BIH::mesh &m) { - m.tris = (const BIH::tri *)tris; - m.numtris = numtris; - m.pos = (const uchar *)&verts->pos; - m.posstride = sizeof(vert); - m.tc = (const uchar *)&verts->tc; - m.tcstride = sizeof(vert); - } static inline void assignvert(vvertn &vv, int j, vert &v, blendcombo &c) { (void)j;(void)c; vv.pos = v.pos; @@ -312,10 +300,10 @@ struct skelmodel : animmodel { }; struct boneinfo { const char *name; - int parent, children, next, group, scheduled, interpindex, interpparent, ragdollindex, correctindex; + int parent, children, next, group, scheduled, interpindex, interpparent, correctindex; float pitchscale, pitchoffset, pitchmin, pitchmax; dualquat base, invbase; - boneinfo() : name(NULL), parent(-1), children(-1), next(-1), group(INT_MAX), scheduled(-1), interpindex(-1), interpparent(-1), ragdollindex(-1), correctindex(-1), pitchscale(0), pitchoffset(0), pitchmin(0), pitchmax(0) {} + boneinfo() : name(NULL), parent(-1), children(-1), next(-1), group(INT_MAX), scheduled(-1), interpindex(-1), interpparent(-1), correctindex(-1), pitchscale(0), pitchoffset(0), pitchmin(0), pitchmax(0) {} ~boneinfo() { DELETEA(name); } @@ -348,20 +336,18 @@ struct skelmodel : animmodel { vector<skelanimspec> skelanims; vector<tag> tags; vector<antipode> antipodes; - ragdollskel *ragdoll; vector<pitchdep> pitchdeps; vector<pitchtarget> pitchtargets; vector<pitchcorrect> pitchcorrects; bool usegpuskel; vector<skelcacheentry> skelcache; hashtable<GLuint, int> blendoffsets; - skeleton() : name(NULL), shared(0), bones(NULL), numbones(0), numinterpbones(0), numgpubones(0), numframes(0), framebones(NULL), ragdoll(NULL), usegpuskel(false), blendoffsets(32) { + skeleton() : name(NULL), shared(0), bones(NULL), numbones(0), numinterpbones(0), numgpubones(0), numframes(0), framebones(NULL), usegpuskel(false), blendoffsets(32) { } ~skeleton() { DELETEA(name); DELETEA(bones); DELETEA(framebones); - DELETEP(ragdoll); loopv(skelcache) { DELETEA(skelcache[i].bdata); } @@ -440,7 +426,6 @@ struct skelmodel : animmodel { loopi(numbones) { boneinfo &info = bones[i]; info.interpindex = -1; - info.ragdollindex = -1; } numgpubones = 0; loopv(users) { @@ -471,13 +456,6 @@ struct skelmodel : animmodel { boneinfo &info = bones[tags[i].bone]; if(info.interpindex < 0) info.interpindex = numinterpbones++; } - if(ragdoll) { - loopv(ragdoll->joints) { - boneinfo &info = bones[ragdoll->joints[i].bone]; - if(info.interpindex < 0) info.interpindex = numinterpbones++; - info.ragdollindex = i; - } - } loopi(numbones) { boneinfo &info = bones[i]; if(info.interpindex < 0) continue; @@ -489,15 +467,6 @@ struct skelmodel : animmodel { if(info.interpindex < 0) continue; info.interpparent = info.parent >= 0 ? bones[info.parent].interpindex : -1; } - if(ragdoll) { - loopi(numbones) { - boneinfo &info = bones[i]; - if(info.interpindex < 0 || info.ragdollindex >= 0) continue; - for(int parent = info.parent; parent >= 0; parent = bones[parent].parent) { - if(bones[parent].ragdollindex >= 0) { ragdoll->addreljoint(i, bones[parent].ragdollindex); break; } - } - } - } calcantipodes(); } @@ -572,7 +541,6 @@ struct skelmodel : animmodel { } void optimize() { cleanup(); - if(ragdoll) ragdoll->setup(); remapbones(); initpitchdeps(); } @@ -694,56 +662,6 @@ struct skelmodel : animmodel { } loopv(antipodes) sc.bdata[antipodes[i].child].fixantipodal(sc.bdata[antipodes[i].parent]); } - void initragdoll(ragdolldata &d, skelcacheentry &sc, part *p) { - const dualquat *bdata = sc.bdata; - loopv(ragdoll->joints) { - const ragdollskel::joint &j = ragdoll->joints[i]; - const boneinfo &b = bones[j.bone]; - const dualquat &q = bdata[b.interpindex]; - loopk(3) if(j.vert[k] >= 0) { - ragdollskel::vert &v = ragdoll->verts[j.vert[k]]; - ragdolldata::vert &dv = d.verts[j.vert[k]]; - dv.pos.add(q.transform(v.pos).mul(v.weight)); - } - } - if(ragdoll->animjoints) loopv(ragdoll->joints) { - const ragdollskel::joint &j = ragdoll->joints[i]; - const boneinfo &b = bones[j.bone]; - const dualquat &q = bdata[b.interpindex]; - d.calcanimjoint(i, matrix4x3(q)); - } - loopv(ragdoll->verts) { - ragdolldata::vert &dv = d.verts[i]; - matrixstack[matrixpos].transform(vec(dv.pos).add(p->translate).mul(p->model->scale), dv.pos); - } - loopv(ragdoll->reljoints) { - const ragdollskel::reljoint &r = ragdoll->reljoints[i]; - const ragdollskel::joint &j = ragdoll->joints[r.parent]; - const boneinfo &br = bones[r.bone], &bj = bones[j.bone]; - d.reljoints[i].mul(dualquat(bdata[bj.interpindex]).invert(), bdata[br.interpindex]); - } - } - void genragdollbones(ragdolldata &d, skelcacheentry &sc, part *p) { - if(!sc.bdata) sc.bdata = new dualquat[numinterpbones]; - sc.nextversion(); - loopv(ragdoll->joints) { - const ragdollskel::joint &j = ragdoll->joints[i]; - const boneinfo &b = bones[j.bone]; - vec pos(0, 0, 0); - loopk(3) if(j.vert[k]>=0) pos.add(d.verts[j.vert[k]].pos); - pos.mul(j.weight/p->model->scale).sub(p->translate); - matrix4x3 m; - m.mul(d.tris[j.tri], pos, d.animjoints ? d.animjoints[i] : j.orient); - sc.bdata[b.interpindex] = dualquat(m); - } - loopv(ragdoll->reljoints) { - const ragdollskel::reljoint &r = ragdoll->reljoints[i]; - const ragdollskel::joint &j = ragdoll->joints[r.parent]; - const boneinfo &br = bones[r.bone], &bj = bones[j.bone]; - sc.bdata[br.interpindex].mul(sc.bdata[bj.interpindex], d.reljoints[i]); - } - loopv(antipodes) sc.bdata[antipodes[i].child].fixantipodal(sc.bdata[antipodes[i].parent]); - } void concattagtransform(part *p, int i, const matrix4x3 &m, matrix4x3 &n) { (void)i;(void)m;(void)n;(void)p; matrix4x3 t; @@ -781,7 +699,8 @@ struct skelmodel : animmodel { usegpuskel = gpuaccelerate(); } } - skelcacheentry &checkskelcache(part *p, const animstate *as, float pitch, const vec &axis, const vec &forward, ragdolldata *rdata) { + skelcacheentry &checkskelcache(part *p, const animstate *as, float pitch, const vec &axis, const vec &forward) { + (void) p; if(skelcache.empty()) { usegpuskel = gpuaccelerate(); } @@ -792,7 +711,7 @@ struct skelmodel : animmodel { loopv(skelcache) { skelcacheentry &c = skelcache[i]; loopj(numanimparts) if(c.as[j]!=as[j]) goto mismatch; - if(c.pitch != pitch || c.partmask != partmask || c.ragdoll != rdata || (rdata && c.millis < rdata->lastmove)) goto mismatch; + if(c.pitch != pitch || c.partmask != partmask) goto mismatch; match = true; sc = &c; break; @@ -804,9 +723,7 @@ struct skelmodel : animmodel { loopi(numanimparts) sc->as[i] = as[i]; sc->pitch = pitch; sc->partmask = partmask; - sc->ragdoll = rdata; - if(rdata) genragdollbones(*rdata, *sc, p); - else interpbones(as, pitch, axis, forward, numanimparts, partmask, *sc); + interpbones(as, pitch, axis, forward, numanimparts, partmask, *sc); } sc->millis = lastmillis; return *sc; @@ -1117,7 +1034,7 @@ struct skelmodel : animmodel { skel->calctags(p); return; } - skelcacheentry &sc = skel->checkskelcache(p, as, pitch, axis, forward, as->cur.anim&ANIM_RAGDOLL || !d || !d->ragdoll || d->ragdoll->skel != skel->ragdoll ? NULL : d->ragdoll); + skelcacheentry &sc = skel->checkskelcache(p, as, pitch, axis, forward); if(!(as->cur.anim&ANIM_NORENDER)) { int owner = &sc-&skel->skelcache[0]; vbocacheentry &vc = skel->usegpuskel ? *vbocache : checkvbocache(sc, owner); @@ -1152,11 +1069,6 @@ struct skelmodel : animmodel { } } skel->calctags(p, &sc); - if(as->cur.anim&ANIM_RAGDOLL && skel->ragdoll && !d->ragdoll) { - d->ragdoll = new ragdolldata(skel->ragdoll, p->model->scale); - skel->initragdoll(*d->ragdoll, sc, p); - d->ragdoll->init(d); - } } }; struct animpartmask { @@ -1429,4 +1341,3 @@ template<class MDL> struct skelcommands : modelcommands<MDL, struct MDL::skelmes } } }; - |
