summaryrefslogtreecommitdiffstats
path: root/src/animation
diff options
context:
space:
mode:
authoreray orçunus <erayorcunus@gmail.com>2020-07-30 14:11:06 +0200
committereray orçunus <erayorcunus@gmail.com>2020-07-30 14:32:34 +0200
commiteafa9cc10797db529e74b0480f51d7b8ade12cfe (patch)
treef71aaea5e1ffad4cb1584f6858e633d07373a651 /src/animation
parentFix Win32 OAL build (diff)
downloadre3-eafa9cc10797db529e74b0480f51d7b8ade12cfe.tar
re3-eafa9cc10797db529e74b0480f51d7b8ade12cfe.tar.gz
re3-eafa9cc10797db529e74b0480f51d7b8ade12cfe.tar.bz2
re3-eafa9cc10797db529e74b0480f51d7b8ade12cfe.tar.lz
re3-eafa9cc10797db529e74b0480f51d7b8ade12cfe.tar.xz
re3-eafa9cc10797db529e74b0480f51d7b8ade12cfe.tar.zst
re3-eafa9cc10797db529e74b0480f51d7b8ade12cfe.zip
Diffstat (limited to 'src/animation')
-rw-r--r--src/animation/AnimManager.cpp22
-rw-r--r--src/animation/CutsceneMgr.cpp81
-rw-r--r--src/animation/CutsceneMgr.h4
3 files changed, 81 insertions, 26 deletions
diff --git a/src/animation/AnimManager.cpp b/src/animation/AnimManager.cpp
index f682964f..a85149e6 100644
--- a/src/animation/AnimManager.cpp
+++ b/src/animation/AnimManager.cpp
@@ -12,7 +12,7 @@
#include "AnimManager.h"
#include "Streaming.h"
-//--MIAMI: code done (except for pointless TODO)
+//--MIAMI: file done
CAnimBlock CAnimManager::ms_aAnimBlocks[NUMANIMBLOCKS];
CAnimBlendHierarchy CAnimManager::ms_aAnimations[NUMANIMATIONS];
@@ -1276,7 +1276,7 @@ CAnimManager::LoadAnimFile(const char *filename)
RwStreamClose(stream, nil);
}
-//--MIAMI: done (except maybe implement some unimplemented compression?)
+//--MIAMI: done
void
CAnimManager::LoadAnimFile(RwStream *stream, bool compress, char (*somename)[32])
{
@@ -1323,7 +1323,14 @@ CAnimManager::LoadAnimFile(RwStream *stream, bool compress, char (*somename)[32]
RwStreamRead(stream, buf, name.size);
hier->SetName(buf);
- // TODO(MIAMI)? some unused crap here
+ // Unimplemented uncompressed anim thing
+ if (somename) {
+ for (int i = 0; somename[i][0]; i++) {
+ if (!CGeneral::faststricmp(somename[i], hier->name))
+ debug("Loading %s uncompressed\n", hier->name);
+ }
+ }
+
hier->compressed = false;
hier->compressed2 = false;
@@ -1357,6 +1364,9 @@ CAnimManager::LoadAnimFile(RwStream *stream, bool compress, char (*somename)[32]
if(strncmp(info.ident, "KR00", 4) == 0){
seq->SetNumFrames(numFrames, false, false);
KeyFrame *kf = seq->GetKeyFrame(0);
+ if (strstr(seq->name, "L Toe"))
+ debug("anim %s has toe keyframes\n", hier->name); // , seq->name);
+
for(l = 0; l < numFrames; l++, kf++){
RwStreamRead(stream, buf, 0x14);
kf->rotation.x = -fbuf[0];
@@ -1368,6 +1378,9 @@ CAnimManager::LoadAnimFile(RwStream *stream, bool compress, char (*somename)[32]
}else if(strncmp(info.ident, "KRT0", 4) == 0){
seq->SetNumFrames(numFrames, true, false);
KeyFrameTrans *kf = (KeyFrameTrans*)seq->GetKeyFrame(0);
+ if (strstr(seq->name, "L Toe"))
+ debug("anim %s has toe keyframes\n", hier->name); // , seq->name);
+
for(l = 0; l < numFrames; l++, kf++){
RwStreamRead(stream, buf, 0x20);
kf->rotation.x = -fbuf[0];
@@ -1382,6 +1395,9 @@ CAnimManager::LoadAnimFile(RwStream *stream, bool compress, char (*somename)[32]
}else if(strncmp(info.ident, "KRTS", 4) == 0){
seq->SetNumFrames(numFrames, true, false);
KeyFrameTrans *kf = (KeyFrameTrans*)seq->GetKeyFrame(0);
+ if (strstr(seq->name, "L Toe"))
+ debug("anim %s has toe keyframes\n", hier->name); // , seq->name);
+
for(l = 0; l < numFrames; l++, kf++){
RwStreamRead(stream, buf, 0x2C);
kf->rotation.x = -fbuf[0];
diff --git a/src/animation/CutsceneMgr.cpp b/src/animation/CutsceneMgr.cpp
index b4f226e8..e720fccb 100644
--- a/src/animation/CutsceneMgr.cpp
+++ b/src/animation/CutsceneMgr.cpp
@@ -119,7 +119,10 @@ int32 CCutsceneMgr::ms_numCutsceneObjs;
bool CCutsceneMgr::ms_loaded;
bool CCutsceneMgr::ms_animLoaded;
bool CCutsceneMgr::ms_useLodMultiplier;
+bool CCutsceneMgr::ms_camLoaded;
char CCutsceneMgr::ms_cutsceneName[CUTSCENENAMESIZE];
+char CCutsceneMgr::ms_uncompressedAnims[8][32];
+uint32 CCutsceneMgr::ms_numUncompressedAnims;
CAnimBlendAssocGroup CCutsceneMgr::ms_cutsceneAssociations;
CVector CCutsceneMgr::ms_cutsceneOffset;
float CCutsceneMgr::ms_cutsceneTimer;
@@ -154,6 +157,9 @@ CCutsceneMgr::Initialise(void)
ms_pCutsceneDir = new CDirectory(CUTSCENEDIRSIZE);
ms_pCutsceneDir->ReadDirFile("ANIM\\CUTS.DIR");
+
+ ms_numUncompressedAnims = 0;
+ ms_uncompressedAnims[0][0] = '\0';
}
void
@@ -194,7 +200,7 @@ CCutsceneMgr::LoadCutsceneData(const char *szCutsceneName)
CStreaming::MakeSpaceFor(size << 11);
CStreaming::ImGonnaUseStreamingMemory();
RwStreamSkip(stream, offset << 11);
- CAnimManager::LoadAnimFile(stream, false);
+ CAnimManager::LoadAnimFile(stream, true, ms_uncompressedAnims);
ms_cutsceneAssociations.CreateAssociations(szCutsceneName);
CStreaming::IHaveUsedStreamingMemory();
ms_animLoaded = true;
@@ -207,13 +213,18 @@ CCutsceneMgr::LoadCutsceneData(const char *szCutsceneName)
file = CFileMgr::OpenFile("ANIM\\CUTS.IMG", "rb");
sprintf(gString, "%s.DAT", szCutsceneName);
if (ms_pCutsceneDir->FindItem(gString, offset, size)) {
+ CStreaming::ImGonnaUseStreamingMemory();
CFileMgr::Seek(file, offset << 11, SEEK_SET);
TheCamera.LoadPathSplines(file);
+ CStreaming::IHaveUsedStreamingMemory();
+ ms_camLoaded = true;
+ } else {
+ ms_camLoaded = false;
}
CFileMgr::CloseFile(file);
- if (CGeneral::faststricmp(ms_cutsceneName, "end")) {
+ if (CGeneral::faststricmp(ms_cutsceneName, "finale")) {
DMAudio.ChangeMusicMode(MUSICMODE_CUTSCENE);
int trackId = FindCutsceneAudioTrackId(szCutsceneName);
if (trackId != -1) {
@@ -241,8 +252,10 @@ void
CCutsceneMgr::FinishCutscene()
{
ms_wasCutsceneSkipped = true;
- CCutsceneMgr::ms_cutsceneTimer = TheCamera.GetCutSceneFinishTime() * 0.001f;
- TheCamera.FinishCutscene();
+ if (ms_camLoaded) {
+ CCutsceneMgr::ms_cutsceneTimer = TheCamera.GetCutSceneFinishTime() * 0.001f;
+ TheCamera.FinishCutscene();
+ }
FindPlayerPed()->bIsVisible = true;
CWorld::Players[CWorld::PlayerInFocus].MakePlayerSafe(false);
@@ -251,9 +264,11 @@ CCutsceneMgr::FinishCutscene()
void
CCutsceneMgr::SetupCutsceneToStart(void)
{
- TheCamera.SetCamCutSceneOffSet(ms_cutsceneOffset);
- TheCamera.TakeControlWithSpline(JUMP_CUT);
- TheCamera.SetWideScreenOn();
+ if (ms_camLoaded) {
+ TheCamera.SetCamCutSceneOffSet(ms_cutsceneOffset);
+ TheCamera.TakeControlWithSpline(JUMP_CUT);
+ TheCamera.SetWideScreenOn();
+ }
ms_cutsceneOffset.z++;
@@ -363,8 +378,14 @@ CCutsceneMgr::DeleteCutsceneData(void)
CAnimManager::RemoveLastAnimFile();
ms_animLoaded = false;
- TheCamera.RestoreWithJumpCut();
- TheCamera.SetWideScreenOff();
+ ms_numUncompressedAnims = 0;
+ ms_uncompressedAnims[0][0] = '\0';
+
+ if (ms_camLoaded) {
+ TheCamera.RestoreWithJumpCut();
+ TheCamera.SetWideScreenOff();
+ TheCamera.DeleteCutSceneCamDataMemory();
+ }
ms_running = false;
ms_loaded = false;
@@ -372,12 +393,14 @@ CCutsceneMgr::DeleteCutsceneData(void)
CPad::GetPad(0)->SetEnablePlayerControls(PLAYERCONTROL_CUTSCENE);
CWorld::Players[CWorld::PlayerInFocus].MakePlayerSafe(false);
- if (CGeneral::faststricmp(ms_cutsceneName, "end")) {
+ if (CGeneral::faststricmp(ms_cutsceneName, "finale")) {
DMAudio.StopCutSceneMusic();
- if (CGeneral::faststricmp(ms_cutsceneName, "bet"))
- DMAudio.ChangeMusicMode(MUSICMODE_GAME);
+ DMAudio.ChangeMusicMode(MUSICMODE_GAME);
}
- CGame::DrasticTidyUpMemory(TheCamera.GetScreenFadeStatus() == 2);
+
+ if(ms_camLoaded)
+ CGame::DrasticTidyUpMemory(TheCamera.GetScreenFadeStatus() == 2);
+
CTimer::Resume();
}
@@ -395,7 +418,7 @@ CCutsceneMgr::Update(void)
switch (ms_cutsceneLoadStatus) {
case CUTSCENE_LOADING_AUDIO:
SetupCutsceneToStart();
- if (CGeneral::faststricmp(ms_cutsceneName, "end"))
+ if (CGeneral::faststricmp(ms_cutsceneName, "finale"))
DMAudio.PlayPreloadedCutSceneMusic();
ms_cutsceneLoadStatus++;
break;
@@ -413,15 +436,27 @@ CCutsceneMgr::Update(void)
if (!ms_running) return;
ms_cutsceneTimer += CTimer::GetTimeStepNonClippedInSeconds();
- if (CGeneral::faststricmp(ms_cutsceneName, "end") && TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_FLYBY && ms_cutsceneLoadStatus == CUTSCENE_LOADING_0) {
- if (CPad::GetPad(0)->GetCrossJustDown()
- || (CGame::playingIntro && CPad::GetPad(0)->GetStartJustDown())
- || CPad::GetPad(0)->GetLeftMouseJustDown()
- || CPad::GetPad(0)->GetEnterJustDown()
- || CPad::GetPad(0)->GetCharJustDown(' '))
- FinishCutscene();
- }
+
+ if (ms_camLoaded)
+ if (CGeneral::faststricmp(ms_cutsceneName, "finale") && TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_FLYBY && ms_cutsceneLoadStatus == CUTSCENE_LOADING_0) {
+ if (CPad::GetPad(0)->GetCrossJustDown()
+ || (CGame::playingIntro && CPad::GetPad(0)->GetStartJustDown())
+ || CPad::GetPad(0)->GetLeftMouseJustDown()
+ || CPad::GetPad(0)->GetEnterJustDown()
+ || CPad::GetPad(0)->GetCharJustDown(' '))
+ FinishCutscene();
+ }
}
-bool CCutsceneMgr::HasCutsceneFinished(void) { return TheCamera.GetPositionAlongSpline() == 1.0f; }
+bool CCutsceneMgr::HasCutsceneFinished(void) { return !ms_camLoaded || TheCamera.GetPositionAlongSpline() == 1.0f; }
+void
+CCutsceneMgr::LoadAnimationUncompressed(char const* name)
+{
+ strcpy(ms_uncompressedAnims[ms_numUncompressedAnims], name);
+
+ // Because that's how CAnimManager knows the end of array
+ ++ms_numUncompressedAnims;
+ assert(ms_numUncompressedAnims < ARRAY_SIZE(ms_uncompressedAnims));
+ ms_uncompressedAnims[ms_numUncompressedAnims][0] = '\0';
+} \ No newline at end of file
diff --git a/src/animation/CutsceneMgr.h b/src/animation/CutsceneMgr.h
index 97093fb1..c3f86273 100644
--- a/src/animation/CutsceneMgr.h
+++ b/src/animation/CutsceneMgr.h
@@ -17,7 +17,10 @@ class CCutsceneMgr
static bool ms_animLoaded;
static bool ms_useLodMultiplier;
+ static bool ms_camLoaded;
static char ms_cutsceneName[CUTSCENENAMESIZE];
+ static char ms_uncompressedAnims[8][32];
+ static uint32 ms_numUncompressedAnims;
static CAnimBlendAssocGroup ms_cutsceneAssociations;
static CVector ms_cutsceneOffset;
static float ms_cutsceneTimer;
@@ -49,5 +52,6 @@ public:
static CCutsceneHead *AddCutsceneHead(CObject *pObject, int modelId);
static CCutsceneObject *CreateCutsceneObject(int modelId);
static void DeleteCutsceneData(void);
+ static void LoadAnimationUncompressed(char const*);
static void Update(void);
};