mirror of https://github.com/AxioDL/metaforce.git
Work on CStateManager rendering functions
This commit is contained in:
parent
39040b5ab3
commit
5c884fec0c
|
@ -0,0 +1,19 @@
|
||||||
|
#include "CFluidPlaneManager.hpp"
|
||||||
|
|
||||||
|
namespace urde
|
||||||
|
{
|
||||||
|
|
||||||
|
CFluidPlaneManager::CFluidProfile CFluidPlaneManager::sProfile = {};
|
||||||
|
|
||||||
|
void CFluidPlaneManager::CFluidProfile::Clear()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CFluidPlaneManager::StartFrame(bool b)
|
||||||
|
{
|
||||||
|
x121_ = b;
|
||||||
|
sProfile.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -6,6 +6,15 @@ namespace urde
|
||||||
|
|
||||||
class CFluidPlaneManager
|
class CFluidPlaneManager
|
||||||
{
|
{
|
||||||
|
bool x121_;
|
||||||
|
class CFluidProfile
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void Clear();
|
||||||
|
};
|
||||||
|
static CFluidProfile sProfile;
|
||||||
|
public:
|
||||||
|
void StartFrame(bool);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,6 +61,7 @@ public:
|
||||||
TUniqueId GetFirstObjectIndex() const { return x2008_firstId; }
|
TUniqueId GetFirstObjectIndex() const { return x2008_firstId; }
|
||||||
TUniqueId GetNextObjectIndex(TUniqueId prev) const { return x0_list[prev & 0x3ff].next; }
|
TUniqueId GetNextObjectIndex(TUniqueId prev) const { return x0_list[prev & 0x3ff].next; }
|
||||||
virtual bool IsQualified(const CEntity&);
|
virtual bool IsQualified(const CEntity&);
|
||||||
|
u16 size() const { return x200a_count; }
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include "Camera/CCameraShakeData.hpp"
|
#include "Camera/CCameraShakeData.hpp"
|
||||||
#include "Camera/CGameCamera.hpp"
|
#include "Camera/CGameCamera.hpp"
|
||||||
#include "Graphics/CBooRenderer.hpp"
|
#include "Graphics/CBooRenderer.hpp"
|
||||||
|
#include "World/CGameLight.hpp"
|
||||||
#include "CSortedLists.hpp"
|
#include "CSortedLists.hpp"
|
||||||
#include "Weapon/CWeaponMgr.hpp"
|
#include "Weapon/CWeaponMgr.hpp"
|
||||||
#include "CFluidPlaneManager.hpp"
|
#include "CFluidPlaneManager.hpp"
|
||||||
|
@ -25,6 +26,10 @@
|
||||||
#include "CMemoryCardSys.hpp"
|
#include "CMemoryCardSys.hpp"
|
||||||
#include "TCastTo.hpp"
|
#include "TCastTo.hpp"
|
||||||
#include "World/CScriptSpecialFunction.hpp"
|
#include "World/CScriptSpecialFunction.hpp"
|
||||||
|
#include "CTimeProvider.hpp"
|
||||||
|
#include "Camera/CBallCamera.hpp"
|
||||||
|
#include "Collision/CMaterialFilter.hpp"
|
||||||
|
#include "World/CScriptDock.hpp"
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
|
@ -288,7 +293,27 @@ bool CStateManager::SpecialSkipCinematic()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CStateManager::GetVisAreaId() const {}
|
TAreaId CStateManager::GetVisAreaId() const
|
||||||
|
{
|
||||||
|
const CGameCamera* cam = static_cast<const CGameCamera*>(x870_cameraManager->GetCurrentCamera(*this));
|
||||||
|
const CBallCamera* ballCam = x870_cameraManager->GetBallCamera();
|
||||||
|
TAreaId curArea = x850_world->x68_curAreaId;
|
||||||
|
if (cam != ballCam)
|
||||||
|
return curArea;
|
||||||
|
|
||||||
|
const zeus::CVector3f& camTranslation = ballCam->GetTranslation();
|
||||||
|
zeus::CAABox camAABB(camTranslation, camTranslation);
|
||||||
|
camAABB.accumulateBounds(x84c_player->GetTranslation());
|
||||||
|
rstl::reserved_vector<TUniqueId, 1024> nearList;
|
||||||
|
BuildNearList(nearList, camAABB, CMaterialFilter(EMaterialTypes::AIBlock, CMaterialList(),
|
||||||
|
CMaterialFilter::EFilterType::One), nullptr);
|
||||||
|
for (TUniqueId id : nearList)
|
||||||
|
if (TCastToConstPtr<CScriptDock> dock = GetObjectById(id))
|
||||||
|
if (dock->GetDestinationAreaId() == curArea && dock->HasPointCrossedDock(*this, camTranslation))
|
||||||
|
return dock->GetCurrentConnectedAreaId(*this);
|
||||||
|
|
||||||
|
return curArea;
|
||||||
|
}
|
||||||
|
|
||||||
void CStateManager::GetWeaponIdCount(TUniqueId, EWeaponType) {}
|
void CStateManager::GetWeaponIdCount(TUniqueId, EWeaponType) {}
|
||||||
|
|
||||||
|
@ -351,7 +376,29 @@ bool CStateManager::CanCreateProjectile(TUniqueId, EWeaponType, int) const { ret
|
||||||
|
|
||||||
const CGameLightList* CStateManager::GetDynamicLightList() const { return nullptr; }
|
const CGameLightList* CStateManager::GetDynamicLightList() const { return nullptr; }
|
||||||
|
|
||||||
void CStateManager::BuildDynamicLightListForWorld(std::vector<CLight>& listOut) const {}
|
void CStateManager::BuildDynamicLightListForWorld()
|
||||||
|
{
|
||||||
|
if (x8b8_playerState->GetActiveVisor(*this) == CPlayerState::EPlayerVisor::Thermal)
|
||||||
|
{
|
||||||
|
x8e0_dynamicLights.clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (x82c_lightObjs->size() == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
x8e0_dynamicLights.clear();
|
||||||
|
for (CEntity* ent : *x82c_lightObjs)
|
||||||
|
{
|
||||||
|
CGameLight& light = static_cast<CGameLight&>(*ent);
|
||||||
|
if (light.GetActive())
|
||||||
|
{
|
||||||
|
CLight l = light.GetLight();
|
||||||
|
if (l.GetIntensity() > FLT_EPSILON && l.GetRadius() > FLT_EPSILON)
|
||||||
|
x8e0_dynamicLights.push_back(l);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CStateManager::DrawDebugStuff() const {}
|
void CStateManager::DrawDebugStuff() const {}
|
||||||
|
|
||||||
|
@ -361,11 +408,87 @@ void CStateManager::DrawE3DeathEffect() const {}
|
||||||
|
|
||||||
void CStateManager::DrawAdditionalFilters() const {}
|
void CStateManager::DrawAdditionalFilters() const {}
|
||||||
|
|
||||||
void CStateManager::DrawWorld() const {}
|
zeus::CFrustum CStateManager::SetupViewForDraw(const SViewport& vp) const
|
||||||
|
{
|
||||||
|
const CGameCamera* cam = static_cast<const CGameCamera*>(x870_cameraManager->GetCurrentCamera(*this));
|
||||||
|
zeus::CTransform camXf = x870_cameraManager->GetCurrentCameraTransform(*this);
|
||||||
|
g_Renderer->SetWorldViewpoint(camXf);
|
||||||
|
CBooModel::SetNewPlayerPositionAndTime(x84c_player->GetTranslation());
|
||||||
|
int vpWidth = xf2c_viewportScale.x * vp.x8_width;
|
||||||
|
int vpHeight = xf2c_viewportScale.y * vp.xc_height;
|
||||||
|
int vpLeft = (vp.x8_width - vpWidth) / 2 + vp.x0_left;
|
||||||
|
int vpTop = (vp.xc_height - vpHeight) / 2 + vp.x4_top;
|
||||||
|
g_Renderer->SetViewport(vpLeft, vpTop, vpWidth, vpHeight);
|
||||||
|
CGraphics::SetDepthRange(0.125f, 1.f);
|
||||||
|
float fov = std::atan(std::tan(zeus::degToRad(cam->GetFov()) * 0.5f) * xf2c_viewportScale.y * 2.f);
|
||||||
|
float width = xf2c_viewportScale.x * vp.x8_width;
|
||||||
|
float height = xf2c_viewportScale.y * vp.xc_height;
|
||||||
|
g_Renderer->SetPerspective(zeus::radToDeg(fov), width, height,
|
||||||
|
cam->GetNearClipDistance(), cam->GetFarClipDistance());
|
||||||
|
zeus::CFrustum frustum;
|
||||||
|
zeus::CProjection proj;
|
||||||
|
proj.setPersp(zeus::SProjPersp{fov, width / height, cam->GetNearClipDistance(), cam->GetFarClipDistance()});
|
||||||
|
frustum.updatePlanes(camXf, proj);
|
||||||
|
g_Renderer->SetClippingPlanes(frustum);
|
||||||
|
//g_Renderer->PrimColor(zeus::CColor::skWhite);
|
||||||
|
CGraphics::SetModelMatrix(zeus::CTransform::Identity());
|
||||||
|
x87c_fluidPlaneManager->StartFrame(false);
|
||||||
|
g_Renderer->SetDebugOption(IRenderer::EDebugOption::One, 1);
|
||||||
|
return frustum;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CStateManager::DrawWorld() const
|
||||||
|
{
|
||||||
|
CTimeProvider timeProvider(xf14_);
|
||||||
|
zeus::CFrustum frustum = SetupViewForDraw(g_Viewport);
|
||||||
|
|
||||||
|
GetVisAreaId();
|
||||||
|
}
|
||||||
|
|
||||||
void CStateManager::SetupFogForArea(const CGameArea& area) const {}
|
void CStateManager::SetupFogForArea(const CGameArea& area) const {}
|
||||||
|
|
||||||
void CStateManager::PreRender() {}
|
void CStateManager::PreRender()
|
||||||
|
{
|
||||||
|
if (xf94_24_)
|
||||||
|
{
|
||||||
|
x86c_stateManagerContainer->xf370_.clear();
|
||||||
|
x86c_stateManagerContainer->xf39c_.clear();
|
||||||
|
xf7c_ = 0;
|
||||||
|
x850_world->PreRender();
|
||||||
|
BuildDynamicLightListForWorld();
|
||||||
|
CGameCamera* cam = static_cast<CGameCamera*>(x870_cameraManager->GetCurrentCamera(*this));
|
||||||
|
zeus::CFrustum frustum;
|
||||||
|
zeus::CProjection proj;
|
||||||
|
proj.setPersp(zeus::SProjPersp{zeus::degToRad(cam->GetFov()),
|
||||||
|
cam->GetAspectRatio(), cam->GetNearClipDistance(), cam->GetFarClipDistance()});
|
||||||
|
frustum.updatePlanes(x870_cameraManager->GetCurrentCameraTransform(*this), proj);
|
||||||
|
for (CGameArea* area = x850_world->x4c_chainHeads[3];
|
||||||
|
area != CWorld::AliveAreasEnd();
|
||||||
|
area = area->x130_next)
|
||||||
|
{
|
||||||
|
CGameArea::EOcclusionState occState = CGameArea::EOcclusionState::NotOccluded;
|
||||||
|
if (area->IsPostConstructed())
|
||||||
|
occState = area->GetOcclusionState();
|
||||||
|
if (occState == CGameArea::EOcclusionState::Occluded)
|
||||||
|
{
|
||||||
|
for (CEntity* ent : *area->GetPostConstructed()->x10c0_areaObjs)
|
||||||
|
{
|
||||||
|
if (TCastToPtr<CActor> act = ent)
|
||||||
|
{
|
||||||
|
if (act->GetE7_29())
|
||||||
|
{
|
||||||
|
act->CalculateRenderBounds();
|
||||||
|
act->PreRender(*this, frustum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CacheReflection();
|
||||||
|
g_Renderer->PrepareDynamicLights(x8e0_dynamicLights);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool CStateManager::GetVisSetForArea(TAreaId a, TAreaId b, CPVSVisSet& setOut) const
|
bool CStateManager::GetVisSetForArea(TAreaId a, TAreaId b, CPVSVisSet& setOut) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -107,8 +107,8 @@ class CStateManager
|
||||||
CActorModelParticles xf168_actorModelParticles;
|
CActorModelParticles xf168_actorModelParticles;
|
||||||
CRumbleManager xf250_rumbleManager;
|
CRumbleManager xf250_rumbleManager;
|
||||||
u32 xf344_ = 0;
|
u32 xf344_ = 0;
|
||||||
u32 xf370_ = 0;
|
rstl::reserved_vector<TUniqueId, 20> xf370_;
|
||||||
u32 xf39c_ = 0;
|
rstl::reserved_vector<TUniqueId, 20> xf39c_;
|
||||||
};
|
};
|
||||||
std::unique_ptr<CStateManagerContainer> x86c_stateManagerContainer;
|
std::unique_ptr<CStateManagerContainer> x86c_stateManagerContainer;
|
||||||
CCameraManager* x870_cameraManager = nullptr;
|
CCameraManager* x870_cameraManager = nullptr;
|
||||||
|
@ -134,7 +134,7 @@ class CStateManager
|
||||||
//u32 x8d4_updateFrameIdx = 0;
|
//u32 x8d4_updateFrameIdx = 0;
|
||||||
//u32 x8d8_drawFrameIdx = 0;
|
//u32 x8d8_drawFrameIdx = 0;
|
||||||
|
|
||||||
std::vector<CLight> x8dc_dynamicLights;
|
std::vector<CLight> x8e0_dynamicLights;
|
||||||
|
|
||||||
TLockedToken<CTexture> x8f0_shadowTex; /* DefaultShadow in MiscData */
|
TLockedToken<CTexture> x8f0_shadowTex; /* DefaultShadow in MiscData */
|
||||||
CRandom16 x8fc_random;
|
CRandom16 x8fc_random;
|
||||||
|
@ -191,8 +191,7 @@ class CStateManager
|
||||||
u32 xf20_ = 0;
|
u32 xf20_ = 0;
|
||||||
float xf24_thermColdScale1 = 0.f;
|
float xf24_thermColdScale1 = 0.f;
|
||||||
float xf28_thermColdScale2 = 0.f;
|
float xf28_thermColdScale2 = 0.f;
|
||||||
float xf2c_ = 1.f;
|
zeus::CVector2f xf2c_viewportScale = {1.f, 1.f};
|
||||||
float xf30_ = 1.f;
|
|
||||||
u32 xf34_ = 2;
|
u32 xf34_ = 2;
|
||||||
TUniqueId xf38_skipCineSpecialFunc = kInvalidUniqueId;
|
TUniqueId xf38_skipCineSpecialFunc = kInvalidUniqueId;
|
||||||
std::list<u32> xf3c_;
|
std::list<u32> xf3c_;
|
||||||
|
@ -243,7 +242,7 @@ public:
|
||||||
void AddDrawableActorPlane(const CActor& actor, const zeus::CPlane&, const zeus::CAABox& aabb) const;
|
void AddDrawableActorPlane(const CActor& actor, const zeus::CPlane&, const zeus::CAABox& aabb) const;
|
||||||
void AddDrawableActor(const CActor& actor, const zeus::CVector3f& vec, const zeus::CAABox& aabb) const;
|
void AddDrawableActor(const CActor& actor, const zeus::CVector3f& vec, const zeus::CAABox& aabb) const;
|
||||||
bool SpecialSkipCinematic();
|
bool SpecialSkipCinematic();
|
||||||
void GetVisAreaId() const;
|
TAreaId GetVisAreaId() const;
|
||||||
void GetWeaponIdCount(TUniqueId, EWeaponType);
|
void GetWeaponIdCount(TUniqueId, EWeaponType);
|
||||||
void RemoveWeaponId(TUniqueId, EWeaponType);
|
void RemoveWeaponId(TUniqueId, EWeaponType);
|
||||||
void AddWeaponId(TUniqueId, EWeaponType);
|
void AddWeaponId(TUniqueId, EWeaponType);
|
||||||
|
@ -261,11 +260,12 @@ public:
|
||||||
void CacheReflection();
|
void CacheReflection();
|
||||||
bool CanCreateProjectile(TUniqueId, EWeaponType, int) const;
|
bool CanCreateProjectile(TUniqueId, EWeaponType, int) const;
|
||||||
const CGameLightList* GetDynamicLightList() const;
|
const CGameLightList* GetDynamicLightList() const;
|
||||||
void BuildDynamicLightListForWorld(std::vector<CLight>& listOut) const;
|
void BuildDynamicLightListForWorld();
|
||||||
void DrawDebugStuff() const;
|
void DrawDebugStuff() const;
|
||||||
void RenderCamerasAndAreaLights() const;
|
void RenderCamerasAndAreaLights() const;
|
||||||
void DrawE3DeathEffect() const;
|
void DrawE3DeathEffect() const;
|
||||||
void DrawAdditionalFilters() const;
|
void DrawAdditionalFilters() const;
|
||||||
|
zeus::CFrustum SetupViewForDraw(const SViewport& vp) const;
|
||||||
void DrawWorld() const;
|
void DrawWorld() const;
|
||||||
void SetupFogForArea(const CGameArea& area) const;
|
void SetupFogForArea(const CGameArea& area) const;
|
||||||
void PreRender();
|
void PreRender();
|
||||||
|
|
|
@ -37,8 +37,8 @@ void CCameraBlurPass::Draw()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SClipScreenRect rect = {};
|
SClipScreenRect rect = {};
|
||||||
rect.xc_width = CGraphics::g_ViewportResolution.x;
|
rect.xc_width = g_Viewport.x8_width;
|
||||||
rect.x10_height = CGraphics::g_ViewportResolution.y;
|
rect.x10_height = g_Viewport.xc_height;
|
||||||
CGraphics::ResolveSpareTexture(rect);
|
CGraphics::ResolveSpareTexture(rect);
|
||||||
|
|
||||||
if (x10_curType == EBlurType::Xray)
|
if (x10_curType == EBlurType::Xray)
|
||||||
|
|
|
@ -28,7 +28,7 @@ CCameraManager::CCameraManager(TUniqueId curCameraId) : x0_curCameraId(curCamera
|
||||||
{
|
{
|
||||||
CSfxManager::AddListener(CSfxManager::ESfxChannels::Game, zeus::CVector3f::skZero, zeus::CVector3f::skZero,
|
CSfxManager::AddListener(CSfxManager::ESfxChannels::Game, zeus::CVector3f::skZero, zeus::CVector3f::skZero,
|
||||||
{1.f, 0.f, 0.f}, {0.f, 0.f, 1.f}, 50.f, 50.f, 1000.f, 1, 0x7f);
|
{1.f, 0.f, 0.f}, {0.f, 0.f, 1.f}, 50.f, 50.f, 1000.f, 1, 0x7f);
|
||||||
sAspect = float(gViewport.x8_width / gViewport.xc_height);
|
sAspect = float(g_Viewport.x8_width / g_Viewport.xc_height);
|
||||||
sFirstPersonFOV = g_tweakGame->GetFirstPersonFOV();
|
sFirstPersonFOV = g_tweakGame->GetFirstPersonFOV();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -101,16 +101,6 @@ zeus::CTransform CGameCamera::ValidateCameraTransform(const zeus::CTransform& a,
|
||||||
return xfCpy;
|
return xfCpy;
|
||||||
}
|
}
|
||||||
|
|
||||||
float CGameCamera::GetNearClipDistance() const { return x160_znear; }
|
|
||||||
|
|
||||||
float CGameCamera::GetFarClipDistance() const { return x164_zfar; }
|
|
||||||
|
|
||||||
float CGameCamera::GetAspectRatio() const { return x168_aspect; }
|
|
||||||
|
|
||||||
TUniqueId CGameCamera::GetWatchedObject() const { return xe8_watchedObject; }
|
|
||||||
|
|
||||||
float CGameCamera::GetFov() const { return x15c_currentFov; }
|
|
||||||
|
|
||||||
void CGameCamera::UpdatePerspective(float dt)
|
void CGameCamera::UpdatePerspective(float dt)
|
||||||
{
|
{
|
||||||
if (x174_ > 0.f)
|
if (x174_ > 0.f)
|
||||||
|
|
|
@ -38,11 +38,11 @@ public:
|
||||||
zeus::CMatrix4f GetPerspectiveMatrix() const;
|
zeus::CMatrix4f GetPerspectiveMatrix() const;
|
||||||
zeus::CVector3f ConvertToScreenSpace(const zeus::CVector3f&) const;
|
zeus::CVector3f ConvertToScreenSpace(const zeus::CVector3f&) const;
|
||||||
zeus::CTransform ValidateCameraTransform(const zeus::CTransform&, const zeus::CTransform&);
|
zeus::CTransform ValidateCameraTransform(const zeus::CTransform&, const zeus::CTransform&);
|
||||||
float GetNearClipDistance() const;
|
float GetNearClipDistance() const { return x160_znear; }
|
||||||
float GetFarClipDistance() const;
|
float GetFarClipDistance() const { return x164_zfar; }
|
||||||
float GetAspectRatio() const;
|
float GetAspectRatio() const { return x168_aspect; }
|
||||||
TUniqueId GetWatchedObject() const;
|
TUniqueId GetWatchedObject() const { return xe8_watchedObject; }
|
||||||
float GetFov() const;
|
float GetFov() const { return x15c_currentFov; }
|
||||||
void GetControllerNumber() const;
|
void GetControllerNumber() const;
|
||||||
bool DisablesInput() const;
|
bool DisablesInput() const;
|
||||||
void UpdatePerspective(float);
|
void UpdatePerspective(float);
|
||||||
|
|
|
@ -141,9 +141,12 @@ void Buckets::Init()
|
||||||
}
|
}
|
||||||
|
|
||||||
CBooRenderer::CAreaListItem::CAreaListItem
|
CBooRenderer::CAreaListItem::CAreaListItem
|
||||||
(const std::vector<CMetroidModelInstance>* geom, const CAreaRenderOctTree* octTree,
|
(const std::vector<CMetroidModelInstance>* geom,
|
||||||
|
const CAreaRenderOctTree* octTree,
|
||||||
|
std::vector<TCachedToken<CTexture>>&& textures,
|
||||||
std::vector<CBooModel*>&& models, int areaIdx)
|
std::vector<CBooModel*>&& models, int areaIdx)
|
||||||
: x0_geometry(geom), x4_octTree(octTree), x10_models(std::move(models)), x18_areaIdx(areaIdx) {}
|
: x0_geometry(geom), x4_octTree(octTree), x8_textures(std::move(textures)),
|
||||||
|
x10_models(std::move(models)), x18_areaIdx(areaIdx) {}
|
||||||
|
|
||||||
CBooRenderer::CAreaListItem::~CAreaListItem() {}
|
CBooRenderer::CAreaListItem::~CAreaListItem() {}
|
||||||
|
|
||||||
|
@ -152,7 +155,7 @@ void CBooRenderer::ActivateLightsForModel(CAreaListItem* item, CBooModel& model)
|
||||||
std::vector<CLight> thisLights;
|
std::vector<CLight> thisLights;
|
||||||
thisLights.reserve(4);
|
thisLights.reserve(4);
|
||||||
|
|
||||||
if (x304_lights.size())
|
if (x300_dynamicLights.size())
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
void* unk3 = nullptr;
|
void* unk3 = nullptr;
|
||||||
|
@ -168,7 +171,7 @@ void CBooRenderer::ActivateLightsForModel(CAreaListItem* item, CBooModel& model)
|
||||||
float lightRads[] = {-1.f, -1.f, -1.f, -1.f};
|
float lightRads[] = {-1.f, -1.f, -1.f, -1.f};
|
||||||
for (int i=0 ; i<4 ; ++i)
|
for (int i=0 ; i<4 ; ++i)
|
||||||
{
|
{
|
||||||
for (CLight& light : x304_lights)
|
for (CLight& light : x300_dynamicLights)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
if (unk3)
|
if (unk3)
|
||||||
|
@ -337,14 +340,16 @@ void CBooRenderer::AddStaticGeometry(const std::vector<CMetroidModelInstance>* g
|
||||||
auto search = FindStaticGeometry(geometry);
|
auto search = FindStaticGeometry(geometry);
|
||||||
if (search == x1c_areaListItems.end())
|
if (search == x1c_areaListItems.end())
|
||||||
{
|
{
|
||||||
|
std::vector<TCachedToken<CTexture>> textures;
|
||||||
std::vector<CBooModel*> models;
|
std::vector<CBooModel*> models;
|
||||||
if (geometry->size())
|
if (geometry->size())
|
||||||
{
|
{
|
||||||
|
(*geometry)[0].m_instance->MakeTexturesFromMats(textures, xc_store);
|
||||||
models.reserve(geometry->size());
|
models.reserve(geometry->size());
|
||||||
for (const CMetroidModelInstance& inst : *geometry)
|
for (const CMetroidModelInstance& inst : *geometry)
|
||||||
models.push_back(inst.m_instance);
|
models.push_back(inst.m_instance);
|
||||||
}
|
}
|
||||||
x1c_areaListItems.emplace_back(geometry, octTree, std::move(models), areaIdx);
|
x1c_areaListItems.emplace_back(geometry, octTree, std::move(textures), std::move(models), areaIdx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -532,10 +537,10 @@ void CBooRenderer::SetPerspective(float fovy, float aspect, float znear, float z
|
||||||
|
|
||||||
zeus::CRectangle CBooRenderer::SetViewportOrtho(bool centered, float znear, float zfar)
|
zeus::CRectangle CBooRenderer::SetViewportOrtho(bool centered, float znear, float zfar)
|
||||||
{
|
{
|
||||||
float left = centered ? CGraphics::g_ViewportResolutionHalf.x : 0;
|
float left = centered ? g_Viewport.x10_halfWidth : 0;
|
||||||
float bottom = centered ? CGraphics::g_ViewportResolutionHalf.y : 0;
|
float bottom = centered ? g_Viewport.x14_halfHeight : 0;
|
||||||
float top = centered ? CGraphics::g_ViewportResolutionHalf.y : CGraphics::g_ViewportResolution.y;
|
float top = centered ? g_Viewport.x14_halfHeight : g_Viewport.xc_height;
|
||||||
float right = centered ? CGraphics::g_ViewportResolutionHalf.x : CGraphics::g_ViewportResolution.x;
|
float right = centered ? g_Viewport.x10_halfWidth : g_Viewport.x8_width;
|
||||||
|
|
||||||
CGraphics::SetOrtho(left, right, top, bottom, znear, zfar);
|
CGraphics::SetOrtho(left, right, top, bottom, znear, zfar);
|
||||||
CGraphics::SetViewPointMatrix(zeus::CTransform::Identity());
|
CGraphics::SetViewPointMatrix(zeus::CTransform::Identity());
|
||||||
|
@ -561,7 +566,7 @@ void CBooRenderer::SetDebugOption(EDebugOption, int)
|
||||||
|
|
||||||
void CBooRenderer::BeginScene()
|
void CBooRenderer::BeginScene()
|
||||||
{
|
{
|
||||||
CGraphics::SetViewport(0, 0, CGraphics::g_ViewportResolution.x, CGraphics::g_ViewportResolution.y);
|
CGraphics::SetViewport(0, 0, g_Viewport.x8_width, g_Viewport.xc_height);
|
||||||
CGraphics::SetPerspective(75.f, CGraphics::g_ProjAspect, 1.f, 4096.f);
|
CGraphics::SetPerspective(75.f, CGraphics::g_ProjAspect, 1.f, 4096.f);
|
||||||
CGraphics::SetModelMatrix(zeus::CTransform::Identity());
|
CGraphics::SetModelMatrix(zeus::CTransform::Identity());
|
||||||
CGraphics::BeginScene();
|
CGraphics::BeginScene();
|
||||||
|
@ -699,4 +704,27 @@ u32 CBooRenderer::GetStaticWorldDataSize()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CBooRenderer::PrepareDynamicLights(const std::vector<CLight>& lights)
|
||||||
|
{
|
||||||
|
x300_dynamicLights = lights;
|
||||||
|
for (CAreaListItem& area : x1c_areaListItems)
|
||||||
|
{
|
||||||
|
if (const CAreaRenderOctTree* arot = area.x4_octTree)
|
||||||
|
{
|
||||||
|
area.x1c_lightOctreeWords.clear();
|
||||||
|
area.x1c_lightOctreeWords.resize(arot->x14_bitmapWordCount * lights.size());
|
||||||
|
u32* wordPtr = area.x1c_lightOctreeWords.data();
|
||||||
|
for (const CLight& light : lights)
|
||||||
|
{
|
||||||
|
float radius = light.GetRadius();
|
||||||
|
zeus::CVector3f vMin = light.GetPosition() - radius;
|
||||||
|
zeus::CVector3f vMax = light.GetPosition() + radius;
|
||||||
|
zeus::CAABox aabb(vMin, vMax);
|
||||||
|
arot->FindOverlappingModels(wordPtr, aabb);
|
||||||
|
wordPtr += arot->x14_bitmapWordCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,12 +54,16 @@ class CBooRenderer : public IRenderer
|
||||||
{
|
{
|
||||||
const std::vector<CMetroidModelInstance>* x0_geometry;
|
const std::vector<CMetroidModelInstance>* x0_geometry;
|
||||||
const CAreaRenderOctTree* x4_octTree;
|
const CAreaRenderOctTree* x4_octTree;
|
||||||
//std::vector<TCachedToken<CTexture>> x8_textures;
|
/* originally auto_ptrs of vectors */
|
||||||
|
std::vector<TCachedToken<CTexture>> x8_textures;
|
||||||
std::vector<CBooModel*> x10_models;
|
std::vector<CBooModel*> x10_models;
|
||||||
int x18_areaIdx;
|
int x18_areaIdx;
|
||||||
std::vector<u32> x20_;
|
/* Per-area octree-word major, light bits minor */
|
||||||
|
std::vector<u32> x1c_lightOctreeWords;
|
||||||
|
|
||||||
CAreaListItem(const std::vector<CMetroidModelInstance>* geom, const CAreaRenderOctTree* octTree,
|
CAreaListItem(const std::vector<CMetroidModelInstance>* geom,
|
||||||
|
const CAreaRenderOctTree* octTree,
|
||||||
|
std::vector<TCachedToken<CTexture>>&& textures,
|
||||||
std::vector<CBooModel*>&& models, int areaIdx);
|
std::vector<CBooModel*>&& models, int areaIdx);
|
||||||
~CAreaListItem();
|
~CAreaListItem();
|
||||||
};
|
};
|
||||||
|
@ -110,7 +114,7 @@ class CBooRenderer : public IRenderer
|
||||||
CThermalColdFilter m_thermColdFilter;
|
CThermalColdFilter m_thermColdFilter;
|
||||||
std::experimental::optional<CThermalHotFilter> m_thermHotFilter;
|
std::experimental::optional<CThermalHotFilter> m_thermHotFilter;
|
||||||
|
|
||||||
std::vector<CLight> x304_lights;
|
std::vector<CLight> x300_dynamicLights;
|
||||||
|
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
|
@ -198,6 +202,7 @@ public:
|
||||||
void DoThermalBlendCold();
|
void DoThermalBlendCold();
|
||||||
void DoThermalBlendHot();
|
void DoThermalBlendHot();
|
||||||
u32 GetStaticWorldDataSize();
|
u32 GetStaticWorldDataSize();
|
||||||
|
void PrepareDynamicLights(const std::vector<CLight>& lights);
|
||||||
|
|
||||||
boo::ITexture* GetThermoPalette() {return x288_thermoPalette;}
|
boo::ITexture* GetThermoPalette() {return x288_thermoPalette;}
|
||||||
|
|
||||||
|
|
|
@ -25,12 +25,10 @@ zeus::CTransform CGraphics::g_ViewMatrix;
|
||||||
zeus::CVector3f CGraphics::g_ViewPoint;
|
zeus::CVector3f CGraphics::g_ViewPoint;
|
||||||
zeus::CTransform CGraphics::g_GXViewPointMatrix;
|
zeus::CTransform CGraphics::g_GXViewPointMatrix;
|
||||||
zeus::CTransform CGraphics::g_CameraMatrix;
|
zeus::CTransform CGraphics::g_CameraMatrix;
|
||||||
zeus::CVector2i CGraphics::g_ViewportResolution;
|
|
||||||
zeus::CVector2i CGraphics::g_ViewportResolutionHalf;
|
|
||||||
SClipScreenRect CGraphics::g_CroppedViewport;
|
SClipScreenRect CGraphics::g_CroppedViewport;
|
||||||
int CGraphics::g_ViewportSamples = 1;
|
int CGraphics::g_ViewportSamples = 1;
|
||||||
bool CGraphics::g_IsGXModelMatrixIdentity = true;
|
bool CGraphics::g_IsGXModelMatrixIdentity = true;
|
||||||
SViewport gViewport = {0, 0, 640, 480, 640 / 2.f, 480 / 2.f};
|
SViewport g_Viewport = {0, 0, 640, 480, 640 / 2.f, 480 / 2.f};
|
||||||
|
|
||||||
void CGraphics::DisableAllLights()
|
void CGraphics::DisableAllLights()
|
||||||
{
|
{
|
||||||
|
@ -380,8 +378,8 @@ void CGraphics::FlushProjection()
|
||||||
zeus::CVector2i CGraphics::ProjectPoint(const zeus::CVector3f& point)
|
zeus::CVector2i CGraphics::ProjectPoint(const zeus::CVector3f& point)
|
||||||
{
|
{
|
||||||
zeus::CVector3f projPt = GetPerspectiveProjectionMatrix(false).multiplyOneOverW(point);
|
zeus::CVector3f projPt = GetPerspectiveProjectionMatrix(false).multiplyOneOverW(point);
|
||||||
return {int(projPt.x * g_ViewportResolutionHalf.x) + g_ViewportResolutionHalf.x,
|
return {int(projPt.x * g_Viewport.x10_halfWidth) + g_Viewport.x10_halfWidth,
|
||||||
g_ViewportResolution.y - (int(projPt.y * g_ViewportResolutionHalf.y) + g_ViewportResolutionHalf.y)};
|
g_Viewport.x14_halfHeight - (int(projPt.y * g_Viewport.x14_halfHeight) + g_Viewport.x14_halfHeight)};
|
||||||
}
|
}
|
||||||
|
|
||||||
SClipScreenRect CGraphics::ClipScreenRectFromMS(const zeus::CVector3f& p1,
|
SClipScreenRect CGraphics::ClipScreenRectFromMS(const zeus::CVector3f& p1,
|
||||||
|
@ -413,7 +411,7 @@ SClipScreenRect CGraphics::ClipScreenRectFromVS(const zeus::CVector3f& p1,
|
||||||
int minY2 = minY & 0xfffffffe;
|
int minY2 = minY & 0xfffffffe;
|
||||||
|
|
||||||
|
|
||||||
if (minX2 >= g_ViewportResolution.x)
|
if (minX2 >= g_Viewport.x8_width)
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
int maxX = abs(sp1.x - sp2.x) + minX;
|
int maxX = abs(sp1.x - sp2.x) + minX;
|
||||||
|
@ -422,10 +420,10 @@ SClipScreenRect CGraphics::ClipScreenRectFromVS(const zeus::CVector3f& p1,
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
int finalMinX = std::max(minX, 0 /* ViewportX origin */);
|
int finalMinX = std::max(minX, 0 /* ViewportX origin */);
|
||||||
int finalMaxX = std::min(maxX, g_ViewportResolution.x);
|
int finalMaxX = std::min(maxX, int(g_Viewport.x8_width));
|
||||||
|
|
||||||
|
|
||||||
if (minY2 >= g_ViewportResolution.y)
|
if (minY2 >= g_Viewport.xc_height)
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
int maxY = abs(sp1.y - sp2.y) + minY;
|
int maxY = abs(sp1.y - sp2.y) + minY;
|
||||||
|
@ -434,13 +432,13 @@ SClipScreenRect CGraphics::ClipScreenRectFromVS(const zeus::CVector3f& p1,
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
int finalMinY = std::max(minY, 0 /* ViewportY origin */);
|
int finalMinY = std::max(minY, 0 /* ViewportY origin */);
|
||||||
int finalMaxY = std::min(maxY, g_ViewportResolution.y);
|
int finalMaxY = std::min(maxY, int(g_Viewport.xc_height));
|
||||||
|
|
||||||
int width = maxX2 - minX2;
|
int width = maxX2 - minX2;
|
||||||
int height = maxY2 - minY2;
|
int height = maxY2 - minY2;
|
||||||
return {true, minX2, minY2, width, height, width,
|
return {true, minX2, minY2, width, height, width,
|
||||||
minX2 / float(g_ViewportResolution.x), maxX2 / float(g_ViewportResolution.x),
|
minX2 / float(g_Viewport.x8_width), maxX2 / float(g_Viewport.x8_width),
|
||||||
1.f - maxY2 / float(g_ViewportResolution.y), 1.f - minY2 / float(g_ViewportResolution.y)};
|
1.f - maxY2 / float(g_Viewport.xc_height), 1.f - minY2 / float(g_Viewport.xc_height)};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -452,11 +450,13 @@ zeus::CVector3f CGraphics::ProjectModelPointToViewportSpace(const zeus::CVector3
|
||||||
|
|
||||||
void CGraphics::SetViewportResolution(const zeus::CVector2i& res)
|
void CGraphics::SetViewportResolution(const zeus::CVector2i& res)
|
||||||
{
|
{
|
||||||
g_ViewportResolution = res;
|
g_Viewport.x8_width = res.x;
|
||||||
|
g_Viewport.xc_height = res.y;
|
||||||
g_CroppedViewport = SClipScreenRect();
|
g_CroppedViewport = SClipScreenRect();
|
||||||
g_CroppedViewport.xc_width = res.x;
|
g_CroppedViewport.xc_width = res.x;
|
||||||
g_CroppedViewport.x10_height = res.y;
|
g_CroppedViewport.x10_height = res.y;
|
||||||
g_ViewportResolutionHalf = {res.x / 2, res.y / 2};
|
g_Viewport.x10_halfWidth = res.x / 2.f;
|
||||||
|
g_Viewport.x14_halfHeight = res.y / 2.f;
|
||||||
if (g_GuiSys)
|
if (g_GuiSys)
|
||||||
g_GuiSys->OnViewportResize();
|
g_GuiSys->OnViewportResize();
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,7 +149,7 @@ struct SViewport
|
||||||
float x14_halfHeight;
|
float x14_halfHeight;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern SViewport gViewport;
|
extern SViewport g_Viewport;
|
||||||
|
|
||||||
struct SClipScreenRect
|
struct SClipScreenRect
|
||||||
{
|
{
|
||||||
|
@ -236,8 +236,6 @@ public:
|
||||||
static zeus::CVector3f g_ViewPoint;
|
static zeus::CVector3f g_ViewPoint;
|
||||||
static zeus::CTransform g_GXViewPointMatrix;
|
static zeus::CTransform g_GXViewPointMatrix;
|
||||||
static zeus::CTransform g_CameraMatrix;
|
static zeus::CTransform g_CameraMatrix;
|
||||||
static zeus::CVector2i g_ViewportResolution;
|
|
||||||
static zeus::CVector2i g_ViewportResolutionHalf;
|
|
||||||
static SClipScreenRect g_CroppedViewport;
|
static SClipScreenRect g_CroppedViewport;
|
||||||
static int g_ViewportSamples;
|
static int g_ViewportSamples;
|
||||||
static bool g_IsGXModelMatrixIdentity;
|
static bool g_IsGXModelMatrixIdentity;
|
||||||
|
|
|
@ -128,15 +128,23 @@ private:
|
||||||
|
|
||||||
void VerifyCurrentShader(int shaderIdx);
|
void VerifyCurrentShader(int shaderIdx);
|
||||||
|
|
||||||
|
static zeus::CVector3f g_PlayerPosition;
|
||||||
|
static float g_ModSeconds;
|
||||||
|
static float g_TransformedTime;
|
||||||
|
static float g_TransformedTime2;
|
||||||
|
static CBooModel* g_LastModelCached;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~CBooModel();
|
~CBooModel();
|
||||||
CBooModel(TToken<CModel>& token, std::vector<CBooSurface>* surfaces, SShader& shader,
|
CBooModel(TToken<CModel>& token, std::vector<CBooSurface>* surfaces, SShader& shader,
|
||||||
boo::IVertexFormat* vtxFmt, boo::IGraphicsBufferS* vbo, boo::IGraphicsBufferS* ibo,
|
boo::IVertexFormat* vtxFmt, boo::IGraphicsBufferS* vbo, boo::IGraphicsBufferS* ibo,
|
||||||
size_t weightVecCount, size_t skinBankCount, const zeus::CAABox& aabb, int numInsts);
|
size_t weightVecCount, size_t skinBankCount, const zeus::CAABox& aabb, int numInsts);
|
||||||
|
|
||||||
static void MakeTexuresFromMats(const MaterialSet& matSet,
|
static void MakeTexturesFromMats(const MaterialSet& matSet,
|
||||||
std::vector<TCachedToken<CTexture>>& toksOut,
|
std::vector<TCachedToken<CTexture>>& toksOut,
|
||||||
IObjectStore& store);
|
IObjectStore& store);
|
||||||
|
void MakeTexturesFromMats(std::vector<TCachedToken<CTexture>>& toksOut,
|
||||||
|
IObjectStore& store);
|
||||||
|
|
||||||
bool IsOpaque() const {return x3c_firstSortedSurface == nullptr;}
|
bool IsOpaque() const {return x3c_firstSortedSurface == nullptr;}
|
||||||
void ActivateLights(const std::vector<CLight>& lights);
|
void ActivateLights(const std::vector<CLight>& lights);
|
||||||
|
@ -167,6 +175,9 @@ public:
|
||||||
|
|
||||||
static bool g_DrawingOccluders;
|
static bool g_DrawingOccluders;
|
||||||
static void SetDrawingOccluders(bool occ) {g_DrawingOccluders = occ;}
|
static void SetDrawingOccluders(bool occ) {g_DrawingOccluders = occ;}
|
||||||
|
|
||||||
|
static void SetNewPlayerPositionAndTime(const zeus::CVector3f& pos);
|
||||||
|
static void KillCachedViewDepState();
|
||||||
};
|
};
|
||||||
|
|
||||||
class CModel
|
class CModel
|
||||||
|
|
|
@ -25,6 +25,27 @@ void CBooModel::ClearModelUniformCounters()
|
||||||
model->ClearUniformCounter();
|
model->ClearUniformCounter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
zeus::CVector3f CBooModel::g_PlayerPosition = {};
|
||||||
|
float CBooModel::g_ModSeconds = 0.f;
|
||||||
|
float CBooModel::g_TransformedTime = 0.f;
|
||||||
|
float CBooModel::g_TransformedTime2 = 0.f;
|
||||||
|
void CBooModel::SetNewPlayerPositionAndTime(const zeus::CVector3f& pos)
|
||||||
|
{
|
||||||
|
g_PlayerPosition = pos;
|
||||||
|
KillCachedViewDepState();
|
||||||
|
u32 modMillis = std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||||
|
std::chrono::steady_clock::now().time_since_epoch()).count() % u64(100000.f * 4.f * M_PIF / 3.f);
|
||||||
|
g_ModSeconds = modMillis / 1000.f;
|
||||||
|
g_TransformedTime = 1.f / -(0.05f * std::sin(g_ModSeconds * 1.5f) - 1.f);
|
||||||
|
g_TransformedTime2 = 1.f / -(0.015f * std::sin(g_ModSeconds * 1.5f + 1.f) - 1.f);
|
||||||
|
}
|
||||||
|
|
||||||
|
CBooModel* CBooModel::g_LastModelCached = nullptr;
|
||||||
|
void CBooModel::KillCachedViewDepState()
|
||||||
|
{
|
||||||
|
g_LastModelCached = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
CBooModel::~CBooModel()
|
CBooModel::~CBooModel()
|
||||||
{
|
{
|
||||||
if (m_prev)
|
if (m_prev)
|
||||||
|
@ -213,15 +234,21 @@ CBooModel::ModelInstance* CBooModel::PushNewModelInstance()
|
||||||
return &newInst;
|
return &newInst;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBooModel::MakeTexuresFromMats(const MaterialSet& matSet,
|
void CBooModel::MakeTexturesFromMats(const MaterialSet& matSet,
|
||||||
std::vector<TCachedToken<CTexture>>& toksOut,
|
std::vector<TCachedToken<CTexture>>& toksOut,
|
||||||
IObjectStore& store)
|
IObjectStore& store)
|
||||||
{
|
{
|
||||||
toksOut.reserve(matSet.head.textureIDs.size());
|
toksOut.reserve(matSet.head.textureIDs.size());
|
||||||
for (const DataSpec::UniqueID32& id : matSet.head.textureIDs)
|
for (const DataSpec::UniqueID32& id : matSet.head.textureIDs)
|
||||||
toksOut.emplace_back(store.GetObj({SBIG('TXTR'), id.toUint32()}));
|
toksOut.emplace_back(store.GetObj({SBIG('TXTR'), id.toUint32()}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CBooModel::MakeTexturesFromMats(std::vector<TCachedToken<CTexture>>& toksOut,
|
||||||
|
IObjectStore& store)
|
||||||
|
{
|
||||||
|
MakeTexturesFromMats(*x4_matSet, toksOut, store);
|
||||||
|
}
|
||||||
|
|
||||||
void CBooModel::ActivateLights(const std::vector<CLight>& lights)
|
void CBooModel::ActivateLights(const std::vector<CLight>& lights)
|
||||||
{
|
{
|
||||||
m_lightingData.ambient = zeus::CColor::skBlack;
|
m_lightingData.ambient = zeus::CColor::skBlack;
|
||||||
|
@ -694,7 +721,7 @@ CModel::CModel(std::unique_ptr<u8[]>&& in, u32 /* dataLen */, IObjectStore* stor
|
||||||
CBooModel::SShader& shader = x18_matSets.back();
|
CBooModel::SShader& shader = x18_matSets.back();
|
||||||
athena::io::MemoryReader r(sec, matSetSz);
|
athena::io::MemoryReader r(sec, matSetSz);
|
||||||
shader.m_matSet.read(r);
|
shader.m_matSet.read(r);
|
||||||
CBooModel::MakeTexuresFromMats(shader.m_matSet, shader.x0_textures, *store);
|
CBooModel::MakeTexturesFromMats(shader.m_matSet, shader.x0_textures, *store);
|
||||||
}
|
}
|
||||||
|
|
||||||
hecl::HMDLMeta hmdlMeta;
|
hecl::HMDLMeta hmdlMeta;
|
||||||
|
|
|
@ -35,6 +35,8 @@ public:
|
||||||
};
|
};
|
||||||
enum class EDebugOption
|
enum class EDebugOption
|
||||||
{
|
{
|
||||||
|
Zero,
|
||||||
|
One
|
||||||
};
|
};
|
||||||
enum class EPrimitiveType
|
enum class EPrimitiveType
|
||||||
{
|
{
|
||||||
|
@ -97,6 +99,7 @@ public:
|
||||||
virtual void DoThermalBlendCold()=0;
|
virtual void DoThermalBlendCold()=0;
|
||||||
virtual void DoThermalBlendHot()=0;
|
virtual void DoThermalBlendHot()=0;
|
||||||
virtual u32 GetStaticWorldDataSize()=0;
|
virtual u32 GetStaticWorldDataSize()=0;
|
||||||
|
virtual void PrepareDynamicLights(const std::vector<CLight>& lights)=0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,15 +21,15 @@ void CCameraBlurFilter::draw(float amount)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SClipScreenRect clipRect = {};
|
SClipScreenRect clipRect = {};
|
||||||
clipRect.xc_width = CGraphics::g_ViewportResolution.x;
|
clipRect.xc_width = g_Viewport.x8_width;
|
||||||
clipRect.x10_height = CGraphics::g_ViewportResolution.y;
|
clipRect.x10_height = g_Viewport.xc_height;
|
||||||
CGraphics::ResolveSpareTexture(clipRect);
|
CGraphics::ResolveSpareTexture(clipRect);
|
||||||
float aspect = CGraphics::g_CroppedViewport.xc_width / float(CGraphics::g_CroppedViewport.x10_height);
|
float aspect = CGraphics::g_CroppedViewport.xc_width / float(CGraphics::g_CroppedViewport.x10_height);
|
||||||
|
|
||||||
float xFac = CGraphics::g_CroppedViewport.xc_width / float(CGraphics::g_ViewportResolution.x);
|
float xFac = CGraphics::g_CroppedViewport.xc_width / float(g_Viewport.x8_width);
|
||||||
float yFac = CGraphics::g_CroppedViewport.x10_height / float(CGraphics::g_ViewportResolution.y);
|
float yFac = CGraphics::g_CroppedViewport.x10_height / float(g_Viewport.xc_height);
|
||||||
float xBias = CGraphics::g_CroppedViewport.x4_left / float(CGraphics::g_ViewportResolution.x);
|
float xBias = CGraphics::g_CroppedViewport.x4_left / float(g_Viewport.x8_width);
|
||||||
float yBias = CGraphics::g_CroppedViewport.x8_top / float(CGraphics::g_ViewportResolution.y);
|
float yBias = CGraphics::g_CroppedViewport.x8_top / float(g_Viewport.xc_height);
|
||||||
|
|
||||||
Vert verts[4] =
|
Vert verts[4] =
|
||||||
{
|
{
|
||||||
|
|
|
@ -39,12 +39,12 @@ void CColoredQuadFilter::draw(const zeus::CColor& color, const zeus::CRectangle&
|
||||||
|
|
||||||
void CWideScreenFilter::draw(const zeus::CColor& color, float t)
|
void CWideScreenFilter::draw(const zeus::CColor& color, float t)
|
||||||
{
|
{
|
||||||
float aspect = CGraphics::g_ViewportResolution.x / float(CGraphics::g_ViewportResolution.y);
|
float aspect = g_Viewport.x8_width / float(g_Viewport.xc_height);
|
||||||
if (aspect < 1.7777f)
|
if (aspect < 1.7777f)
|
||||||
{
|
{
|
||||||
float targetHeight = CGraphics::g_ViewportResolution.x / 1.7777f;
|
float targetHeight = g_Viewport.x8_width / 1.7777f;
|
||||||
float delta = (CGraphics::g_ViewportResolution.y - targetHeight) * t / 2.f;
|
float delta = (g_Viewport.xc_height - targetHeight) * t / 2.f;
|
||||||
delta /= float(CGraphics::g_ViewportResolution.y);
|
delta /= float(g_Viewport.xc_height);
|
||||||
zeus::CRectangle rect(0.f, 0.f, 1.f, delta);
|
zeus::CRectangle rect(0.f, 0.f, 1.f, delta);
|
||||||
m_bottom.draw(color, rect);
|
m_bottom.draw(color, rect);
|
||||||
rect.position.y = 1.f - delta;
|
rect.position.y = 1.f - delta;
|
||||||
|
@ -54,14 +54,14 @@ void CWideScreenFilter::draw(const zeus::CColor& color, float t)
|
||||||
|
|
||||||
float CWideScreenFilter::SetViewportToMatch(float t)
|
float CWideScreenFilter::SetViewportToMatch(float t)
|
||||||
{
|
{
|
||||||
float aspect = CGraphics::g_ViewportResolution.x / float(CGraphics::g_ViewportResolution.y);
|
float aspect = g_Viewport.x8_width / float(g_Viewport.xc_height);
|
||||||
if (aspect < 1.7777f)
|
if (aspect < 1.7777f)
|
||||||
{
|
{
|
||||||
float targetHeight = CGraphics::g_ViewportResolution.x / 1.7777f;
|
float targetHeight = g_Viewport.x8_width / 1.7777f;
|
||||||
float delta = (CGraphics::g_ViewportResolution.y - targetHeight) * t / 2.f;
|
float delta = (g_Viewport.xc_height - targetHeight) * t / 2.f;
|
||||||
boo::SWindowRect rect = {};
|
boo::SWindowRect rect = {};
|
||||||
rect.size[0] = CGraphics::g_ViewportResolution.x;
|
rect.size[0] = g_Viewport.x8_width;
|
||||||
rect.size[1] = CGraphics::g_ViewportResolution.y - delta * 2.f;
|
rect.size[1] = g_Viewport.xc_height - delta * 2.f;
|
||||||
rect.location[1] = delta;
|
rect.location[1] = delta;
|
||||||
CGraphics::g_CroppedViewport = rect;
|
CGraphics::g_CroppedViewport = rect;
|
||||||
CGraphics::g_BooMainCommandQueue->setViewport(rect);
|
CGraphics::g_BooMainCommandQueue->setViewport(rect);
|
||||||
|
@ -77,8 +77,8 @@ float CWideScreenFilter::SetViewportToMatch(float t)
|
||||||
void CWideScreenFilter::SetViewportToFull()
|
void CWideScreenFilter::SetViewportToFull()
|
||||||
{
|
{
|
||||||
boo::SWindowRect rect = {};
|
boo::SWindowRect rect = {};
|
||||||
rect.size[0] = CGraphics::g_ViewportResolution.x;
|
rect.size[0] = g_Viewport.x8_width;
|
||||||
rect.size[1] = CGraphics::g_ViewportResolution.y;
|
rect.size[1] = g_Viewport.xc_height;
|
||||||
CGraphics::g_CroppedViewport = rect;
|
CGraphics::g_CroppedViewport = rect;
|
||||||
CGraphics::g_BooMainCommandQueue->setViewport(rect);
|
CGraphics::g_BooMainCommandQueue->setViewport(rect);
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,10 +53,10 @@ void CTexturedQuadFilter::draw(const zeus::CColor& color, float uvScale, const z
|
||||||
|
|
||||||
void CTexturedQuadFilter::drawCropped(const zeus::CColor& color, float uvScale)
|
void CTexturedQuadFilter::drawCropped(const zeus::CColor& color, float uvScale)
|
||||||
{
|
{
|
||||||
float xFac = CGraphics::g_CroppedViewport.xc_width / float(CGraphics::g_ViewportResolution.x);
|
float xFac = CGraphics::g_CroppedViewport.xc_width / float(g_Viewport.x8_width);
|
||||||
float yFac = CGraphics::g_CroppedViewport.x10_height / float(CGraphics::g_ViewportResolution.y);
|
float yFac = CGraphics::g_CroppedViewport.x10_height / float(g_Viewport.xc_height);
|
||||||
float xBias = CGraphics::g_CroppedViewport.x4_left / float(CGraphics::g_ViewportResolution.x);
|
float xBias = CGraphics::g_CroppedViewport.x4_left / float(g_Viewport.x8_width);
|
||||||
float yBias = CGraphics::g_CroppedViewport.x8_top / float(CGraphics::g_ViewportResolution.y);
|
float yBias = CGraphics::g_CroppedViewport.x8_top / float(g_Viewport.xc_height);
|
||||||
|
|
||||||
Vert verts[4] =
|
Vert verts[4] =
|
||||||
{
|
{
|
||||||
|
|
|
@ -77,7 +77,7 @@ void CGuiSys::OnViewportResize()
|
||||||
|
|
||||||
void CGuiSys::ViewportResizeFrame(CGuiFrame* frame)
|
void CGuiSys::ViewportResizeFrame(CGuiFrame* frame)
|
||||||
{
|
{
|
||||||
float vpAspectRatio = CGraphics::g_ViewportResolution.x / float(CGraphics::g_ViewportResolution.y);
|
float vpAspectRatio = g_Viewport.x8_width / float(g_Viewport.xc_height);
|
||||||
if (frame->m_aspectConstraint > 0.f)
|
if (frame->m_aspectConstraint > 0.f)
|
||||||
{
|
{
|
||||||
float hPad, vPad;
|
float hPad, vPad;
|
||||||
|
|
|
@ -66,7 +66,7 @@ void CSplashScreen::Draw() const
|
||||||
color.a = x18_splashTimeout * 2.f;
|
color.a = x18_splashTimeout * 2.f;
|
||||||
|
|
||||||
zeus::CRectangle rect;
|
zeus::CRectangle rect;
|
||||||
float aspect = CGraphics::g_ViewportResolution.x / float(CGraphics::g_ViewportResolution.y);
|
float aspect = g_Viewport.x8_width / float(g_Viewport.xc_height);
|
||||||
rect.size.x = m_quad.GetTex()->GetWidth() / (480.f * aspect);
|
rect.size.x = m_quad.GetTex()->GetWidth() / (480.f * aspect);
|
||||||
rect.size.y = m_quad.GetTex()->GetHeight() / 480.f;
|
rect.size.y = m_quad.GetTex()->GetHeight() / 480.f;
|
||||||
rect.position.x = 0.5f - rect.size.x / 2.f;
|
rect.position.x = 0.5f - rect.size.x / 2.f;
|
||||||
|
|
|
@ -2187,7 +2187,7 @@ void CFrontEndUI::Draw() const
|
||||||
g_Renderer->SetViewportOrtho(false, -4096.f, 4096.f);
|
g_Renderer->SetViewportOrtho(false, -4096.f, 4096.f);
|
||||||
|
|
||||||
/* Correct movie aspect ratio */
|
/* Correct movie aspect ratio */
|
||||||
float vpAspectRatio = CGraphics::g_ViewportResolution.x / float(CGraphics::g_ViewportResolution.y);
|
float vpAspectRatio = g_Viewport.x8_width / float(g_Viewport.xc_height);
|
||||||
float hPad, vPad;
|
float hPad, vPad;
|
||||||
if (vpAspectRatio >= 1.78f)
|
if (vpAspectRatio >= 1.78f)
|
||||||
{
|
{
|
||||||
|
|
|
@ -160,6 +160,7 @@ public:
|
||||||
void EnsureRendered(const CStateManager&, const zeus::CVector3f&, const zeus::CVector3f&);
|
void EnsureRendered(const CStateManager&, const zeus::CVector3f&, const zeus::CVector3f&);
|
||||||
SAdvancementDeltas UpdateAnimation(float, CStateManager&, bool);
|
SAdvancementDeltas UpdateAnimation(float, CStateManager&, bool);
|
||||||
void SetActorLights(std::unique_ptr<CActorLights>);
|
void SetActorLights(std::unique_ptr<CActorLights>);
|
||||||
|
bool GetE7_29() const { return xe7_29_; }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -176,6 +176,12 @@ void CAreaRenderOctTree::FindOverlappingModels(std::vector<u32>& out, const zeus
|
||||||
RecursiveBuildOverlaps(out.data(), *this, x18_aabb, testAABB);
|
RecursiveBuildOverlaps(out.data(), *this, x18_aabb, testAABB);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CAreaRenderOctTree::FindOverlappingModels(u32* out, const zeus::CAABox& testAABB) const
|
||||||
|
{
|
||||||
|
reinterpret_cast<Node*>(x38_entries[x34_indirectionTable[0]])->
|
||||||
|
RecursiveBuildOverlaps(out, *this, x18_aabb, testAABB);
|
||||||
|
}
|
||||||
|
|
||||||
void CGameArea::CAreaFog::SetCurrent() const
|
void CGameArea::CAreaFog::SetCurrent() const
|
||||||
{
|
{
|
||||||
g_Renderer->SetWorldFog(x0_fogMode, x4_rangeCur[0], x4_rangeCur[1], x1c_colorCur);
|
g_Renderer->SetWorldFog(x0_fogMode, x4_rangeCur[0], x4_rangeCur[1], x1c_colorCur);
|
||||||
|
|
|
@ -74,11 +74,13 @@ struct CAreaRenderOctTree
|
||||||
CAreaRenderOctTree(const u8* buf);
|
CAreaRenderOctTree(const u8* buf);
|
||||||
|
|
||||||
void FindOverlappingModels(std::vector<u32>& out, const zeus::CAABox& testAABB) const;
|
void FindOverlappingModels(std::vector<u32>& out, const zeus::CAABox& testAABB) const;
|
||||||
|
void FindOverlappingModels(u32* out, const zeus::CAABox& testAABB) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CGameArea : public IGameArea
|
class CGameArea : public IGameArea
|
||||||
{
|
{
|
||||||
friend class CWorld;
|
friend class CWorld;
|
||||||
|
friend class CStateManager;
|
||||||
|
|
||||||
int x4_selfIdx;
|
int x4_selfIdx;
|
||||||
ResId x8_nameSTRG;
|
ResId x8_nameSTRG;
|
||||||
|
|
|
@ -573,4 +573,12 @@ void CWorld::PropogateAreaChain(CGameArea::EOcclusionState occlusionState, CGame
|
||||||
if (occlusionState == CGameArea::EOcclusionState::NotOccluded)
|
if (occlusionState == CGameArea::EOcclusionState::NotOccluded)
|
||||||
area->SetOcclusionState(CGameArea::EOcclusionState::NotOccluded);
|
area->SetOcclusionState(CGameArea::EOcclusionState::NotOccluded);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CWorld::PreRender()
|
||||||
|
{
|
||||||
|
for (CGameArea* head = x4c_chainHeads[3] ; head != skGlobalNonConstEnd ; head = head->x130_next)
|
||||||
|
{
|
||||||
|
head->PreRender();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -184,6 +184,8 @@ public:
|
||||||
static void PropogateAreaChain(CGameArea::EOcclusionState, CGameArea*, CWorld*);
|
static void PropogateAreaChain(CGameArea::EOcclusionState, CGameArea*, CWorld*);
|
||||||
static const CGameArea* GetAliveAreasEnd() { return skGlobalEnd; }
|
static const CGameArea* GetAliveAreasEnd() { return skGlobalEnd; }
|
||||||
static CGameArea* AliveAreasEnd() { return skGlobalNonConstEnd; }
|
static CGameArea* AliveAreasEnd() { return skGlobalNonConstEnd; }
|
||||||
|
|
||||||
|
void PreRender();
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CWorldLayers
|
struct CWorldLayers
|
||||||
|
|
|
@ -279,8 +279,8 @@ void CWorldTransManager::DrawEnabled()
|
||||||
float t = zeus::clamp(0.f, (x0_curTime - x4_modelData->x1d0_dissolveStartTime) / 2.f, 1.f);
|
float t = zeus::clamp(0.f, (x0_curTime - x4_modelData->x1d0_dissolveStartTime) / 2.f, 1.f);
|
||||||
DrawFirstPass();
|
DrawFirstPass();
|
||||||
SClipScreenRect rect = {};
|
SClipScreenRect rect = {};
|
||||||
rect.xc_width = CGraphics::g_ViewportResolution.x;
|
rect.xc_width = g_Viewport.x8_width;
|
||||||
rect.x10_height = CGraphics::g_ViewportResolution.y;
|
rect.x10_height = g_Viewport.xc_height;
|
||||||
CGraphics::ResolveSpareTexture(rect);
|
CGraphics::ResolveSpareTexture(rect);
|
||||||
CGraphics::g_BooMainCommandQueue->clearTarget(true, true);
|
CGraphics::g_BooMainCommandQueue->clearTarget(true, true);
|
||||||
DrawSecondPass();
|
DrawSecondPass();
|
||||||
|
@ -308,7 +308,7 @@ void CWorldTransManager::DrawDisabled()
|
||||||
|
|
||||||
void CWorldTransManager::DrawText()
|
void CWorldTransManager::DrawText()
|
||||||
{
|
{
|
||||||
float vpAspectRatio = CGraphics::g_ViewportResolution.x / float(CGraphics::g_ViewportResolution.y);
|
float vpAspectRatio = g_Viewport.x8_width / float(g_Viewport.xc_height);
|
||||||
float width = 448.f * vpAspectRatio;
|
float width = 448.f * vpAspectRatio;
|
||||||
CGraphics::SetOrtho(0.f, width, 448.f, 0.f, -4096.f, 4096.f);
|
CGraphics::SetOrtho(0.f, width, 448.f, 0.f, -4096.f, 4096.f);
|
||||||
CGraphics::SetViewPointMatrix(zeus::CTransform::Identity());
|
CGraphics::SetViewPointMatrix(zeus::CTransform::Identity());
|
||||||
|
|
Loading…
Reference in New Issue