From ab3e810a95f60a97b2482f714608e88ac14f118b Mon Sep 17 00:00:00 2001 From: erorcun Date: Thu, 3 Dec 2020 05:22:58 +0300 Subject: AnimViewer done, comment cleanup --- src/core/AnimViewer.cpp | 49 +++++++++++++++++++++++++---------- src/core/main.cpp | 30 ++++++++++------------ src/peds/CivilianPed.cpp | 4 +-- src/peds/Ped.cpp | 11 ++++---- src/peds/Ped.h | 7 ++--- src/peds/PedFight.cpp | 4 +-- src/render/Occlusion.cpp | 5 ++++ src/skel/crossplatform.h | 3 --- src/skel/glfw/glfw.cpp | 67 ++++++++++++++++++++---------------------------- src/skel/skeleton.cpp | 5 ++-- src/skel/skeleton.h | 3 --- src/skel/win/win.cpp | 50 +++++++++++++++--------------------- 12 files changed, 116 insertions(+), 122 deletions(-) diff --git a/src/core/AnimViewer.cpp b/src/core/AnimViewer.cpp index d39be754..2b45ce02 100644 --- a/src/core/AnimViewer.cpp +++ b/src/core/AnimViewer.cpp @@ -18,6 +18,7 @@ #include "World.h" #include "Renderer.h" #include "AnimManager.h" +#include "AnimBlendAssocGroup.h" #include "AnimViewer.h" #include "PlayerPed.h" #include "Pools.h" @@ -60,11 +61,14 @@ CAnimViewer::Render(void) { void CAnimViewer::Initialise(void) { - LoadingScreen("Loading the ModelViewer", "", GetRandomSplashScreen()); - animTxdSlot = CTxdStore::AddTxdSlot("generic"); - CTxdStore::Create(animTxdSlot); + + // we need messages, messages needs hud, hud needs those int hudSlot = CTxdStore::AddTxdSlot("hud"); CTxdStore::LoadTxd(hudSlot, "MODELS/HUD.TXD"); + CHud::m_Wants_To_Draw_Hud = false; + + animTxdSlot = CTxdStore::AddTxdSlot("generic"); + CTxdStore::Create(animTxdSlot); int particleSlot = CTxdStore::AddTxdSlot("particle"); CTxdStore::LoadTxd(particleSlot, "MODELS/PARTICLE.TXD"); CTxdStore::SetCurrentTxd(animTxdSlot); @@ -73,10 +77,6 @@ CAnimViewer::Initialise(void) { TheCamera.Init(); TheCamera.SetRwCamera(Scene.camera); TheCamera.Cams[TheCamera.ActiveCam].Distance = 5.0f; - - gbModelViewer = true; - CHud::m_Wants_To_Draw_Hud = false; - ThePaths.Init(); ThePaths.AllocatePathFindInfoMem(4500); CCollision::Init(); @@ -138,6 +138,25 @@ CAnimViewer::Initialise(void) { } else { // TODO? maybe request some special models here so the thing doesn't crash } + + // From LCS. idk if needed + int vanBlock = CAnimManager::GetAnimationBlockIndex("van"); + int bikesBlock = CAnimManager::GetAnimationBlockIndex("bikes"); + int bikevBlock = CAnimManager::GetAnimationBlockIndex("bikev"); + int bikehBlock = CAnimManager::GetAnimationBlockIndex("bikeh"); + int bikedBlock = CAnimManager::GetAnimationBlockIndex("biked"); + CStreaming::FlushRequestList(); + CStreaming::RequestAnim(vanBlock, STREAMFLAGS_DEPENDENCY); + CStreaming::RequestAnim(bikesBlock, STREAMFLAGS_DEPENDENCY); + CStreaming::RequestAnim(bikevBlock, STREAMFLAGS_DEPENDENCY); + CStreaming::RequestAnim(bikehBlock, STREAMFLAGS_DEPENDENCY); + CStreaming::RequestAnim(bikedBlock, STREAMFLAGS_DEPENDENCY); + CStreaming::LoadAllRequestedModels(false); + CAnimManager::AddAnimBlockRef(vanBlock); + CAnimManager::AddAnimBlockRef(bikesBlock); + CAnimManager::AddAnimBlockRef(bikevBlock); + CAnimManager::AddAnimBlockRef(bikehBlock); + CAnimManager::AddAnimBlockRef(bikedBlock); } int @@ -215,8 +234,7 @@ CAnimViewer::Update(void) { static int modelId = 0; static int animId = 0; - // Please don't make this bool, static bool's are problematic on my side. - static int reloadIFP = 0; + static bool reloadIFP = false; AssocGroupId animGroup = ASSOCGRP_STD; int nextModelId = modelId; @@ -241,7 +259,7 @@ CAnimViewer::Update(void) CAnimManager::Initialise(); CAnimManager::LoadAnimFiles(); - reloadIFP = 0; + reloadIFP = false; } } else { animGroup = ASSOCGRP_STD; @@ -299,7 +317,7 @@ CAnimViewer::Update(void) // Triangle in mobile if (pad->GetSquareJustDown()) { - reloadIFP = 1; + reloadIFP = true; AsciiToUnicode("IFP reloaded", gUString); CMessages::AddMessage(gUString, 1000, 0); @@ -316,7 +334,7 @@ CAnimViewer::Update(void) } else if (pad->GetDPadUpJustDown()) { animId--; if (animId < 0) { - animId = NUM_ANIMS - 1; + animId = NUM_STD_ANIMS - 1; } PlayAnimation(pTarget->GetClump(), animGroup, (AnimationId)animId); @@ -325,7 +343,7 @@ CAnimViewer::Update(void) CMessages::AddMessage(gUString, 1000, 0); } else if (pad->GetDPadDownJustDown()) { - animId = (animId == (NUM_ANIMS - 1) ? 0 : animId + 1); + animId = (animId == (NUM_STD_ANIMS - 1) ? 0 : animId + 1); PlayAnimation(pTarget->GetClump(), animGroup, (AnimationId)animId); sprintf(gString, "Current anim: %d", animId); @@ -344,6 +362,11 @@ CAnimViewer::Update(void) AsciiToUnicode("Ped Col model will be animated as long as you hold the button", gUString); CMessages::AddMessage(gUString, 100, 0); } + + // From LCS + if (CAnimManager::GetAnimAssocGroups()[animGroup].numAssociations <= animId) + animId = 0; + } else if (modelInfo->GetModelType() == MITYPE_VEHICLE) { if (pad->GetLeftShoulder1JustDown()) { diff --git a/src/core/main.cpp b/src/core/main.cpp index ef40777f..7fb07fff 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -599,8 +599,10 @@ LoadingScreen(const char *str1, const char *str2, const char *splashscreen) AsciiToUnicode(str1, tmpstr); CFont::PrintString(hpos, top, tmpstr); top += 22*yscale; - AsciiToUnicode(str2, tmpstr); - CFont::PrintString(hpos, top, tmpstr); + if (str2) { + AsciiToUnicode(str2, tmpstr); + CFont::PrintString(hpos, top, tmpstr); + } #endif } @@ -1424,15 +1426,6 @@ AppEventHandler(RsEvent event, void *param) return rsEVENTPROCESSED; } -#ifndef MASTER - case rsANIMVIEWER: - { - TheModelViewer(); - - return rsEVENTPROCESSED; - } -#endif - default: { return rsEVENTNOTPROCESSED; @@ -1448,22 +1441,27 @@ TheModelViewer(void) //TODO #else - CDraw::CalculateAspectRatio(); + // This is not original. Because; + // 1- We want 2D things to be initalized, whereas original AnimViewer doesn't use them. my additions marked with X + // 2- VC Mobile code run it like main function(as opposed to III and LCS), so it has it's own loop inside it, but our func. already called in a loop. + + CDraw::CalculateAspectRatio(); // X CAnimViewer::Update(); - CTimer::Update(); SetLightsWithTimeOfDayColour(Scene.world); CRenderer::ConstructRenderList(); DoRWStuffStartOfFrame(CTimeCycle::GetSkyTopRed()*0.5f, CTimeCycle::GetSkyTopGreen()*0.5f, CTimeCycle::GetSkyTopBlue()*0.5f, CTimeCycle::GetSkyBottomRed(), CTimeCycle::GetSkyBottomGreen(), CTimeCycle::GetSkyBottomBlue(), 255); - CSprite2d::InitPerFrame(); - CFont::InitPerFrame(); + CSprite2d::SetRecipNearClip(); // X + CSprite2d::InitPerFrame(); // X + CFont::InitPerFrame(); // X DefinedState(); CVisibilityPlugins::InitAlphaEntityList(); CAnimViewer::Render(); - Render2dStuff(); + Render2dStuff(); // X DoRWStuffEndOfFrame(); + CTimer::Update(); #endif } #endif diff --git a/src/peds/CivilianPed.cpp b/src/peds/CivilianPed.cpp index bb7cfe76..a024b77a 100644 --- a/src/peds/CivilianPed.cpp +++ b/src/peds/CivilianPed.cpp @@ -18,7 +18,7 @@ #include #endif -// --MIAMI: file done except TODOs +// --MIAMI: file done CCivilianPed::CCivilianPed(ePedType pedtype, uint32 mi) : CPed(pedtype) { @@ -228,7 +228,7 @@ CCivilianPed::CivilianAI(void) void CCivilianPed::ProcessControl(void) { - if (CharCreatedBy == TODO_CHAR) + if (CharCreatedBy == UNK_CHAR) return; CPed::ProcessControl(); diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index 3df45145..b7623a33 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -39,8 +39,7 @@ #include "CutsceneShadow.h" #include "Clock.h" -// --MIAMI: file done except TODOs - +// --MIAMI: file done CPed *gapTempPedList[50]; uint16 gnNumTempPedList; @@ -4559,7 +4558,7 @@ CPed::PedSetInCarCB(CAnimBlendAssociation *animAssoc, void *arg) ped->bChangedSeat = true; } -// --MIAMI: Done, but what is TODO_CHAR?? +// --MIAMI: Done bool CPed::CanBeDeleted(void) { @@ -4571,7 +4570,7 @@ CPed::CanBeDeleted(void) return true; case MISSION_CHAR: return false; - case TODO_CHAR: + case UNK_CHAR: return false; default: return true; @@ -4587,7 +4586,7 @@ CPed::CanBeDeletedEvenInVehicle(void) return true; case MISSION_CHAR: return false; - case TODO_CHAR: + case UNK_CHAR: return false; default: return true; @@ -5522,7 +5521,7 @@ CPed::SetGetUp(void) if (m_nWaitState == WAITSTATE_SUN_BATHE_IDLE) { m_headingRate = 0.0f; - // TODO(Miami): Looks like that should've been another getup anim but R* forgot it. Visit here later + // Seemingly they planned to use different getup anims for different conditions, but sadly in final game all getup anims(GETUP1, GETUP2, GETUP3) are same... if (bFleeWhenStanding && m_threatEx) animAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_GETUP1, 1000.0f); else diff --git a/src/peds/Ped.h b/src/peds/Ped.h index 2af6dccd..608bb710 100644 --- a/src/peds/Ped.h +++ b/src/peds/Ped.h @@ -254,7 +254,7 @@ enum eObjective : uint32 { enum { RANDOM_CHAR = 1, MISSION_CHAR, - TODO_CHAR, // TODO(Miami) + UNK_CHAR, }; enum PedLineUpPhase { @@ -1155,10 +1155,7 @@ void FinishTalkingOnMobileCB(CAnimBlendAssociation* assoc, void* arg); void StartTalkingOnMobileCB(CAnimBlendAssociation* assoc, void* arg); void PlayRandomAnimationsFromAnimBlock(CPed* ped, AssocGroupId animGroup, uint32 first, uint32 amount); -// TODO(Miami): Change those when Ped struct is done -#ifndef PED_SKIN -VALIDATE_SIZE(CPed, 0x53C); -#endif +VALIDATE_SIZE(CPed, 0x5F4); bool IsPedPointerValid(CPed*); bool IsPedPointerValid_NotInWorld(CPed*); diff --git a/src/peds/PedFight.cpp b/src/peds/PedFight.cpp index f0f38b75..0367ef4c 100644 --- a/src/peds/PedFight.cpp +++ b/src/peds/PedFight.cpp @@ -26,7 +26,7 @@ #include "Glass.h" #include "SpecialFX.h" -//--MIAMI: file done except TODOs +//--MIAMI: file done uint16 nPlayerInComboMove; RpClump* flyingClumpTemp; @@ -4220,4 +4220,4 @@ CPed::RemoveWeaponAnims(int unused, float animDelta) else CAnimManager::BlendAnimation(GetClump(), m_animGroup, ANIM_IDLE_STANCE, -animDelta); } -} \ No newline at end of file +} diff --git a/src/render/Occlusion.cpp b/src/render/Occlusion.cpp index 79ce0461..5fef6e21 100644 --- a/src/render/Occlusion.cpp +++ b/src/render/Occlusion.cpp @@ -292,6 +292,11 @@ COcclusion::ProcessBeforeRendering(void) { NumActiveOccluders = 0; +#ifndef MASTER + if (gbModelViewer) + return; +#endif + if (CGame::currArea != AREA_MAIN_MAP) return; diff --git a/src/skel/crossplatform.h b/src/skel/crossplatform.h index fe1f22fd..bfc03913 100644 --- a/src/skel/crossplatform.h +++ b/src/skel/crossplatform.h @@ -87,9 +87,6 @@ enum eGameState GS_FRONTEND, GS_INIT_PLAYING_GAME, GS_PLAYING_GAME, -#ifndef MASTER - GS_ANIMVIEWER, -#endif }; extern RwUInt32 gGameState; diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index a20c1cc6..c219e711 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -1259,17 +1259,11 @@ void resizeCB(GLFWwindow* window, int width, int height) { * memory things don't work. */ /* redraw window */ -#ifndef MASTER - if (RwInitialised && (gGameState == GS_PLAYING_GAME || gGameState == GS_ANIMVIEWER)) - { - RsEventHandler((gGameState == GS_PLAYING_GAME ? rsIDLE : rsANIMVIEWER), (void *)TRUE); - } -#else + if (RwInitialised && gGameState == GS_PLAYING_GAME) { RsEventHandler(rsIDLE, (void *)TRUE); } -#endif if (RwInitialised && height > 0 && width > 0) { RwRect r; @@ -1644,18 +1638,6 @@ main(int argc, char *argv[]) FrontEndMenuManager.DrawMemoryCardStartUpMenus(); } #endif - - if (TurnOnAnimViewer) - { -#ifndef MASTER - CAnimViewer::Initialise(); -#ifndef PS2_MENU - FrontEndMenuManager.m_bGameNotLoaded = false; -#endif - gGameState = GS_ANIMVIEWER; - TurnOnAnimViewer = false; -#endif - } initkeymap(); @@ -1675,6 +1657,18 @@ main(int argc, char *argv[]) * Enter the message processing loop... */ +#ifndef MASTER + if (gbModelViewer) { + // This is TheModelViewer in LCS + LoadingScreen("Loading the ModelViewer", NULL, GetRandomSplashScreen()); + CAnimViewer::Initialise(); + CTimer::Update(); +#ifndef PS2_MENU + FrontEndMenuManager.m_bGameNotLoaded = false; +#endif + } +#endif + #ifdef PS2_MENU if (TheMemoryCard.m_bWantToLoad) LoadSplash(GetLevelSplashScreen(CGame::currLevel)); @@ -1689,7 +1683,13 @@ main(int argc, char *argv[]) #endif { glfwPollEvents(); - if( ForegroundApp ) +#ifndef MASTER + if (gbModelViewer) { + // This is TheModelViewerCore in LCS + TheModelViewer(); + } else +#endif + if ( ForegroundApp ) { switch ( gGameState ) { @@ -1893,18 +1893,6 @@ main(int argc, char *argv[]) } break; } -#ifndef MASTER - case GS_ANIMVIEWER: - { - float ms = (float)CTimer::GetCurrentTimeInCycles() / (float)CTimer::GetCyclesPerMillisecond(); - if (RwInitialised) - { - if (!FrontEndMenuManager.m_PrefsFrameLimiter || (1000.0f / (float)RsGlobal.maxFPS) < ms) - RsEventHandler(rsANIMVIEWER, (void*)TRUE); - } - break; - } -#endif } } else @@ -1976,12 +1964,13 @@ main(int argc, char *argv[]) } else { - if ( gGameState == GS_PLAYING_GAME ) - CGame::ShutDown(); #ifndef MASTER - else if ( gGameState == GS_ANIMVIEWER ) + if ( gbModelViewer ) CAnimViewer::Shutdown(); + else #endif + if ( gGameState == GS_PLAYING_GAME ) + CGame::ShutDown(); CTimer::Stop(); @@ -2002,13 +1991,13 @@ main(int argc, char *argv[]) #endif } - - if ( gGameState == GS_PLAYING_GAME ) - CGame::ShutDown(); #ifndef MASTER - else if ( gGameState == GS_ANIMVIEWER ) + if ( gbModelViewer ) CAnimViewer::Shutdown(); + else #endif + if ( gGameState == GS_PLAYING_GAME ) + CGame::ShutDown(); DMAudio.Terminate(); diff --git a/src/skel/skeleton.cpp b/src/skel/skeleton.cpp index e21abb17..a21d5674 100644 --- a/src/skel/skeleton.cpp +++ b/src/skel/skeleton.cpp @@ -10,13 +10,12 @@ #include "skeleton.h" #include "platform.h" +#include "main.h" // --MIAMI: file done static RwBool DefaultVideoMode = TRUE; -bool TurnOnAnimViewer = false; - RsGlobalType RsGlobal; #ifdef _WIN32 @@ -161,7 +160,7 @@ rsPreInitCommandLine(RwChar *arg) #ifndef MASTER if (!strcmp(arg, RWSTRING("-animviewer"))) { - TurnOnAnimViewer = TRUE; + gbModelViewer = TRUE; return TRUE; } diff --git a/src/skel/skeleton.h b/src/skel/skeleton.h index 1c468179..380b6c05 100644 --- a/src/skel/skeleton.h +++ b/src/skel/skeleton.h @@ -79,11 +79,8 @@ enum RsEvent rsPADANALOGUERIGHTRESET, rsPREINITCOMMANDLINE, rsACTIVATE, - rsANIMVIEWER, }; -extern bool TurnOnAnimViewer; - typedef enum RsEvent RsEvent; typedef RsEventStatus (*RsInputEventHandler)(RsEvent event, void *param); diff --git a/src/skel/win/win.cpp b/src/skel/win/win.cpp index b2d5a64f..a437a3b4 100644 --- a/src/skel/win/win.cpp +++ b/src/skel/win/win.cpp @@ -1008,17 +1008,11 @@ MainWndProc(HWND window, UINT message, WPARAM wParam, LPARAM lParam) RECT rect; /* redraw window */ -#ifndef MASTER - if (RwInitialised && (gGameState == GS_PLAYING_GAME || gGameState == GS_ANIMVIEWER)) - { - RsEventHandler((gGameState == GS_PLAYING_GAME ? rsIDLE : rsANIMVIEWER), (void *)TRUE); - } -#else + if (RwInitialised && gGameState == GS_PLAYING_GAME) { RsEventHandler(rsIDLE, (void *)TRUE); } -#endif /* Manually resize window */ rect.left = rect.top = 0; @@ -2173,17 +2167,17 @@ WinMain(HINSTANCE instance, } #endif - if (TurnOnAnimViewer) - { #ifndef MASTER + if (gbModelViewer) { + // This is TheModelViewer in LCS + LoadingScreen("Loading the ModelViewer", NULL, GetRandomSplashScreen()); CAnimViewer::Initialise(); + CTimer::Update(); #ifndef PS2_MENU FrontEndMenuManager.m_bGameNotLoaded = false; -#endif - gGameState = GS_ANIMVIEWER; - TurnOnAnimViewer = false; #endif } +#endif while ( TRUE ) { @@ -2228,6 +2222,12 @@ WinMain(HINSTANCE instance, DispatchMessage(&message); } } +#ifndef MASTER + else if (gbModelViewer) { + // This is TheModelViewerCore in LCS + TheModelViewer(); + } +#endif else if( ForegroundApp ) { switch ( gGameState ) @@ -2447,18 +2447,6 @@ WinMain(HINSTANCE instance, } break; } -#ifndef MASTER - case GS_ANIMVIEWER: - { - float ms = (float)CTimer::GetCurrentTimeInCycles() / (float)CTimer::GetCyclesPerMillisecond(); - if (RwInitialised) - { - if (!FrontEndMenuManager.m_PrefsFrameLimiter || (1000.0f / (float)RsGlobal.maxFPS) < ms) - RsEventHandler(rsANIMVIEWER, (void*)TRUE); - } - break; - } -#endif } } else @@ -2530,12 +2518,13 @@ WinMain(HINSTANCE instance, } else { - if ( gGameState == GS_PLAYING_GAME ) - CGame::ShutDown(); #ifndef MASTER - else if ( gGameState == GS_ANIMVIEWER ) + if ( gbModelViewer ) CAnimViewer::Shutdown(); + else #endif + if ( gGameState == GS_PLAYING_GAME ) + CGame::ShutDown(); CTimer::Stop(); @@ -2557,12 +2546,13 @@ WinMain(HINSTANCE instance, } - if ( gGameState == GS_PLAYING_GAME ) - CGame::ShutDown(); #ifndef MASTER - else if ( gGameState == GS_ANIMVIEWER ) + if ( gbModelViewer ) CAnimViewer::Shutdown(); + else #endif + if ( gGameState == GS_PLAYING_GAME ) + CGame::ShutDown(); DMAudio.Terminate(); -- cgit v1.2.3