shadows done

This commit is contained in:
Fire-Head 2019-07-24 19:55:43 +03:00
parent ad1920bc6f
commit b4ecb3e3da
20 changed files with 2412 additions and 60 deletions

View File

@ -40,6 +40,13 @@ CCamera::IsSphereVisible(const CVector &center, float radius, const CMatrix *mat
return true;
}
bool
CCamera::IsSphereVisible(const CVector &center, float radius)
{
CMatrix mat = m_cameraMatrix;
return IsSphereVisible(center, radius, &mat);
}
bool
CCamera::IsPointVisible(const CVector &center, const CMatrix *mat)
{
@ -1290,7 +1297,7 @@ CCam::GetWeaponFirstPersonOn()
}
STARTPATCHES
InjectHook(0x42C760, &CCamera::IsSphereVisible, PATCH_JUMP);
InjectHook(0x42C760, (bool (CCamera::*)(const CVector &center, float radius, const CMatrix *mat))&CCamera::IsSphereVisible, PATCH_JUMP);
InjectHook(0x46FD00, &CCamera::SetFadeColour, PATCH_JUMP);
InjectHook(0x46FD40, &CCamera::SetMotionBlur, PATCH_JUMP);

View File

@ -445,6 +445,7 @@ int m_iModeObbeCamIsInForCar;
CVector &GetGameCamPosition(void) { return m_vecGameCamPos; }
bool IsPointVisible(const CVector &center, const CMatrix *mat);
bool IsSphereVisible(const CVector &center, float radius, const CMatrix *mat);
bool IsSphereVisible(const CVector &center, float radius);
bool IsBoxVisible(RwV3d *box, const CMatrix *mat);
int GetLookDirection(void);

View File

@ -1,6 +1,9 @@
#include "common.h"
#include "patcher.h"
#include "Game.h"
#include "Main.h"
#include "CdStream.h"
#include "FileMgr.h"
eLevelName &CGame::currLevel = *(eLevelName*)0x941514;
bool &CGame::bDemoMode = *(bool*)0x5F4DD0;
@ -11,9 +14,21 @@ bool &CGame::noProstitutes = *(bool*)0x95CDCF;
bool &CGame::playingIntro = *(bool*)0x95CDC2;
char *CGame::aDatFile = (char*)0x773A48;
bool
CGame::InitialiseOnceBeforeRW(void)
{
CFileMgr::Initialise();
CdStreamInit(MAX_CDCHANNELS);
ValidateVersion();
return true;
}
WRAPPER void CGame::Initialise(const char *datFile) { EAXJMP(0x48BED0); }
WRAPPER void CGame::Process(void) { EAXJMP(0x48C850); }
WRAPPER bool CGame::InitialiseOnceBeforeRW(void) { EAXJMP(0x48BB80); }
WRAPPER bool CGame::InitialiseRenderWare(void) { EAXJMP(0x48BBA0); }
WRAPPER void CGame::ShutdownRenderWare(void) { EAXJMP(0x48BCB0); }
WRAPPER void CGame::FinalShutdown(void) { EAXJMP(0x48BEC0); }

View File

@ -354,10 +354,18 @@ public:
bool GetRightShoulder1JustDown() { return !!(NewState.RightShoulder1 && !OldState.RightShoulder1); }
bool GetRightShoulder2JustDown() { return !!(NewState.RightShoulder2 && !OldState.RightShoulder2); }
int32 GetLeftShoulder1(void) { return NewState.LeftShoulder1; }
int32 GetLeftShoulder2(void) { return NewState.LeftShoulder2; }
int32 GetRightShoulder1(void) { return NewState.RightShoulder1; }
int32 GetRightShoulder2(void) { return NewState.RightShoulder2; }
bool GetTriangle() { return !!NewState.Triangle; }
bool GetCircle() { return !!NewState.Circle; }
bool GetCross() { return !!NewState.Cross; }
bool GetSquare() { return !!NewState.Square; }
bool GetDPadUp() { return !!NewState.DPadUp; }
bool GetDPadDown() { return !!NewState.DPadDown; }
bool GetDPadLeft() { return !!NewState.DPadLeft; }
bool GetDPadRight() { return !!NewState.DPadRight; }
bool GetLeftShoulder1(void) { return !!NewState.LeftShoulder1; }
bool GetLeftShoulder2(void) { return !!NewState.LeftShoulder2; }
bool GetRightShoulder1(void) { return !!NewState.RightShoulder1; }
bool GetRightShoulder2(void) { return !!NewState.RightShoulder2; }
};
VALIDATE_SIZE(CPad, 0xFC);

View File

@ -178,3 +178,120 @@ void re3_assert(const char *expr, const char *filename, unsigned int lineno, con
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define STRINGIFY(x) #x
#define STR(x) STRINGIFY(x)
#define CONCAT_(x,y) x##y
#define CONCAT(x,y) CONCAT_(x,y)
// Tweaking stuff for debugmenu
#define TWEAKPATH ___tw___TWEAKPATH
#define SETTWEAKPATH(path) static const char *___tw___TWEAKPATH = path;
#define TWEAKFUNC(v) static CTweakFunc CONCAT(___tw___tweak, __COUNTER__)(&v, STR(v), TWEAKPATH);
#define TWEAKFUNCN(v, name) static CTweakFunc CONCAT(___tw___tweak, __COUNTER__)(&v, name, TWEAKPATH);
#define TWEAKBOOL(v) static CTweakBool CONCAT(___tw___tweak, __COUNTER__)(&v, STR(v), TWEAKPATH);
#define TWEAKBOOLN(v, name) static CTweakBool CONCAT(___tw___tweak, __COUNTER__)(&v, name, TWEAKPATH);
#define TWEAKINT32(v, lower, upper, step) static CTweakInt32 CONCAT(___tw___tweak, __COUNTER__)(&v, STR(v), lower, upper, step, TWEAKPATH);
#define TWEAKINT32N(v, lower, upper, step, name) static CTweakInt32 CONCAT(___tw___tweak, __COUNTER__)(&v, name, lower, upper, step, TWEAKPATH);
#define TWEAKUINT32(v, lower, upper, step) static CTweakUInt32 CONCAT(___tw___tweak, __COUNTER__)(&v, STR(v), lower, upper, step, TWEAKPATH);
#define TWEAKUINT32N(v, lower, upper, step, name) static CTweakUInt32 CONCAT(___tw___tweak, __COUNTER__)(&v, name, lower, upper, step, TWEAKPATH);
#define TWEAKINT16(v, lower, upper, step) static CTweakInt16 CONCAT(___tw___tweak, __COUNTER__)(&v, STR(v), lower, upper, step, TWEAKPATH);
#define TWEAKINT16N(v, lower, upper, step, name) static CTweakInt16 CONCAT(___tw___tweak, __COUNTER__)(&v, name, lower, upper, step, TWEAKPATH);
#define TWEAKUINT16(v, lower, upper, step) static CTweakUInt16 CONCAT(___tw___tweak, __COUNTER__)(&v, STR(v), lower, upper, step, TWEAKPATH);
#define TWEAKUINT16N(v, lower, upper, step, name) static CTweakUInt16 CONCAT(___tw___tweak, __COUNTER__)(&v, name, lower, upper, step, TWEAKPATH);
#define TWEAKINT8(v, lower, upper, step) static CTweakInt8 CONCAT(___tw___tweak, __COUNTER__)(&v, STR(v), lower, upper, step, TWEAKPATH);
#define TWEAKINT8N(v, lower, upper, step, name) static CTweakInt8 CONCAT(___tw___tweak, __COUNTER__)(&v, name, lower, upper, step, TWEAKPATH);
#define TWEAKUINT8(v, lower, upper, step) static CTweakUInt8 CONCAT(___tw___tweak, __COUNTER__)(&v, STR(v), lower, upper, step, TWEAKPATH);
#define TWEAKUINT8N(v, lower, upper, step, name) static CTweakUInt8 CONCAT(___tw___tweak, __COUNTER__)(&v, name, lower, upper, step, TWEAKPATH);
#define TWEAKFLOAT(v, lower, upper, step) static CTweakFloat CONCAT(___tw___tweak, __COUNTER__)(&v, STR(v), lower, upper, step, TWEAKPATH);
#define TWEAKFLOATN(v, lower, upper, step, name) static CTweakFloat CONCAT(___tw___tweak, __COUNTER__)(&v, name, lower, upper, step, TWEAKPATH);
#define TWEAKSWITCH(v, lower, upper, str, f) static CTweakSwitch CONCAT(___tw___tweak, __COUNTER__)(&v, STR(v), lower, upper, str, f, TWEAKPATH);
#define TWEAKSWITCHN(v, lower, upper, str, f, name) static CTweakSwitch CONCAT(___tw___tweak, __COUNTER__)(&v, name, lower, upper, str, f, TWEAKPATH);
// interface
class CTweakVar
{
public:
virtual void AddDBG(const char *path) = 0;
};
class CTweakVars
{
public:
static void Add(CTweakVar *var);
static void AddDBG(const char *path);
};
class CTweakFunc : public CTweakVar
{
const char *m_pPath, *m_pVarName;
void (*m_pFunc)();
public:
CTweakFunc(void (*pFunc)(), const char *strName, const char *strPath) :
m_pFunc(pFunc), m_pVarName(strName), m_pPath(strPath)
{
CTweakVars::Add(this);
}
void AddDBG(const char *path);
};
class CTweakBool : public CTweakVar
{
const char *m_pPath, *m_pVarName;
bool *m_pBoolVar;
public:
CTweakBool(bool *pBool, const char *strName, const char *strPath) :
m_pBoolVar(pBool), m_pVarName(strName), m_pPath(strPath)
{
CTweakVars::Add(this);
}
void AddDBG(const char *path);
};
class CTweakSwitch : public CTweakVar
{
const char *m_pPath, *m_pVarName;
void *m_pIntVar;
int32 m_nMin, m_nMax;
const char **m_aStr;
void (*m_pFunc)();
public:
CTweakSwitch(void *pInt, const char *strName, int32 nMin, int32 nMax, const char **aStr, void (*pFunc)(), const char *strPath) :
m_pVarName(strName), m_pPath(strPath),
m_aStr(aStr), m_pIntVar(pInt), m_nMin(nMin), m_nMax(nMax)
{
CTweakVars::Add(this);
}
void AddDBG(const char *path);
};
#define _TWEEKCLASS(name, type) \
class name : public CTweakVar \
{ \
public: \
const char *m_pPath, *m_pVarName; \
type *m_pIntVar, m_nLoawerBound, m_nUpperBound, m_nStep; \
\
name(type *pInt, const char *strName, type nLower, type nUpper, type nStep, const char *strPath) : \
m_pIntVar(pInt), m_nLoawerBound(nLower), m_nUpperBound(nUpper), m_nStep(nStep), \
m_pVarName(strName), m_pPath(strPath) \
{ \
CTweakVars::Add(this); \
} \
\
void AddDBG(const char *path); \
};
_TWEEKCLASS(CTweakInt8, int8);
_TWEEKCLASS(CTweakUInt8, uint8);
_TWEEKCLASS(CTweakInt16, int16);
_TWEEKCLASS(CTweakUInt16, uint16);
_TWEEKCLASS(CTweakInt32, int32);
_TWEEKCLASS(CTweakUInt32, uint32);
_TWEEKCLASS(CTweakFloat, float);
#undef _TWEEKCLASS

View File

@ -3,6 +3,7 @@
enum Config {
NUMCDIMAGES = 12, // gta3.img duplicates (not used on PC)
MAX_CDIMAGES = 8, // additional cdimages
MAX_CDCHANNELS = 5,
MODELINFOSIZE = 5500,
TXDSTORESIZE = 850,
@ -113,7 +114,7 @@ enum Config {
# define CHATTYSPLASH // print what the game is loading
#endif
#define FIX_BUGS // fix bugs in the game, TODO: use this more
//#define FIX_BUGS // fix bugs in the game, TODO: use this more
#define KANGAROO_CHEAT
#define ASPECT_RATIO_SCALE
#define USE_DEBUG_SCRIPT_LOADER

View File

@ -66,6 +66,12 @@ wchar *gUString2 = (wchar*)0x6EDD70;
bool &b_FoundRecentSavedGameWantToLoad = *(bool*)0x95CDA8;
char version_name[64];
float FramesPerSecond = 30.0f;
bool gbPrintShite = false;
bool DoRWStuffStartOfFrame_Horizon(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 BottomRed, int16 BottomGreen, int16 BottomBlue, int16 Alpha);
void DoRWStuffEndOfFrame(void);
@ -173,9 +179,6 @@ Idle(void *arg)
}
RenderMenus();
#ifndef FINAL
PrintGameVersion();
#endif
DoFade();
Render2dStuffAfterFade();
CCredits::Render();
@ -211,9 +214,6 @@ FrontendIdle(void)
DefinedState();
RenderMenus();
#ifndef FINAL
PrintGameVersion();
#endif
DoFade();
Render2dStuffAfterFade();
CFont::DrawFonts();
@ -473,9 +473,137 @@ DoFade(void)
}
}
float FramesPerSecondCounter;
int32 FrameSamples;
struct tZonePrint
{
char name[12];
CRect rect;
};
tZonePrint ZonePrint[] =
{
{ "suburban", CRect(-1639.4f, 1014.3f, -226.23f, -1347.9f) },
{ "comntop", CRect(-223.52f, 203.62f, 616.79f, -413.6f) },
{ "comnbtm", CRect(-227.24f, -413.6f, 620.51f, -911.84f) },
{ "comse", CRect( 200.35f, -911.84f, 620.51f, -1737.3f) },
{ "comsw", CRect(-223.52f, -911.84f, 200.35f, -1737.3f) },
{ "industsw", CRect( 744.05f, -473.0f, 1067.5f, -1331.5f) },
{ "industne", CRect( 1067.5f, 282.19f, 1915.3f, -473.0f) },
{ "industnw", CRect( 744.05f, 324.95f, 1067.5f, -473.0f) },
{ "industse", CRect( 1070.3f, -473.0f, 1918.1f, -1331.5f) },
{ "no zone", CRect( 0.0f, 0.0f, 0.0f, 0.0f) }
};
#ifndef MASTER
void
DisplayGameDebugText()
{
static bool bDisplayPosn = false;
static bool bDisplayRate = false;
{
SETTWEAKPATH("GameDebugText");
TWEAKBOOL(bDisplayPosn);
TWEAKBOOL(bDisplayRate);
}
char str[200];
wchar ustr[200];
wchar ver[200];
AsciiToUnicode(version_name, ver);
CFont::SetPropOn();
CFont::SetBackgroundOff();
CFont::SetFontStyle(FONT_BANK);
CFont::SetScale(SCREEN_STRETCH_X(0.5f), SCREEN_STRETCH_Y(0.5f));
CFont::SetCentreOff();
CFont::SetRightJustifyOff();
CFont::SetWrapx(SCREEN_WIDTH);
CFont::SetJustifyOff();
CFont::SetBackGroundOnlyTextOff();
CFont::SetColor(CRGBA(255, 108, 0, 255));
CFont::PrintString(10.0f, 10.0f, ver);
FrameSamples++;
FramesPerSecondCounter += 1000.0f / (CTimer::GetTimeStepNonClippedInSeconds() * 1000.0f);
FramesPerSecond = FramesPerSecondCounter / FrameSamples;
if ( FrameSamples > 30 )
{
FramesPerSecondCounter = 0.0f;
FrameSamples = 0;
}
if ( !TheCamera.WorldViewerBeingUsed
&& CPad::GetPad(1)->GetSquare()
&& CPad::GetPad(1)->GetTriangle()
&& CPad::GetPad(1)->GetLeftShoulder2JustDown() )
{
bDisplayPosn = !bDisplayPosn;
}
if ( CPad::GetPad(1)->GetSquare()
&& CPad::GetPad(1)->GetTriangle()
&& CPad::GetPad(1)->GetRightShoulder2JustDown() )
{
bDisplayRate = !bDisplayRate;
}
if ( bDisplayPosn || bDisplayRate )
{
CVector pos = FindPlayerCoors();
int32 ZoneId = ARRAY_SIZE(ZonePrint)-1; // no zone
for ( int32 i = 0; i < ARRAY_SIZE(ZonePrint)-1; i++ )
{
if ( pos.x > ZonePrint[i].rect.left
&& pos.x < ZonePrint[i].rect.right
&& pos.y > ZonePrint[i].rect.bottom
&& pos.y < ZonePrint[i].rect.top )
{
ZoneId = i;
}
}
//NOTE: fps should be 30, but its 29 due to different fp2int conversion
if ( bDisplayRate )
sprintf(str, "X:%5.1f, Y:%5.1f, Z:%5.1f, F-%d, %s", pos.x, pos.y, pos.z, (int32)FramesPerSecond, ZonePrint[ZoneId].name);
else
sprintf(str, "X:%5.1f, Y:%5.1f, Z:%5.1f, %s", pos.x, pos.y, pos.z, ZonePrint[ZoneId].name);
AsciiToUnicode(str, ustr);
CFont::SetPropOff();
CFont::SetBackgroundOff();
CFont::SetScale(0.7f, 1.5f);
CFont::SetCentreOff();
CFont::SetRightJustifyOff();
CFont::SetJustifyOff();
CFont::SetBackGroundOnlyTextOff();
CFont::SetWrapx(640.0f);
CFont::SetFontStyle(FONT_HEADING);
CFont::SetColor(CRGBA(0, 0, 0, 255));
CFont::PrintString(42.0f, 42.0f, ustr);
CFont::SetColor(CRGBA(255, 108, 0, 255));
CFont::PrintString(40.0f, 40.0f, ustr);
}
}
#endif
void
Render2dStuffAfterFade(void)
{
#ifndef MASTER
DisplayGameDebugText();
//PrintGameVersion();
#endif
CHud::DrawAfterFade();
CFont::DrawFonts();
}
@ -871,6 +999,41 @@ void PrintGameVersion()
CFont::PrintString(SCREEN_SCALE_X(10.5f), SCREEN_SCALE_Y(8.0f), gUString);
}
void
ValidateVersion()
{
int32 file = CFileMgr::OpenFile("models\\coll\\peds.col", "rb");
char buff[128];
if ( file != -1 )
{
CFileMgr::Seek(file, 100, SEEK_SET);
for ( int i = 0; i < 128; i++ )
{
CFileMgr::Read(file, &buff[i], sizeof(char));
buff[i] -= 23;
if ( buff[i] == '\0' )
break;
CFileMgr::Seek(file, 99, SEEK_CUR);
}
if ( !strncmp(buff, "grandtheftauto3", 15) )
{
strncpy(version_name, &buff[15], 64);
CFileMgr::CloseFile(file);
return;
}
}
LoadingScreen("Invalid version", NULL, NULL);
while(true)
{
;
}
}
STARTPATCHES
InjectHook(0x48E480, Idle, PATCH_JUMP);
InjectHook(0x48E700, FrontendIdle, PATCH_JUMP);

View File

@ -17,6 +17,7 @@ extern char *gString2;
extern wchar *gUString;
extern wchar *gUString2;
extern bool &b_FoundRecentSavedGameWantToLoad;
extern bool gbPrintShite;
class CSprite2d;
@ -26,3 +27,4 @@ void LoadingIslandScreen(const char *levelName);
CSprite2d *LoadSplash(const char *name);
char *GetLevelSplashScreen(int level);
char *GetRandomSplashScreen(void);
void ValidateVersion();

View File

@ -17,6 +17,7 @@
#include "debugmenu_public.h"
#include <vector>
#include <list>
std::vector<int32> usedAddresses;
@ -167,9 +168,71 @@ FixCar(void)
((CAutomobile*)veh)->Fix();
}
static std::list<CTweakVar *> TweakVarsList;
static bool bAddTweakVarsNow = false;
static const char *pTweakVarsDefaultPath = NULL;
void CTweakVars::Add(CTweakVar *var)
{
TweakVarsList.push_back(var);
if ( bAddTweakVarsNow )
var->AddDBG(pTweakVarsDefaultPath);
}
void CTweakVars::AddDBG(const char *path)
{
pTweakVarsDefaultPath = path;
for(auto i = TweakVarsList.begin(); i != TweakVarsList.end(); ++i)
(*i)->AddDBG(pTweakVarsDefaultPath);
bAddTweakVarsNow = true;
}
//inline DebugMenuEntry * DebugMenuAddVar (const char *path , name, ptr, trig, step, lowerBound, upperBound, const char **strings)
/*
inline DebugMenuEntry *
DebugMenuAddVar
(const char *path,
const char *name,
int8_t *ptr,
TriggerFunc triggerFunc,
int8_t step,
int8_t lowerBound,
int8_t upperBound,
const char **strings)
*/
void CTweakSwitch::AddDBG(const char *path)
{
DebugMenuEntry *e = DebugMenuAddVar(m_pPath == NULL ? path : m_pPath, m_pVarName, (int32_t *)m_pIntVar, m_pFunc, 1, m_nMin, m_nMax, m_aStr);
DebugMenuEntrySetWrap(e, true);
}
void CTweakFunc::AddDBG (const char *path) { DebugMenuAddCmd (m_pPath == NULL ? path : m_pPath, m_pVarName, m_pFunc); }
void CTweakBool::AddDBG (const char *path) { DebugMenuAddVarBool8(m_pPath == NULL ? path : m_pPath, m_pVarName, (int8_t *)m_pBoolVar, NULL); }
void CTweakInt8::AddDBG (const char *path) { DebugMenuAddVar (m_pPath == NULL ? path : m_pPath, m_pVarName, (int8_t *)m_pIntVar, NULL, m_nStep, m_nLoawerBound, m_nUpperBound, NULL); }
void CTweakUInt8::AddDBG (const char *path) { DebugMenuAddVar (m_pPath == NULL ? path : m_pPath, m_pVarName, (uint8_t *)m_pIntVar, NULL, m_nStep, m_nLoawerBound, m_nUpperBound, NULL); }
void CTweakInt16::AddDBG (const char *path) { DebugMenuAddVar (m_pPath == NULL ? path : m_pPath, m_pVarName, (int16_t *)m_pIntVar, NULL, m_nStep, m_nLoawerBound, m_nUpperBound, NULL); }
void CTweakUInt16::AddDBG(const char *path) { DebugMenuAddVar (m_pPath == NULL ? path : m_pPath, m_pVarName, (uint16_t *)m_pIntVar, NULL, m_nStep, m_nLoawerBound, m_nUpperBound, NULL); }
void CTweakInt32::AddDBG (const char *path) { DebugMenuAddVar (m_pPath == NULL ? path : m_pPath, m_pVarName, (int32_t *)m_pIntVar, NULL, m_nStep, m_nLoawerBound, m_nUpperBound, NULL); }
void CTweakUInt32::AddDBG(const char *path) { DebugMenuAddVar (m_pPath == NULL ? path : m_pPath, m_pVarName, (uint32_t *)m_pIntVar, NULL, m_nStep, m_nLoawerBound, m_nUpperBound, NULL); }
void CTweakFloat::AddDBG (const char *path) { DebugMenuAddVar (m_pPath == NULL ? path : m_pPath, m_pVarName, (float *)m_pIntVar, NULL, m_nStep, m_nLoawerBound, m_nUpperBound); }
/*
static const char *wt[] = {
"Sunny", "Cloudy", "Rainy", "Foggy"
};
SETTWEAKPATH("TEST");
TWEAKSWITCH(CWeather::NewWeatherType, 0, 3, wt, NULL);
*/
void
DebugMenuPopulate(void)
{
{
if(DebugMenuLoad()){
static const char *weathers[] = {
"Sunny", "Cloudy", "Rainy", "Foggy"
@ -223,6 +286,8 @@ DebugMenuPopulate(void)
DebugMenuAddCmd("Debug", "Start Credits", CCredits::Start);
DebugMenuAddCmd("Debug", "Stop Credits", CCredits::Stop);
CTweakVars::AddDBG("Debug");
}
}

View File

@ -12,5 +12,6 @@ inline float Atan(float x) { return atanf(x); }
inline float Atan2(float y, float x) { return atan2f(y, x); }
inline float Abs(float x) { return fabs(x); }
inline float Sqrt(float x) { return sqrtf(x); }
inline float RecipSqrt(float x) { return 1.0f/Sqrt(x); }
inline float RecipSqrt(float x, float y) { return x/Sqrt(y); }
inline float RecipSqrt(float x) { return RecipSqrt(1.0f, x); }
inline float Pow(float x, float y) { return powf(x, y); }

View File

@ -226,6 +226,10 @@ int32 Randomizer;
int32 nParticleCreationInterval = 1;
float fParticleScaleLimit = 0.5f;
SETTWEAKPATH("Particle");
TWEAKINT32(nParticleCreationInterval, 0, 5, 1);
TWEAKFLOAT(fParticleScaleLimit, 0.0f, 1.0f, 0.1f);
TWEAKFUNC(CParticle::ReloadConfig);
void CParticle::ReloadConfig()
{
@ -1143,7 +1147,7 @@ void CParticle::Update()
{
bRemoveParticle = true;
int32 randVal = int32(CGeneral::GetRandomNumber());
int32 randVal = CGeneral::GetRandomNumber();
if ( randVal & 1 )
{
@ -1188,23 +1192,19 @@ void CParticle::Update()
if ( randVal == 5 )
{
int32 randTime = int32(CGeneral::GetRandomNumber());
CShadows::AddPermanentShadow(1, gpBloodPoolTex, &vecPosn,
0.1f, 0.0f, 0.0f, -0.1f,
255,
255, 0, 0,
4.0f, (randTime & 0xFFF) + 2000, 1.0f);
4.0f, (CGeneral::GetRandomNumber() & 4095) + 2000, 1.0f);
}
else if ( randVal == 2 )
{
int32 randTime = int32(CGeneral::GetRandomNumber());
CShadows::AddPermanentShadow(1, gpBloodPoolTex, &vecPosn,
0.2f, 0.0f, 0.0f, -0.2f,
255,
255, 0, 0,
4.0f, (randTime & 0xFFF) + 8000, 1.0f);
4.0f, (CGeneral::GetRandomNumber() & 4095) + 8000, 1.0f);
}
continue;
}
@ -1600,7 +1600,7 @@ void CParticle::Render()
fTrailLength = fDist;
//Float fRot = Atan2( vecDist.x / fDist, Sqrt(1.0f - vecDist.x / fDist * (vecDist.x / fDist)) );
float fRot = asinf(vecDist.x / fDist);
float fRot = Asin(vecDist.x / fDist);
fRotation = fRot;
@ -1652,7 +1652,7 @@ void CParticle::Render()
fTrailLength = fDist;
//Float fRot = Atan2(vecDist.x / fDist, Sqrt(1.0f - vecDist.x / fDist * (vecDist.x / fDist)));
float fRot = asinf(vecDist.x / fDist);
float fRot = Asin(vecDist.x / fDist);
fRotation = fRot;

View File

@ -17,10 +17,10 @@ static_assert(sizeof(CRegisteredPointLight) == 0x2C, "CRegisteredPointLight: err
class CPointLights
{
// Probably have to make this public for shadows later
public:
static int16 &NumLights;
static CRegisteredPointLight *aLights; //[NUMPOINTLIGHTS]
public:
enum {
LIGHT_POINT,
LIGHT_DIRECTIONAL,

View File

@ -8,8 +8,8 @@ int32 &TempBufferIndicesStored = *(int32*)0x8F1A4C;
RwIm3DVertex *TempBufferRenderVertices = (RwIm3DVertex*)0x862330;
RwImVertexIndex *TempBufferRenderIndexList = (RwImVertexIndex*)0x846288;
int RenderBuffer::VerticesToBeStored;
int RenderBuffer::IndicesToBeStored;
int &RenderBuffer::VerticesToBeStored = *(int*)0x8F59C4;
int &RenderBuffer::IndicesToBeStored = *(int*)0x8E28B0;
void
RenderBuffer::ClearRenderBuffer(void)

View File

@ -1,8 +1,8 @@
class RenderBuffer
{
public:
static int VerticesToBeStored;
static int IndicesToBeStored;
static int &VerticesToBeStored;
static int &IndicesToBeStored;
static void ClearRenderBuffer(void);
static void StartStoring(int numIndices, int numVertices, RwImVertexIndex **indexStart, RwIm3DVertex **vertexStart);
static void StopStoring(void);

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,11 @@
#pragma once
#define MAX_STOREDSHADOWS 48
#define MAX_POLYBUNCHES 300
#define MAX_STATICSHADOWS 64
#define MAX_PERMAMENTSHADOWS 48
struct RwTexture;
class CEntity;
@ -8,19 +14,170 @@ enum
SHADOWTYPE_2 = 2
};
enum eShadowType
{
SHADOWTYPE_NONE = 0,
SHADOWTYPE_DARK,
SHADOWTYPE_ADDITIVE,
SHADOWTYPE_INVCOLOR
};
enum eShadowTextureType
{
SHADOWTEX_NONE = 0,
SHADOWTEX_CAR,
SHADOWTEX_PED,
SHADOWTEX_EXPLOSION,
SHADOWTEX_HELI,
SHADOWTEX_HEADLIGHTS,
SHADOWTEX_BLOOD
};
class CStoredShadow
{
public:
CVector m_vecPos;
CVector2D m_vecFront;
CVector2D m_vecSide;
float m_fZDistance;
float m_fScale;
int16 m_nIntensity;
uint8 m_ShadowType;
uint8 m_nRed;
uint8 m_nGreen;
uint8 m_nBlue;
struct
{
uint8 bDrawOnWater : 1;
uint8 bRendered : 1;
//uint8 bDrawOnBuildings : 1;
} m_nFlags;
char _pad0;
RwTexture *m_pTexture;
CStoredShadow()
{ }
};
VALIDATE_SIZE(CStoredShadow, 0x30);
class CPolyBunch
{
public:
int16 m_nNumVerts;
char _pad0[2];
CVector m_aVerts[7];
uint8 m_aU[7];
uint8 m_aV[7];
char _pad1[2];
CPolyBunch *m_pNext;
CPolyBunch()
{ }
};
VALIDATE_SIZE(CPolyBunch, 0x6C);
class CStaticShadow
{
public:
uint32 m_nId;
CPolyBunch *m_pPolyBunch;
uint32 m_nTimeCreated;
CVector m_vecPosn;
CVector2D m_vecFront;
CVector2D m_vecSide;
float m_fZDistance;
float m_fScale;
uint8 m_nType;
char _pad0;
int16 m_nIntensity; // unsigned ?
uint8 m_nRed;
uint8 m_nGreen;
uint8 m_nBlue;
bool m_bJustCreated;
bool m_bRendered;
bool m_bTemp;
char _pad1[2];
RwTexture *m_pTexture;
CStaticShadow()
{ }
void Free();
};
VALIDATE_SIZE(CStaticShadow, 0x40);
class CPermanentShadow
{
public:
CVector m_vecPos;
CVector2D m_vecFront;
CVector2D m_vecSide;
float m_fZDistance;
float m_fScale;
int16 m_nIntensity;
uint8 m_nType; // eShadowType
uint8 m_nRed;
uint8 m_nGreen;
uint8 m_nBlue;
char _pad0[2];
uint32 m_nTimeCreated;
uint32 m_nLifeTime;
RwTexture *m_pTexture;
CPermanentShadow()
{ }
};
VALIDATE_SIZE(CPermanentShadow, 0x38);
class CPtrList;
class CAutomobile;
class CPed;
class CShadows
{
public:
static void AddPermanentShadow(uint8 ShadowType, RwTexture* pTexture, CVector* pPosn, float fX1, float fY1, float fX2, float fY2, short nTransparency, uint8 nRed, uint8 nGreen, uint8 nBlue, float fZDistance, uint32 nTime, float fScale);
static void RenderStaticShadows(void);
static void RenderStoredShadows(void);
static void RenderExtraPlayerShadows(void);
static void CalcPedShadowValues(CVector light, float *frontX, float *frontY, float *sideX, float *sideY, float *dispX, float *dispY);
static void StoreShadowForTree(CEntity *ent);
static void StoreShadowForPole(CEntity *ent, float offsetX, float offsetY, float offsetZ, float poleHeight, float poleWidth, uint32 subId);
static void StoreShadowForPedObject(CEntity *ent, float dispX, float dispY, float frontX, float frontY, float sideX, float sideY);
static void StoreStaticShadow(uint32 id, uint8 type, RwTexture *texture, CVector *coors, float frontX, float frontY, float sideX, float sideY, int16 intensity, uint8 red, uint8 green, uint8 blue, float zDistance, float scale, float drawDistance, bool temporaryShadow, float upDistance);;
static void StoreShadowToBeRendered(uint8 type, RwTexture *texture, CVector *coors, float frontX, float frontY, float sideX, float sideY, int16 intensity, uint8 red, uint8 green, uint8 blue, float zDistance, bool drawOnWater, float upDistance);
#if 1
static int16 ShadowsStoredToBeRendered;
static CStoredShadow asShadowsStored [MAX_STOREDSHADOWS];
static CPolyBunch aPolyBunches [MAX_POLYBUNCHES];
static CStaticShadow aStaticShadows [MAX_STATICSHADOWS];
static CPolyBunch *pEmptyBunchList;
static CPermanentShadow aPermanentShadows[MAX_PERMAMENTSHADOWS];
#else
static int16 &ShadowsStoredToBeRendered;
static CStoredShadow (&asShadowsStored) [MAX_STOREDSHADOWS];
static CPolyBunch (&aPolyBunches) [MAX_POLYBUNCHES];
static CStaticShadow (&aStaticShadows) [MAX_STATICSHADOWS];
static CPolyBunch *&pEmptyBunchList;
static CPermanentShadow (&aPermanentShadows)[MAX_PERMAMENTSHADOWS];
#endif
static void Init (void);
static void Shutdown (void);
static void AddPermanentShadow ( uint8 ShadowType, RwTexture *pTexture, CVector *pPosn, float fFrontX, float fFrontY, float fSideX, float fSideY, int16 nIntensity, uint8 nRed, uint8 nGreen, uint8 nBlue, float fZDistance, uint32 nTime, float fScale);
static void StoreStaticShadow (uint32 nID, uint8 ShadowType, RwTexture *pTexture, CVector *pPosn, float fFrontX, float fFrontY, float fSideX, float fSideY, int16 nIntensity, uint8 nRed, uint8 nGreen, uint8 nBlue, float fZDistance, float fScale, float fDrawDistance, bool bTempShadow, float fUpDistance);
static void StoreShadowToBeRendered ( uint8 ShadowType, CVector *pPosn, float fFrontX, float fFrontY, float fSideX, float fSideY, int16 nIntensity, uint8 nRed, uint8 nGreen, uint8 nBlue);
static void StoreShadowToBeRendered ( uint8 ShadowType, RwTexture *pTexture, CVector *pPosn, float fFrontX, float fFrontY, float fSideX, float fSideY, int16 nIntensity, uint8 nRed, uint8 nGreen, uint8 nBlue, float fZDistance, bool bDrawOnWater, float fScale);
static void StoreShadowForCar (CAutomobile *pCar);
static void StoreCarLightShadow (CAutomobile *pCar, int32 nID, RwTexture *pTexture, CVector *pPosn, float fFrontX, float fFrontY, float fSideX, float fSideY, uint8 nRed, uint8 nGreen, uint8 nBlue, float fMaxViewAngle);
static void StoreShadowForPed (CPed *pPed, float fDisplacementX, float fDisplacementY, float fFrontX, float fFrontY, float fSideX, float fSideY);
static void StoreShadowForPedObject (CEntity *pPedObject, float fDisplacementX, float fDisplacementY, float fFrontX, float fFrontY, float fSideX, float fSideY);
static void StoreShadowForTree (CEntity *pTree);
static void StoreShadowForPole (CEntity *pPole, float fOffsetX, float fOffsetY, float fOffsetZ, float fPoleHeight, float fPoleWidth, uint32 nID);
static void SetRenderModeForShadowType (uint8 ShadowType);
static void RenderStoredShadows (void);
static void RenderStaticShadows (void);
static void GeneratePolysForStaticShadow (int16 nStaticShadowID);
static void CastShadowSectorList (CPtrList &PtrList, float fStartX, float fStartY, float fEndX, float fEndY,
CVector *pPosn, float fFrontX, float fFrontY, float fSideX, float fSideY, int16 nIntensity, uint8 nRed, uint8 nGreen, uint8 nBlue, float fZDistance, float fScale, CPolyBunch **ppPolyBunch);
static void CastShadowEntity (CEntity *pEntity, float fStartX, float fStartY, float fEndX, float fEndY,
CVector *pPosn, float fFrontX, float fFrontY, float fSideX, float fSideY, int16 nIntensity, uint8 nRed, uint8 nGreen, uint8 nBlue, float fZDistance, float fScale, CPolyBunch **ppPolyBunch);
static void UpdateStaticShadows (void);
static void UpdatePermanentShadows (void);
static void CalcPedShadowValues (CVector vecLightDir, float *pfDisplacementX, float *pfDisplacementY, float *pfFrontX, float *pfFrontY, float *pfSideX, float *pfSideY);
static void RenderExtraPlayerShadows (void);
static void TidyUpShadows (void);
static void RenderIndicatorShadow (uint32 nID, uint8 ShadowType, RwTexture *pTexture, CVector *pPosn, float fFrontX, float fFrontY, float fSideX, float fSideY, int16 nIntensity);
};
extern RwTexture *&gpBloodPoolTex;

View File

@ -10,3 +10,6 @@ WRAPPER void CMotionBlurStreaks::RegisterStreak(int32 id, uint8 r, uint8 g, uint
CBulletTrace (&CBulletTraces::aTraces)[16] = *(CBulletTrace(*)[16])*(uintptr*)0x72B1B8;
WRAPPER void CBulletTraces::Init(void) { EAXJMP(0x518DE0); }
WRAPPER void C3dMarkers::PlaceMarkerSet(uint32 id, uint16 type, CVector& pos, float size, uint8 r, uint8 g, uint8 b, uint8 a, uint16 pulsePeriod, float pulseFraction, int16 rotateRate) { EAXJMP(0x51BB80); }

View File

@ -28,3 +28,9 @@ public:
static void Init(void);
};
class C3dMarkers
{
public:
static void PlaceMarkerSet(uint32 id, uint16 type, CVector& pos, float size, uint8 r, uint8 g, uint8 b, uint8 a, uint16 pulsePeriod, float pulseFraction, int16 rotateRate);
};

View File

@ -119,6 +119,8 @@ public:
static int GetSunCoronaBlue(void) { return m_nCurrentSunCoronaBlue; }
static float GetSunSize(void) { return m_fCurrentSunSize; }
static float GetSpriteBrightness(void) { return m_fCurrentSpriteBrightness; }
static int GetShadowStrength(void) { return m_nCurrentShadowStrength; }
static int GetLightShadowStrength(void) { return m_nCurrentLightShadowStrength; }
static float GetFarClip(void) { return m_fCurrentFarClip; }
static float GetFogStart(void) { return m_fCurrentFogStart; }
@ -138,4 +140,10 @@ public:
static void Initialise(void);
static void Update(void);
static CVector &GetSunPosition(void) { return m_VectorToSun[m_CurrentStoredValue]; }
static float GetShadowFrontX(void) { return m_fShadowFrontX[m_CurrentStoredValue]; }
static float GetShadowFrontY(void) { return m_fShadowFrontY[m_CurrentStoredValue]; }
static float GetShadowSideX(void) { return m_fShadowSideX[m_CurrentStoredValue]; }
static float GetShadowSideY(void) { return m_fShadowSideY[m_CurrentStoredValue]; }
static float GetShadowDisplacementX(void) { return m_fShadowDisplacementX[m_CurrentStoredValue]; }
static float GetShadowDisplacementY(void) { return m_fShadowDisplacementY[m_CurrentStoredValue]; }
};

View File

@ -238,7 +238,7 @@ CWaterLevel::GetWaterLevel(float fX, float fY, float fZ, float *pfOutLevel, bool
float fAngle = (CTimer::GetTimeInMilliseconds() & 4095) * (TWOPI / 4096.0f);
float fWave = sin
float fWave = Sin
(
/*( WATER_UNSIGN_Y(fY) - float(y) * MAX_HUGE_SECTORS + WATER_UNSIGN_X(fX) - float(x) * MAX_HUGE_SECTORS )*/ // VC
(float)( ((int32)fX & (MAX_HUGE_SECTORS-1)) + ((int32)fY & (MAX_HUGE_SECTORS-1)) )
@ -306,7 +306,7 @@ _GetCamBounds(bool *bUseCamStartY, bool *bUseCamEndY, bool *bUseCamStartX, bool
{
if ( TheCamera.GetForward().z > -0.8f )
{
if ( fabsf(TheCamera.GetForward().x) > fabsf(TheCamera.GetForward().y) )
if ( Abs(TheCamera.GetForward().x) > Abs(TheCamera.GetForward().y) )
{
if ( TheCamera.GetForward().x > 0.0f )
*bUseCamStartX = true;
@ -326,7 +326,7 @@ _GetCamBounds(bool *bUseCamStartY, bool *bUseCamEndY, bool *bUseCamStartX, bool
float
SectorRadius(float fSize)
{
return sqrtf(powf(fSize, 2) + powf(fSize, 2));
return Sqrt(Pow(fSize, 2) + Pow(fSize, 2));
}
void
@ -714,7 +714,7 @@ CWaterLevel::RenderWater()
static CVector prev_front(0.0f, 0.0f, 0.0f);
static int32 timecounter;
if ( fabs(prev_pos.x - cur_pos.x) + fabs(prev_pos.y - cur_pos.y) + fabs(prev_pos.z - cur_pos.z) > 1.5f )
if ( Abs(prev_pos.x - cur_pos.x) + Abs(prev_pos.y - cur_pos.y) + Abs(prev_pos.z - cur_pos.z) > 1.5f )
{
prev_pos = cur_pos;
timecounter = CTimer::GetTimeInMilliseconds();
@ -962,8 +962,8 @@ CWaterLevel::RenderOneWavySector(float fX, float fY, float fZ, RwRGBA const &col
RwRGBAAssign(&wavyPreLights[9*i+j], &color);
wavyVertices[9*i+j].z = ( CWeather::Wind * 0.7f + 0.3f )
* ( sinf(float(i + j) * DEGTORAD(45.0f) + fAngle) )
+ ( CWeather::Wind * 0.2f * sinf(float(j - i) * PI + (2.0f * fAngle)) );
* ( Sin(float(i + j) * DEGTORAD(45.0f) + fAngle) )
+ ( CWeather::Wind * 0.2f * Sin(float(j - i) * PI + (2.0f * fAngle)) );
}
}
@ -1119,7 +1119,7 @@ CWaterLevel::CalcDistanceToWater(float fX, float fY)
}
}
return clamp(sqrt(fDistSqr) - 23.0f, 0.0f, fSectorMaxRenderDist);
return clamp(Sqrt(fDistSqr) - 23.0f, 0.0f, fSectorMaxRenderDist);
}
void