Merge pull request #863 from erorcun/miami

AnimViewer done, comment cleanup
This commit is contained in:
erorcun 2020-12-03 13:06:55 +03:00 committed by GitHub
commit a37ce3ee9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 120 additions and 126 deletions

View File

@ -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()) {

View File

@ -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

View File

@ -18,7 +18,7 @@
#include <float.h>
#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();

View File

@ -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

View File

@ -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*);

View File

@ -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);
}
}
}

View File

@ -292,6 +292,11 @@ COcclusion::ProcessBeforeRendering(void)
{
NumActiveOccluders = 0;
#ifndef MASTER
if (gbModelViewer)
return;
#endif
if (CGame::currArea != AREA_MAIN_MAP)
return;

View File

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

View File

@ -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
{
#ifndef MASTER
if ( gbModelViewer )
CAnimViewer::Shutdown();
else
#endif
if ( gGameState == GS_PLAYING_GAME )
CGame::ShutDown();
#ifndef MASTER
else if ( gGameState == GS_ANIMVIEWER )
CAnimViewer::Shutdown();
#endif
CTimer::Stop();
@ -2002,13 +1991,13 @@ main(int argc, char *argv[])
#endif
}
#ifndef MASTER
if ( gbModelViewer )
CAnimViewer::Shutdown();
else
#endif
if ( gGameState == GS_PLAYING_GAME )
CGame::ShutDown();
#ifndef MASTER
else if ( gGameState == GS_ANIMVIEWER )
CAnimViewer::Shutdown();
#endif
DMAudio.Terminate();

View File

@ -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;
}

View File

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

View File

@ -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
{
#ifndef MASTER
if ( gbModelViewer )
CAnimViewer::Shutdown();
else
#endif
if ( gGameState == GS_PLAYING_GAME )
CGame::ShutDown();
#ifndef MASTER
else if ( gGameState == GS_ANIMVIEWER )
CAnimViewer::Shutdown();
#endif
CTimer::Stop();
@ -2557,12 +2546,13 @@ WinMain(HINSTANCE instance,
}
#ifndef MASTER
if ( gbModelViewer )
CAnimViewer::Shutdown();
else
#endif
if ( gGameState == GS_PLAYING_GAME )
CGame::ShutDown();
#ifndef MASTER
else if ( gGameState == GS_ANIMVIEWER )
CAnimViewer::Shutdown();
#endif
DMAudio.Terminate();