mirror of
https://git.rip/DMCA_FUCKER/re3.git
synced 2024-12-23 11:29:59 +00:00
WaterLevel done
This commit is contained in:
parent
53023eb65b
commit
a644c4e9ce
|
@ -138,6 +138,7 @@ inline float sq(float x) { return x*x; }
|
||||||
#define SQR(x) ((x) * (x))
|
#define SQR(x) ((x) * (x))
|
||||||
|
|
||||||
#define PI M_PI
|
#define PI M_PI
|
||||||
|
#define TWOPI PI*2
|
||||||
#define DEGTORAD(x) ((x) * PI / 180.0f)
|
#define DEGTORAD(x) ((x) * PI / 180.0f)
|
||||||
#define RADTODEG(x) ((x) * 180.0f / PI)
|
#define RADTODEG(x) ((x) * 180.0f / PI)
|
||||||
|
|
||||||
|
|
|
@ -6,13 +6,13 @@ class CEntity;
|
||||||
|
|
||||||
class CParticle
|
class CParticle
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
RAND_TABLE_SIZE = 20,
|
RAND_TABLE_SIZE = 20,
|
||||||
SIN_COS_TABLE_SIZE = 1024
|
SIN_COS_TABLE_SIZE = 1024
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
|
||||||
CVector m_vecPosition;
|
CVector m_vecPosition;
|
||||||
CVector m_vecVelocity;
|
CVector m_vecVelocity;
|
||||||
CVector m_vecScreenPosition;
|
CVector m_vecScreenPosition;
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
int32 &TempBufferVerticesStored = *(int32*)0x8F5F78;
|
int32 &TempBufferVerticesStored = *(int32*)0x8F5F78;
|
||||||
int32 &TempBufferIndicesStored = *(int32*)0x8F1A4C;
|
int32 &TempBufferIndicesStored = *(int32*)0x8F1A4C;
|
||||||
|
|
||||||
RwIm3DVertex *TempVertexBuffer = (RwIm3DVertex*)0x862330;
|
RwIm3DVertex *TempBufferRenderVertices = (RwIm3DVertex*)0x862330;
|
||||||
RwImVertexIndex *TempBufferRenderIndexList = (RwImVertexIndex*)0x846288;
|
RwImVertexIndex *TempBufferRenderIndexList = (RwImVertexIndex*)0x846288;
|
||||||
|
|
||||||
int RenderBuffer::VerticesToBeStored;
|
int RenderBuffer::VerticesToBeStored;
|
||||||
|
@ -21,12 +21,12 @@ RenderBuffer::ClearRenderBuffer(void)
|
||||||
void
|
void
|
||||||
RenderBuffer::StartStoring(int numIndices, int numVertices, RwImVertexIndex **indexStart, RwIm3DVertex **vertexStart)
|
RenderBuffer::StartStoring(int numIndices, int numVertices, RwImVertexIndex **indexStart, RwIm3DVertex **vertexStart)
|
||||||
{
|
{
|
||||||
if(TempBufferIndicesStored + numIndices >= 1024)
|
if(TempBufferIndicesStored + numIndices >= TEMPBUFFERINDEXSIZE)
|
||||||
RenderStuffInBuffer();
|
RenderStuffInBuffer();
|
||||||
if(TempBufferVerticesStored + numVertices >= 256)
|
if(TempBufferVerticesStored + numVertices >= TEMPBUFFERVERTSIZE)
|
||||||
RenderStuffInBuffer();
|
RenderStuffInBuffer();
|
||||||
*indexStart = &TempBufferRenderIndexList[TempBufferIndicesStored];
|
*indexStart = &TempBufferRenderIndexList[TempBufferIndicesStored];
|
||||||
*vertexStart = &TempVertexBuffer[TempBufferVerticesStored];
|
*vertexStart = &TempBufferRenderVertices[TempBufferVerticesStored];
|
||||||
IndicesToBeStored = numIndices;
|
IndicesToBeStored = numIndices;
|
||||||
VerticesToBeStored = numVertices;
|
VerticesToBeStored = numVertices;
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ RenderBuffer::StopStoring(void)
|
||||||
void
|
void
|
||||||
RenderBuffer::RenderStuffInBuffer(void)
|
RenderBuffer::RenderStuffInBuffer(void)
|
||||||
{
|
{
|
||||||
if(TempBufferVerticesStored && RwIm3DTransform(TempVertexBuffer, TempBufferVerticesStored, nil, rwIM3D_VERTEXUV)){
|
if(TempBufferVerticesStored && RwIm3DTransform(TempBufferRenderVertices, TempBufferVerticesStored, nil, rwIM3D_VERTEXUV)){
|
||||||
RwIm3DRenderIndexedPrimitive(rwPRIMTYPETRILIST, TempBufferRenderIndexList, TempBufferIndicesStored);
|
RwIm3DRenderIndexedPrimitive(rwPRIMTYPETRILIST, TempBufferRenderIndexList, TempBufferIndicesStored);
|
||||||
RwIm3DEnd();
|
RwIm3DEnd();
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,3 +8,11 @@ public:
|
||||||
static void StopStoring(void);
|
static void StopStoring(void);
|
||||||
static void RenderStuffInBuffer(void);
|
static void RenderStuffInBuffer(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define TEMPBUFFERVERTSIZE 256
|
||||||
|
#define TEMPBUFFERINDEXSIZE 1024
|
||||||
|
|
||||||
|
extern int32 &TempBufferVerticesStored;
|
||||||
|
extern int32 &TempBufferIndicesStored;
|
||||||
|
extern RwIm3DVertex *TempBufferRenderVertices;
|
||||||
|
extern RwImVertexIndex *TempBufferRenderIndexList;
|
File diff suppressed because it is too large
Load diff
|
@ -1,7 +1,97 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
#define WATER_BLOCK_SIZE LARGE_SECTOR_SIZE
|
||||||
|
#define WATER_FINEBLOCK_SIZE HUGE_SECTOR_SIZE
|
||||||
|
#define WATER_Z_OFFSET (1.5f)
|
||||||
|
|
||||||
|
#define MAX_SMALL_SECTORS 128
|
||||||
|
#define MAX_LARGE_SECTORS 64
|
||||||
|
#define MAX_HUGE_SECTORS 32
|
||||||
|
#define MAX_EXTRAHUGE_SECTORS 16
|
||||||
|
|
||||||
|
#define SMALL_SECTOR_SIZE 32
|
||||||
|
#define LARGE_SECTOR_SIZE 64
|
||||||
|
#define HUGE_SECTOR_SIZE 128
|
||||||
|
#define EXTRAHUGE_SECTOR_SIZE 256
|
||||||
|
|
||||||
|
#define WATER_START_X -2048.0f
|
||||||
|
#define WATER_END_X 2048.0f
|
||||||
|
|
||||||
|
#define WATER_START_Y -2048.0f
|
||||||
|
#define WATER_END_Y 2048.0f
|
||||||
|
|
||||||
|
#define WATER_WIDTH ((WATER_END_X - WATER_START_X))
|
||||||
|
#define WATER_HEIGHT ((WATER_END_Y - WATER_START_Y))
|
||||||
|
|
||||||
|
|
||||||
|
#define WATER_UNSIGN_X(x) ( (x) + (WATER_WIDTH /2) )
|
||||||
|
#define WATER_UNSIGN_Y(y) ( (y) + (WATER_HEIGHT/2) )
|
||||||
|
#define WATER_SIGN_X(x) ( (x) - (WATER_WIDTH /2) )
|
||||||
|
#define WATER_SIGN_Y(y) ( (y) - (WATER_HEIGHT/2) )
|
||||||
|
|
||||||
|
// 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 )
|
||||||
|
#define WATER_FROM_SMALL_SECTOR_X(x) ( ((x) - (MAX_SMALL_SECTORS/2) ) * SMALL_SECTOR_SIZE )
|
||||||
|
#define WATER_FROM_SMALL_SECTOR_Y(y) ( ((y) - (MAX_SMALL_SECTORS/2) ) * SMALL_SECTOR_SIZE )
|
||||||
|
#define WATER_TO_SMALL_SECTOR_X(x) ( WATER_UNSIGN_X(x) / SMALL_SECTOR_SIZE )
|
||||||
|
#define WATER_TO_SMALL_SECTOR_Y(y) ( WATER_UNSIGN_Y(y) / SMALL_SECTOR_SIZE )
|
||||||
|
|
||||||
|
// 64
|
||||||
|
#define WATER_LARGE_X(x) ( WATER_UNSIGN_X(x) / MAX_LARGE_SECTORS )
|
||||||
|
#define WATER_LARGE_Y(y) ( WATER_UNSIGN_Y(y) / MAX_LARGE_SECTORS )
|
||||||
|
#define WATER_FROM_LARGE_SECTOR_X(x) ( ((x) - (MAX_LARGE_SECTORS/2) ) * LARGE_SECTOR_SIZE )
|
||||||
|
#define WATER_FROM_LARGE_SECTOR_Y(y) ( ((y) - (MAX_LARGE_SECTORS/2) ) * LARGE_SECTOR_SIZE )
|
||||||
|
#define WATER_TO_LARGE_SECTOR_X(x) ( WATER_UNSIGN_X(x) / LARGE_SECTOR_SIZE )
|
||||||
|
#define WATER_TO_LARGE_SECTOR_Y(y) ( WATER_UNSIGN_Y(y) / LARGE_SECTOR_SIZE )
|
||||||
|
|
||||||
|
// 128
|
||||||
|
#define WATER_HUGE_X(x) ( WATER_UNSIGN_X(x) / MAX_HUGE_SECTORS )
|
||||||
|
#define WATER_HUGE_Y(y) ( WATER_UNSIGN_Y(y) / MAX_HUGE_SECTORS )
|
||||||
|
#define WATER_FROM_HUGE_SECTOR_X(x) ( ((x) - (MAX_HUGE_SECTORS/2) ) * HUGE_SECTOR_SIZE )
|
||||||
|
#define WATER_FROM_HUGE_SECTOR_Y(y) ( ((y) - (MAX_HUGE_SECTORS/2) ) * HUGE_SECTOR_SIZE )
|
||||||
|
#define WATER_TO_HUGE_SECTOR_X(x) ( WATER_UNSIGN_X(x) / HUGE_SECTOR_SIZE )
|
||||||
|
#define WATER_TO_HUGE_SECTOR_Y(y) ( WATER_UNSIGN_Y(y) / HUGE_SECTOR_SIZE )
|
||||||
|
|
||||||
|
// 256
|
||||||
|
#define WATER_EXTRAHUGE_X(x) ( WATER_UNSIGN_X(x) / MAX_EXTRAHUGE_SECTORS )
|
||||||
|
#define WATER_EXTRAHUGE_Y(y) ( WATER_UNSIGN_Y(y) / MAX_EXTRAHUGE_SECTORS )
|
||||||
|
#define WATER_FROM_EXTRAHUGE_SECTOR_X(x) ( ((x) - (MAX_EXTRAHUGE_SECTORS/2)) * EXTRAHUGE_SECTOR_SIZE )
|
||||||
|
#define WATER_FROM_EXTRAHUGE_SECTOR_Y(y) ( ((y) - (MAX_EXTRAHUGE_SECTORS/2)) * EXTRAHUGE_SECTOR_SIZE )
|
||||||
|
#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 )
|
||||||
|
|
||||||
|
|
||||||
|
#define MAX_BOAT_WAKES 8
|
||||||
|
|
||||||
class CWaterLevel
|
class CWaterLevel
|
||||||
{
|
{
|
||||||
|
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 bool WavesCalculatedThisFrame;
|
||||||
|
static RpAtomic *ms_pWavyAtomic;
|
||||||
|
static RpGeometry *apGeomArray[MAX_BOAT_WAKES];
|
||||||
|
static int16 nGeomUsed;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void RenderWater(void);
|
static void Initialise(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 GetWaterLevelNoWaves(float fX, float fY, float fZ, float *pfOutLevel);
|
||||||
|
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();
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,6 +2,17 @@
|
||||||
#include "patcher.h"
|
#include "patcher.h"
|
||||||
#include "Boat.h"
|
#include "Boat.h"
|
||||||
|
|
||||||
|
float &fShapeLength = *(float*)0x600E78;
|
||||||
|
float &fShapeTime = *(float*)0x600E7C;
|
||||||
|
float &fRangeMult = *(float*)0x600E80; //0.6f; // 0.75f gta 3
|
||||||
|
float &fTimeMult = *(float*)0xA0FCF4;
|
||||||
|
|
||||||
|
float MAX_WAKE_LENGTH = 50.0f;
|
||||||
|
float MIN_WAKE_INTERVAL = 1.0f;
|
||||||
|
float WAKE_LIFETIME = 400.0f;
|
||||||
|
|
||||||
|
CBoat * (&CBoat::apFrameWakeGeneratingBoats)[4] = *(CBoat * (*)[4])*(uintptr*)0x8620E0;
|
||||||
|
|
||||||
CBoat::CBoat(int mi, uint8 owner)
|
CBoat::CBoat(int mi, uint8 owner)
|
||||||
{
|
{
|
||||||
ctor(mi, owner);
|
ctor(mi, owner);
|
||||||
|
@ -9,6 +20,58 @@ CBoat::CBoat(int mi, uint8 owner)
|
||||||
|
|
||||||
WRAPPER CBoat* CBoat::ctor(int, uint8) { EAXJMP(0x53E3E0); }
|
WRAPPER CBoat* CBoat::ctor(int, uint8) { EAXJMP(0x53E3E0); }
|
||||||
|
|
||||||
|
|
||||||
|
bool CBoat::IsSectorAffectedByWake(CVector2D sector, float fSize, CBoat **apBoats)
|
||||||
|
{
|
||||||
|
uint8 numVerts = 0;
|
||||||
|
|
||||||
|
if ( apFrameWakeGeneratingBoats[0] == NULL )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for ( int32 i = 0; i < 4; i++ )
|
||||||
|
{
|
||||||
|
CBoat *pBoat = apFrameWakeGeneratingBoats[i];
|
||||||
|
if ( !pBoat )
|
||||||
|
break;
|
||||||
|
|
||||||
|
for ( int j = 0; j < pBoat->m_nNumWakePoints; j++ )
|
||||||
|
{
|
||||||
|
float fDist = (WAKE_LIFETIME - pBoat->m_afWakePointLifeTime[j]) * fShapeTime + float(j) * fShapeLength + fSize;
|
||||||
|
|
||||||
|
if ( fabs(pBoat->m_avec2dWakePoints[j].x - sector.x) < fDist
|
||||||
|
&& fabs(pBoat->m_avec2dWakePoints[i].y - sector.y) < fDist )
|
||||||
|
{
|
||||||
|
apBoats[numVerts] = pBoat;
|
||||||
|
numVerts = 1; // += ?
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return numVerts != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
float CBoat::IsVertexAffectedByWake(CVector vecVertex, CBoat *pBoat)
|
||||||
|
{
|
||||||
|
for ( int i = 0; i < pBoat->m_nNumWakePoints; i++ )
|
||||||
|
{
|
||||||
|
float fMaxDist = (WAKE_LIFETIME - pBoat->m_afWakePointLifeTime[i]) * fShapeTime + float(i) * fShapeLength;
|
||||||
|
|
||||||
|
float fX = pBoat->m_avec2dWakePoints[i].x - vecVertex.x;
|
||||||
|
float fY = pBoat->m_avec2dWakePoints[i].y - vecVertex.y;
|
||||||
|
|
||||||
|
float fDist = fY * fY + fX * fX;
|
||||||
|
|
||||||
|
if ( fDist < SQR(fMaxDist) )
|
||||||
|
return 1.0f - min(fRangeMult * sqrt(fDist / SQR(fMaxDist)) + (WAKE_LIFETIME - pBoat->m_afWakePointLifeTime[i]) * fTimeMult, 1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
WRAPPER void CBoat::FillBoatList(void) { EAXJMP(0x542250); }
|
||||||
|
|
||||||
|
|
||||||
STARTPATCHES
|
STARTPATCHES
|
||||||
InjectHook(0x53E790, &CBoat::dtor, PATCH_JUMP);
|
InjectHook(0x53E790, &CBoat::dtor, PATCH_JUMP);
|
||||||
ENDPATCHES
|
ENDPATCHES
|
|
@ -6,12 +6,52 @@ class CBoat : public CVehicle
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// 0x288
|
// 0x288
|
||||||
uint8 stuff1[57];
|
float field_288;
|
||||||
|
float field_28C;
|
||||||
|
float field_290;
|
||||||
|
float field_294;
|
||||||
|
float field_298;
|
||||||
|
float field_29C;
|
||||||
|
float field_2A0;
|
||||||
|
float field_2A4;
|
||||||
|
float m_fMovingHiRotation;
|
||||||
|
int32 _unk0;
|
||||||
|
RwFrame *m_aBoatNodes[4];
|
||||||
|
uint8 m_nBoatFlags;
|
||||||
bool m_bIsAnchored;
|
bool m_bIsAnchored;
|
||||||
uint8 stuff[450];
|
char _pad0[2];
|
||||||
|
float field_2C4;
|
||||||
|
int32 _unk1;
|
||||||
|
float field_2CC;
|
||||||
|
CEntity *field_2D0;
|
||||||
|
bool _unk2;
|
||||||
|
char _pad1[3];
|
||||||
|
float m_fAccelerate;
|
||||||
|
float m_fBrake;
|
||||||
|
float m_fSteeringLeftRight;
|
||||||
|
uint8 m_nPadID;
|
||||||
|
char _pad2[3];
|
||||||
|
int32 _unk3;
|
||||||
|
float m_fTurnForceZ;
|
||||||
|
CVector m_vecMoveForce;
|
||||||
|
float field_2FC;
|
||||||
|
uint16 field_300;
|
||||||
|
uint16 m_nNumWakePoints;
|
||||||
|
CVector2D m_avec2dWakePoints[32];
|
||||||
|
float m_afWakePointLifeTime[32];
|
||||||
|
|
||||||
CBoat(int, uint8);
|
CBoat(int, uint8);
|
||||||
CBoat* ctor(int, uint8);
|
CBoat* ctor(int, uint8);
|
||||||
void dtor() { this->CBoat::~CBoat(); };
|
void dtor() { this->CBoat::~CBoat(); };
|
||||||
|
|
||||||
|
static CBoat *(&apFrameWakeGeneratingBoats)[4];
|
||||||
|
|
||||||
|
static bool IsSectorAffectedByWake(CVector2D sector, float fSize, CBoat **apBoats);
|
||||||
|
static float IsVertexAffectedByWake(CVector vecVertex, CBoat *pBoat);
|
||||||
|
static void FillBoatList(void);
|
||||||
};
|
};
|
||||||
static_assert(sizeof(CBoat) == 0x484, "CBoat: error");
|
static_assert(sizeof(CBoat) == 0x484, "CBoat: error");
|
||||||
|
|
||||||
|
extern float MAX_WAKE_LENGTH;
|
||||||
|
extern float MIN_WAKE_INTERVAL;
|
||||||
|
extern float WAKE_LIFETIME;
|
Loading…
Reference in a new issue