AnimViewer fixes, commentary from miami

This commit is contained in:
erorcun 2020-12-09 04:57:45 +03:00
parent 0dfa833610
commit e1044a7947
7 changed files with 76 additions and 107 deletions

View File

@ -45,7 +45,7 @@ CEntity *CAnimViewer::pTarget = nil;
void void
CAnimViewer::Render(void) { CAnimViewer::Render(void) {
if (pTarget) { if (pTarget) {
// pTarget->GetPosition() = CVector(0.0f, 0.0f, 0.0f); // pTarget->GetPosition() = CVector(0.0f, 0.0f, 0.0f); // Only on Mobile
if (pTarget) { if (pTarget) {
#ifdef FIX_BUGS #ifdef FIX_BUGS
#ifdef PED_SKIN #ifdef PED_SKIN
@ -61,7 +61,9 @@ CAnimViewer::Render(void) {
void void
CAnimViewer::Initialise(void) { CAnimViewer::Initialise(void) {
LoadingScreen("Loading the ModelViewer", "", GetRandomSplashScreen()); // we need messages, messages needs hud, hud needs this
CHud::m_Wants_To_Draw_Hud = false;
animTxdSlot = CTxdStore::AddTxdSlot("generic"); animTxdSlot = CTxdStore::AddTxdSlot("generic");
CTxdStore::Create(animTxdSlot); CTxdStore::Create(animTxdSlot);
int hudSlot = CTxdStore::AddTxdSlot("hud"); int hudSlot = CTxdStore::AddTxdSlot("hud");
@ -75,9 +77,6 @@ CAnimViewer::Initialise(void) {
TheCamera.SetRwCamera(Scene.camera); TheCamera.SetRwCamera(Scene.camera);
TheCamera.Cams[TheCamera.ActiveCam].Distance = 5.0f; TheCamera.Cams[TheCamera.ActiveCam].Distance = 5.0f;
gbModelViewer = true;
CHud::m_Wants_To_Draw_Hud = false;
ThePaths.Init(); ThePaths.Init();
ThePaths.AllocatePathFindInfoMem(4500); ThePaths.AllocatePathFindInfoMem(4500);
CCollision::Init(); CCollision::Init();
@ -113,7 +112,7 @@ CAnimViewer::Initialise(void) {
CTimeCycle::Initialise(); CTimeCycle::Initialise();
CCarCtrl::Init(); CCarCtrl::Init();
CPlayerPed *player = new CPlayerPed(); CPlayerPed *player = new CPlayerPed();
player->SetPosition(0.0f, 0.0f, 0.0f); player->SetPosition(0.0f, 0.0f, 0.0f); // This is 1000.f for all axes on Xbox, but 0.f on mobile?
CWorld::Players[0].m_pPed = player; CWorld::Players[0].m_pPed = player;
CDraw::SetFOV(120.0f); CDraw::SetFOV(120.0f);
CDraw::ms_fLODDistance = 500.0f; CDraw::ms_fLODDistance = 500.0f;
@ -222,8 +221,7 @@ CAnimViewer::Update(void)
{ {
static int modelId = 0; static int modelId = 0;
static int animId = 0; static int animId = 0;
// Please don't make this bool, static bool's are problematic on my side. static bool reloadIFP = false;
static int reloadIFP = 0;
AssocGroupId animGroup = ASSOCGRP_STD; AssocGroupId animGroup = ASSOCGRP_STD;
int nextModelId = modelId; int nextModelId = modelId;
@ -248,7 +246,7 @@ CAnimViewer::Update(void)
CAnimManager::Initialise(); CAnimManager::Initialise();
CAnimManager::LoadAnimFiles(); CAnimManager::LoadAnimFiles();
reloadIFP = 0; reloadIFP = false;
} }
} else { } else {
animGroup = ASSOCGRP_STD; animGroup = ASSOCGRP_STD;
@ -302,6 +300,7 @@ CAnimViewer::Update(void)
pTarget->GetMatrix().GetPosition().z = 10.0f; pTarget->GetMatrix().GetPosition().z = 10.0f;
#else #else
pTarget->GetMatrix().GetPosition().z = 0.0f; pTarget->GetMatrix().GetPosition().z = 0.0f;
#endif #endif
if (modelInfo->GetModelType() == MITYPE_PED) { if (modelInfo->GetModelType() == MITYPE_PED) {
@ -309,7 +308,7 @@ CAnimViewer::Update(void)
// Triangle in mobile // Triangle in mobile
if (pad->GetSquareJustDown()) { if (pad->GetSquareJustDown()) {
reloadIFP = 1; reloadIFP = true;
AsciiToUnicode("IFP reloaded", gUString); AsciiToUnicode("IFP reloaded", gUString);
CMessages::AddMessage(gUString, 1000, 0); CMessages::AddMessage(gUString, 1000, 0);

View File

@ -616,8 +616,10 @@ LoadingScreen(const char *str1, const char *str2, const char *splashscreen)
AsciiToUnicode(str1, tmpstr); AsciiToUnicode(str1, tmpstr);
CFont::PrintString(hpos, vpos, tmpstr); CFont::PrintString(hpos, vpos, tmpstr);
vpos += 22*yscale; vpos += 22*yscale;
AsciiToUnicode(str2, tmpstr); if (str2) {
CFont::PrintString(hpos, vpos, tmpstr); AsciiToUnicode(str2, tmpstr);
CFont::PrintString(hpos, vpos, tmpstr);
}
#endif #endif
} }
@ -1513,15 +1515,6 @@ AppEventHandler(RsEvent event, void *param)
return rsEVENTPROCESSED; return rsEVENTPROCESSED;
} }
#ifndef MASTER
case rsANIMVIEWER:
{
TheModelViewer();
return rsEVENTPROCESSED;
}
#endif
default: default:
{ {
return rsEVENTNOTPROCESSED; return rsEVENTNOTPROCESSED;
@ -1536,8 +1529,11 @@ TheModelViewer(void)
#if (defined(GTA_PS2) || defined(GTA_XBOX)) #if (defined(GTA_PS2) || defined(GTA_XBOX))
//TODO //TODO
#else #else
// This is III Mobile code. III Xbox code run it like main function, which is impossible to implement on PC's state machine implementation.
// Also we want 2D things initialized in here to print animation ids etc., our additions for that marked with X
#ifdef ASPECT_RATIO_SCALE #ifdef ASPECT_RATIO_SCALE
CDraw::SetAspectRatio(CDraw::FindAspectRatio()); CDraw::SetAspectRatio(CDraw::FindAspectRatio()); // X
#endif #endif
CAnimViewer::Update(); CAnimViewer::Update();
CTimer::Update(); CTimer::Update();
@ -1547,12 +1543,12 @@ TheModelViewer(void)
CTimeCycle::GetSkyBottomRed(), CTimeCycle::GetSkyBottomGreen(), CTimeCycle::GetSkyBottomBlue(), CTimeCycle::GetSkyBottomRed(), CTimeCycle::GetSkyBottomGreen(), CTimeCycle::GetSkyBottomBlue(),
255); 255);
CSprite2d::InitPerFrame(); CSprite2d::InitPerFrame(); // X
CFont::InitPerFrame(); CFont::InitPerFrame(); // X
DefinedState(); DefinedState();
CVisibilityPlugins::InitAlphaEntityList(); CVisibilityPlugins::InitAlphaEntityList();
CAnimViewer::Render(); CAnimViewer::Render();
Render2dStuff(); Render2dStuff(); // X
DoRWStuffEndOfFrame(); DoRWStuffEndOfFrame();
#endif #endif
} }

View File

@ -83,9 +83,6 @@ enum eGameState
GS_FRONTEND, GS_FRONTEND,
GS_INIT_PLAYING_GAME, GS_INIT_PLAYING_GAME,
GS_PLAYING_GAME, GS_PLAYING_GAME,
#ifndef MASTER
GS_ANIMVIEWER,
#endif
}; };
extern RwUInt32 gGameState; extern RwUInt32 gGameState;

View File

@ -1257,17 +1257,11 @@ void resizeCB(GLFWwindow* window, int width, int height) {
* memory things don't work. * memory things don't work.
*/ */
/* redraw window */ /* 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) if (RwInitialised && gGameState == GS_PLAYING_GAME)
{ {
RsEventHandler(rsIDLE, (void *)TRUE); RsEventHandler(rsIDLE, (void *)TRUE);
} }
#endif
if (RwInitialised && height > 0 && width > 0) { if (RwInitialised && height > 0 && width > 0) {
RwRect r; RwRect r;
@ -1646,18 +1640,6 @@ main(int argc, char *argv[])
FrontEndMenuManager.DrawMemoryCardStartUpMenus(); FrontEndMenuManager.DrawMemoryCardStartUpMenus();
} }
#endif #endif
if (TurnOnAnimViewer)
{
#ifndef MASTER
CAnimViewer::Initialise();
#ifndef PS2_MENU
FrontEndMenuManager.m_bGameNotLoaded = false;
#endif
gGameState = GS_ANIMVIEWER;
TurnOnAnimViewer = false;
#endif
}
initkeymap(); initkeymap();
@ -1677,6 +1659,18 @@ main(int argc, char *argv[])
* Enter the message processing loop... * Enter the message processing loop...
*/ */
#ifndef MASTER
if (gbModelViewer) {
// This is TheModelViewer in LCS, but not compiled on III Mobile.
LoadingScreen("Loading the ModelViewer", NULL, GetRandomSplashScreen());
CAnimViewer::Initialise();
CTimer::Update();
#ifndef PS2_MENU
FrontEndMenuManager.m_bGameNotLoaded = false;
#endif
}
#endif
#ifdef PS2_MENU #ifdef PS2_MENU
if (TheMemoryCard.m_bWantToLoad) if (TheMemoryCard.m_bWantToLoad)
LoadSplash(GetLevelSplashScreen(CGame::currLevel)); LoadSplash(GetLevelSplashScreen(CGame::currLevel));
@ -1691,7 +1685,13 @@ main(int argc, char *argv[])
#endif #endif
{ {
glfwPollEvents(); glfwPollEvents();
if( ForegroundApp ) #ifndef MASTER
if (gbModelViewer) {
// This is TheModelViewerCore in LCS, but TheModelViewer on other state-machine III-VCs.
TheModelViewer();
} else
#endif
if ( ForegroundApp )
{ {
switch ( gGameState ) switch ( gGameState )
{ {
@ -1894,18 +1894,6 @@ main(int argc, char *argv[])
} }
break; break;
} }
#ifndef MASTER
case GS_ANIMVIEWER:
{
float ms = (float)CTimer::GetCurrentTimeInCycles() / (float)CTimer::GetCyclesPerMillisecond();
if (RwInitialised)
{
if (!CMenuManager::m_PrefsFrameLimiter || (1000.0f / (float)RsGlobal.maxFPS) < ms)
RsEventHandler(rsANIMVIEWER, (void*)TRUE);
}
break;
}
#endif
} }
} }
else else
@ -1977,12 +1965,13 @@ main(int argc, char *argv[])
} }
else else
{ {
#ifndef MASTER
if ( gbModelViewer )
CAnimViewer::Shutdown();
else
#endif
if ( gGameState == GS_PLAYING_GAME ) if ( gGameState == GS_PLAYING_GAME )
CGame::ShutDown(); CGame::ShutDown();
#ifndef MASTER
else if ( gGameState == GS_ANIMVIEWER )
CAnimViewer::Shutdown();
#endif
CTimer::Stop(); CTimer::Stop();
@ -2004,12 +1993,13 @@ main(int argc, char *argv[])
} }
#ifndef MASTER
if ( gbModelViewer )
CAnimViewer::Shutdown();
else
#endif
if ( gGameState == GS_PLAYING_GAME ) if ( gGameState == GS_PLAYING_GAME )
CGame::ShutDown(); CGame::ShutDown();
#ifndef MASTER
else if ( gGameState == GS_ANIMVIEWER )
CAnimViewer::Shutdown();
#endif
DMAudio.Terminate(); DMAudio.Terminate();

View File

@ -10,14 +10,13 @@
#include "skeleton.h" #include "skeleton.h"
#include "platform.h" #include "platform.h"
#include "main.h"
#include "MemoryHeap.h" #include "MemoryHeap.h"
static RwBool DefaultVideoMode = TRUE; static RwBool DefaultVideoMode = TRUE;
bool TurnOnAnimViewer = false;
RsGlobalType RsGlobal; RsGlobalType RsGlobal;
#ifdef _WIN32 #ifdef _WIN32
@ -162,7 +161,7 @@ rsPreInitCommandLine(RwChar *arg)
#ifndef MASTER #ifndef MASTER
if (!strcmp(arg, RWSTRING("-animviewer"))) if (!strcmp(arg, RWSTRING("-animviewer")))
{ {
TurnOnAnimViewer = TRUE; gbModelViewer = TRUE;
return TRUE; return TRUE;
} }

View File

@ -79,11 +79,8 @@ enum RsEvent
rsPADANALOGUERIGHTRESET, rsPADANALOGUERIGHTRESET,
rsPREINITCOMMANDLINE, rsPREINITCOMMANDLINE,
rsACTIVATE, rsACTIVATE,
rsANIMVIEWER,
}; };
extern bool TurnOnAnimViewer;
typedef enum RsEvent RsEvent; typedef enum RsEvent RsEvent;
typedef RsEventStatus (*RsInputEventHandler)(RsEvent event, void *param); typedef RsEventStatus (*RsInputEventHandler)(RsEvent event, void *param);

View File

@ -1017,17 +1017,12 @@ MainWndProc(HWND window, UINT message, WPARAM wParam, LPARAM lParam)
RECT rect; RECT rect;
/* redraw window */ /* 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) if (RwInitialised && gGameState == GS_PLAYING_GAME)
{ {
RsEventHandler(rsIDLE, (void *)TRUE); RsEventHandler(rsIDLE, (void *)TRUE);
} }
#endif
/* Manually resize window */ /* Manually resize window */
rect.left = rect.top = 0; rect.left = rect.top = 0;
rect.bottom = newPos->bottom - newPos->top; rect.bottom = newPos->bottom - newPos->top;
@ -2183,17 +2178,17 @@ WinMain(HINSTANCE instance,
} }
#endif #endif
if (TurnOnAnimViewer)
{
#ifndef MASTER #ifndef MASTER
if (gbModelViewer) {
// This is TheModelViewer in LCS, but not compiled on III Mobile.
LoadingScreen("Loading the ModelViewer", NULL, GetRandomSplashScreen());
CAnimViewer::Initialise(); CAnimViewer::Initialise();
CTimer::Update();
#ifndef PS2_MENU #ifndef PS2_MENU
FrontEndMenuManager.m_bGameNotLoaded = false; FrontEndMenuManager.m_bGameNotLoaded = false;
#endif
gGameState = GS_ANIMVIEWER;
TurnOnAnimViewer = false;
#endif #endif
} }
#endif
while ( TRUE ) while ( TRUE )
{ {
@ -2238,6 +2233,12 @@ WinMain(HINSTANCE instance,
DispatchMessage(&message); DispatchMessage(&message);
} }
} }
#ifndef MASTER
else if (gbModelViewer) {
// This is TheModelViewerCore in LCS
TheModelViewer();
}
#endif
else if( ForegroundApp ) else if( ForegroundApp )
{ {
switch ( gGameState ) switch ( gGameState )
@ -2451,18 +2452,6 @@ WinMain(HINSTANCE instance,
} }
break; break;
} }
#ifndef MASTER
case GS_ANIMVIEWER:
{
float ms = (float)CTimer::GetCurrentTimeInCycles() / (float)CTimer::GetCyclesPerMillisecond();
if (RwInitialised)
{
if (!CMenuManager::m_PrefsFrameLimiter || (1000.0f / (float)RsGlobal.maxFPS) < ms)
RsEventHandler(rsANIMVIEWER, (void*)TRUE);
}
break;
}
#endif
} }
} }
else else
@ -2534,13 +2523,14 @@ WinMain(HINSTANCE instance,
} }
else else
{ {
#ifndef MASTER
if ( gbModelViewer )
CAnimViewer::Shutdown();
else
#endif
if ( gGameState == GS_PLAYING_GAME ) if ( gGameState == GS_PLAYING_GAME )
CGame::ShutDown(); CGame::ShutDown();
#ifndef MASTER
else if ( gGameState == GS_ANIMVIEWER )
CAnimViewer::Shutdown();
#endif
CTimer::Stop(); CTimer::Stop();
if ( FrontEndMenuManager.m_bFirstTime == true ) if ( FrontEndMenuManager.m_bFirstTime == true )
@ -2561,12 +2551,13 @@ WinMain(HINSTANCE instance,
} }
#ifndef MASTER
if ( gbModelViewer )
CAnimViewer::Shutdown();
else
#endif
if ( gGameState == GS_PLAYING_GAME ) if ( gGameState == GS_PLAYING_GAME )
CGame::ShutDown(); CGame::ShutDown();
#ifndef MASTER
else if ( gGameState == GS_ANIMVIEWER )
CAnimViewer::Shutdown();
#endif
DMAudio.Terminate(); DMAudio.Terminate();