1
0
Fork 0
mirror of https://git.rip/DMCA_FUCKER/re3.git synced 2024-12-23 03:00:01 +00:00

anim fixes

This commit is contained in:
aap 2020-12-18 23:47:38 +01:00
parent a080fbfbd4
commit df5bafc80c
6 changed files with 49 additions and 40 deletions

View file

@ -52,7 +52,6 @@ CAnimBlendHierarchy::RemoveQuaternionFlips(void)
void
CAnimBlendHierarchy::RemoveAnimSequences(void)
{
if(sequences)
delete[] sequences;
numSequences = 0;
}

View file

@ -15,7 +15,7 @@ public:
char name[24];
CAnimBlendSequence *sequences;
int16 numSequences;
int16 compressed; // not really used
int16 compressed;
float totalLength;
CLink<CAnimBlendHierarchy*> *linkPtr;

View file

@ -16,9 +16,10 @@ CAnimBlendSequence::CAnimBlendSequence(void)
CAnimBlendSequence::~CAnimBlendSequence(void)
{
assert(keyFramesCompressed == nil);
if(keyFrames)
RwFree(keyFrames);
if(keyFramesCompressed)
RwFree(keyFramesCompressed);
}
void

View file

@ -841,54 +841,57 @@ CAnimManager::LoadAnimFile(int fd, bool compress)
ROUNDSIZE(anim.size);
CFileMgr::Read(fd, buf, anim.size);
int numFrames = *(int*)(buf+28);
seq->SetName(buf);
#ifdef PED_SKIN
if(anim.size == 44)
seq->SetBoneTag(*(int*)(buf+40));
#endif
seq->SetName(buf);
if(numFrames == 0)
continue;
bool hasScale = false;
bool hasTranslation = false;
CFileMgr::Read(fd, (char*)&info, sizeof(info));
if(strncmp(info.ident, "KR00", 4) == 0){
seq->SetNumFrames(numFrames, false);
KeyFrame *kf = seq->GetKeyFrame(0);
for(l = 0; l < numFrames; l++, kf++){
CFileMgr::Read(fd, buf, 0x14);
kf->rotation.x = -fbuf[0];
kf->rotation.y = -fbuf[1];
kf->rotation.z = -fbuf[2];
kf->rotation.w = fbuf[3];
kf->deltaTime = fbuf[4]; // absolute time here
}
if(strncmp(info.ident, "KRTS", 4) == 0){
hasScale = true;
seq->SetNumFrames(numFrames, true);
}else if(strncmp(info.ident, "KRT0", 4) == 0){
hasTranslation = true;
seq->SetNumFrames(numFrames, true);
KeyFrameTrans *kf = (KeyFrameTrans*)seq->GetKeyFrame(0);
for(l = 0; l < numFrames; l++, kf++){
CFileMgr::Read(fd, buf, 0x20);
kf->rotation.x = -fbuf[0];
kf->rotation.y = -fbuf[1];
kf->rotation.z = -fbuf[2];
kf->rotation.w = fbuf[3];
kf->translation.x = fbuf[4];
kf->translation.y = fbuf[5];
kf->translation.z = fbuf[6];
kf->deltaTime = fbuf[7]; // absolute time here
}else if(strncmp(info.ident, "KR00", 4) == 0){
seq->SetNumFrames(numFrames, false);
}
}else if(strncmp(info.ident, "KRTS", 4) == 0){
seq->SetNumFrames(numFrames, true);
KeyFrameTrans *kf = (KeyFrameTrans*)seq->GetKeyFrame(0);
for(l = 0; l < numFrames; l++, kf++){
for(l = 0; l < numFrames; l++){
if(hasScale){
CFileMgr::Read(fd, buf, 0x2C);
kf->rotation.x = -fbuf[0];
kf->rotation.y = -fbuf[1];
kf->rotation.z = -fbuf[2];
kf->rotation.w = fbuf[3];
kf->translation.x = fbuf[4];
kf->translation.y = fbuf[5];
kf->translation.z = fbuf[6];
CQuaternion rot(fbuf[0], fbuf[1], fbuf[2], fbuf[3]);
rot.Invert();
CVector trans(fbuf[4], fbuf[5], fbuf[6]);
KeyFrameTrans *kf = (KeyFrameTrans*)seq->GetKeyFrame(l);
kf->rotation = rot;
kf->translation = trans;
// scaling ignored
kf->deltaTime = fbuf[10]; // absolute time here
}else if(hasTranslation){
CFileMgr::Read(fd, buf, 0x20);
CQuaternion rot(fbuf[0], fbuf[1], fbuf[2], fbuf[3]);
rot.Invert();
CVector trans(fbuf[4], fbuf[5], fbuf[6]);
KeyFrameTrans *kf = (KeyFrameTrans*)seq->GetKeyFrame(l);
kf->rotation = rot;
kf->translation = trans;
kf->deltaTime = fbuf[7]; // absolute time here
}else{
CFileMgr::Read(fd, buf, 0x14);
CQuaternion rot(fbuf[0], fbuf[1], fbuf[2], fbuf[3]);
rot.Invert();
KeyFrame *kf = (KeyFrame*)seq->GetKeyFrame(l);
kf->rotation = rot;
kf->deltaTime = fbuf[4]; // absolute time here
}
}

View file

@ -8,6 +8,7 @@
#include "AnimBlendClumpData.h"
#include "AnimBlendHierarchy.h"
#include "AnimBlendAssociation.h"
#include "AnimManager.h"
#include "RpAnimBlend.h"
#ifdef PED_SKIN
#include "PedModelInfo.h"
@ -441,7 +442,7 @@ RpAnimBlendClumpUpdateAnimations(RpClump *clump, float timeDelta)
next = link->next;
CAnimBlendAssociation *assoc = CAnimBlendAssociation::FromLink(link);
if(assoc->UpdateBlend(timeDelta)){
// CAnimManager::UncompressAnimation(v6->hierarchy)
CAnimManager::UncompressAnimation(assoc->hierarchy);
updateData.nodes[i++] = assoc->GetNode(0);
if(assoc->flags & ASSOC_MOVEMENT){
totalLength += assoc->hierarchy->totalLength/assoc->speed * assoc->blendAmount;

View file

@ -12,6 +12,11 @@ public:
float MagnitudeSqr(void) const { return x*x + y*y + z*z + w*w; }
void Normalise(void);
void Multiply(const CQuaternion &q1, const CQuaternion &q2);
void Invert(void){ // Conjugate would have been a better name
x = -x;
y = -y;
z = -z;
}
const CQuaternion &operator+=(CQuaternion const &right) {
x += right.x;