mirror of https://github.com/AxioDL/metaforce.git
CCubeRenderer: More rendering imps
This commit is contained in:
parent
aea7ac597a
commit
35674c27e5
|
@ -66,7 +66,7 @@ void Buckets::Sort() {
|
||||||
precision = 50 / u32(sPlaneObjectBucket->size() + 1);
|
precision = 50 / u32(sPlaneObjectBucket->size() + 1);
|
||||||
pitch = 1.f / (delta / float(precision - 2));
|
pitch = 1.f / (delta / float(precision - 2));
|
||||||
|
|
||||||
int accum = 0;
|
s32 accum = 0;
|
||||||
for (u16 idx : *sPlaneObjectBucket) {
|
for (u16 idx : *sPlaneObjectBucket) {
|
||||||
++accum;
|
++accum;
|
||||||
CDrawablePlaneObject& planeObj = (*sPlaneObjectData)[idx];
|
CDrawablePlaneObject& planeObj = (*sPlaneObjectData)[idx];
|
||||||
|
@ -75,12 +75,12 @@ void Buckets::Sort() {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (CDrawable& drawable : *sData) {
|
for (CDrawable& drawable : *sData) {
|
||||||
int slot;
|
s32 slot;
|
||||||
float relDist = drawable.GetDistance() - sMinMaxDistance[0];
|
float relDist = drawable.GetDistance() - sMinMaxDistance[0];
|
||||||
if (sPlaneObjectBucket->empty()) {
|
if (sPlaneObjectBucket->empty()) {
|
||||||
slot = zeus::clamp(1, int(relDist * pitch), 49);
|
slot = zeus::clamp(1, s32(relDist * pitch), 49);
|
||||||
} else {
|
} else {
|
||||||
slot = zeus::clamp(0, int(relDist * pitch), int(precision) - 2);
|
slot = zeus::clamp(0, s32(relDist * pitch), s32(precision) - 2);
|
||||||
for (u16 idx : *sPlaneObjectBucket) {
|
for (u16 idx : *sPlaneObjectBucket) {
|
||||||
CDrawablePlaneObject& planeObj = (*sPlaneObjectData)[idx];
|
CDrawablePlaneObject& planeObj = (*sPlaneObjectData)[idx];
|
||||||
bool partial, full;
|
bool partial, full;
|
||||||
|
@ -175,7 +175,7 @@ CCubeRenderer::CAreaListItem::CAreaListItem(const std::vector<CMetroidModelInsta
|
||||||
const CAreaRenderOctTree* octTree,
|
const CAreaRenderOctTree* octTree,
|
||||||
std::unique_ptr<std::vector<TCachedToken<CTexture>>>&& textures,
|
std::unique_ptr<std::vector<TCachedToken<CTexture>>>&& textures,
|
||||||
std::unique_ptr<std::vector<std::unique_ptr<CCubeModel>>>&& models,
|
std::unique_ptr<std::vector<std::unique_ptr<CCubeModel>>>&& models,
|
||||||
int areaIdx)
|
s32 areaIdx)
|
||||||
: x0_geometry(geom)
|
: x0_geometry(geom)
|
||||||
, x4_octTree(octTree)
|
, x4_octTree(octTree)
|
||||||
, x8_textures(std::move(textures))
|
, x8_textures(std::move(textures))
|
||||||
|
@ -217,7 +217,7 @@ void CCubeRenderer::AddWorldSurfaces(CCubeModel& model) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void CCubeRenderer::AddStaticGeometry(const std::vector<CMetroidModelInstance>* geometry,
|
void CCubeRenderer::AddStaticGeometry(const std::vector<CMetroidModelInstance>* geometry,
|
||||||
const CAreaRenderOctTree* octTree, int areaIdx) {
|
const CAreaRenderOctTree* octTree, s32 areaIdx) {
|
||||||
auto search = FindStaticGeometry(geometry);
|
auto search = FindStaticGeometry(geometry);
|
||||||
if (search == x1c_areaListItems.end()) {
|
if (search == x1c_areaListItems.end()) {
|
||||||
auto textures = std::make_unique<std::vector<TCachedToken<CTexture>>>();
|
auto textures = std::make_unique<std::vector<TCachedToken<CTexture>>>();
|
||||||
|
@ -225,7 +225,7 @@ void CCubeRenderer::AddStaticGeometry(const std::vector<CMetroidModelInstance>*
|
||||||
if (!geometry->empty()) {
|
if (!geometry->empty()) {
|
||||||
CCubeModel::MakeTexturesFromMats((*geometry)[0].GetMaterialPointer(), *textures.get(), &xc_store, false);
|
CCubeModel::MakeTexturesFromMats((*geometry)[0].GetMaterialPointer(), *textures.get(), &xc_store, false);
|
||||||
models->reserve(geometry->size());
|
models->reserve(geometry->size());
|
||||||
int instIdx = 0;
|
s32 instIdx = 0;
|
||||||
for (const CMetroidModelInstance& inst : *geometry) {
|
for (const CMetroidModelInstance& inst : *geometry) {
|
||||||
models->emplace_back(
|
models->emplace_back(
|
||||||
std::make_unique<CCubeModel>(const_cast<std::vector<CCubeSurface>*>(inst.GetSurfaces()), textures.get(),
|
std::make_unique<CCubeModel>(const_cast<std::vector<CCubeSurface>*>(inst.GetSurfaces()), textures.get(),
|
||||||
|
@ -256,30 +256,40 @@ 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) {
|
auto search = FindStaticGeometry(geometry);
|
||||||
SCOPED_GRAPHICS_DEBUG_GROUP("CBooRenderer::DrawUnsortedGeometry", zeus::skPurple);
|
if (search != x1c_areaListItems.end()) {
|
||||||
|
x1c_areaListItems.erase(search);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CCubeRenderer::DrawUnsortedGeometry(s32 areaIdx, s32 mask, s32 targetMask, bool shadowRender) {
|
||||||
SetupRendererStates(true);
|
SetupRendererStates(true);
|
||||||
CModelFlags flags;
|
CModelFlags flags;
|
||||||
CAreaListItem* lastOctreeItem = nullptr;
|
CAreaListItem* lastOctreeItem = nullptr;
|
||||||
|
|
||||||
for (CAreaListItem& item : x1c_areaListItems) {
|
for (CAreaListItem& item : x1c_areaListItems) {
|
||||||
if (areaIdx != -1 && item.x18_areaIdx != areaIdx)
|
if (areaIdx != -1 && item.x18_areaIdx != areaIdx) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (item.x4_octTree)
|
if (item.x4_octTree != nullptr) {
|
||||||
lastOctreeItem = &item;
|
lastOctreeItem = &item;
|
||||||
|
}
|
||||||
|
|
||||||
CPVSVisSet* pvs = nullptr;
|
CPVSVisSet* pvs = nullptr;
|
||||||
if (xc8_pvs)
|
if (xc8_pvs) {
|
||||||
pvs = &*xc8_pvs;
|
pvs = &*xc8_pvs;
|
||||||
if (xe0_pvsAreaIdx != item.x18_areaIdx)
|
}
|
||||||
|
|
||||||
|
if (xe0_pvsAreaIdx != item.x18_areaIdx) {
|
||||||
pvs = nullptr;
|
pvs = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
u32 idx = 0;
|
u32 idx = 0;
|
||||||
for (auto it = item.x10_models->begin(); it != item.x10_models->end(); ++it, ++idx) {
|
for (auto it = item.x10_models->begin(); it != item.x10_models->end(); ++it, ++idx) {
|
||||||
const auto& model = *it;
|
const auto& model = *it;
|
||||||
if (pvs) {
|
if (pvs != nullptr) {
|
||||||
bool vis = pvs->GetVisible(idx) != EPVSVisSetState::EndOfTree;
|
bool vis = pvs->GetVisible(idx) != EPVSVisSetState::EndOfTree;
|
||||||
switch (xc0_pvsMode) {
|
switch (xc0_pvsMode) {
|
||||||
case EPVSMode::PVS: {
|
case EPVSMode::PVS: {
|
||||||
|
@ -325,7 +335,7 @@ void CCubeRenderer::DrawUnsortedGeometry(int areaIdx, int mask, int targetMask,
|
||||||
SetupCGraphicsState();
|
SetupCGraphicsState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCubeRenderer::DrawSortedGeometry(int areaIdx, int mask, int targetMask) {
|
void CCubeRenderer::DrawSortedGeometry(s32 areaIdx, s32 mask, s32 targetMask) {
|
||||||
SetupRendererStates(true);
|
SetupRendererStates(true);
|
||||||
const CAreaListItem* item = nullptr;
|
const CAreaListItem* item = nullptr;
|
||||||
for (const auto& areaListItem : x1c_areaListItems) {
|
for (const auto& areaListItem : x1c_areaListItems) {
|
||||||
|
@ -348,10 +358,96 @@ void CCubeRenderer::DrawSortedGeometry(int areaIdx, int mask, int targetMask) {
|
||||||
Buckets::Clear();
|
Buckets::Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCubeRenderer::DrawStaticGeometry(int areaIdx, int mask, int targetMask) {}
|
void CCubeRenderer::DrawStaticGeometry(s32 areaIdx, s32 mask, s32 targetMask) {
|
||||||
void CCubeRenderer::DrawAreaGeometry(int areaIdx, int mask, int targetMask) {}
|
DrawUnsortedGeometry(areaIdx, mask, targetMask);
|
||||||
|
DrawSortedGeometry(areaIdx, mask, targetMask);
|
||||||
|
}
|
||||||
|
|
||||||
void CCubeRenderer::RenderBucketItems(const CAreaListItem* lights) {}
|
void CCubeRenderer::DrawAreaGeometry(s32 areaIdx, s32 mask, s32 targetMask) {
|
||||||
|
x318_30_inAreaDraw = true;
|
||||||
|
SetupRendererStates(true);
|
||||||
|
CModelFlags flags;
|
||||||
|
|
||||||
|
for (CAreaListItem& item : x1c_areaListItems) {
|
||||||
|
if (areaIdx != -1 || item.x18_areaIdx == areaIdx) {
|
||||||
|
CPVSVisSet* pvs = xc8_pvs ? &*xc8_pvs : nullptr;
|
||||||
|
if (xe0_pvsAreaIdx != item.x18_areaIdx) {
|
||||||
|
pvs = nullptr;
|
||||||
|
}
|
||||||
|
s32 modelIdx = 0;
|
||||||
|
for (auto it = item.x10_models->begin(); it != item.x10_models->end(); ++it, ++modelIdx) {
|
||||||
|
const auto& model = *it;
|
||||||
|
if (pvs != nullptr) {
|
||||||
|
bool visible = pvs->GetVisible(modelIdx) != EPVSVisSetState::EndOfTree;
|
||||||
|
if ((xc0_pvsMode == EPVSMode::PVS && !visible) || (xc0_pvsMode == EPVSMode::PVSAndMask && visible)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((model->GetFlags() & mask) != targetMask) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!x44_frustumPlanes.aabbFrustumTest(model->GetBounds())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const auto* surf = model->GetFirstUnsortedSurface(); surf != nullptr; surf = surf->GetNextSurface()) {
|
||||||
|
model->DrawSurface(*surf, CModelFlags(0, 0, 3, zeus::skWhite));
|
||||||
|
}
|
||||||
|
for (const auto* surf = model->GetFirstSortedSurface(); surf != nullptr; surf = surf->GetNextSurface()) {
|
||||||
|
model->DrawSurface(*surf, CModelFlags(0, 0, 3, zeus::skWhite));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
x318_30_inAreaDraw = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CCubeRenderer::RenderBucketItems(const CAreaListItem* item) {
|
||||||
|
CCubeModel* lastModel = nullptr;
|
||||||
|
EDrawableType lastDrawableType = EDrawableType::Invalid;
|
||||||
|
for (u16 idx : Buckets::sBucketIndex) {
|
||||||
|
rstl::reserved_vector<CDrawable*, 128>& bucket = (*Buckets::sBuckets)[idx];
|
||||||
|
for (CDrawable* drawable : bucket) {
|
||||||
|
EDrawableType type = drawable->GetType();
|
||||||
|
switch (type) {
|
||||||
|
case EDrawableType::Particle: {
|
||||||
|
if (lastDrawableType != EDrawableType::Particle) {
|
||||||
|
SetupCGraphicsState();
|
||||||
|
}
|
||||||
|
|
||||||
|
static_cast<CParticleGen*>(drawable->GetData())->Render();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case EDrawableType::WorldSurface: {
|
||||||
|
if (lastDrawableType != EDrawableType::WorldSurface) {
|
||||||
|
SetupRendererStates(false);
|
||||||
|
lastModel = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto* surface = static_cast<CCubeSurface*>(drawable->GetData());
|
||||||
|
auto* model = surface->GetParent();
|
||||||
|
if (model != lastModel) {
|
||||||
|
model->SetArraysCurrent();
|
||||||
|
ActivateLightsForModel(item, *model);
|
||||||
|
}
|
||||||
|
model->DrawSurface(*surface, CModelFlags(0, 0, 1, zeus::skWhite));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
if (type != lastDrawableType) {
|
||||||
|
CCubeMaterial::EnsureTevsDirect();
|
||||||
|
}
|
||||||
|
if (xa8_drawableCallback != nullptr) {
|
||||||
|
xa8_drawableCallback(drawable->GetData(), xac_drawableCallbackUserData, s32(drawable->GetType()) - 2);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lastDrawableType = type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
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); }
|
||||||
|
|
||||||
|
@ -377,9 +473,7 @@ void CCubeRenderer::HandleUnsortedModelWireframe(CAreaListItem* areaItem, CCubeM
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCubeRenderer::ActivateLightsForModel(CAreaListItem* areaItem, CCubeModel& model) {
|
void CCubeRenderer::ActivateLightsForModel(const CAreaListItem* areaItem, CCubeModel& model) {}
|
||||||
|
|
||||||
}
|
|
||||||
void CCubeRenderer::AddParticleGen(CParticleGen& gen) {
|
void CCubeRenderer::AddParticleGen(CParticleGen& gen) {
|
||||||
auto bounds = gen.GetBounds();
|
auto bounds = gen.GetBounds();
|
||||||
|
|
||||||
|
@ -393,33 +487,22 @@ void CCubeRenderer::AddParticleGen(CParticleGen& gen, const zeus::CVector3f& pos
|
||||||
Buckets::Insert(pos, bounds, EDrawableType::Particle, reinterpret_cast<void*>(&gen), xb0_viewPlane, 0);
|
Buckets::Insert(pos, bounds, EDrawableType::Particle, reinterpret_cast<void*>(&gen), xb0_viewPlane, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCubeRenderer::AddPlaneObject(void* obj, const zeus::CAABox& aabb, const zeus::CPlane& plane, int type) {
|
void CCubeRenderer::AddPlaneObject(void* obj, const zeus::CAABox& aabb, const zeus::CPlane& plane, s32 type) {
|
||||||
|
|
||||||
auto closestPoint = aabb.closestPointAlongVector(xb0_viewPlane.normal());
|
const auto closestPoint = aabb.closestPointAlongVector(xb0_viewPlane.normal());
|
||||||
auto closestDist = xb0_viewPlane.pointToPlaneDist(closestPoint);
|
const auto closestDist = xb0_viewPlane.pointToPlaneDist(closestPoint);
|
||||||
auto furthestPoint = aabb.furthestPointAlongVector(xb0_viewPlane.normal());
|
const auto furthestPoint = aabb.furthestPointAlongVector(xb0_viewPlane.normal());
|
||||||
auto furthestDist = xb0_viewPlane.pointToPlaneDist(furthestPoint);
|
const auto furthestDist = xb0_viewPlane.pointToPlaneDist(furthestPoint);
|
||||||
|
|
||||||
if (closestDist >= 0.f || furthestDist >= 0.f) {
|
if (closestDist >= 0.f || furthestDist >= 0.f) {
|
||||||
bool zOnly = false;
|
const bool zOnly = plane.normal() == zeus::skUp;
|
||||||
if (plane.normal() == zeus::skUp) {
|
const bool invertTest = zOnly ? CGraphics::g_GXModelView.origin.z() >= plane.d()
|
||||||
zOnly = true;
|
: plane.pointToPlaneDist(CGraphics::g_GXModelView.origin) >= 0.f;
|
||||||
}
|
|
||||||
|
|
||||||
bool invertTest = false;
|
|
||||||
if (zOnly) {
|
|
||||||
invertTest = CGraphics::g_GXModelView.origin.z() >= plane.d();
|
|
||||||
} else if (plane.pointToPlaneDist(CGraphics::g_GXModelView.origin) < 0.f) {
|
|
||||||
invertTest = false;
|
|
||||||
} else {
|
|
||||||
invertTest = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Buckets::InsertPlaneObject(closestDist, furthestDist, aabb, invertTest, plane, zOnly, EDrawableType(type + 2), obj);
|
Buckets::InsertPlaneObject(closestDist, furthestDist, aabb, invertTest, plane, zOnly, EDrawableType(type + 2), obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCubeRenderer::AddDrawable(void* obj, const zeus::CVector3f& pos, const zeus::CAABox& aabb, int mode,
|
void CCubeRenderer::AddDrawable(void* obj, const zeus::CVector3f& pos, const zeus::CAABox& aabb, s32 mode,
|
||||||
IRenderer::EDrawableSorting sorting) {
|
IRenderer::EDrawableSorting sorting) {
|
||||||
if (sorting == EDrawableSorting::UnsortedCallback) {
|
if (sorting == EDrawableSorting::UnsortedCallback) {
|
||||||
xa8_drawableCallback(obj, xac_drawableCallbackUserData, mode);
|
xa8_drawableCallback(obj, xac_drawableCallbackUserData, mode);
|
||||||
|
@ -464,7 +547,7 @@ std::pair<zeus::CVector2f, zeus::CVector2f> CCubeRenderer::SetViewportOrtho(bool
|
||||||
|
|
||||||
void CCubeRenderer::SetClippingPlanes(const zeus::CFrustum& frustum) { x44_frustumPlanes = frustum; }
|
void CCubeRenderer::SetClippingPlanes(const zeus::CFrustum& frustum) { x44_frustumPlanes = frustum; }
|
||||||
|
|
||||||
void CCubeRenderer::SetViewport(int left, int bottom, int width, int height) {
|
void CCubeRenderer::SetViewport(s32 left, s32 bottom, s32 width, s32 height) {
|
||||||
CGraphics::SetViewport(left, bottom, width, height);
|
CGraphics::SetViewport(left, bottom, width, height);
|
||||||
CGraphics::SetScissor(left, bottom, width, height);
|
CGraphics::SetScissor(left, bottom, width, height);
|
||||||
}
|
}
|
||||||
|
@ -508,7 +591,7 @@ void CCubeRenderer::EndScene() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCubeRenderer::SetDebugOption(IRenderer::EDebugOption option, int value) {
|
void CCubeRenderer::SetDebugOption(IRenderer::EDebugOption option, s32 value) {
|
||||||
if (option == EDebugOption::PVSState) {
|
if (option == EDebugOption::PVSState) {
|
||||||
xc8_pvs->SetState(EPVSVisSetState(value));
|
xc8_pvs->SetState(EPVSVisSetState(value));
|
||||||
} else if (option == EDebugOption::PVSMode) {
|
} else if (option == EDebugOption::PVSMode) {
|
||||||
|
@ -543,7 +626,7 @@ void CCubeRenderer::EndPrimitive() {
|
||||||
CGraphics::StreamEnd();
|
CGraphics::StreamEnd();
|
||||||
}
|
}
|
||||||
void CCubeRenderer::SetAmbientColor(const zeus::CColor& color) { CGraphics::SetAmbientColor(color); }
|
void CCubeRenderer::SetAmbientColor(const zeus::CColor& color) { CGraphics::SetAmbientColor(color); }
|
||||||
void CCubeRenderer::DrawString(const char* string, int x, int y) { x10_font.DrawString(string, x, y, zeus::skWhite); }
|
void CCubeRenderer::DrawString(const char* string, s32 x, s32 y) { x10_font.DrawString(string, x, y, zeus::skWhite); }
|
||||||
|
|
||||||
u32 CCubeRenderer::GetFPS() { return CGraphics::GetFPS(); }
|
u32 CCubeRenderer::GetFPS() { return CGraphics::GetFPS(); }
|
||||||
void CCubeRenderer::CacheReflection(IRenderer::TReflectionCallback cb, void* ctx, bool clearAfter) {}
|
void CCubeRenderer::CacheReflection(IRenderer::TReflectionCallback cb, void* ctx, bool clearAfter) {}
|
||||||
|
@ -553,7 +636,7 @@ void CCubeRenderer::DrawThermalModel(const CModel& model, const zeus::CColor& mu
|
||||||
void CCubeRenderer::DrawModelDisintegrate(const CModel& model, const CTexture& tex, const zeus::CColor& color,
|
void CCubeRenderer::DrawModelDisintegrate(const CModel& model, const CTexture& tex, const zeus::CColor& color,
|
||||||
TVectorRef positions, TVectorRef normals) {}
|
TVectorRef positions, TVectorRef normals) {}
|
||||||
void CCubeRenderer::DrawModelFlat(const CModel& model, const CModelFlags& flags, bool unsortedOnly) {}
|
void CCubeRenderer::DrawModelFlat(const CModel& model, const CModelFlags& flags, bool unsortedOnly) {}
|
||||||
void CCubeRenderer::SetWireframeFlags(int flags) {}
|
void CCubeRenderer::SetWireframeFlags(s32 flags) {}
|
||||||
void CCubeRenderer::SetWorldFog(ERglFogMode mode, float startz, float endz, const zeus::CColor& color) {}
|
void CCubeRenderer::SetWorldFog(ERglFogMode mode, float startz, float endz, const zeus::CColor& color) {}
|
||||||
void CCubeRenderer::RenderFogVolume(const zeus::CColor& color, const zeus::CAABox& aabb,
|
void CCubeRenderer::RenderFogVolume(const zeus::CColor& color, const zeus::CAABox& aabb,
|
||||||
const TLockedToken<CModel>* model, const CSkinnedModel* sModel) {}
|
const TLockedToken<CModel>* model, const CSkinnedModel* sModel) {}
|
||||||
|
@ -583,11 +666,13 @@ CCubeRenderer::FindStaticGeometry(const std::vector<CMetroidModelInstance>* geom
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCubeRenderer::FindOverlappingWorldModels(std::vector<u32>& modelBits, const zeus::CAABox& aabb) const {}
|
void CCubeRenderer::FindOverlappingWorldModels(std::vector<u32>& modelBits, const zeus::CAABox& aabb) const {}
|
||||||
int CCubeRenderer::DrawOverlappingWorldModelIDs(int alphaVal, const std::vector<u32>& modelBits,
|
s32 CCubeRenderer::DrawOverlappingWorldModelIDs(s32 alphaVal, const std::vector<u32>& modelBits,
|
||||||
const zeus::CAABox& aabb) {
|
const zeus::CAABox& aabb) {
|
||||||
|
SetupRendererStates(true);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
void CCubeRenderer::DrawOverlappingWorldModelShadows(int alphaVal, const std::vector<u32>& modelBits,
|
void CCubeRenderer::DrawOverlappingWorldModelShadows(s32 alphaVal, const std::vector<u32>& modelBits,
|
||||||
const zeus::CAABox& aabb, float alpha) {}
|
const zeus::CAABox& aabb, float alpha) {}
|
||||||
|
|
||||||
void CCubeRenderer::SetupCGraphicsState() {
|
void CCubeRenderer::SetupCGraphicsState() {
|
||||||
|
|
|
@ -25,13 +25,13 @@ class CCubeRenderer final : public IRenderer {
|
||||||
/* originally auto_ptrs of vectors */
|
/* originally auto_ptrs of vectors */
|
||||||
std::unique_ptr<std::vector<TCachedToken<CTexture>>> x8_textures;
|
std::unique_ptr<std::vector<TCachedToken<CTexture>>> x8_textures;
|
||||||
std::unique_ptr<std::vector<std::unique_ptr<CCubeModel>>> x10_models;
|
std::unique_ptr<std::vector<std::unique_ptr<CCubeModel>>> x10_models;
|
||||||
int x18_areaIdx;
|
s32 x18_areaIdx;
|
||||||
/* Per-area octree-word major, light bits minor */
|
/* Per-area octree-word major, light bits minor */
|
||||||
std::vector<u32> x1c_lightOctreeWords;
|
std::vector<u32> x1c_lightOctreeWords;
|
||||||
|
|
||||||
CAreaListItem(const std::vector<CMetroidModelInstance>* geom, const CAreaRenderOctTree* octTree,
|
CAreaListItem(const std::vector<CMetroidModelInstance>* geom, const CAreaRenderOctTree* octTree,
|
||||||
std::unique_ptr<std::vector<TCachedToken<CTexture>>>&& textures,
|
std::unique_ptr<std::vector<TCachedToken<CTexture>>>&& textures,
|
||||||
std::unique_ptr<std::vector<std::unique_ptr<CCubeModel>>>&& models, int areaIdx);
|
std::unique_ptr<std::vector<std::unique_ptr<CCubeModel>>>&& models, s32 areaIdx);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CFogVolumeListItem {
|
struct CFogVolumeListItem {
|
||||||
|
@ -109,20 +109,20 @@ public:
|
||||||
|
|
||||||
void AddWorldSurfaces(CCubeModel& model);
|
void AddWorldSurfaces(CCubeModel& model);
|
||||||
void AddStaticGeometry(const std::vector<CMetroidModelInstance>* geometry, const CAreaRenderOctTree* octTree,
|
void AddStaticGeometry(const std::vector<CMetroidModelInstance>* geometry, const CAreaRenderOctTree* octTree,
|
||||||
int areaIdx) override;
|
s32 areaIdx) override;
|
||||||
void EnablePVS(const CPVSVisSet& set, u32 areaIdx) override;
|
void EnablePVS(const CPVSVisSet& set, u32 areaIdx) override;
|
||||||
void DisablePVS() override;
|
void DisablePVS() override;
|
||||||
void RemoveStaticGeometry(const std::vector<CMetroidModelInstance>* geometry) override;
|
void RemoveStaticGeometry(const std::vector<CMetroidModelInstance>* geometry) override;
|
||||||
void DrawUnsortedGeometry(int areaIdx, int mask, int targetMask, bool shadowRender = false) override;
|
void DrawUnsortedGeometry(s32 areaIdx, s32 mask, s32 targetMask, bool shadowRender = false) override;
|
||||||
void DrawSortedGeometry(int areaIdx, int mask, int targetMask) override;
|
void DrawSortedGeometry(s32 areaIdx, s32 mask, s32 targetMask) override;
|
||||||
void DrawStaticGeometry(int areaIdx, int mask, int targetMask) override;
|
void DrawStaticGeometry(s32 areaIdx, s32 mask, s32 targetMask) override;
|
||||||
void DrawAreaGeometry(int areaIdx, int mask, int targetMask) override;
|
void DrawAreaGeometry(s32 areaIdx, s32 mask, s32 targetMask) override;
|
||||||
void PostRenderFogs() override;
|
void PostRenderFogs() override;
|
||||||
void SetModelMatrix(const zeus::CTransform& xf) override;
|
void SetModelMatrix(const zeus::CTransform& xf) override;
|
||||||
void AddParticleGen(CParticleGen& gen) override;
|
void AddParticleGen(CParticleGen& gen) override;
|
||||||
void AddParticleGen(CParticleGen& gen, const zeus::CVector3f& pos, const zeus::CAABox& bounds) override;
|
void AddParticleGen(CParticleGen& gen, const zeus::CVector3f& pos, const zeus::CAABox& bounds) override;
|
||||||
void AddPlaneObject(void* obj, const zeus::CAABox& aabb, const zeus::CPlane& plane, int type) override;
|
void AddPlaneObject(void* obj, const zeus::CAABox& aabb, const zeus::CPlane& plane, s32 type) override;
|
||||||
void AddDrawable(void* obj, const zeus::CVector3f& pos, const zeus::CAABox& aabb, int mode,
|
void AddDrawable(void* obj, const zeus::CVector3f& pos, const zeus::CAABox& aabb, s32 mode,
|
||||||
EDrawableSorting sorting) override;
|
EDrawableSorting sorting) override;
|
||||||
void SetDrawableCallback(TDrawableCallback cb, void* ctx) override;
|
void SetDrawableCallback(TDrawableCallback cb, void* ctx) override;
|
||||||
void SetWorldViewpoint(const zeus::CTransform& xf) override;
|
void SetWorldViewpoint(const zeus::CTransform& xf) override;
|
||||||
|
@ -130,7 +130,7 @@ public:
|
||||||
void SetPerspective(float fovy, float width, float height, float znear, float zfar) override;
|
void SetPerspective(float fovy, float width, float height, float znear, float zfar) override;
|
||||||
std::pair<zeus::CVector2f, zeus::CVector2f> SetViewportOrtho(bool centered, float znear, float zfar) override;
|
std::pair<zeus::CVector2f, zeus::CVector2f> SetViewportOrtho(bool centered, float znear, float zfar) override;
|
||||||
void SetClippingPlanes(const zeus::CFrustum& frustum) override;
|
void SetClippingPlanes(const zeus::CFrustum& frustum) override;
|
||||||
void SetViewport(int left, int right, int width, int height) override;
|
void SetViewport(s32 left, s32 right, s32 width, s32 height) override;
|
||||||
void SetDepthReadWrite(bool read, bool write) override {
|
void SetDepthReadWrite(bool read, bool write) override {
|
||||||
CGraphics::SetDepthWriteMode(read, ERglEnum::LEqual, write);
|
CGraphics::SetDepthWriteMode(read, ERglEnum::LEqual, write);
|
||||||
}
|
}
|
||||||
|
@ -162,8 +162,8 @@ public:
|
||||||
}
|
}
|
||||||
void BeginScene() override;
|
void BeginScene() override;
|
||||||
void EndScene() override;
|
void EndScene() override;
|
||||||
void SetDebugOption(EDebugOption, int) override;
|
void SetDebugOption(EDebugOption, s32) override;
|
||||||
void BeginPrimitive(EPrimitiveType, int) override;
|
void BeginPrimitive(EPrimitiveType, s32) override;
|
||||||
void BeginLines(int) override;
|
void BeginLines(int) override;
|
||||||
void BeginLineStrip(int) override;
|
void BeginLineStrip(int) override;
|
||||||
void BeginTriangles(int) override;
|
void BeginTriangles(int) override;
|
||||||
|
@ -175,7 +175,7 @@ public:
|
||||||
void PrimColor(const zeus::CColor&) override;
|
void PrimColor(const zeus::CColor&) override;
|
||||||
void EndPrimitive() override;
|
void EndPrimitive() override;
|
||||||
void SetAmbientColor(const zeus::CColor& color) override;
|
void SetAmbientColor(const zeus::CColor& color) override;
|
||||||
void DrawString(const char* string, int, int) override;
|
void DrawString(const char* string, s32, s32) override;
|
||||||
u32 GetFPS() override;
|
u32 GetFPS() override;
|
||||||
void CacheReflection(TReflectionCallback cb, void* ctx, bool clearAfter) override;
|
void CacheReflection(TReflectionCallback cb, void* ctx, bool clearAfter) override;
|
||||||
void DrawSpaceWarp(const zeus::CVector3f& pt, float strength) override;
|
void DrawSpaceWarp(const zeus::CVector3f& pt, float strength) override;
|
||||||
|
@ -184,7 +184,7 @@ public:
|
||||||
void DrawModelDisintegrate(const CModel& model, const CTexture& tex, const zeus::CColor& color, TVectorRef positions,
|
void DrawModelDisintegrate(const CModel& model, const CTexture& tex, const zeus::CColor& color, TVectorRef positions,
|
||||||
TVectorRef normals) override;
|
TVectorRef normals) override;
|
||||||
void DrawModelFlat(const CModel& model, const CModelFlags& flags, bool unsortedOnly) override;
|
void DrawModelFlat(const CModel& model, const CModelFlags& flags, bool unsortedOnly) override;
|
||||||
void SetWireframeFlags(int flags) override;
|
void SetWireframeFlags(s32 flags) override;
|
||||||
void SetWorldFog(ERglFogMode mode, float startz, float endz, const zeus::CColor& color) override;
|
void SetWorldFog(ERglFogMode mode, float startz, float endz, const zeus::CColor& color) override;
|
||||||
void RenderFogVolume(const zeus::CColor& color, const zeus::CAABox& aabb, const TLockedToken<CModel>* model,
|
void RenderFogVolume(const zeus::CColor& color, const zeus::CAABox& aabb, const TLockedToken<CModel>* model,
|
||||||
const CSkinnedModel* sModel) override;
|
const CSkinnedModel* sModel) override;
|
||||||
|
@ -206,8 +206,8 @@ public:
|
||||||
void DrawXRayOutline(const zeus::CAABox& aabb);
|
void DrawXRayOutline(const zeus::CAABox& aabb);
|
||||||
std::list<CAreaListItem>::iterator FindStaticGeometry(const std::vector<CMetroidModelInstance>* geometry);
|
std::list<CAreaListItem>::iterator FindStaticGeometry(const std::vector<CMetroidModelInstance>* geometry);
|
||||||
void FindOverlappingWorldModels(std::vector<u32>& modelBits, const zeus::CAABox& aabb) const;
|
void FindOverlappingWorldModels(std::vector<u32>& modelBits, const zeus::CAABox& aabb) const;
|
||||||
int DrawOverlappingWorldModelIDs(int alphaVal, const std::vector<u32>& modelBits, const zeus::CAABox& aabb);
|
s32 DrawOverlappingWorldModelIDs(s32 alphaVal, const std::vector<u32>& modelBits, const zeus::CAABox& aabb);
|
||||||
void DrawOverlappingWorldModelShadows(int alphaVal, const std::vector<u32>& modelBits, const zeus::CAABox& aabb,
|
void DrawOverlappingWorldModelShadows(s32 alphaVal, const std::vector<u32>& modelBits, const zeus::CAABox& aabb,
|
||||||
float alpha);
|
float alpha);
|
||||||
void RenderBucketItems(const CAreaListItem* lights);
|
void RenderBucketItems(const CAreaListItem* lights);
|
||||||
void DrawRenderBucketsDebug() {}
|
void DrawRenderBucketsDebug() {}
|
||||||
|
@ -215,13 +215,21 @@ public:
|
||||||
void HandleUnsortedModel(CAreaListItem* areaItem, CCubeModel& model, const CModelFlags& flags);
|
void HandleUnsortedModel(CAreaListItem* areaItem, CCubeModel& model, const CModelFlags& flags);
|
||||||
void HandleUnsortedModelWireframe(CAreaListItem* areaItem, CCubeModel& model);
|
void HandleUnsortedModelWireframe(CAreaListItem* areaItem, CCubeModel& model);
|
||||||
|
|
||||||
void ActivateLightsForModel(CAreaListItem* areaItem, CCubeModel& model);
|
void ActivateLightsForModel(const 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; }
|
||||||
void SetReflectionDirty(bool v) { x318_24_refectionDirty = v; }
|
void SetReflectionDirty(bool v) { x318_24_refectionDirty = v; }
|
||||||
[[nodiscard]] bool IsThermalVisorActive() const { return x318_29_thermalVisor; }
|
[[nodiscard]] bool IsThermalVisorActive() const { return x318_29_thermalVisor; }
|
||||||
|
CTexture* GetRealReflection() {
|
||||||
|
x2dc_reflectionAge = 0;
|
||||||
|
if (x14c_reflectionTex) {
|
||||||
|
return x14c_reflectionTex.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
return &xe4_blackTex;
|
||||||
|
}
|
||||||
|
|
||||||
static void SetupCGraphicsState();
|
static void SetupCGraphicsState();
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,7 +4,14 @@
|
||||||
#include <zeus/CAABox.hpp>
|
#include <zeus/CAABox.hpp>
|
||||||
|
|
||||||
namespace metaforce {
|
namespace metaforce {
|
||||||
enum class EDrawableType : u16 { WorldSurface, Particle, Actor, SimpleShadow, Decal };
|
enum class EDrawableType : u16 {
|
||||||
|
WorldSurface,
|
||||||
|
Particle,
|
||||||
|
Actor,
|
||||||
|
SimpleShadow,
|
||||||
|
Decal,
|
||||||
|
Invalid = 0xFFFF,
|
||||||
|
};
|
||||||
|
|
||||||
class CDrawable {
|
class CDrawable {
|
||||||
EDrawableType x0_type;
|
EDrawableType x0_type;
|
||||||
|
|
|
@ -42,20 +42,20 @@ public:
|
||||||
|
|
||||||
virtual ~IRenderer() = default;
|
virtual ~IRenderer() = default;
|
||||||
virtual void AddStaticGeometry(const std::vector<CMetroidModelInstance>* geometry, const CAreaRenderOctTree* octTree,
|
virtual void AddStaticGeometry(const std::vector<CMetroidModelInstance>* geometry, const CAreaRenderOctTree* octTree,
|
||||||
int areaIdx) = 0;
|
s32 areaIdx) = 0;
|
||||||
virtual void EnablePVS(const CPVSVisSet& set, u32 areaIdx) = 0;
|
virtual void EnablePVS(const CPVSVisSet& set, u32 areaIdx) = 0;
|
||||||
virtual void DisablePVS() = 0;
|
virtual void DisablePVS() = 0;
|
||||||
virtual void RemoveStaticGeometry(const std::vector<CMetroidModelInstance>* geometry) = 0;
|
virtual void RemoveStaticGeometry(const std::vector<CMetroidModelInstance>* geometry) = 0;
|
||||||
virtual void DrawUnsortedGeometry(int areaIdx, int mask, int targetMask, bool shadowRender = false) = 0;
|
virtual void DrawUnsortedGeometry(s32 areaIdx, s32 mask, s32 targetMask, bool shadowRender = false) = 0;
|
||||||
virtual void DrawSortedGeometry(int areaIdx, int mask, int targetMask) = 0;
|
virtual void DrawSortedGeometry(s32 areaIdx, s32 mask, s32 targetMask) = 0;
|
||||||
virtual void DrawStaticGeometry(int areaIdx, int mask, int targetMask) = 0;
|
virtual void DrawStaticGeometry(s32 areaIdx, s32 mask, s32 targetMask) = 0;
|
||||||
virtual void DrawAreaGeometry(int areaIdx, int mask, int targetMask) = 0;
|
virtual void DrawAreaGeometry(s32 areaIdx, s32 mask, s32 targetMask) = 0;
|
||||||
virtual void PostRenderFogs() = 0;
|
virtual void PostRenderFogs() = 0;
|
||||||
virtual void SetModelMatrix(const zeus::CTransform& xf) = 0;
|
virtual void SetModelMatrix(const zeus::CTransform& xf) = 0;
|
||||||
virtual void AddParticleGen(CParticleGen& gen) = 0;
|
virtual void AddParticleGen(CParticleGen& gen) = 0;
|
||||||
virtual void AddParticleGen(CParticleGen& gen, const zeus::CVector3f& pos, const zeus::CAABox& bounds) = 0;
|
virtual void AddParticleGen(CParticleGen& gen, const zeus::CVector3f& pos, const zeus::CAABox& bounds) = 0;
|
||||||
virtual void AddPlaneObject(void* obj, const zeus::CAABox& aabb, const zeus::CPlane& plane, int type) = 0;
|
virtual void AddPlaneObject(void* obj, const zeus::CAABox& aabb, const zeus::CPlane& plane, s32 type) = 0;
|
||||||
virtual void AddDrawable(void* obj, const zeus::CVector3f& pos, const zeus::CAABox& aabb, int mode,
|
virtual void AddDrawable(void* obj, const zeus::CVector3f& pos, const zeus::CAABox& aabb, s32 mode,
|
||||||
EDrawableSorting sorting) = 0;
|
EDrawableSorting sorting) = 0;
|
||||||
virtual void SetDrawableCallback(TDrawableCallback cb, void* ctx) = 0;
|
virtual void SetDrawableCallback(TDrawableCallback cb, void* ctx) = 0;
|
||||||
virtual void SetWorldViewpoint(const zeus::CTransform& xf) = 0;
|
virtual void SetWorldViewpoint(const zeus::CTransform& xf) = 0;
|
||||||
|
@ -63,7 +63,7 @@ public:
|
||||||
virtual void SetPerspective(float fovy, float aspect, float znear, float zfar) = 0;
|
virtual void SetPerspective(float fovy, float aspect, float znear, float zfar) = 0;
|
||||||
virtual std::pair<zeus::CVector2f, zeus::CVector2f> SetViewportOrtho(bool centered, float znear, float zfar) = 0;
|
virtual std::pair<zeus::CVector2f, zeus::CVector2f> SetViewportOrtho(bool centered, float znear, float zfar) = 0;
|
||||||
virtual void SetClippingPlanes(const zeus::CFrustum& frustum) = 0;
|
virtual void SetClippingPlanes(const zeus::CFrustum& frustum) = 0;
|
||||||
virtual void SetViewport(int left, int bottom, int width, int height) = 0;
|
virtual void SetViewport(s32 left, s32 bottom, s32 width, s32 height) = 0;
|
||||||
virtual void SetDepthReadWrite(bool, bool) = 0;
|
virtual void SetDepthReadWrite(bool, bool) = 0;
|
||||||
virtual void SetBlendMode_AdditiveAlpha() = 0;
|
virtual void SetBlendMode_AdditiveAlpha() = 0;
|
||||||
virtual void SetBlendMode_AlphaBlended() = 0;
|
virtual void SetBlendMode_AlphaBlended() = 0;
|
||||||
|
@ -73,15 +73,15 @@ public:
|
||||||
virtual void SetBlendMode_InvertSrc() = 0;
|
virtual void SetBlendMode_InvertSrc() = 0;
|
||||||
virtual void SetBlendMode_Replace() = 0;
|
virtual void SetBlendMode_Replace() = 0;
|
||||||
virtual void SetBlendMode_AdditiveDestColor() = 0;
|
virtual void SetBlendMode_AdditiveDestColor() = 0;
|
||||||
virtual void SetDebugOption(EDebugOption, int) = 0;
|
virtual void SetDebugOption(EDebugOption, s32) = 0;
|
||||||
virtual void BeginScene() = 0;
|
virtual void BeginScene() = 0;
|
||||||
virtual void EndScene() = 0;
|
virtual void EndScene() = 0;
|
||||||
virtual void BeginPrimitive(EPrimitiveType, int) = 0;
|
virtual void BeginPrimitive(EPrimitiveType, s32) = 0;
|
||||||
virtual void BeginLines(int) = 0;
|
virtual void BeginLines(s32) = 0;
|
||||||
virtual void BeginLineStrip(int) = 0;
|
virtual void BeginLineStrip(s32) = 0;
|
||||||
virtual void BeginTriangles(int) = 0;
|
virtual void BeginTriangles(s32) = 0;
|
||||||
virtual void BeginTriangleStrip(int) = 0;
|
virtual void BeginTriangleStrip(s32) = 0;
|
||||||
virtual void BeginTriangleFan(int) = 0;
|
virtual void BeginTriangleFan(s32) = 0;
|
||||||
virtual void PrimVertex(const zeus::CVector3f&) = 0;
|
virtual void PrimVertex(const zeus::CVector3f&) = 0;
|
||||||
virtual void PrimNormal(const zeus::CVector3f&) = 0;
|
virtual void PrimNormal(const zeus::CVector3f&) = 0;
|
||||||
virtual void PrimColor(float, float, float, float) = 0;
|
virtual void PrimColor(float, float, float, float) = 0;
|
||||||
|
@ -97,7 +97,7 @@ public:
|
||||||
virtual void DrawModelDisintegrate(const CModel& model, const CTexture& tex, const zeus::CColor& color,
|
virtual void DrawModelDisintegrate(const CModel& model, const CTexture& tex, const zeus::CColor& color,
|
||||||
TVectorRef positions, TVectorRef normals) = 0;
|
TVectorRef positions, TVectorRef normals) = 0;
|
||||||
virtual void DrawModelFlat(const CModel& model, const CModelFlags& flags, bool unsortedOnly) = 0;
|
virtual void DrawModelFlat(const CModel& model, const CModelFlags& flags, bool unsortedOnly) = 0;
|
||||||
virtual void SetWireframeFlags(int flags) = 0;
|
virtual void SetWireframeFlags(s32 flags) = 0;
|
||||||
virtual void SetWorldFog(ERglFogMode mode, float startz, float endz, const zeus::CColor& color) = 0;
|
virtual void SetWorldFog(ERglFogMode mode, float startz, float endz, const zeus::CColor& color) = 0;
|
||||||
virtual void RenderFogVolume(const zeus::CColor& color, const zeus::CAABox& aabb, const TLockedToken<CModel>* model,
|
virtual void RenderFogVolume(const zeus::CColor& color, const zeus::CAABox& aabb, const TLockedToken<CModel>* model,
|
||||||
const CSkinnedModel* sModel) = 0;
|
const CSkinnedModel* sModel) = 0;
|
||||||
|
|
Loading…
Reference in New Issue