Use GXCopyTex; various implementations

- Fix CTexture::LoadMipLevel
- Fix boid rendering for CFishCloud, CSnakeWeedSwarm, CWallCrawlerSwarm
- Update aurora
This commit is contained in:
Luke Street 2022-08-09 02:10:51 -04:00
parent c057379457
commit ae0f62c021
23 changed files with 190 additions and 170 deletions

View File

@ -51,6 +51,7 @@ CAnimData::CAnimData(CAssetId id, const CCharacterInfo& character, int defaultAn
, xd8_modelData(std::move(model))
, xfc_animCtx(ctx.lock())
, x100_animMgr(std::move(animMgr))
, x108_aabb()
, x1d8_selfId(id)
, x1fc_transMgr(std::move(transMgr))
, x204_charIdx(charIdx)
@ -68,7 +69,10 @@ CAnimData::CAnimData(CAssetId id, const CCharacterInfo& character, int defaultAn
g_SoundPOINodes.resize(20);
g_TransientInt32POINodes.resize(16);
x108_aabb = xd8_modelData->GetModel()->GetAABB();
xd8_modelData->CalculateDefault();
for (const auto& item : *xd8_modelData->GetModel()->GetPositions()) {
x108_aabb.accumulateBounds(item);
}
x120_particleDB.CacheParticleDesc(xc_charInfo.GetParticleResData());
CHierarchyPoseBuilder pb(CLayoutDescription{xcc_layoutData});
@ -799,10 +803,12 @@ void CAnimData::AdvanceAnim(CCharAnimTime& time, zeus::CVector3f& offset, zeus::
void CAnimData::SetXRayModel(const TLockedToken<CModel>& model, const TLockedToken<CSkinRules>& skinRules) {
xf4_xrayModel = std::make_shared<CSkinnedModel>(model, skinRules, xd8_modelData->GetLayoutInfo());
xf4_xrayModel->CalculateDefault();
}
void CAnimData::SetInfraModel(const TLockedToken<CModel>& model, const TLockedToken<CSkinRules>& skinRules) {
xf8_infraModel = std::make_shared<CSkinnedModel>(model, skinRules, xd8_modelData->GetLayoutInfo());
xf4_xrayModel->CalculateDefault();
}
void CAnimData::PoseSkinnedModel(CSkinnedModel& model, const CPoseAsTransforms& pose, CVertexMorphEffect* morphEffect,
@ -885,9 +891,10 @@ zeus::CAABox CAnimData::GetBoundingBox() const {
void CAnimData::SubstituteModelData(const TCachedToken<CSkinnedModel>& model) {
xd8_modelData = model;
// TODO
// xd8_modelData.CalculateDefault();
// x108_aabb = xd8_modelData->GetBounds();
x108_aabb = {};
for (const auto& item : *xd8_modelData->GetModel()->GetPositions()) {
x108_aabb.accumulateBounds(item);
}
}
void CAnimData::SetParticleCEXTValue(std::string_view name, int idx, float value) {

View File

@ -281,11 +281,6 @@ void CModelData::Touch(EWhichModel which, int shaderIdx) {
void CModelData::Touch(const CStateManager& stateMgr, int shaderIdx) { Touch(GetRenderingModel(stateMgr), shaderIdx); }
void CModelData::RenderThermal(const zeus::CColor& mulColor, const zeus::CColor& addColor, const CModelFlags& flags) {
// TODO float* params and xc_
// g_Renderer->DrawThermalModel(xc_, mulColor, addColor, nullptr, nullptr, flags);
}
void CModelData::RenderThermal(const zeus::CTransform& xf, const zeus::CColor& mulColor, const zeus::CColor& addColor,
const CModelFlags& flags) {
CGraphics::SetModelMatrix(xf * zeus::CTransform::Scale(x0_scale));
@ -466,4 +461,9 @@ void CModelData::ThermalDraw(CSkinnedModel& model, const zeus::CColor& mulColor,
});
}
void CModelData::ThermalDraw(CSkinnedModel& model, TConstVectorRef positions, TConstVectorRef normals,
const zeus::CColor& mulColor, const zeus::CColor& addColor, const CModelFlags& flags) {
g_Renderer->DrawThermalModel(*model.GetModel(), mulColor, addColor, positions, normals, flags);
}
} // namespace metaforce

View File

@ -60,7 +60,6 @@ public:
class CModelData {
friend class CActor;
zeus::CVector3f x0_scale;
bool xc_ = false;
std::unique_ptr<CAnimData> x10_animData;
bool x14_24_renderSorted : 1 = false;
bool x14_25_sortThermal : 1 = false;
@ -113,7 +112,6 @@ public:
void RenderParticles(const zeus::CFrustum& frustum) const;
void Touch(EWhichModel, int shaderIdx);
void Touch(const CStateManager& stateMgr, int shaderIdx);
void RenderThermal(const zeus::CColor& mulColor, const zeus::CColor& addColor, const CModelFlags& flags);
void RenderThermal(const zeus::CTransform& xf, const zeus::CColor& mulColor, const zeus::CColor& addColor,
const CModelFlags& flags);
void RenderUnsortedParts(EWhichModel, const zeus::CTransform& xf, const CActorLights* lights,
@ -133,6 +131,8 @@ public:
float t);
static void ThermalDraw(CSkinnedModel& model, const zeus::CColor& mulColor, const zeus::CColor& addColor,
const CModelFlags& flags);
static void ThermalDraw(CSkinnedModel& model, TConstVectorRef positions, TConstVectorRef normals,
const zeus::CColor& mulColor, const zeus::CColor& addColor, const CModelFlags& flags);
CAnimData* GetAnimationData() { return x10_animData.get(); }
const CAnimData* GetAnimationData() const { return x10_animData.get(); }

View File

@ -176,7 +176,7 @@ void CCubeModel::DrawFlat(TConstVectorRef positions, TConstVectorRef normals, ES
void CCubeModel::DrawNormal(TConstVectorRef positions, TConstVectorRef normals, ESurfaceSelection surfaces) {
CGX::SetNumIndStages(0);
CGX::SetNumTevStages(1);
CGX::SetNumTexGens(1); // TODO should this be 0?
CGX::SetNumTexGens(1);
CGX::SetZMode(true, GX_LEQUAL, true);
CGX::SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR_NULL);
CGX::SetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO);

View File

@ -982,20 +982,10 @@ void CCubeRenderer::DoThermalBlendCold() {
const auto top = CGraphics::GetViewportTop();
const auto left = CGraphics::GetViewportLeft();
CGX::SetZMode(true, GX_LEQUAL, false);
// GXSetTexCopySrc(left, top, width, height);
// GXSetTexCopyDst(width, height, GX_TF_I4, false);
// GXCopyTex(sSpareTextureData, true);
// TODO TODO TODO
// CGraphics::ResolveSpareTexture(
// aurora::gfx::ClipRect{
// .x = static_cast<int32_t>(left),
// .y = static_cast<int32_t>(top),
// .width = static_cast<int32_t>(width),
// .height = static_cast<int32_t>(height),
// },
// 0, GX_TF_I4);
// CGraphics::LoadDolphinSpareTexture(width, height, GX_TF_I4, nullptr, GX_TEXMAP7);
CGraphics::LoadDolphinSpareTexture(0, GX_TF_I4, GX_TEXMAP7);
GXSetTexCopySrc(left, top, width, height);
GXSetTexCopyDst(width, height, GX_TF_I4, false);
GXCopyTex(CGraphics::sSpareTextureData, true);
CGraphics::LoadDolphinSpareTexture(width, height, GX_TF_I4, nullptr, GX_TEXMAP7);
// Upload random static texture (game reads from .text)
const u8* buf = CDvdFile::GetDolBuf() + 0x4f60;
@ -1108,13 +1098,11 @@ void CCubeRenderer::DoThermalBlendHot() {
const auto top = CGraphics::GetViewportTop();
const auto left = CGraphics::GetViewportLeft();
CGX::SetZMode(true, GX_LEQUAL, true);
// GXSetTexCopySrc(left, top, width, height);
// GXSetTexCopyDst(width, height, GX_TF_I4, false);
// GXCopyTex(sSpareTextureData, false);
CGraphics::ResolveSpareTexture(CGraphics::g_Viewport, 0, GX_TF_I4);
GXSetTexCopySrc(left, top, width, height);
GXSetTexCopyDst(width, height, GX_TF_I4, false);
GXCopyTex(CGraphics::sSpareTextureData, false);
x288_thermoPalette.Load();
// CGraphics::LoadDolphinSpareTexture(width, height, GX_TF_C4, GX::TLUT0, nullptr, GX_TEXMAP7);
CGraphics::LoadDolphinSpareTexture(0, GX_TF_C4, GX_TLUT0, GX_TEXMAP7);
CGraphics::LoadDolphinSpareTexture(width, height, GX_TF_C4, GX_TLUT0, nullptr, GX_TEXMAP7);
CGX::SetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_TEXA, GX_CC_TEXC, GX_CC_ZERO);
CGX::SetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_TEXA);
CGX::SetStandardTevColorAlphaOp(GX_TEVSTAGE0);
@ -1468,19 +1456,11 @@ void CCubeRenderer::ReallyDrawSpaceWarp(const zeus::CVector3f& pt, float strengt
GXColor fogColor;
CGX::GetFog(&fogType, &fogStartZ, &fogEndZ, &fogNearZ, &fogFarZ, &fogColor);
CGX::SetFog(GX_FOG_NONE, fogStartZ, fogEndZ, fogNearZ, fogFarZ, fogColor);
// GXSetTexCopySrc(v2right.x, v2right.y, v2sub.x, v2sub.y);
// GXSetTexCopyDst(v2sub.x, v2sub.y, GX_TF_RGBA8, false);
// GXCopyTex(sSpareTextureData, false);
// GXPixModeSync();
CGraphics::ResolveSpareTexture(
SViewport{
.x0_left = static_cast<u32>(v2right.x),
.x4_top = static_cast<u32>(v2right.y),
.x8_width = static_cast<u32>(v2sub.x),
.xc_height = static_cast<u32>(v2sub.y),
},
1, GX_TF_RGBA8);
CGraphics::LoadDolphinSpareTexture(1, GX_TF_RGBA8, GX_TEXMAP7);
GXSetTexCopySrc(v2right.x, v2right.y, v2sub.x, v2sub.y);
GXSetTexCopyDst(v2sub.x, v2sub.y, GX_TF_RGBA8, false);
GXCopyTex(CGraphics::sSpareTextureData, false);
GXPixModeSync();
CGraphics::LoadDolphinSpareTexture(v2sub.x, v2sub.y, GX_TF_RGBA8, nullptr, GX_TEXMAP7);
x150_reflectionTex.Load(GX_TEXMAP1, EClampMode::Clamp);
CGX::SetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO, GX_CC_TEXC);
CGX::SetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, true, GX_TEVPREV);

View File

@ -57,6 +57,8 @@ const std::array<zeus::CMatrix3f, 6> CGraphics::skCubeBasisMats{{
/* Forward */
{-1.f, 0.f, 0.f, 0.f, 1.f, 0.f, 0.f, 0.f, -1.f},
}};
// We don't actually store anything here
u8 CGraphics::sSpareTextureData[] = {0};
// Stream API
static u32 sStreamFlags;
@ -733,4 +735,41 @@ void CGraphics::SetDefaultVtxAttrFmt() {
void CGraphics::ResetGfxStates() noexcept {
// sRenderState.x0_ = 0;
}
void CGraphics::LoadDolphinSpareTexture(int width, int height, GXTexFmt format, void* data, GXTexMapID id) {
void* ptr = static_cast<void*>(sSpareTextureData);
if (data != nullptr) {
ptr = data;
}
GXTexObj obj;
GXInitTexObj(&obj, ptr, width, height, format, GX_CLAMP, GX_CLAMP, false);
GXInitTexObjLOD(&obj, GX_NEAR, GX_NEAR, 0.0, 0.0, 0.0, false, false, GX_ANISO_1);
GXLoadTexObj(&obj, id);
// CTexture::InvalidateTexmap(id);
if (id == GX_TEXMAP7) {
// GXInvalidateTexRegion(...);
}
#ifdef AURORA
GXDestroyTexObj(&obj);
#endif
}
void CGraphics::LoadDolphinSpareTexture(int width, int height, GXCITexFmt format, GXTlut tlut, void* data,
GXTexMapID id) {
void* ptr = static_cast<void*>(sSpareTextureData);
if (data != nullptr) {
ptr = data;
}
GXTexObj obj;
GXInitTexObjCI(&obj, ptr, width, height, format, GX_CLAMP, GX_CLAMP, false, tlut);
GXInitTexObjLOD(&obj, GX_NEAR, GX_NEAR, 0.0, 0.0, 0.0, false, false, GX_ANISO_1);
GXLoadTexObj(&obj, id);
// CTexture::InvalidateTexmap(id);
if (id == GX_TEXMAP7) {
// GXInvalidateTexRegion(...);
}
#ifdef AURORA
GXDestroyTexObj(&obj);
#endif
}
} // namespace metaforce

View File

@ -15,6 +15,7 @@
#include <zeus/CVector2f.hpp>
#include <zeus/CVector2i.hpp>
#include <aurora/aurora.h>
#include <optick.h>
using frame_clock = std::chrono::high_resolution_clock;
@ -164,14 +165,6 @@ struct SClipScreenRect {
, x20_uvYMin(uvYMin)
, x24_uvYMax(uvYMax) {}
// SClipScreenRect(const aurora::gfx::ClipRect& rect) {
// x4_left = rect.x;
// x8_top = rect.y;
// xc_width = rect.width;
// x10_height = rect.height;
// x14_dstWidth = rect.width;
// }
SClipScreenRect(const SViewport& vp) {
x4_left = vp.x0_left;
x8_top = vp.x4_top;
@ -307,29 +300,10 @@ public:
static float GetCroppedViewportUVYMax() { return g_CroppedViewport.x24_uvYMax; }
static const std::array<zeus::CMatrix3f, 6> skCubeBasisMats;
static u8 sSpareTextureData[];
static void ResolveSpareTexture(const SClipScreenRect& rect, int bindIdx, GXTexFmt format, bool clearDepth = false) {
// TODO
// aurora::gfx::resolve_color({rect.x4_left, rect.x8_top, rect.xc_width, rect.x10_height}, bindIdx, format,
// clearDepth);
}
static void LoadDolphinSpareTexture(int bindIdx, GXTexFmt format, GXTexMapID id) {
// TODO
// GXTexObj obj;
// GXInitTexObjResolved(&obj, bindIdx, format, GX_CLAMP, GX_CLAMP, GX_TLUT0);
// GXInitTexObjLOD(&obj, GX_NEAR, GX_NEAR, 0.f, 0.f, 0.f, false, false, GX_ANISO_1);
// GXLoadTexObj(&obj, id);
}
static void LoadDolphinSpareTexture(int bindIdx, GXCITexFmt format, GXTlut tlut, GXTexMapID id) {
// TODO
// GXTexObj obj;
// GXInitTexObjResolved(&obj, bindIdx, static_cast<GXTexFmt>(format), GX_CLAMP, GX_CLAMP, tlut);
// GXInitTexObjLOD(&obj, GX_NEAR, GX_NEAR, 0.f, 0.f, 0.f, false, false, GX_ANISO_1);
// GXLoadTexObj(&obj, id);
}
static void ResolveSpareDepth(const SClipScreenRect& rect, int bindIdx = 0) {
// aurora::gfx::resolve_depth({rect.x4_left, rect.x8_top, rect.xc_width, rect.x10_height}, bindIdx);
}
static void LoadDolphinSpareTexture(int width, int height, GXTexFmt format, void* data, GXTexMapID id);
static void LoadDolphinSpareTexture(int width, int height, GXCITexFmt format, GXTlut tlut, void* data, GXTexMapID id);
static void ResetGfxStates() noexcept;
static void SetTevStates(u32 flags) noexcept;

View File

@ -28,9 +28,11 @@ static void MyTHPYuv2RgbTextureSetup(void* dataY, void* dataU, void* dataV, u16
CTexture::InvalidateTexMap(GX_TEXMAP0);
CTexture::InvalidateTexMap(GX_TEXMAP1);
CTexture::InvalidateTexMap(GX_TEXMAP2);
#ifdef AURORA
GXDestroyTexObj(&texV);
GXDestroyTexObj(&texU);
GXDestroyTexObj(&texY);
#endif
}
const std::array<u8, 32> InterlaceTex{
@ -57,7 +59,9 @@ static void MyTHPGXYuv2RgbSetup(bool interlaced2ndFrame, bool fieldFlip) {
GXInitTexObj(&texObj, InterlaceTex.data(), 8, 4, GX_TF_I8, GX_REPEAT, GX_REPEAT, false);
GXInitTexObjLOD(&texObj, GX_NEAR, GX_NEAR, 0.f, 0.f, 0.f, false, false, GX_ANISO_1);
GXLoadTexObj(&texObj, GX_TEXMAP3);
#ifdef AURORA
GXDestroyTexObj(&texObj);
#endif
CTexture::InvalidateTexMap(GX_TEXMAP3);
CGX::SetTevOrder(GX_TEVSTAGE4, GX_TEXCOORD2, GX_TEXMAP3, GX_COLOR_NULL);
CGX::SetStandardTevColorAlphaOp(GX_TEVSTAGE4);

View File

@ -1,6 +1,7 @@
#include "Runtime/Graphics/CSkinnedModel.hpp"
#include "Runtime/Character/CSkinRules.hpp"
#include "Runtime/Graphics/CCubeRenderer.hpp"
#include "Runtime/Graphics/CVertexMorphEffect.hpp"
#include <logvisor/logvisor.hpp>
@ -45,6 +46,8 @@ void CSkinnedModel::Calculate(const CPoseAsTransforms& pose, CVertexMorphEffect*
}
AllocateStorage();
workspace = &m_workspace;
} else {
workspace->Reset(*x10_skinRules);
}
x10_skinRules->BuildAccumulatedTransforms(pose, *x1c_layoutInfo);
@ -93,6 +96,10 @@ void CSkinnedModel::DoDrawCallback(const FCustomDraw& func) const {
}
}
void CSkinnedModel::CalculateDefault() { m_workspace.Clear(); }
SSkinningWorkspace CSkinnedModel::CloneWorkspace() { return m_workspace; }
CSkinnedModelWithAvgNormals::CSkinnedModelWithAvgNormals(IObjectStore& store, CAssetId model, CAssetId skinRules,
CAssetId layoutInfo)
: CSkinnedModel(store, model, skinRules, layoutInfo) {

View File

@ -30,6 +30,10 @@ struct SSkinningWorkspace {
m_vertexWorkspace.reserve(rules.GetVertexCount());
m_normalWorkspace.reserve(rules.GetNormalCount());
}
void Clear() {
m_vertexWorkspace.clear();
m_normalWorkspace.clear();
}
[[nodiscard]] bool IsEmpty() const { return m_vertexWorkspace.empty() || m_normalWorkspace.empty(); }
};
@ -69,6 +73,9 @@ public:
void Draw(TConstVectorRef verts, TConstVectorRef normals, const CModelFlags& drawFlags);
void Draw(const CModelFlags& drawFlags);
void DoDrawCallback(const FCustomDraw& func) const;
void CalculateDefault();
// Originally returns cloned vertex workspace, with arg for cloned normal workspace
SSkinningWorkspace CloneWorkspace();
static void SetPointGeneratorFunc(FPointGenerator func) { g_PointGenFunc = std::move(func); }
static void ClearPointGeneratorFunc() { g_PointGenFunc = nullptr; }

View File

@ -106,29 +106,32 @@ void CTexture::Load(GXTexMapID id, EClampMode clamp) {
}
}
void CTexture::LoadMipLevel(float lod, GXTexMapID id, EClampMode clamp) {
// auto image_ptr = /*x44_aramToken.GetMRAMSafe() */ x44_aramToken_x4_buff.get();
// u32 width = x4_w;
// u32 height = x6_h;
// u32 iVar15 = 0;
// u32 offset = 0;
// if (mip > 0) {
// for (u32 i = 0; i < mip; ++i) {
// offset += ROUND_UP_32(x9_bitsPerPixel * (ROUND_UP_4(width) * ROUND_UP_4(height)));
// width /= 2;
// height /= 2;
// }
// }
void CTexture::LoadMipLevel(s32 mip, GXTexMapID id, EClampMode clamp) {
auto* image_ptr = /*x44_aramToken.GetMRAMSafe() */ x44_aramToken_x4_buff.get();
u32 width = x4_w;
u32 height = x6_h;
u32 iVar15 = 0;
u32 offset = 0;
if (mip > 0) {
for (u32 i = 0; i < mip; ++i) {
offset += ROUND_UP_32(x9_bitsPerPixel * (ROUND_UP_4(width) * ROUND_UP_4(height)));
width /= 2;
height /= 2;
}
}
// TODO
// GXTexObj texObj;
// GXInitTexObj(&texObj, image_ptr + offset, width, height, x18_gxFormat);
// GXInitTexObjLOD(&texObj, GX_LINEAR, GX_LINEAR, 0.f, 1.f, 0.f, false, false, GX_ANISO_1);
// if (HasPalette()) {
// x10_graphicsPalette->Load();
// xa_25_canLoadPalette = false;
// }
// GXLoadTexObj(&x20_texObj, id);
GXTexObj texObj;
const auto wrap = static_cast<GXTexWrapMode>(clamp);
GXInitTexObj(&texObj, image_ptr + offset, width, height, x18_gxFormat, wrap, wrap, false);
GXInitTexObjLOD(&texObj, GX_LINEAR, GX_LINEAR, 0.f, 1.f, 0.f, false, false, GX_ANISO_1);
if (HasPalette()) {
x10_graphicsPalette->Load();
xa_25_canLoadPalette = false;
}
GXLoadTexObj(&texObj, id);
#ifdef AURORA
GXDestroyTexObj(&texObj);
#endif
x64_frameAllocated = sCurrentFrameCount;
sLoadedTextures[id] = nullptr;
}
@ -277,9 +280,7 @@ bool CTexture::sMangleMips = false;
u32 CTexture::sCurrentFrameCount = 0;
u32 CTexture::sTotalAllocatedMemory = 0;
void CTexture::InvalidateTexMap(GXTexMapID id) {
sLoadedTextures[id] = nullptr;
}
void CTexture::InvalidateTexMap(GXTexMapID id) { sLoadedTextures[id] = nullptr; }
CFactoryFnReturn FTextureFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms,
CObjectReference* selfRef) {

View File

@ -117,7 +117,7 @@ public:
[[nodiscard]] u8* Lock();
void UnLock();
void Load(GXTexMapID id, EClampMode clamp);
void LoadMipLevel(float lod, GXTexMapID id, EClampMode clamp); // was an s32 mip parameter, adjusted to use lod
void LoadMipLevel(s32 mip, GXTexMapID id, EClampMode clamp);
// void UnloadBitmapData(u32) const;
// void TryReloadBitmapData(CResFactory&) const;
// void LoadToMRAM() const;

View File

@ -80,7 +80,7 @@ void CAuiImagePane::DoDrawImagePane(const zeus::CColor& color, CTexture& tex, in
if ((x14c_deResFactor == 0.f && alpha == 1.f) || tex.GetNumberOfMipMaps() == 1) {
CGraphics::SetTevOp(ERglTevStage::Stage0, CTevCombiners::sTevPass805a5ebc);
CGraphics::SetTevOp(ERglTevStage::Stage1, CTevCombiners::skPassThru);
tex.LoadMipLevel(0.f, GX_TEXMAP0, EClampMode::Repeat);
tex.LoadMipLevel(0, GX_TEXMAP0, EClampMode::Repeat);
CGraphics::StreamBegin(GX_TRIANGLESTRIP);
CGraphics::StreamColor(useColor);
for (u32 i = 0; i < useUVs->size(); ++i) {

View File

@ -595,8 +595,8 @@ void CInGameGuiManager::Draw(CStateManager& stateMgr) {
float zT = 1.f - zeus::clamp(0.f, (stateMgr.GetPlayer().GetDeathTime() - zStart) / 0.5f, 1.f);
float xT = 1.f - zeus::clamp(0.f, (stateMgr.GetPlayer().GetDeathTime() - xStart) / 0.5f, 1.f);
float colT = 1.f - zeus::clamp(0.f, (stateMgr.GetPlayer().GetDeathTime() - colStart) / 0.5f, 1.f);
SClipScreenRect rect(CGraphics::g_Viewport);
CGraphics::ResolveSpareTexture(rect, 0, GX_TF_RGB565);
// SClipScreenRect rect(CGraphics::g_Viewport);
// CGraphics::ResolveSpareTexture(rect, 0, GX_TF_RGB565);
CCameraFilterPass::DrawFilter(EFilterType::Blend, EFilterShape::Fullscreen, zeus::skBlack, nullptr, 1.f);
float z = 0.5f * (zT * zT * zT * zT * zT * (CGraphics::GetViewportHeight() - 12.f) + 12.f);
float x = 0.5f * (xT * (CGraphics::GetViewportWidth() - 12.f) + 12.f);

View File

@ -55,6 +55,7 @@ int CPlayerVisor::FindCachedInactiveScanTarget(TUniqueId uid) const {
}
bool CPlayerVisor::DrawScanObjectIndicators(const CStateManager& mgr) {
SCOPED_GRAPHICS_DEBUG_GROUP("CPlayerVisor::DrawScanObjectIndicators", zeus::skMagenta);
if (!x124_scanIconNoncritical.IsLoaded() || !x130_scanIconCritical.IsLoaded())
return false;
if (!x114_scanShield.IsLoaded())
@ -348,12 +349,11 @@ void CPlayerVisor::DrawScanEffect(const CStateManager& mgr, CTargetingManager* t
float vpH = 152.218f * x48_interpWindowDims.y() * divisor;
vpH = zeus::clamp(0.f, vpH, 448.f) * vpScale;
SClipScreenRect rect;
rect.x4_left = int((CGraphics::GetViewportWidth() - vpW) / 2.f);
rect.x8_top = int((CGraphics::GetViewportHeight() - vpH) / 2.f);
rect.xc_width = int(vpW);
rect.x10_height = int(vpH);
CGraphics::ResolveSpareTexture(rect, 0, GX_TF_RGB565);
GXSetTexCopySrc(int((CGraphics::GetViewportWidth() - vpW) / 2.f), int((CGraphics::GetViewportHeight() - vpH) / 2.f),
vpW, vpH);
GXSetTexCopyDst(vpW, vpH, GX_TF_RGB565, false);
GXCopyTex(CGraphics::sSpareTextureData, false);
GXPixModeSync();
{
SCOPED_GRAPHICS_DEBUG_GROUP("x64_scanDim Draw", zeus::skMagenta);
@ -366,7 +366,7 @@ void CPlayerVisor::DrawScanEffect(const CStateManager& mgr, CTargetingManager* t
const zeus::CTransform seventeenScale = zeus::CTransform::Scale(17.f * vpScale, 1.f, 17.f * vpScale);
const zeus::CTransform mm = seventeenScale * windowScale;
g_Renderer->SetModelMatrix(mm);
CGraphics::LoadDolphinSpareTexture(0, GX_TF_RGB565, GX_TEXMAP0);
CGraphics::LoadDolphinSpareTexture(vpW, vpH, GX_TF_RGB565, CGraphics::sSpareTextureData, GX_TEXMAP0);
if (x108_newScanPane) {
SCOPED_GRAPHICS_DEBUG_GROUP("x108_newScanPane Draw", zeus::skMagenta);

View File

@ -2133,18 +2133,12 @@ zeus::CVector3f CPlayerGun::ConvertToScreenSpace(const zeus::CVector3f& pos, con
void CPlayerGun::CopyScreenTex() {
// Copy lower right quadrant to gpCopyTexBuf as RGBA8
// GXSetTexCopySrc(320, 224, 320, 224);
// GXSetTexCopyDst(320, 224, GX_TF_RGBA8, false);
// GXCopyTex(sSpareTextureData, false);
// GXPixModeSync();
SViewport viewport = CGraphics::g_Viewport;
viewport.x8_width /= 2;
viewport.xc_height /= 2;
viewport.x0_left = viewport.x8_width;
viewport.x4_top = viewport.xc_height;
viewport.x10_halfWidth *= 0.5f;
viewport.x14_halfHeight *= 0.5f;
CGraphics::ResolveSpareTexture(viewport, 2, GX_TF_RGBA8, false);
u16 width = CGraphics::g_Viewport.x8_width / 2;
u16 height = CGraphics::g_Viewport.xc_height / 2;
GXSetTexCopySrc(width, height, width, height);
GXSetTexCopyDst(width, height, GX_TF_RGBA8, false);
GXCopyTex(CGraphics::sSpareTextureData, false);
GXPixModeSync();
}
void CPlayerGun::DrawScreenTex(float z) {
@ -2156,7 +2150,9 @@ void CPlayerGun::DrawScreenTex(float z) {
g_Renderer->SetViewportOrtho(false, -1.f, 1.f);
g_Renderer->SetBlendMode_AlphaBlended();
CGraphics::SetDepthWriteMode(true, ERglEnum::GEqual, true);
CGraphics::LoadDolphinSpareTexture(2, GX_TF_RGBA8, GX_TEXMAP7);
u16 width = CGraphics::g_Viewport.x8_width / 2;
u16 height = CGraphics::g_Viewport.xc_height / 2;
CGraphics::LoadDolphinSpareTexture(width, height, GX_TF_RGBA8, nullptr, GX_TEXMAP7);
constexpr std::array vtxDescList{
GXVtxDescList{GX_VA_POS, GX_DIRECT},
GXVtxDescList{GX_VA_TEX0, GX_DIRECT},

View File

@ -509,8 +509,10 @@ void CFishCloud::Think(float dt, CStateManager& mgr) {
void CFishCloud::CreatePartitionList() { xf8_boidPartitionLists.reserve(343); }
void CFishCloud::AllocateSkinnedModels(CStateManager& mgr, CModelData::EWhichModel which) {
x178_workspaces.clear();
int idx = 0;
for (auto& m : x1b0_models) {
x178_workspaces.emplace_back(m->PickAnimatedModel(which).CloneWorkspace());
m->EnableLooping(true);
m->AdvanceAnimation(m->GetAnimationData()->GetAnimTimeRemaining("Whole Body"sv) * 0.25f * float(idx), mgr,
x4_areaId, true);
@ -569,24 +571,22 @@ void CFishCloud::RenderBoid(int idx, const CBoid& boid, u32& drawMask, bool ther
const u32 modelIndex = idx & 0x3;
CModelData& mData = *x1b0_models[modelIndex];
CSkinnedModel& model = mData.PickAnimatedModel(CModelData::EWhichModel::Normal);
// TODO this whole function
// if (!model.GetModel()->TryLockTextures()) {
// return;
// }
const u32 thisDrawMask = 1u << modelIndex;
if ((drawMask & thisDrawMask) != 0) {
drawMask &= ~thisDrawMask;
mData.GetAnimationData()->BuildPose();
model.Calculate(mData.GetAnimationData()->GetPose(), nullptr, nullptr, &x178_workspaces[modelIndex]);
}
// model.GetModelInst()->SetAmbientColor(zeus::skWhite);
CGraphics::SetModelMatrix(zeus::lookAt(boid.x0_pos, boid.x0_pos + boid.xc_vel));
const auto* positions = &x178_workspaces[modelIndex].m_vertexWorkspace;
const auto* normals = &x178_workspaces[modelIndex].m_normalWorkspace;
if (thermalHot) {
constexpr CModelFlags thermFlags(0, 0, 3, zeus::skWhite);
mData.RenderThermal(zeus::skWhite, zeus::CColor(0.f, 0.25f), thermFlags);
CModelData::ThermalDraw(model, positions, normals, zeus::skWhite, zeus::CColor(0.f, 0.25f), thermFlags);
} else {
mData.GetAnimationData()->Render(model, flags, nullptr, nullptr);
model.Draw(positions, normals, flags);
}
}
@ -609,7 +609,8 @@ void CFishCloud::Render(CStateManager& mgr) {
AddParticlesToRenderer();
if (x250_27_validModel) {
// Ambient white
g_Renderer->SetAmbientColor(zeus::skWhite);
CGraphics::DisableAllLights();
int idx = 0;
u32 drawMask = 0xffffffff;
for (const auto& b : xe8_boids) {
@ -619,7 +620,8 @@ void CFishCloud::Render(CStateManager& mgr) {
++idx;
}
} else {
CGraphics::SetModelMatrix(zeus::CTransform());
g_Renderer->SetAmbientColor(zeus::skWhite);
g_Renderer->SetModelMatrix({});
for (const auto& b : xe8_boids) {
if (b.x20_active) {
x64_modelData->SetScale(zeus::CVector3f(b.x18_scale));

View File

@ -75,9 +75,10 @@ class CFishCloud : public CActor {
zeus::CColor x16c_color;
float x170_weaponKillRadius;
float x174_containmentRadius;
/* Used to be position and normal arrays */
// rstl::reserved_vector<std::unique_ptr<float[]>, 4> x178_;
// rstl::reserved_vector<std::unique_ptr<float[]>, 4> x19c_;
mutable rstl::reserved_vector<SSkinningWorkspace, 4> x178_workspaces;
// Originally:
// rstl::reserved_vector<rstl::auto_ptr<float[]>, 4> x178_posWorkspaces;
// rstl::reserved_vector<float[], 4> x19c_nrmWorkspaces;
rstl::reserved_vector<std::shared_ptr<CModelData>, 4> x1b0_models;
rstl::reserved_vector<TLockedToken<CGenDescription>, 4> x1c4_particleDescs;
rstl::reserved_vector<std::unique_ptr<CElementGen>, 4> x1f8_particleGens;

View File

@ -80,8 +80,10 @@ CSnakeWeedSwarm::CSnakeWeedSwarm(TUniqueId uid, bool active, std::string_view na
void CSnakeWeedSwarm::Accept(metaforce::IVisitor& visitor) { visitor.Visit(this); }
void CSnakeWeedSwarm::AllocateSkinnedModels(CStateManager& mgr, CModelData::EWhichModel which) {
x178_workspaces.clear();
for (int i = 0; i < x1b0_modelData.size(); ++i) {
auto& modelData = *x1b0_modelData[i];
x178_workspaces.emplace_back(modelData.PickAnimatedModel(which).CloneWorkspace());
modelData.EnableLooping(true);
const float dt = modelData.GetAnimationData()->GetAnimTimeRemaining("Whole Body"sv) * (i * 0.25f);
modelData.AdvanceAnimation(dt, mgr, x4_areaId, true);
@ -413,16 +415,17 @@ void CSnakeWeedSwarm::RenderBoid(u32 idx, const CBoid& boid, u32& posesToBuild)
auto& modelData = *x1b0_modelData[modelIdx];
auto& model = modelData.PickAnimatedModel(x1c4_which);
auto& animData = *modelData.GetAnimationData();
auto& workspace = x178_workspaces[modelIdx];
if (posesToBuild & 1 << modelIdx) {
posesToBuild &= ~(1 << modelIdx);
animData.BuildPose();
model.Calculate(animData.GetPose(), nullptr, nullptr, nullptr); // TODO x178_workspaces[modelIdx]
model.Calculate(animData.GetPose(), nullptr, nullptr, &workspace);
}
CGraphics::SetModelMatrix(
zeus::CTransform::Translate(boid.GetPosition() - zeus::CVector3f(0.f, 0.f, boid.GetZOffset())) *
zeus::CTransform::Scale(boid.GetScale()));
constexpr CModelFlags useFlags{0, 0, 3, zeus::skWhite};
animData.Render(model, useFlags, nullptr, nullptr);
model.Draw(&workspace.m_vertexWorkspace, &workspace.m_normalWorkspace, useFlags);
}
void CSnakeWeedSwarm::ApplyRadiusDamage(const zeus::CVector3f& pos, const CDamageInfo& info, CStateManager& mgr) {

View File

@ -72,7 +72,10 @@ private:
bool x140_26_playerTouching : 1 = false;
zeus::CAABox x144_touchBounds = zeus::skInvertedBox;
CDamageInfo x15c_damageInfo;
// x178_ / x19c_: vectors of CSkinnedModel*, not needed
mutable rstl::reserved_vector<SSkinningWorkspace, 4> x178_workspaces;
// Originally:
// rstl::reserved_vector<rstl::auto_ptr<float[]>, 4> x178_posWorkspaces;
// rstl::reserved_vector<float[], 4> x19c_nrmWorkspaces;
rstl::reserved_vector<std::unique_ptr<CModelData>, 4> x1b0_modelData;
CModelData::EWhichModel x1c4_which;
std::unique_ptr<std::vector<zeus::CVector3f>> x1c8_boidPositions;

View File

@ -11,6 +11,7 @@
#include "Runtime/Collision/CMaterialList.hpp"
#include "Runtime/Collision/CMetroidAreaCollider.hpp"
#include "Runtime/Graphics/CCubeRenderer.hpp"
#include "Runtime/Graphics/CGX.hpp"
#include "Runtime/Graphics/CSkinnedModel.hpp"
#include "Runtime/Graphics/CVertexMorphEffect.hpp"
#include "Runtime/Weapon/CGameProjectile.hpp"
@ -119,15 +120,15 @@ CWallCrawlerSwarm::CWallCrawlerSwarm(
void CWallCrawlerSwarm::Accept(IVisitor& visitor) { visitor.Visit(this); }
void CWallCrawlerSwarm::AllocateSkinnedModels(CStateManager& mgr, CModelData::EWhichModel which) {
// x430_.clear();
x430_workspaces.clear();
for (size_t i = 0; i < 9; ++i) {
// x430_.push_back(x4b0_[i]->PickAnimatedModel(which).Clone());
x430_workspaces.emplace_back(x4b0_modelDatas[i]->PickAnimatedModel(which).CloneWorkspace());
x4b0_modelDatas[i]->EnableLooping(true);
x4b0_modelDatas[i]->AdvanceAnimation(x4b0_modelDatas[i]->GetAnimationData()->GetAnimTimeRemaining("Whole Body"sv) *
(float(i) * 0.0625f),
mgr, x4_areaId, true);
}
// x430_.push_back(x4b0_.back()->PickAnimatedModel(which).Clone());
x430_workspaces.emplace_back(x4b0_modelDatas.back()->PickAnimatedModel(which).CloneWorkspace());
x4dc_whichModel = which;
}
@ -1021,13 +1022,7 @@ void CWallCrawlerSwarm::HardwareLight(const CStateManager& mgr, const zeus::CAAB
lights.SetFindShadowLight(false);
lights.BuildAreaLightList(mgr, *mgr.GetWorld()->GetAreaAlways(x4_areaId), aabb);
lights.BuildDynamicLightList(mgr, aabb);
// TODO
// for (const auto& m : x4b0_modelDatas) {
// lights.ActivateLights(*m->PickAnimatedModel(x4dc_whichModel).GetModelInst());
// if (const auto iceModel = m->GetAnimationData()->GetIceModel()) {
// lights.ActivateLights(*iceModel->GetModelInst());
// }
// }
lights.ActivateLights();
}
void CWallCrawlerSwarm::RenderBoid(const CBoid* boid, u32& drawMask, bool thermalHot, const CModelFlags& flags) const {
@ -1042,27 +1037,24 @@ void CWallCrawlerSwarm::RenderBoid(const CBoid* boid, u32& drawMask, bool therma
CModelData& mData = *x4b0_modelDatas[modelIndex];
CSkinnedModel& model = mData.PickAnimatedModel(x4dc_whichModel);
// TODO
// if (!model.GetModelInst()->TryLockTextures()) {
// return;
// }
const u32 thisDrawMask = 1u << modelIndex;
if (drawMask & thisDrawMask) {
if ((drawMask & thisDrawMask) != 0u) {
drawMask &= ~thisDrawMask;
mData.GetAnimationData()->BuildPose();
model.Calculate(mData.GetAnimationData()->GetPose(), nullptr, nullptr, &x430_workspaces[modelIndex]);
}
// model.GetModelInst()->SetAmbientColor(boid->x40_ambientLighting);
CGraphics::SetModelMatrix(boid->GetTransform());
g_Renderer->SetAmbientColor(boid->x40_ambientLighting);
g_Renderer->SetModelMatrix(boid->GetTransform());
const auto* positions = &x430_workspaces[modelIndex].m_vertexWorkspace;
const auto* normals = &x430_workspaces[modelIndex].m_normalWorkspace;
if (boid->x48_timeToDie > 0.f && !thermalHot) {
constexpr CModelFlags useFlags(0, 0, 3, zeus::skWhite);
mData.GetAnimationData()->Render(model, useFlags, nullptr, nullptr);
model.Draw(positions, normals, useFlags);
if (auto iceModel = mData.GetAnimationData()->GetIceModel()) {
// if (!iceModel->GetModelInst()->TryLockTextures()) {
// return;
// }
// iceModel->GetModelInst()->SetAmbientColor(zeus::skWhite);
g_Renderer->SetAmbientColor(zeus::skWhite);
const float alpha = 1.f - boid->x48_timeToDie;
const zeus::CColor color(1.f, alpha > 0.f ? boid->x48_timeToDie : 1.f);
const CModelFlags iceFlags(5, 0, 3, color);
@ -1070,9 +1062,9 @@ void CWallCrawlerSwarm::RenderBoid(const CBoid* boid, u32& drawMask, bool therma
}
} else if (thermalHot) {
constexpr CModelFlags thermFlags(5, 0, 3, zeus::skWhite);
mData.RenderThermal(zeus::skWhite, zeus::CColor(0.f, 0.25f), thermFlags);
CModelData::ThermalDraw(model, positions, normals, zeus::skWhite, zeus::CColor(0.f, 0.25f), thermFlags);
} else {
mData.GetAnimationData()->Render(model, flags, nullptr, nullptr);
model.Draw(positions, normals, flags);
}
}
@ -1084,7 +1076,8 @@ void CWallCrawlerSwarm::Render(CStateManager& mgr) {
const bool r24 = x560_24_enableLighting;
const bool r23 = x560_25_useSoftwareLight;
if (!r24) {
// Ambient 50% grey
CGraphics::DisableAllLights();
g_Renderer->SetAmbientColor(zeus::CColor{0.5f, 1.f});
}
const bool thermalHot = mgr.GetThermalDrawFlag() == EThermalDrawFlag::Hot;
@ -1092,6 +1085,7 @@ void CWallCrawlerSwarm::Render(CStateManager& mgr) {
if (mgr.GetPlayerState()->GetActiveVisor(mgr) == CPlayerState::EPlayerVisor::XRay) {
flags = CModelFlags(5, 0, 3, zeus::CColor(1.f, 0.3f));
}
CGX::SetChanCtrl(CGX::EChannelId::Channel0, CGraphics::g_LightActive);
for (int r27 = 0; r27 < 5; ++r27) {
for (int r28 = 0; r28 < 5; ++r28) {
@ -1142,6 +1136,7 @@ void CWallCrawlerSwarm::Render(CStateManager& mgr) {
RenderBoid(b, drawMask, thermalHot, flags);
}
}
CGraphics::DisableAllLights();
DrawTouchBounds();
}
@ -1236,8 +1231,8 @@ void CWallCrawlerSwarm::ApplyRadiusDamage(const zeus::CVector3f& pos, const CDam
}
}
void CWallCrawlerSwarm::FreezeCollision(CMarkerGrid const &grid) {
for (CBoid &boid : x108_boids) {
void CWallCrawlerSwarm::FreezeCollision(CMarkerGrid const& grid) {
for (CBoid& boid : x108_boids) {
if (!boid.x80_24_active) {
continue;
}

View File

@ -96,9 +96,10 @@ private:
CHealthInfo x3bc_hInfo;
CDamageVulnerability x3c4_dVuln;
s32 x42c_lockOnIdx = -1;
/* Used to be position and normal array pointers */
// rstl::reserved_vector<std::unique_ptr<float[]>, 10> x430_;
// rstl::reserved_vector<std::unique_ptr<float[]>, 10> x484_;
mutable rstl::reserved_vector<SSkinningWorkspace, 10> x430_workspaces;
// Originally:
// rstl::reserved_vector<rstl::auto_ptr<float[]>, 10> x430_posWorkspaces;
// rstl::reserved_vector<float[], 10> x484_nrmWorkspaces;
rstl::reserved_vector<std::shared_ptr<CModelData>, 10> x4b0_modelDatas;
CModelData::EWhichModel x4dc_whichModel = CModelData::EWhichModel::Normal;
std::vector<CRepulsor> x4e0_doorRepulsors;

2
extern/aurora vendored

@ -1 +1 @@
Subproject commit 893cabe55a31a6f59c77854d503d891025204acb
Subproject commit c060e1da6b39bf6a84635caa3138616466150c83