Merge pull request #603 from Fire-Head/miami

Miami Water, Seagulls, Ships
This commit is contained in:
aap 2020-05-28 10:23:28 +02:00 committed by GitHub
commit ab7a21e017
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 2455 additions and 632 deletions

View File

@ -306,7 +306,7 @@ bool CGame::Initialise(const char* datFile)
CWorld::Players[0].LoadPlayerSkin();
TestModelIndices();
LoadingScreen("Loading the Game", "Setup water", nil);
CWaterLevel::Initialise("DATA\\WATER.DAT");
WaterLevelInitialise("DATA\\WATER.DAT");
TheConsole.Init();
CDraw::SetFOV(120.0f);
CDraw::ms_fLODDistance = 500.0f;
@ -685,6 +685,13 @@ CGame::InitAfterFocusLoss()
FrontEndMenuManager.m_bStartUpFrontEndRequested = true;
}
bool
CGame::CanSeeWaterFromCurrArea(void)
{
return currArea == AREA_MAIN_MAP || currArea == AREA_MANSION
|| currArea == AREA_HOTEL;
}
bool
CGame::CanSeeOutSideFromCurrArea(void)
{

View File

@ -62,6 +62,7 @@ public:
static void InitAfterFocusLoss(void);
static bool IsInInterior(void) { return currArea != AREA_MAIN_MAP; }
static bool CanSeeWaterFromCurrArea(void);
static bool CanSeeOutSideFromCurrArea(void);
// NB: these do something on PS2

View File

@ -35,6 +35,7 @@
#include "Streaming.h"
#include "PathFind.h"
#include "Wanted.h"
#include "WaterLevel.h"
#include "General.h"
CPad Pads[MAX_PADS];
@ -306,6 +307,21 @@ void PinkCarsCheat()
gbBlackCars = false;
gbPinkCars = true;
}
void NoSeaBedCheat(void)
{
CHud::SetHelpMessage(TheText.Get("CHEAT1"), true);
CWaterLevel::m_bRenderSeaBed = !CWaterLevel::m_bRenderSeaBed;
}
void RenderWaterLayersCheat(void)
{
CHud::SetHelpMessage(TheText.Get("CHEAT1"), true);
if ( ++CWaterLevel::m_nRenderWaterLayers > 5 )
CWaterLevel::m_nRenderWaterLayers = 0;
}
//////////////////////////////////////////////////////////////////////////
#ifdef KANGAROO_CHEAT
@ -1051,6 +1067,16 @@ void CPad::AddToPCCheatString(char c)
if (!_CHEATCMP("ODODRETSAMOTTNAWI"))
AltDodoCheat();
#endif
#if !defined(PC_WATER) && defined(WATER_CHEATS)
// SEABEDCHEAT
if (!_CHEATCMP("TAEHCDEBAESON"))
NoSeaBedCheat();
// WATERLAYERSCHEAT
if (!_CHEATCMP("TAEHCSREYALRETAW"))
RenderWaterLayersCheat();
#endif
#undef _CHEATCMP
}

View File

@ -10,6 +10,8 @@ enum eZoneAttribs
ATTRZONE_NOTCULLZONE = 0x20,
ATTRZONE_DOINEEDCOLLISION = 0x40,
ATTRZONE_SUBWAYVISIBLE = 0x80,
ATTRZONE_WATERFUDGE = 0x400,
};
struct CAttributeZone
@ -53,6 +55,7 @@ public:
static bool DoINeedToLoadCollision(void) { return (CurrentFlags_Player & ATTRZONE_DOINEEDCOLLISION) != 0; }
static bool PlayerNoRain(void) { return (CurrentFlags_Player & ATTRZONE_NORAIN) != 0; }
static bool CamNoRain(void) { return (CurrentFlags_Camera & ATTRZONE_NORAIN) != 0; }
static bool WaterFudge(void) { return (CurrentFlags_Camera & ATTRZONE_WATERFUDGE) != 0; }
static int32 GetWantedLevelDrop(void) { return CurrentWantedLevelDrop_Player; }
//--MIAMI: TODO

View File

@ -205,6 +205,9 @@ enum Config {
#define RELOADABLES // some debug menu options to reload TXD files
#endif
#define PC_WATER
#define WATER_CHEATS
// Particle
#define PC_PARTICLE
//#define PS2_ALTERNATIVE_CARSPLASH // unused on PS2

View File

@ -821,7 +821,7 @@ RenderScene(void)
CRenderer::RenderBoats();
CRenderer::RenderFadingInUnderwaterEntities();
RwRenderStateSet(rwRENDERSTATECULLMODE, (void*)rwCULLMODECULLNONE);
// CWaterLevel::RenderTransparentWater();
CWaterLevel::RenderTransparentWater();
CRenderer::RenderFadingInEntities();
RwRenderStateSet(rwRENDERSTATECULLMODE, (void*)rwCULLMODECULLNONE);
CWeather::RenderRainStreaks();
@ -1008,6 +1008,9 @@ Idle(void *arg)
#endif
#ifdef TIMEBARS
tbStartTimer(0, "CnstrRenderList");
#endif
#ifdef PC_WATER
CWaterLevel::PreCalcWaterGeometry();
#endif
CRenderer::ConstructRenderList();
#ifdef TIMEBARS

View File

@ -18000,8 +18000,9 @@ CPed::SetEnterCar_AllClear(CVehicle *car, uint32 doorNode, uint32 doorFlag)
PedSetInCarCB(nil, this);
bVehExitWillBeInstant = true;
if (IsPlayer())
CWaterLevel::AllocateBoatWakeArray();
// TODO(Miami):
//if (IsPlayer())
// CWaterLevel::AllocateBoatWakeArray();
} else {
if (zDiff > 4.4f) {
if (m_vehEnterType == CAR_DOOR_RF || m_vehEnterType == CAR_DOOR_RR)
@ -18437,8 +18438,10 @@ CPed::SetExitBoat(CVehicle *boat)
SetMoveState(PEDMOVE_STILL);
m_vecMoveSpeed = boat->m_vecMoveSpeed;
#endif
// TODO(Miami):
// Not there in VC.
CWaterLevel::FreeBoatWakeArray();
//CWaterLevel::FreeBoatWakeArray();
}
void

View File

@ -23,4 +23,7 @@ public:
static void Init(void);
static void AddOne(float x, float y, float z, float width, float length, float height, float angle);
static void ProcessBeforeRendering(void);
//TODO:
static bool IsAABoxOccluded(CVector pos, float, float, float) { return false; }
};

File diff suppressed because it is too large Load Diff

View File

@ -2,8 +2,8 @@
#define WATER_X_OFFSET (400.0f)
#define WATER_BLOCK_SIZE LARGE_SECTOR_SIZE
#define WATER_FINEBLOCK_SIZE HUGE_SECTOR_SIZE
#define WATER_BLOCK_SECTORS MAX_LARGE_SECTORS
#define WATER_FINEBLOCK_SECTORS MAX_SMALL_SECTORS
#define WATER_Z_OFFSET (0.5f)
#define MAX_SMALL_SECTORS 128
@ -31,6 +31,14 @@
#define WATER_SIGN_X(x) ( (x) - (WATER_WIDTH /2) )
#define WATER_SIGN_Y(y) ( (y) - (WATER_HEIGHT/2) )
// 64x64 Large blocks 64x64 each
#define WATER_TO_BLOCK_X(x) ( WATER_UNSIGN_X(x) / WATER_BLOCK_SECTORS )
#define WATER_TO_BLOCK_Y(x) ( WATER_UNSIGN_Y(x) / WATER_BLOCK_SECTORS )
// 128x128 Small blocks 32x32 each
#define WATER_TO_FINEBLOCK_X(x) ( WATER_UNSIGN_X(x) / WATER_FINEBLOCK_SECTORS )
#define WATER_TO_FINEBLOCK_Y(x) ( WATER_UNSIGN_Y(x) / WATER_FINEBLOCK_SECTORS )
// 32
#define WATER_SMALL_X(x) ( WATER_UNSIGN_X(x) / MAX_SMALL_SECTORS )
#define WATER_SMALL_Y(y) ( WATER_UNSIGN_Y(y) / MAX_SMALL_SECTORS )
@ -63,39 +71,105 @@
#define WATER_TO_EXTRAHUGE_SECTOR_X(x) ( WATER_UNSIGN_X(x) / EXTRAHUGE_SECTOR_SIZE )
#define WATER_TO_EXTRAHUGE_SECTOR_Y(y) ( WATER_UNSIGN_Y(y) / EXTRAHUGE_SECTOR_SIZE )
struct ColData
{
uint8 SurfaceType;
uint8 PieceType;
};
#define MAX_BOAT_WAKES 8
enum eBeachToy
{
BEACHTOY_0 = 0,
BEACHTOY_BALL,
BEACHTOY_2,
BEACHTOY_3,
BEACHTOY_4,
BEACHTOY_LOUNGE = 5
};
extern RwRaster* gpWaterRaster;
class CEntity;
class CWaterLevel
{
public:
static int32 ms_nNoOfWaterLevels;
static float ms_aWaterZs[48];
static CRect ms_aWaterRects[48];
static uint8 aWaterBlockList[WATER_BLOCK_SIZE][WATER_BLOCK_SIZE];
static uint8 aWaterFineBlockList[WATER_FINEBLOCK_SIZE][WATER_FINEBLOCK_SIZE];
static uint8 aWaterBlockList[WATER_BLOCK_SECTORS][WATER_BLOCK_SECTORS]; // 64x64 Large blocks 64x64 each
static uint8 aWaterFineBlockList[WATER_FINEBLOCK_SECTORS][WATER_FINEBLOCK_SECTORS]; // 128x128 Small blocks 32x32 each
static bool WavesCalculatedThisFrame;
static RpAtomic *ms_pWavyAtomic;
static RpGeometry *apGeomArray[MAX_BOAT_WAKES];
static int16 nGeomUsed;
static bool RequireWavySector;
static bool MaskCalculatedThisFrame;
static CVector PreCalculatedMaskPosn;
static bool m_bRenderSeaBed;
static int32 m_nRenderWaterLayers;
static RpAtomic *ms_pWavyAtomic;
static RpAtomic *ms_pMaskAtomic;
public:
static void Initialise(Const char *pWaterDat);
static void Shutdown();
static void CreateWavyAtomic();
static void DestroyWavyAtomic();
static bool GetWaterLevel(float fX, float fY, float fZ, float *pfOutLevel, bool bDontCheckZ);
static bool GetWaterLevel(CVector coors, float *pfOutLevel, bool bDontCheckZ) { return GetWaterLevel(coors.x, coors.y, coors.z, pfOutLevel, bDontCheckZ); }
static bool GetWaterLevelNoWaves(float fX, float fY, float fZ, float *pfOutLevel);
static float GetWaterWavesOnly(short x, short y); // unused
static CVector GetWaterNormal(float fX, float fY);
static void RenderWater();
static void RenderOneFlatSmallWaterPoly (float fX, float fY, float fZ, RwRGBA const &color);
static void RenderOneFlatLargeWaterPoly (float fX, float fY, float fZ, RwRGBA const &color);
static void RenderOneFlatHugeWaterPoly (float fX, float fY, float fZ, RwRGBA const &color);
static void RenderOneFlatExtraHugeWaterPoly(float fX, float fY, float fZ, RwRGBA const &color);
static void RenderOneWavySector (float fX, float fY, float fZ, RwRGBA const &color, bool bUnk = false);
static float CalcDistanceToWater(float fX, float fY);
static void RenderAndEmptyRenderBuffer();
static void AllocateBoatWakeArray();
static void FreeBoatWakeArray();
static void RenderTransparentWater(void);
// unused
static void RenderOneFlatSmallWaterPoly (float fX, float fY, float fZ, RwRGBA const &color);
// inlined
static void RenderOneFlatLargeWaterPoly (float fX, float fY, float fZ, RwRGBA const &color);
static void RenderOneFlatHugeWaterPoly (float fX, float fY, float fZ, RwRGBA const &color);
static void RenderOneFlatExtraHugeWaterPoly(float fX, float fY, float fZ, RwRGBA const &color);
// inlined
static void RenderOneWavySector (float fX, float fY, float fZ, RwRGBA const &color, bool bDontRender = false);
// unused
#ifdef PC_WATER
static void RenderWavyMask(float fX, float fY, float fZ, float fSectorX, float fSectorY, float fCamPosX, float fCamPosY, float fCamDirX, float fCamDirY, RwRGBA const&color);
#else
static void RenderWavyMask(float fX, float fY, float fZ, float fSectorX, float fSectorY, int32 nCamDirX, int32 nCamDirY, RwRGBA const&color);
#endif
#ifdef PC_WATER
static void PreCalcWaterGeometry(void);
static bool PreCalcWavySector(RwRGBA const &color); //fucked up
static bool PreCalcWavyMask(float fX, float fY, float fZ, float fSectorX, float fSectorY, float fCamPosX, float fCamPosY, float fCamDirX, float fCamDirY, RwRGBA const&color);
#endif
static void RenderBoatWakes(void);
static void RenderWakeSegment(CVector2D &vecA, CVector2D &vecB, CVector2D &vecC, CVector2D &vecD, float &fSizeA, float &fSizeB, float &fAlphaA, float &fAlphaB, float &fWakeZ);
// unused
static void RenderOneSlopedUnderWaterPoly(float fX, float fY, float fZ, RwRGBA const&color); // UNUSED
static void RenderOneFlatSmallWaterPolyBlended(float fX, float fY, float fZ, float fCamX, float fCamY, RwRGBA const &color, RwRGBA const &colorTrans, float fDrawDist);
static float CalcDistanceToWater(float fX, float fY);
static void RenderAndEmptyRenderBuffer();
static bool GetGroundLevel(CVector const &vecPosn, float *pfOutLevel, ColData *pData, float fDistance);
// unused
static bool IsLocationOutOfWorldBounds_WS(CVector const &vecPosn, int nOffset);
// unused
static bool GetGroundLevel_WS(CVector const & vecPosn, float *pfOutLevel, ColData *pData, float fDistance);
static bool GetWaterDepth(CVector const &vecPosn, float *pfDepth, float *pfLevelNoWaves, float *pfGroundLevel);
static void RenderSeaBirds();
static void RenderShipsOnHorizon();
static void HandleSeaLifeForms();
static void HandleBeachToysStuff(void);
static CEntity *CreateBeachToy(CVector const &vec, eBeachToy beachtoy);
};
extern void WaterLevelInitialise(Const char *datFile);

View File

@ -27,12 +27,12 @@
float fShapeLength = 0.4f;
float fShapeTime = 0.05f;
float fRangeMult = 0.75f; //0.6f; // 0.75f gta 3
float fRangeMult = 0.6f;
float fTimeMult;
float MAX_WAKE_LENGTH = 50.0f;
float MIN_WAKE_INTERVAL = 1.0f;
float WAKE_LIFETIME = 400.0f;
float CBoat::MAX_WAKE_LENGTH = 50.0f;
float CBoat::MIN_WAKE_INTERVAL = 2.0f;
float CBoat::WAKE_LIFETIME = 150.0f;
CBoat *CBoat::apFrameWakeGeneratingBoats[4];

View File

@ -45,6 +45,10 @@ public:
CVector2D m_avec2dWakePoints[32];
float m_afWakePointLifeTime[32];
static float MAX_WAKE_LENGTH;
static float MIN_WAKE_INTERVAL;
static float WAKE_LIFETIME;
CBoat(int, uint8);
virtual void SetModelIndex(uint32 id);
@ -75,8 +79,4 @@ public:
#endif
static const uint32 nSaveStructSize;
};
extern float MAX_WAKE_LENGTH;
extern float MIN_WAKE_INTERVAL;
extern float WAKE_LIFETIME;
};