CCubeRenderer: more model darw imps

This commit is contained in:
Phillip Stephens 2022-03-06 13:01:25 -08:00
parent 7d07892198
commit aea7ac597a
Signed by: Antidote
GPG Key ID: F8BEE4C83DACA60D
3 changed files with 101 additions and 1 deletions

View File

@ -91,7 +91,10 @@ public:
void DrawSurfaceWireframe(const CCubeSurface& surface); void DrawSurfaceWireframe(const CCubeSurface& surface);
void SetArraysCurrent(); void SetArraysCurrent();
void SetUsingPackedLightmaps(bool v); void SetUsingPackedLightmaps(bool v);
zeus::CAABox GetBounds() const { return x20_worldAABB; }
u8 GetFlags() const { return x41_visorFlags; }
bool AreTexturesLoaded() const { return x40_24_texturesLoaded; } bool AreTexturesLoaded() const { return x40_24_texturesLoaded; }
void SetVisible(bool v) { x40_25_modelVisible = v; }
bool IsVisible() const { return x40_25_modelVisible; } bool IsVisible() const { return x40_25_modelVisible; }
[[nodiscard]] CCubeSurface* GetFirstUnsortedSurface() { return x38_firstUnsortedSurf; } [[nodiscard]] CCubeSurface* GetFirstUnsortedSurface() { return x38_firstUnsortedSurf; }
[[nodiscard]] const CCubeSurface* GetFirstUnsortedSurface() const { return x38_firstUnsortedSurf; } [[nodiscard]] const CCubeSurface* GetFirstUnsortedSurface() const { return x38_firstUnsortedSurf; }

View File

@ -257,7 +257,74 @@ void CCubeRenderer::EnablePVS(const CPVSVisSet& set, u32 areaIdx) {
void CCubeRenderer::DisablePVS() { xc8_pvs.reset(); } void CCubeRenderer::DisablePVS() { xc8_pvs.reset(); }
void CCubeRenderer::RemoveStaticGeometry(const std::vector<CMetroidModelInstance>* geometry) {} void CCubeRenderer::RemoveStaticGeometry(const std::vector<CMetroidModelInstance>* geometry) {}
void CCubeRenderer::DrawUnsortedGeometry(int areaIdx, int mask, int targetMask, bool shadowRender) {} void CCubeRenderer::DrawUnsortedGeometry(int areaIdx, int mask, int targetMask, bool shadowRender) {
SCOPED_GRAPHICS_DEBUG_GROUP("CBooRenderer::DrawUnsortedGeometry", zeus::skPurple);
SetupRendererStates(true);
CModelFlags flags;
CAreaListItem* lastOctreeItem = nullptr;
for (CAreaListItem& item : x1c_areaListItems) {
if (areaIdx != -1 && item.x18_areaIdx != areaIdx)
continue;
if (item.x4_octTree)
lastOctreeItem = &item;
CPVSVisSet* pvs = nullptr;
if (xc8_pvs)
pvs = &*xc8_pvs;
if (xe0_pvsAreaIdx != item.x18_areaIdx)
pvs = nullptr;
u32 idx = 0;
for (auto it = item.x10_models->begin(); it != item.x10_models->end(); ++it, ++idx) {
const auto& model = *it;
if (pvs) {
bool vis = pvs->GetVisible(idx) != EPVSVisSetState::EndOfTree;
switch (xc0_pvsMode) {
case EPVSMode::PVS: {
if (!vis) {
model->SetVisible(false);
continue;
}
break;
}
case EPVSMode::PVSAndMask: {
if (!vis && (model->GetFlags() & mask) != targetMask) {
model->SetVisible(false);
continue;
}
break;
}
default:
break;
}
}
if ((model->GetFlags() & mask) != targetMask) {
model->SetVisible(false);
continue;
}
if (!x44_frustumPlanes.aabbFrustumTest(model->GetBounds())) {
model->SetVisible(false);
continue;
}
if (x318_25_drawWireframe) {
model->SetVisible(false);
HandleUnsortedModelWireframe(lastOctreeItem, *model);
continue;
}
model->SetVisible(true);
HandleUnsortedModel(lastOctreeItem, *model, flags);
}
}
SetupCGraphicsState();
}
void CCubeRenderer::DrawSortedGeometry(int areaIdx, int mask, int targetMask) { void CCubeRenderer::DrawSortedGeometry(int areaIdx, int mask, int targetMask) {
SetupRendererStates(true); SetupRendererStates(true);
const CAreaListItem* item = nullptr; const CAreaListItem* item = nullptr;
@ -288,6 +355,31 @@ void CCubeRenderer::RenderBucketItems(const CAreaListItem* lights) {}
void CCubeRenderer::PostRenderFogs() {} void CCubeRenderer::PostRenderFogs() {}
void CCubeRenderer::SetModelMatrix(const zeus::CTransform& xf) { CGraphics::SetModelMatrix(xf); } void CCubeRenderer::SetModelMatrix(const zeus::CTransform& xf) { CGraphics::SetModelMatrix(xf); }
void CCubeRenderer::HandleUnsortedModel(CAreaListItem* areaItem, CCubeModel& model, const CModelFlags& flags) {
if (model.GetFirstUnsortedSurface() == nullptr) {
return;
}
model.SetArraysCurrent();
ActivateLightsForModel(areaItem, model);
for (auto *it = model.GetFirstUnsortedSurface(); it != nullptr; it = it->GetNextSurface()) {
model.DrawSurface(*it, CModelFlags(0, 0, 3, zeus::skWhite));
}
}
void CCubeRenderer::HandleUnsortedModelWireframe(CAreaListItem* areaItem, CCubeModel& model) {
model.SetArraysCurrent();
ActivateLightsForModel(areaItem, model);
for (auto* it = model.GetFirstUnsortedSurface(); it != nullptr; it = it->GetNextSurface()) {
model.DrawSurfaceWireframe(*it);
}
for (auto* it = model.GetFirstSortedSurface(); it != nullptr; it = it->GetNextSurface()) {
model.DrawSurfaceWireframe(*it);
}
}
void CCubeRenderer::ActivateLightsForModel(CAreaListItem* areaItem, CCubeModel& model) {
}
void CCubeRenderer::AddParticleGen(CParticleGen& gen) { void CCubeRenderer::AddParticleGen(CParticleGen& gen) {
auto bounds = gen.GetBounds(); auto bounds = gen.GetBounds();

View File

@ -212,6 +212,11 @@ public:
void RenderBucketItems(const CAreaListItem* lights); void RenderBucketItems(const CAreaListItem* lights);
void DrawRenderBucketsDebug() {} void DrawRenderBucketsDebug() {}
void HandleUnsortedModel(CAreaListItem* areaItem, CCubeModel& model, const CModelFlags& flags);
void HandleUnsortedModelWireframe(CAreaListItem* areaItem, CCubeModel& model);
void ActivateLightsForModel(CAreaListItem* areaItem, CCubeModel& model);
// Getters // Getters
[[nodiscard]] bool IsInAreaDraw() const { return x318_30_inAreaDraw; } [[nodiscard]] bool IsInAreaDraw() const { return x318_30_inAreaDraw; }
[[nodiscard]] bool IsReflectionDirty() const { return x318_24_refectionDirty; } [[nodiscard]] bool IsReflectionDirty() const { return x318_24_refectionDirty; }