summaryrefslogtreecommitdiffstats
path: root/src/animation
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/animation/AnimBlendHierarchy.cpp3
-rw-r--r--src/animation/AnimBlendHierarchy.h2
-rw-r--r--src/animation/AnimBlendSequence.cpp3
-rw-r--r--src/animation/AnimManager.cpp91
-rw-r--r--src/animation/AnimManager.h2
-rw-r--r--src/animation/AnimationId.h6
-rw-r--r--src/animation/RpAnimBlend.cpp3
7 files changed, 70 insertions, 40 deletions
diff --git a/src/animation/AnimBlendHierarchy.cpp b/src/animation/AnimBlendHierarchy.cpp
index c7800de5..ea669999 100644
--- a/src/animation/AnimBlendHierarchy.cpp
+++ b/src/animation/AnimBlendHierarchy.cpp
@@ -52,8 +52,7 @@ CAnimBlendHierarchy::RemoveQuaternionFlips(void)
void
CAnimBlendHierarchy::RemoveAnimSequences(void)
{
- if(sequences)
- delete[] sequences;
+ delete[] sequences;
numSequences = 0;
}
diff --git a/src/animation/AnimBlendHierarchy.h b/src/animation/AnimBlendHierarchy.h
index e35b4925..40d2731b 100644
--- a/src/animation/AnimBlendHierarchy.h
+++ b/src/animation/AnimBlendHierarchy.h
@@ -15,7 +15,7 @@ public:
char name[24];
CAnimBlendSequence *sequences;
int16 numSequences;
- int16 compressed; // not really used
+ int16 compressed;
float totalLength;
CLink<CAnimBlendHierarchy*> *linkPtr;
diff --git a/src/animation/AnimBlendSequence.cpp b/src/animation/AnimBlendSequence.cpp
index c958b71a..2ae150c1 100644
--- a/src/animation/AnimBlendSequence.cpp
+++ b/src/animation/AnimBlendSequence.cpp
@@ -16,9 +16,10 @@ CAnimBlendSequence::CAnimBlendSequence(void)
CAnimBlendSequence::~CAnimBlendSequence(void)
{
- assert(keyFramesCompressed == nil);
if(keyFrames)
RwFree(keyFrames);
+ if(keyFramesCompressed)
+ RwFree(keyFramesCompressed);
}
void
diff --git a/src/animation/AnimManager.cpp b/src/animation/AnimManager.cpp
index 877dcd76..8d442b72 100644
--- a/src/animation/AnimManager.cpp
+++ b/src/animation/AnimManager.cpp
@@ -57,6 +57,9 @@ AnimAssocDesc aStdAnimDescs[] = {
{ ANIM_HIT_BACK, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION },
{ ANIM_HIT_RIGHT, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
{ ANIM_FLOOR_HIT, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL },
+#if GTA_VERSION <= GTA3_PS2_160
+ { ANIM_HIT_BODY, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
+#endif
{ ANIM_HIT_BODYBLOW, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION },
{ ANIM_HIT_CHEST, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION },
{ ANIM_HIT_HEAD, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION },
@@ -78,6 +81,8 @@ AnimAssocDesc aStdAnimDescs[] = {
{ ANIM_BOMBER, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_NOWALK },
{ ANIM_HGUN_RELOAD, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_NOWALK },
{ ANIM_AK_RELOAD, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_NOWALK },
+#ifdef PC_PLAYER_CONTROLS
+ // maybe wrong define, but unused anyway
{ ANIM_FPS_PUNCH, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
{ ANIM_FPS_BAT, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
{ ANIM_FPS_UZI, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
@@ -85,6 +90,7 @@ AnimAssocDesc aStdAnimDescs[] = {
{ ANIM_FPS_AK, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
{ ANIM_FPS_M16, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
{ ANIM_FPS_ROCKET, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
+#endif
{ ANIM_FIGHT_IDLE, ASSOC_REPEAT },
{ ANIM_FIGHT2_IDLE, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
{ ANIM_FIGHT_SH_F, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION },
@@ -193,6 +199,7 @@ AnimAssocDesc aStdAnimDescs[] = {
{ ANIM_PHONE_OUT, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
{ ANIM_PHONE_TALK, ASSOC_REPEAT | ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL },
};
+#ifdef PC_PLAYER_CONTROLS
AnimAssocDesc aStdAnimDescsSide[] = {
{ ANIM_WALK, ASSOC_REPEAT | ASSOC_MOVEMENT | ASSOC_HAS_TRANSLATION | ASSOC_WALK | ASSOC_HAS_X_TRANSLATION },
{ ANIM_RUN, ASSOC_REPEAT | ASSOC_MOVEMENT | ASSOC_HAS_TRANSLATION | ASSOC_WALK | ASSOC_HAS_X_TRANSLATION },
@@ -200,6 +207,7 @@ AnimAssocDesc aStdAnimDescsSide[] = {
{ ANIM_IDLE_STANCE, ASSOC_REPEAT },
{ ANIM_WALK_START, ASSOC_HAS_TRANSLATION | ASSOC_HAS_X_TRANSLATION },
};
+#endif
char const *aStdAnimations[] = {
"walk_civi",
"run_civi",
@@ -239,6 +247,9 @@ char const *aStdAnimations[] = {
"HIT_back",
"HIT_R",
"FLOOR_hit",
+#if GTA_VERSION <= GTA3_PS2_160
+ "HIT_body",
+#endif
"HIT_bodyblow",
"HIT_chest",
"HIT_head",
@@ -260,6 +271,8 @@ char const *aStdAnimations[] = {
"bomber",
"WEAPON_hgun_rload",
"WEAPON_AK_rload",
+#ifdef PC_PLAYER_CONTROLS
+ // maybe wrong define, but unused anyway
"FPS_PUNCH",
"FPS_BAT",
"FPS_UZI",
@@ -267,6 +280,7 @@ char const *aStdAnimations[] = {
"FPS_AK",
"FPS_M16",
"FPS_ROCKET",
+#endif
"FIGHTIDLE",
"FIGHT2IDLE",
"FIGHTsh_F",
@@ -488,6 +502,7 @@ char const *aPanicChunkyAnimations[] = {
"woman_runpanic",
"idle_stance",
};
+#ifdef PC_PLAYER_CONTROLS
char const *aPlayerStrafeBackAnimations[] = {
"walk_player_back",
"run_player_back",
@@ -530,6 +545,7 @@ char const *aRocketStrafeRightAnimations[] = {
"idle_rocket",
"walkst_rocket_right",
};
+#endif
#define awc(a) ARRAY_SIZE(a), a
const AnimAssocDefinition CAnimManager::ms_aAnimAssocDefinitions[NUM_ANIM_ASSOC_GROUPS] = {
@@ -552,12 +568,14 @@ const AnimAssocDefinition CAnimManager::ms_aAnimAssocDefinitions[NUM_ANIM_ASSOC_
{ "oldwoman", "ped", MI_COP, awc(aOldWomanAnimations), aStdAnimDescs },
{ "fatwoman", "ped", MI_COP, awc(aFatWomanAnimations), aStdAnimDescs },
{ "panicchunky", "ped", MI_COP, awc(aPanicChunkyAnimations), aStdAnimDescs },
+#ifdef PC_PLAYER_CONTROLS
{ "playerback", "ped", MI_COP, awc(aPlayerStrafeBackAnimations), aStdAnimDescs },
{ "playerleft", "ped", MI_COP, awc(aPlayerStrafeLeftAnimations), aStdAnimDescsSide },
{ "playerright", "ped", MI_COP, awc(aPlayerStrafeRightAnimations), aStdAnimDescsSide },
{ "rocketback", "ped", MI_COP, awc(aRocketStrafeBackAnimations), aStdAnimDescs },
{ "rocketleft", "ped", MI_COP, awc(aRocketStrafeLeftAnimations), aStdAnimDescsSide },
{ "rocketright", "ped", MI_COP, awc(aRocketStrafeRightAnimations), aStdAnimDescsSide },
+#endif
};
#undef awc
@@ -841,54 +859,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
- }
- }else if(strncmp(info.ident, "KRT0", 4) == 0){
+ if(strncmp(info.ident, "KRTS", 4) == 0){
+ hasScale = 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, "KRTS", 4) == 0){
+ }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++){
+ }else if(strncmp(info.ident, "KR00", 4) == 0){
+ seq->SetNumFrames(numFrames, false);
+ }
+
+ 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
}
}
diff --git a/src/animation/AnimManager.h b/src/animation/AnimManager.h
index de15602c..92192c71 100644
--- a/src/animation/AnimManager.h
+++ b/src/animation/AnimManager.h
@@ -24,12 +24,14 @@ enum AssocGroupId
ASSOCGRP_OLDWOMAN,
ASSOCGRP_FATWOMAN,
ASSOCGRP_PANICCHUNKY,
+#ifdef PC_PLAYER_CONTROLS
ASSOCGRP_PLAYERBACK,
ASSOCGRP_PLAYERLEFT,
ASSOCGRP_PLAYERRIGHT,
ASSOCGRP_ROCKETBACK,
ASSOCGRP_ROCKETLEFT,
ASSOCGRP_ROCKETRIGHT,
+#endif
NUM_ANIM_ASSOC_GROUPS
};
diff --git a/src/animation/AnimationId.h b/src/animation/AnimationId.h
index 82fed8bd..4b3dd92d 100644
--- a/src/animation/AnimationId.h
+++ b/src/animation/AnimationId.h
@@ -40,6 +40,9 @@ enum AnimationId
ANIM_HIT_BACK,
ANIM_HIT_RIGHT,
ANIM_FLOOR_HIT,
+#if GTA_VERSION <= GTA3_PS2_160
+ ANIM_HIT_BODY,
+#endif
ANIM_HIT_BODYBLOW,
ANIM_HIT_CHEST,
ANIM_HIT_HEAD,
@@ -61,6 +64,8 @@ enum AnimationId
ANIM_BOMBER,
ANIM_HGUN_RELOAD,
ANIM_AK_RELOAD,
+#ifdef PC_PLAYER_CONTROLS
+ // maybe wrong define, but unused anyway
ANIM_FPS_PUNCH,
ANIM_FPS_BAT,
ANIM_FPS_UZI,
@@ -68,6 +73,7 @@ enum AnimationId
ANIM_FPS_AK,
ANIM_FPS_M16,
ANIM_FPS_ROCKET,
+#endif
ANIM_FIGHT_IDLE,
ANIM_FIGHT2_IDLE,
ANIM_FIGHT_SH_F,
diff --git a/src/animation/RpAnimBlend.cpp b/src/animation/RpAnimBlend.cpp
index dcb656ee..e430e52a 100644
--- a/src/animation/RpAnimBlend.cpp
+++ b/src/animation/RpAnimBlend.cpp
@@ -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;