diff options
author | aap <aap@papnet.eu> | 2019-06-12 21:17:02 +0200 |
---|---|---|
committer | aap <aap@papnet.eu> | 2019-06-12 21:17:02 +0200 |
commit | 9703ef9b591430b86c272e0f042b1f50b6cb437c (patch) | |
tree | 4e27511538090c8872e80c68cc7f70186eeb01f4 /src | |
parent | implemented CCutsceneHead and dependencies (diff) | |
download | re3-9703ef9b591430b86c272e0f042b1f50b6cb437c.tar re3-9703ef9b591430b86c272e0f042b1f50b6cb437c.tar.gz re3-9703ef9b591430b86c272e0f042b1f50b6cb437c.tar.bz2 re3-9703ef9b591430b86c272e0f042b1f50b6cb437c.tar.lz re3-9703ef9b591430b86c272e0f042b1f50b6cb437c.tar.xz re3-9703ef9b591430b86c272e0f042b1f50b6cb437c.tar.zst re3-9703ef9b591430b86c272e0f042b1f50b6cb437c.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/Timecycle.cpp | 2 | ||||
-rw-r--r-- | src/animation/AnimBlendClumpData.cpp | 2 | ||||
-rw-r--r-- | src/animation/AnimBlendClumpData.h | 2 | ||||
-rw-r--r-- | src/animation/FrameUpdate.cpp | 14 | ||||
-rw-r--r-- | src/entities/CutsceneObject.cpp | 86 | ||||
-rw-r--r-- | src/entities/CutsceneObject.h | 15 | ||||
-rw-r--r-- | src/modelinfo/ModelIndices.h | 6 | ||||
-rw-r--r-- | src/render/Renderer.cpp | 13 | ||||
-rw-r--r-- | src/render/Renderer.h | 2 | ||||
-rw-r--r-- | src/render/Shadows.cpp | 3 | ||||
-rw-r--r-- | src/render/Shadows.h | 2 | ||||
-rw-r--r-- | src/render/Sprite2d.cpp | 2 |
12 files changed, 137 insertions, 12 deletions
diff --git a/src/Timecycle.cpp b/src/Timecycle.cpp index 501691c3..56341e32 100644 --- a/src/Timecycle.cpp +++ b/src/Timecycle.cpp @@ -289,7 +289,7 @@ CTimeCycle::Update(void) TheCamera.SetMotionBlur(m_fCurrentBlurRed, m_fCurrentBlurGreen, m_fCurrentBlurBlue, m_fCurrentBlurAlpha, MBLUR_NORMAL); if(m_FogReduction != 0) - m_fCurrentFarClip = max(m_fCurrentFarClip, m_FogReduction/64 * 650.0f); + m_fCurrentFarClip = max(m_fCurrentFarClip, m_FogReduction/64.0f * 650.0f); m_nCurrentFogColourRed = (m_nCurrentSkyTopRed + 2*m_nCurrentSkyBottomRed) / 3; m_nCurrentFogColourGreen = (m_nCurrentSkyTopGreen + 2*m_nCurrentSkyBottomGreen) / 3; m_nCurrentFogColourBlue = (m_nCurrentSkyTopBlue + 2*m_nCurrentSkyBottomBlue) / 3; diff --git a/src/animation/AnimBlendClumpData.cpp b/src/animation/AnimBlendClumpData.cpp index 57985533..73e71246 100644 --- a/src/animation/AnimBlendClumpData.cpp +++ b/src/animation/AnimBlendClumpData.cpp @@ -9,7 +9,7 @@ CAnimBlendClumpData::CAnimBlendClumpData(void) { numFrames = 0; - pedPosition = nil; + velocity = nil; frames = nil; link.Init(); } diff --git a/src/animation/AnimBlendClumpData.h b/src/animation/AnimBlendClumpData.h index 955578f0..df2fbc56 100644 --- a/src/animation/AnimBlendClumpData.h +++ b/src/animation/AnimBlendClumpData.h @@ -38,7 +38,7 @@ public: #ifdef PED_SKIN int32 modelNumber; // doesn't seem to be used #endif - CVector *pedPosition; + CVector *velocity; // order of frames is determined by RW hierarchy AnimBlendFrameData *frames; diff --git a/src/animation/FrameUpdate.cpp b/src/animation/FrameUpdate.cpp index 1533897e..62300527 100644 --- a/src/animation/FrameUpdate.cpp +++ b/src/animation/FrameUpdate.cpp @@ -23,7 +23,7 @@ FrameUpdateCallBack(AnimBlendFrameData *frame, void *arg) AnimBlendFrameUpdateData *updateData = (AnimBlendFrameUpdateData*)arg; if(frame->flag & AnimBlendFrameData::VELOCITY_EXTRACTION && - gpAnimBlendClump->pedPosition){ + gpAnimBlendClump->velocity){ if(frame->flag & AnimBlendFrameData::VELOCITY_EXTRACTION_3D) FrameUpdateCallBackWith3dVelocityExtraction(frame, arg); else @@ -132,11 +132,11 @@ FrameUpdateCallBackWithVelocityExtraction(AnimBlendFrameData *frame, void *arg) } if((frame->flag & AnimBlendFrameData::IGNORE_TRANSLATION) == 0){ - gpAnimBlendClump->pedPosition->x = transx - curx; - gpAnimBlendClump->pedPosition->y = transy - cury; + gpAnimBlendClump->velocity->x = transx - curx; + gpAnimBlendClump->velocity->y = transy - cury; if(looped){ - gpAnimBlendClump->pedPosition->x += endx; - gpAnimBlendClump->pedPosition->y += endy; + gpAnimBlendClump->velocity->x += endx; + gpAnimBlendClump->velocity->y += endy; } mat->pos.x = pos.x - transx; mat->pos.y = pos.y - transy; @@ -211,9 +211,9 @@ FrameUpdateCallBackWith3dVelocityExtraction(AnimBlendFrameData *frame, void *arg } if((frame->flag & AnimBlendFrameData::IGNORE_TRANSLATION) == 0){ - *gpAnimBlendClump->pedPosition = trans - cur; + *gpAnimBlendClump->velocity = trans - cur; if(looped) - *gpAnimBlendClump->pedPosition += end; + *gpAnimBlendClump->velocity += end; mat->pos.x = (pos - trans).x + frame->resetPos.x; mat->pos.y = (pos - trans).y + frame->resetPos.y; mat->pos.z = (pos - trans).z + frame->resetPos.z; diff --git a/src/entities/CutsceneObject.cpp b/src/entities/CutsceneObject.cpp index a856f98b..d00a668b 100644 --- a/src/entities/CutsceneObject.cpp +++ b/src/entities/CutsceneObject.cpp @@ -1,4 +1,13 @@ #include "common.h" +#include "patcher.h" +#include "lights.h" +#include "PointLights.h" +#include "RpAnimBlend.h" +#include "AnimBlendClumpData.h" +#include "Renderer.h" +#include "ModelIndices.h" +#include "Shadows.h" +#include "TimeCycle.h" #include "CutsceneObject.h" CCutsceneObject::CCutsceneObject(void) @@ -10,3 +19,80 @@ CCutsceneObject::CCutsceneObject(void) m_fMass = 1.0f; m_fTurnMass = 1.0f; } + +void +CCutsceneObject::SetModelIndex(uint32 id) +{ + CEntity::SetModelIndex(id); + assert(RwObjectGetType(m_rwObject) == rpCLUMP); + RpAnimBlendClumpInit((RpClump*)m_rwObject); + (*RPANIMBLENDCLUMPDATA(m_rwObject))->velocity = &m_vecMoveSpeed; + (*RPANIMBLENDCLUMPDATA(m_rwObject))->frames[0].flag |= AnimBlendFrameData::VELOCITY_EXTRACTION_3D; +} + +void +CCutsceneObject::ProcessControl(void) +{ + CPhysical::ProcessControl(); + + if(CTimer::GetTimeStep() < 1/100.0f) + m_vecMoveSpeed *= 100.0f; + else + m_vecMoveSpeed *= 1.0f/CTimer::GetTimeStep(); + + ApplyMoveSpeed(); +} + +void +CCutsceneObject::PreRender(void) +{ + if(IsPedModel(GetModelIndex())) + CShadows::StoreShadowForPedObject(this, + CTimeCycle::m_fShadowDisplacementX[CTimeCycle::m_CurrentStoredValue], + CTimeCycle::m_fShadowDisplacementY[CTimeCycle::m_CurrentStoredValue], + CTimeCycle::m_fShadowFrontX[CTimeCycle::m_CurrentStoredValue], + CTimeCycle::m_fShadowFrontY[CTimeCycle::m_CurrentStoredValue], + CTimeCycle::m_fShadowSideX[CTimeCycle::m_CurrentStoredValue], + CTimeCycle::m_fShadowSideY[CTimeCycle::m_CurrentStoredValue]); +} + +void +CCutsceneObject::Render(void) +{ + CObject::Render(); +} + +bool +CCutsceneObject::SetupLighting(void) +{ + ActivateDirectional(); + SetAmbientColoursForPedsCarsAndObjects(); + + if(bRenderScorched){ + WorldReplaceNormalLightsWithScorched(Scene.world, 0.1f); + }else{ + CVector coors = GetPosition(); + float lighting = CPointLights::GenerateLightsAffectingObject(&coors); + if(!m_flagB20 && lighting != 1.0f){ + SetAmbientAndDirectionalColours(lighting); + return true; + } + } + + return false; +} + +void +CCutsceneObject::RemoveLighting(bool reset) +{ + CRenderer::RemoveVehiclePedLights(this, reset); +} + +STARTPATCHES + InjectHook(0x4BA980, &CCutsceneObject::SetModelIndex_, PATCH_JUMP); + InjectHook(0x4BA9C0, &CCutsceneObject::ProcessControl_, PATCH_JUMP); + InjectHook(0x4BAA40, &CCutsceneObject::PreRender_, PATCH_JUMP); + InjectHook(0x4BAAA0, &CCutsceneObject::Render_, PATCH_JUMP); + InjectHook(0x4A7E70, &CCutsceneObject::SetupLighting_, PATCH_JUMP); + InjectHook(0x4A7F00, &CCutsceneObject::RemoveLighting_, PATCH_JUMP); +ENDPATCHES diff --git a/src/entities/CutsceneObject.h b/src/entities/CutsceneObject.h index 8372dd86..182d8612 100644 --- a/src/entities/CutsceneObject.h +++ b/src/entities/CutsceneObject.h @@ -6,5 +6,20 @@ class CCutsceneObject : public CObject { public: CCutsceneObject(void); + + void SetModelIndex(uint32 id); + void ProcessControl(void); + void PreRender(void); + void Render(void); + bool SetupLighting(void); + void RemoveLighting(bool reset); + + + void SetModelIndex_(uint32 id) { CCutsceneObject::SetModelIndex(id); } + void ProcessControl_(void) { CCutsceneObject::ProcessControl(); } + void PreRender_(void) { CCutsceneObject::PreRender(); } + void Render_(void) { CCutsceneObject::Render(); } + bool SetupLighting_(void) { return CCutsceneObject::SetupLighting(); } + void RemoveLighting_(bool reset) { CCutsceneObject::RemoveLighting(reset); } }; static_assert(sizeof(CCutsceneObject) == 0x198, "CCutsceneObject: error"); diff --git a/src/modelinfo/ModelIndices.h b/src/modelinfo/ModelIndices.h index 8b188345..bbf1a58b 100644 --- a/src/modelinfo/ModelIndices.h +++ b/src/modelinfo/ModelIndices.h @@ -264,3 +264,9 @@ IsBoatModel(int16 id) id == MI_SPEEDER || id == MI_GHOST; } + +inline bool +IsPedModel(int16 id) +{ + return id >= 0 && id <= 89; +} diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index c2b341dc..5a27ab32 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -16,6 +16,7 @@ #include "ModelIndices.h" #include "Streaming.h" #include "Shadows.h" +#include "PointLights.h" #include "Renderer.h" bool gbShowPedRoadGroups; @@ -1153,6 +1154,16 @@ CRenderer::IsVehicleCullZoneVisible(CEntity *ent) return true; } +void +CRenderer::RemoveVehiclePedLights(CEntity *ent, bool reset) +{ + if(ent->bRenderScorched) + WorldReplaceScorchedLightsWithNormal(Scene.world); + CPointLights::RemoveLightsAffectingObject(); + if(reset) + ReSetAmbientAndDirectionalColours(); +} + STARTPATCHES InjectHook(0x4A7680, CRenderer::Init, PATCH_JUMP); @@ -1185,4 +1196,6 @@ STARTPATCHES InjectHook(0x4A9840, CRenderer::ShouldModelBeStreamed, PATCH_JUMP); InjectHook(0x4AAA00, CRenderer::IsEntityCullZoneVisible, PATCH_JUMP); InjectHook(0x4AAAA0, CRenderer::IsVehicleCullZoneVisible, PATCH_JUMP); + + InjectHook(0x4A7CF0, CRenderer::RemoveVehiclePedLights, PATCH_JUMP); ENDPATCHES diff --git a/src/render/Renderer.h b/src/render/Renderer.h index 38f2b6f7..e9e056c6 100644 --- a/src/render/Renderer.h +++ b/src/render/Renderer.h @@ -56,4 +56,6 @@ public: static bool ShouldModelBeStreamed(CEntity *ent); static bool IsEntityCullZoneVisible(CEntity *ent); static bool IsVehicleCullZoneVisible(CEntity *ent); + + static void RemoveVehiclePedLights(CEntity *ent, bool reset); }; diff --git a/src/render/Shadows.cpp b/src/render/Shadows.cpp index 498df6e9..d89338c1 100644 --- a/src/render/Shadows.cpp +++ b/src/render/Shadows.cpp @@ -6,4 +6,5 @@ WRAPPER void CShadows::AddPermanentShadow(unsigned char ShadowType, RwTexture* p WRAPPER void CShadows::RenderStaticShadows(void) { EAXJMP(0x5145F0); } WRAPPER void CShadows::RenderStoredShadows(void) { EAXJMP(0x514010); } WRAPPER void CShadows::RenderExtraPlayerShadows(void) { EAXJMP(0x516F90); } -WRAPPER void CShadows::CalcPedShadowValues(CVector light, float *frontX, float *frontY, float *sideX, float *sideY, float *dispX, float *dispY) { EAXJMP(0x516EB0); }
\ No newline at end of file +WRAPPER void CShadows::CalcPedShadowValues(CVector light, float *frontX, float *frontY, float *sideX, float *sideY, float *dispX, float *dispY) { EAXJMP(0x516EB0); } +WRAPPER void CShadows::StoreShadowForPedObject(CEntity *ent, float dispX, float dispY, float frontX, float frontY, float sideX, float sideY) { EAXJMP(0x513CB0); } diff --git a/src/render/Shadows.h b/src/render/Shadows.h index 1efe6507..be3ec0c4 100644 --- a/src/render/Shadows.h +++ b/src/render/Shadows.h @@ -1,6 +1,7 @@ #pragma once struct RwTexture; +class CEntity; class CShadows { @@ -10,4 +11,5 @@ public: 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 StoreShadowForPedObject(CEntity *ent, float dispX, float dispY, float frontX, float frontY, float sideX, float sideY); }; diff --git a/src/render/Sprite2d.cpp b/src/render/Sprite2d.cpp index fd5900b8..3dc1d989 100644 --- a/src/render/Sprite2d.cpp +++ b/src/render/Sprite2d.cpp @@ -145,7 +145,7 @@ CSprite2d::Draw(const CRect &rect, const CRGBA &c0, const CRGBA &c1, const CRGBA void CSprite2d::Draw(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, const CRGBA &col) { - SetVertices(x1, y2, x2, y2, x3, y3, x4, y4, col, col, col, col); + SetVertices(x1, y1, x2, y2, x3, y3, x4, y4, col, col, col, col); SetRenderState(); RwIm2DRenderPrimitive(rwPRIMTYPETRIFAN, CSprite2d::maVertices, 4); } |