From 2b4b7c36a575208679773385aa94318abae4d6e1 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 21 Mar 2020 01:51:28 -0400 Subject: [PATCH] CDecal: Make use of std::array where applicable Same behavior, but with stronger-typing and no implicit array to pointer decay. --- Runtime/Particle/CDecal.cpp | 11 ++++++----- Runtime/Particle/CDecal.hpp | 4 +++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Runtime/Particle/CDecal.cpp b/Runtime/Particle/CDecal.cpp index 70ca59d45..e51bc51b9 100644 --- a/Runtime/Particle/CDecal.cpp +++ b/Runtime/Particle/CDecal.cpp @@ -25,16 +25,17 @@ CDecal::CDecal(const TToken& desc, const zeus::CTransform& xf if (d->x50_DMRT) d->x50_DMRT->GetValue(0, x60_rotation); - } else + } else { x5c_29_modelInvalid = true; + } CGraphics::CommitResources([this](boo::IGraphicsDataFactory::Context& ctx) { - for (int i = 0; i < 2; ++i) { - CQuadDecal& decal = x3c_decalQuads[i]; - if (decal.m_desc->x14_TEX) + for (auto& decal : x3c_decalQuads) { + if (decal.m_desc->x14_TEX) { decal.m_instBuf = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(SParticleInstanceTex), 1); - else + } else { decal.m_instBuf = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(SParticleInstanceNoTex), 1); + } decal.m_uniformBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(SParticleUniforms), 1); CDecalShaders::BuildShaderDataBinding(ctx, decal); } diff --git a/Runtime/Particle/CDecal.hpp b/Runtime/Particle/CDecal.hpp index ee571a535..58c333d37 100644 --- a/Runtime/Particle/CDecal.hpp +++ b/Runtime/Particle/CDecal.hpp @@ -1,5 +1,7 @@ #pragma once +#include + #include "Runtime/CRandom16.hpp" #include "Runtime/CToken.hpp" #include "Runtime/RetroTypes.hpp" @@ -36,7 +38,7 @@ class CDecal { TLockedToken x0_description; zeus::CTransform xc_transform; - CQuadDecal x3c_decalQuads[2]; + std::array x3c_decalQuads; s32 x54_modelLifetime = 0; s32 x58_frameIdx = 0; union {