Implement FlatDraw/DrawFlat calls, add CRandom16 seed value display

This commit is contained in:
Phillip Stephens 2022-07-02 16:16:33 -07:00
parent 52e9afbe98
commit ec9e0bfc0f
6 changed files with 29 additions and 7 deletions

View File

@ -6,9 +6,12 @@ CRandom16* CRandom16::g_randomNumber = nullptr; // &DefaultRandom
CGlobalRandom* CGlobalRandom::g_currentGlobalRandom = nullptr; //&DefaultGlobalRandom;
namespace {
u32 g_numNextCalls = 0;
u32 g_lastSeed = 0;
};
void CRandom16::IncrementNumNextCalls() { ++g_numNextCalls; }
u32 CRandom16::GetNumNextCalls() { return g_numNextCalls; }
void CRandom16::ResetNumNextCalls() { g_numNextCalls = 0; }
u32 CRandom16::GetLastSeed() { return g_lastSeed; }
void CRandom16::SetLastSeed(u32 seed) { g_lastSeed = seed; }
} // namespace metaforce

View File

@ -14,6 +14,7 @@ public:
s32 Next() {
IncrementNumNextCalls();
m_seed = (m_seed * 0x41c64e6d) + 0x00003039;
SetLastSeed(m_seed);
return (m_seed >> 16) & 0xffff;
}
@ -32,6 +33,8 @@ public:
static void IncrementNumNextCalls();
static u32 GetNumNextCalls();
static void ResetNumNextCalls();
static u32 GetLastSeed();
static void SetLastSeed(u32 seed);
};
class CGlobalRandom {

View File

@ -360,6 +360,21 @@ void CModelData::Render(EWhichModel which, const zeus::CTransform& xf, const CAc
x14_24_renderSorted = false;
}
void CModelData::FlatDraw(EWhichModel which, const zeus::CTransform& xf, bool unsortedOnly, const CModelFlags& flags) {
g_Renderer->SetModelMatrix(xf * zeus::CTransform::Scale(x0_scale));
CGraphics::DisableAllLights();
if (!x10_animData) {
g_Renderer->DrawModelFlat(*PickStaticModel(which), flags, unsortedOnly, nullptr, nullptr);
} else {
auto model = PickAnimatedModel(which);
x10_animData->SetupRender(model, nullptr, nullptr);
model.DoDrawCallback([=](TConstVectorRef positions, TConstVectorRef normals) {
auto m = model.GetModel();
g_Renderer->DrawModelFlat(*m, flags, unsortedOnly, positions, normals);
});
}
}
void CModelData::MultiLightingDraw(EWhichModel which, const zeus::CTransform& xf, const CActorLights* lights,
const zeus::CColor& alphaColor, const zeus::CColor& additiveColor) {
CModel* model = nullptr;

View File

@ -121,6 +121,7 @@ public:
void Render(const CStateManager& stateMgr, const zeus::CTransform& xf, const CActorLights* lights,
const CModelFlags& drawFlags);
void Render(EWhichModel, const zeus::CTransform& xf, const CActorLights* lights, const CModelFlags& drawFlags);
void FlatDraw(EWhichModel which, const zeus::CTransform& xf, bool unsortedOnly, const CModelFlags& flags);
void MultiLightingDraw(EWhichModel which, const zeus::CTransform& xf, const CActorLights* lights,
const zeus::CColor& alphaColor, const zeus::CColor& additiveColor);

View File

@ -941,6 +941,7 @@ void ImGuiConsole::ShowDebugOverlay() {
ImGuiStringViewText(
fmt::format(FMT_STRING("CRandom16::Next calls: {}\n"), metaforce::CRandom16::GetNumNextCalls()));
ImGuiStringViewText(fmt::format(FMT_STRING("CRandom16::LastSeed: 0x{:08X}\n"), CRandom16::GetLastSeed()));
}
if (m_resourceStats && g_SimplePool != nullptr) {
if (hasPrevious) {

View File

@ -7,6 +7,7 @@
#include "Runtime/CGameState.hpp"
#include "Runtime/CSimplePool.hpp"
#include "Runtime/GameGlobalObjects.hpp"
#include "Runtime/Graphics/CCubeRenderer.hpp"
#include "Runtime/Graphics/CSkinnedModel.hpp"
#include "Runtime/Graphics/CVertexMorphEffect.hpp"
#include "Runtime/Weapon/CEnergyProjectile.hpp"
@ -503,17 +504,15 @@ void CGunWeapon::DrawHologram(const CStateManager& mgr, const zeus::CTransform&
// TODO
if (x218_29_drawHologram) {
CModelFlags useFlags = flags;
// useFlags.m_extendedShader = EExtendedShader::Flat;
x60_holoModelData->Render(CModelData::EWhichModel::Normal, xf, nullptr, useFlags);
x60_holoModelData->FlatDraw(CModelData::EWhichModel::Normal, xf, false, useFlags);
} else {
CGraphics::SetModelMatrix(xf * zeus::CTransform::Scale(x10_solidModelData->GetScale()));
// CGraphics::DisableAllLights();
// g_Renderer->SetAmbientColor(zeus::skWhite);
CGraphics::DisableAllLights();
g_Renderer->SetAmbientColor(zeus::skWhite);
CSkinnedModel& model = *x60_holoModelData->GetAnimationData()->GetModelData();
// model.GetModelInst()->ActivateLights({CLight::BuildLocalAmbient({}, zeus::skWhite)});
x10_solidModelData->GetAnimationData()->Render(model, flags, nullptr, nullptr);
// g_Renderer->SetAmbientColor(zeus::skWhite);
// CGraphics::DisableAllLights();
g_Renderer->SetAmbientColor(zeus::skWhite);
CGraphics::DisableAllLights();
}
}