diff options
author | saml1er <danishroar@gmail.com> | 2020-04-16 21:01:53 +0200 |
---|---|---|
committer | saml1er <danishroar@gmail.com> | 2020-04-16 21:01:53 +0200 |
commit | e52a02fb9e1dd5602e80d88691f2ee2291d1fa52 (patch) | |
tree | 333caa1599e2f0c6b91bdae2092cf085eaf8238a /src/render | |
parent | Reverse CWorld (diff) | |
parent | More refs removed (diff) | |
download | re3-e52a02fb9e1dd5602e80d88691f2ee2291d1fa52.tar re3-e52a02fb9e1dd5602e80d88691f2ee2291d1fa52.tar.gz re3-e52a02fb9e1dd5602e80d88691f2ee2291d1fa52.tar.bz2 re3-e52a02fb9e1dd5602e80d88691f2ee2291d1fa52.tar.lz re3-e52a02fb9e1dd5602e80d88691f2ee2291d1fa52.tar.xz re3-e52a02fb9e1dd5602e80d88691f2ee2291d1fa52.tar.zst re3-e52a02fb9e1dd5602e80d88691f2ee2291d1fa52.zip |
Diffstat (limited to 'src/render')
-rw-r--r-- | src/render/Clouds.cpp | 2 | ||||
-rw-r--r-- | src/render/Console.cpp | 1 | ||||
-rw-r--r-- | src/render/Glass.cpp | 16 | ||||
-rw-r--r-- | src/render/Hud.cpp | 6 | ||||
-rw-r--r-- | src/render/Instance.cpp | 20 | ||||
-rw-r--r-- | src/render/Instance.h | 14 | ||||
-rw-r--r-- | src/render/Renderer.cpp | 17 | ||||
-rw-r--r-- | src/render/Renderer.h | 16 | ||||
-rw-r--r-- | src/render/Shadows.h | 1 | ||||
-rw-r--r-- | src/render/Sprite.cpp | 18 | ||||
-rw-r--r-- | src/render/Sprite2d.cpp | 14 | ||||
-rw-r--r-- | src/render/Sprite2d.h | 14 | ||||
-rw-r--r-- | src/render/WeaponEffects.cpp | 106 | ||||
-rw-r--r-- | src/render/WeaponEffects.h | 27 | ||||
-rw-r--r-- | src/render/Weather.cpp | 2 |
15 files changed, 93 insertions, 181 deletions
diff --git a/src/render/Clouds.cpp b/src/render/Clouds.cpp index 39866294..7debe3d3 100644 --- a/src/render/Clouds.cpp +++ b/src/render/Clouds.cpp @@ -233,7 +233,7 @@ CClouds::Render(void) szx*55.0f, szy*55.0f, tr, tg, tb, br, bg, bb, 0.0f, -1.0f, 1.0f/screenpos.z, - IndividualRotation/65336.0f * 2*3.14f + ms_cameraRoll, + (uint16)IndividualRotation/65336.0f * 6.28f + ms_cameraRoll, fluffyalpha); bCloudOnScreen[i] = true; }else diff --git a/src/render/Console.cpp b/src/render/Console.cpp index d4940955..545122b0 100644 --- a/src/render/Console.cpp +++ b/src/render/Console.cpp @@ -1,4 +1,5 @@ #include "common.h" +#include <stdarg.h> #include "patcher.h" #include "Console.h" #include "Font.h" diff --git a/src/render/Glass.cpp b/src/render/Glass.cpp index 41d31985..ac6c1728 100644 --- a/src/render/Glass.cpp +++ b/src/render/Glass.cpp @@ -404,6 +404,7 @@ CGlass::AskForObjectToBeRenderedInGlass(CEntity *entity) void CGlass::RenderEntityInGlass(CEntity *entity) { + ASSERT(entity!=nil); CObject *object = (CObject *)entity; if ( object->bGlassBroken ) @@ -419,7 +420,7 @@ CGlass::RenderEntityInGlass(CEntity *entity) uint8 alpha = CalcAlphaWithNormal(&fwdNorm); CColModel *col = object->GetColModel(); - + ASSERT(col!=nil); if ( col->numTriangles >= 2 ) { CVector a = object->GetMatrix() * col->vertices[0]; @@ -523,6 +524,8 @@ CGlass::RenderEntityInGlass(CEntity *entity) int32 CGlass::CalcAlphaWithNormal(CVector *normal) { + ASSERT(normal!=nil); + float fwdDir = 2.0f * DotProduct(*normal, TheCamera.GetForward()); float fwdDot = DotProduct(TheCamera.GetForward()-fwdDir*(*normal), CVector(0.57f, 0.57f, -0.57f)); return int32(lerp(fwdDot*fwdDot*fwdDot*fwdDot*fwdDot*fwdDot, 20.0f, 255.0f)); @@ -597,6 +600,8 @@ CGlass::RenderReflectionPolys(void) void CGlass::WindowRespondsToCollision(CEntity *entity, float amount, CVector speed, CVector point, bool explosion) { + ASSERT(entity!=nil); + CObject *object = (CObject *)entity; if ( object->bGlassBroken ) @@ -605,7 +610,8 @@ CGlass::WindowRespondsToCollision(CEntity *entity, float amount, CVector speed, object->bGlassCracked = true; CColModel *col = object->GetColModel(); - + ASSERT(col!=nil); + CVector a = object->GetMatrix() * col->vertices[0]; CVector b = object->GetMatrix() * col->vertices[1]; CVector c = object->GetMatrix() * col->vertices[2]; @@ -647,6 +653,8 @@ CGlass::WindowRespondsToCollision(CEntity *entity, float amount, CVector speed, void CGlass::WindowRespondsToSoftCollision(CEntity *entity, float amount) { + ASSERT(entity!=nil); + CObject *object = (CObject *)entity; if ( amount > 50.0f && !object->bGlassCracked ) @@ -659,6 +667,8 @@ CGlass::WindowRespondsToSoftCollision(CEntity *entity, float amount) void CGlass::WasGlassHitByBullet(CEntity *entity, CVector point) { + ASSERT(entity!=nil); + CObject *object = (CObject *)entity; if ( IsGlass(object->GetModelIndex()) ) @@ -679,6 +689,8 @@ CGlass::WasGlassHitByBullet(CEntity *entity, CVector point) void CGlass::WindowRespondsToExplosion(CEntity *entity, CVector point) { + ASSERT(entity!=nil); + CObject *object = (CObject *)entity; CVector distToGlass = object->GetPosition() - point; diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp index f8b86bd2..9529c4c1 100644 --- a/src/render/Hud.cpp +++ b/src/render/Hud.cpp @@ -144,12 +144,10 @@ void CHud::Draw() float fMultBright = SpriteBrightness * 0.03f * (0.25f * fStep + 0.75f); CRect rect; if (DrawCrossHairPC && TheCamera.Cams[TheCamera.ActiveCam].Using3rdPersonMouseCam()) { -#ifndef ASPECT_RATIO_SCALE float f3rdX = SCREEN_WIDTH * TheCamera.m_f3rdPersonCHairMultX; float f3rdY = SCREEN_HEIGHT * TheCamera.m_f3rdPersonCHairMultY; -#else - float f3rdX = (((TheCamera.m_f3rdPersonCHairMultX - 0.5f) / ((CDraw::GetAspectRatio()) / (DEFAULT_ASPECT_RATIO))) + 0.5f) * SCREEN_WIDTH; - float f3rdY = SCREEN_HEIGHT * TheCamera.m_f3rdPersonCHairMultY + SCREEN_SCALE_Y(-2.0f); +#ifdef ASPECT_RATIO_SCALE + f3rdY -= SCREEN_SCALE_Y(2.0f); #endif if (FindPlayerPed() && WeaponType == WEAPONTYPE_M16) { rect.left = f3rdX - SCREEN_SCALE_X(32.0f * 0.6f); diff --git a/src/render/Instance.cpp b/src/render/Instance.cpp new file mode 100644 index 00000000..775341be --- /dev/null +++ b/src/render/Instance.cpp @@ -0,0 +1,20 @@ +#include "common.h" +#include "patcher.h" +#include "Instance.h" + +void +CInstance::Shutdown() +{ + GetMatrix().Detach(); +} + +class CInstance_ : public CInstance +{ +public: + void dtor() { CInstance::~CInstance(); } +}; + +STARTPATCHES + InjectHook(0x50BE90, &CInstance_::dtor, PATCH_JUMP); + InjectHook(0x50B850, &CInstance::Shutdown, PATCH_JUMP); +ENDPATCHES diff --git a/src/render/Instance.h b/src/render/Instance.h new file mode 100644 index 00000000..01dfb6a2 --- /dev/null +++ b/src/render/Instance.h @@ -0,0 +1,14 @@ +#pragma once + +#include "Placeable.h" + +// unused + +class CInstance : public CPlaceable +{ +public: + int m_modelIndex; +public: + ~CInstance() = default; + void Shutdown(); +}; diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index d7834065..7b2f90e8 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -39,16 +39,17 @@ struct EntityInfo float sort; }; -CLinkList<EntityInfo> &gSortedVehiclesAndPeds = *(CLinkList<EntityInfo>*)0x629AC0; +CLinkList<EntityInfo> gSortedVehiclesAndPeds; -int32 &CRenderer::ms_nNoOfVisibleEntities = *(int32*)0x940730; -CEntity *(&CRenderer::ms_aVisibleEntityPtrs)[NUMVISIBLEENTITIES] = *(CEntity * (*)[NUMVISIBLEENTITIES]) * (uintptr*)0x6E9920; -CEntity *(&CRenderer::ms_aInVisibleEntityPtrs)[NUMINVISIBLEENTITIES] = *(CEntity * (*)[NUMINVISIBLEENTITIES]) * (uintptr*)0x880B50; -int32 &CRenderer::ms_nNoOfInVisibleEntities = *(int32*)0x8F1B78; +int32 CRenderer::ms_nNoOfVisibleEntities; +CEntity *CRenderer::ms_aVisibleEntityPtrs[NUMVISIBLEENTITIES]; +CEntity *CRenderer::ms_aInVisibleEntityPtrs[NUMINVISIBLEENTITIES]; +int32 CRenderer::ms_nNoOfInVisibleEntities; -CVector &CRenderer::ms_vecCameraPosition = *(CVector*)0x8E2C3C; -CVehicle *&CRenderer::m_pFirstPersonVehicle = *(CVehicle**)0x885B80; -bool &CRenderer::m_loadingPriority = *(bool*)0x95CD86; +CVector CRenderer::ms_vecCameraPosition; +CVehicle *CRenderer::m_pFirstPersonVehicle; +bool CRenderer::m_loadingPriority; +float CRenderer::ms_lodDistScale = 1.2f; void CRenderer::Init(void) diff --git a/src/render/Renderer.h b/src/render/Renderer.h index 42c154ec..362741e3 100644 --- a/src/render/Renderer.h +++ b/src/render/Renderer.h @@ -20,17 +20,17 @@ class CPtrList; class CRenderer { - static int32 &ms_nNoOfVisibleEntities; - static CEntity *(&ms_aVisibleEntityPtrs)[NUMVISIBLEENTITIES]; - static int32 &ms_nNoOfInVisibleEntities; - static CEntity *(&ms_aInVisibleEntityPtrs)[NUMINVISIBLEENTITIES]; + static int32 ms_nNoOfVisibleEntities; + static CEntity *ms_aVisibleEntityPtrs[NUMVISIBLEENTITIES]; + static int32 ms_nNoOfInVisibleEntities; + static CEntity *ms_aInVisibleEntityPtrs[NUMINVISIBLEENTITIES]; - static CVector &ms_vecCameraPosition; - static CVehicle *&m_pFirstPersonVehicle; + static CVector ms_vecCameraPosition; + static CVehicle *m_pFirstPersonVehicle; public: - static float ms_lodDistScale; // defined in Frontend.cpp - static bool &m_loadingPriority; + static float ms_lodDistScale; + static bool m_loadingPriority; static void Init(void); static void Shutdown(void); diff --git a/src/render/Shadows.h b/src/render/Shadows.h index fb41ebbc..ced9f11b 100644 --- a/src/render/Shadows.h +++ b/src/render/Shadows.h @@ -6,7 +6,6 @@ #define MAX_PERMAMENTSHADOWS 48 -struct RwTexture; class CEntity; enum eShadowType diff --git a/src/render/Sprite.cpp b/src/render/Sprite.cpp index 8ac2315f..82754121 100644 --- a/src/render/Sprite.cpp +++ b/src/render/Sprite.cpp @@ -137,8 +137,8 @@ CSprite::RenderOneXLUSprite(float x, float y, float z, float w, float h, uint8 r void CSprite::RenderOneXLUSprite_Rotate_Aspect(float x, float y, float z, float w, float h, uint8 r, uint8 g, uint8 b, int16 intens, float recipz, float rotation, uint8 a) { - float c = Cos(DEGTORAD(rotation)); - float s = Sin(DEGTORAD(rotation)); + float c = Cos(rotation); + float s = Sin(rotation); float xs[4]; float ys[4]; @@ -315,8 +315,8 @@ void CSprite::RenderBufferedOneXLUSprite_Rotate_Aspect(float x, float y, float z, float w, float h, uint8 r, uint8 g, uint8 b, int16 intens, float recipz, float rotation, uint8 a) { m_bFlushSpriteBufferSwitchZTest = 0; - float c = Cos(DEGTORAD(rotation)); - float s = Sin(DEGTORAD(rotation)); + float c = Cos(rotation); + float s = Sin(rotation); float xs[4]; float ys[4]; @@ -367,8 +367,8 @@ void CSprite::RenderBufferedOneXLUSprite_Rotate_2Colours(float x, float y, float z, float w, float h, uint8 r1, uint8 g1, uint8 b1, uint8 r2, uint8 g2, uint8 b2, float cx, float cy, float recipz, float rotation, uint8 a) { m_bFlushSpriteBufferSwitchZTest = 0; - float c = Cos(DEGTORAD(rotation)); - float s = Sin(DEGTORAD(rotation)); + float c = Cos(rotation); + float s = Sin(rotation); float xs[4]; float ys[4]; @@ -398,11 +398,11 @@ CSprite::RenderBufferedOneXLUSprite_Rotate_2Colours(float x, float y, float z, f // Colour factors, cx/y is the direction in which colours change from rgb1 to rgb2 cf[0] = (cx*(-c-s) + cy*(-c+s))*0.5f + 0.5f; cf[0] = clamp(cf[0], 0.0f, 1.0f); - cf[1] = (cx*(-c-s) + cy*(-c+s))*0.5f + 0.5f; + cf[1] = (cx*(-c+s) + cy*( c+s))*0.5f + 0.5f; cf[1] = clamp(cf[1], 0.0f, 1.0f); - cf[2] = (cx*(-c-s) + cy*(-c+s))*0.5f + 0.5f; + cf[2] = (cx*( c+s) + cy*( c-s))*0.5f + 0.5f; cf[2] = clamp(cf[2], 0.0f, 1.0f); - cf[3] = (cx*(-c-s) + cy*(-c+s))*0.5f + 0.5f; + cf[3] = (cx*( c-s) + cy*(-c-s))*0.5f + 0.5f; cf[3] = clamp(cf[3], 0.0f, 1.0f); float screenz = m_f2DNearScreenZ + diff --git a/src/render/Sprite2d.cpp b/src/render/Sprite2d.cpp index 3f21516a..1fe70121 100644 --- a/src/render/Sprite2d.cpp +++ b/src/render/Sprite2d.cpp @@ -5,13 +5,13 @@ #include "Camera.h" #include "Sprite2d.h" -RwIm2DVertex *CSprite2d::maVertices = (RwIm2DVertex*)0x6E9168; -float &CSprite2d::RecipNearClip = *(float*)0x880DB4; -int32 &CSprite2d::mCurrentBank = *(int32*)0x8F1AF4; -RwTexture **CSprite2d::mpBankTextures = (RwTexture**)0x774DC0; -int32 *CSprite2d::mCurrentSprite = (int32*)0x6F4500; -int32 *CSprite2d::mBankStart = (int32*)0x774BE8; -RwIm2DVertex *CSprite2d::maBankVertices = (RwIm2DVertex*)0x8429F8; +RwIm2DVertex CSprite2d::maVertices[4]; +float CSprite2d::RecipNearClip; +int32 CSprite2d::mCurrentBank; +RwTexture *CSprite2d::mpBankTextures[10]; +int32 CSprite2d::mCurrentSprite[10]; +int32 CSprite2d::mBankStart[10]; +RwIm2DVertex CSprite2d::maBankVertices[500]; void CSprite2d::SetRecipNearClip(void) diff --git a/src/render/Sprite2d.h b/src/render/Sprite2d.h index 268c7d2b..0b073557 100644 --- a/src/render/Sprite2d.h +++ b/src/render/Sprite2d.h @@ -2,13 +2,13 @@ class CSprite2d { - static float &RecipNearClip; - static int32 &mCurrentBank; - static RwTexture **mpBankTextures; //[10]; - static int32 *mCurrentSprite; //[10]; - static int32 *mBankStart; //[10]; - static RwIm2DVertex *maBankVertices; //[500]; - static RwIm2DVertex *maVertices; //[4]; + static float RecipNearClip; + static int32 mCurrentBank; + static RwTexture *mpBankTextures[10]; + static int32 mCurrentSprite[10]; + static int32 mBankStart[10]; + static RwIm2DVertex maBankVertices[500]; + static RwIm2DVertex maVertices[4]; public: RwTexture *m_pTexture; diff --git a/src/render/WeaponEffects.cpp b/src/render/WeaponEffects.cpp deleted file mode 100644 index 2ed9e662..00000000 --- a/src/render/WeaponEffects.cpp +++ /dev/null @@ -1,106 +0,0 @@ -#include "common.h" -#include "patcher.h" -#include "WeaponEffects.h" -#include "TxdStore.h" -#include "Sprite.h" - -RwTexture *gpCrossHairTex; -RwRaster *gpCrossHairRaster; - -CWeaponEffects gCrossHair; - -CWeaponEffects::CWeaponEffects() -{ - -} - -CWeaponEffects::~CWeaponEffects() -{ - -} - -void -CWeaponEffects::Init(void) -{ - gCrossHair.m_bActive = false; - gCrossHair.m_vecPos = CVector(0.0f, 0.0f, 0.0f); - gCrossHair.m_nRed = 0; - gCrossHair.m_nGreen = 0; - gCrossHair.m_nBlue = 0; - gCrossHair.m_nAlpha = 255; - gCrossHair.m_fSize = 1.0f; - gCrossHair.m_fRotation = 0.0f; - - - CTxdStore::PushCurrentTxd(); - int32 slot = CTxdStore::FindTxdSlot("particle"); - CTxdStore::SetCurrentTxd(slot); - - gpCrossHairTex = RwTextureRead("crosshair", nil); - gpCrossHairRaster = RwTextureGetRaster(gpCrossHairTex); - - CTxdStore::PopCurrentTxd(); -} - -void -CWeaponEffects::Shutdown(void) -{ - RwTextureDestroy(gpCrossHairTex); -} - -void -CWeaponEffects::MarkTarget(CVector pos, uint8 red, uint8 green, uint8 blue, uint8 alpha, float size) -{ - gCrossHair.m_bActive = true; - gCrossHair.m_vecPos = pos; - gCrossHair.m_nRed = red; - gCrossHair.m_nGreen = green; - gCrossHair.m_nBlue = blue; - gCrossHair.m_nAlpha = alpha; - gCrossHair.m_fSize = size; -} - -void -CWeaponEffects::ClearCrossHair(void) -{ - gCrossHair.m_bActive = false; -} - -void -CWeaponEffects::Render(void) -{ - if ( gCrossHair.m_bActive ) - { - RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void *)FALSE); - RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void *)TRUE); - RwRenderStateSet(rwRENDERSTATESRCBLEND, (void *)rwBLENDONE); - RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void *)rwBLENDONE); - RwRenderStateSet(rwRENDERSTATETEXTURERASTER, (void *)gpCrossHairRaster); - - RwV3d pos; - float w, h; - if ( CSprite::CalcScreenCoors(gCrossHair.m_vecPos, &pos, &w, &h, true) ) - { - float recipz = 1.0f / pos.z; - CSprite::RenderOneXLUSprite(pos.x, pos.y, pos.z, - gCrossHair.m_fSize * w, gCrossHair.m_fSize * h, - gCrossHair.m_nRed, gCrossHair.m_nGreen, gCrossHair.m_nBlue, 255, - recipz, 255); - } - - RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void *)FALSE); - RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void *)FALSE); - RwRenderStateSet(rwRENDERSTATESRCBLEND, (void *)rwBLENDSRCALPHA); - RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void *)rwBLENDINVSRCALPHA); - } -} - -STARTPATCHES - //InjectHook(0x564C40, CWeaponEffects::CWeaponEffects, PATCH_JUMP); - //InjectHook(0x564C50, CWeaponEffects::~CWeaponEffects, PATCH_JUMP); - InjectHook(0x564C60, CWeaponEffects::Init, PATCH_JUMP); - InjectHook(0x564CF0, CWeaponEffects::Shutdown, PATCH_JUMP); - InjectHook(0x564D00, CWeaponEffects::MarkTarget, PATCH_JUMP); - InjectHook(0x564D60, CWeaponEffects::ClearCrossHair, PATCH_JUMP); - InjectHook(0x564D70, CWeaponEffects::Render, PATCH_JUMP); -ENDPATCHES
\ No newline at end of file diff --git a/src/render/WeaponEffects.h b/src/render/WeaponEffects.h deleted file mode 100644 index 31c5a309..00000000 --- a/src/render/WeaponEffects.h +++ /dev/null @@ -1,27 +0,0 @@ -#pragma once - -class CWeaponEffects -{ -public: - bool m_bActive; - char _pad[3]; - CVector m_vecPos; - uint8 m_nRed; - uint8 m_nGreen; - uint8 m_nBlue; - uint8 m_nAlpha; - float m_fSize; - float m_fRotation; - -public: - CWeaponEffects(); - ~CWeaponEffects(); - - static void Init(void); - static void Shutdown(void); - static void MarkTarget(CVector pos, uint8 red, uint8 green, uint8 blue, uint8 alpha, float size); - static void ClearCrossHair(void); - static void Render(void); -}; - -VALIDATE_SIZE(CWeaponEffects, 0x1C);
\ No newline at end of file diff --git a/src/render/Weather.cpp b/src/render/Weather.cpp index b440e77c..7aa2778f 100644 --- a/src/render/Weather.cpp +++ b/src/render/Weather.cpp @@ -126,7 +126,7 @@ void CWeather::Update(void) if (ForcedWeatherType >= 0) NewWeatherType = ForcedWeatherType; else { - WeatherTypeInList = (WeatherTypeInList + 1) % ARRAYSIZE(WeatherTypesList); + WeatherTypeInList = (WeatherTypeInList + 1) % ARRAY_SIZE(WeatherTypesList); NewWeatherType = WeatherTypesList[WeatherTypeInList]; #ifdef FIX_BUGS } |