mirror of https://github.com/AxioDL/metaforce.git
Merge pull request #244 from lioncash/pane
CAui*: Make use of std::array where applicable
This commit is contained in:
commit
7c8de88fd7
|
@ -54,15 +54,16 @@ void CAuiEnergyBarT01::Update(float dt) {
|
|||
}
|
||||
|
||||
void CAuiEnergyBarT01::Draw(const CGuiWidgetDrawParms& drawParms) const {
|
||||
if (!xbc_tex || !xbc_tex.IsLoaded() || !xd8_coordFunc)
|
||||
if (!xbc_tex || !xbc_tex.IsLoaded() || !xd8_coordFunc) {
|
||||
return;
|
||||
}
|
||||
SCOPED_GRAPHICS_DEBUG_GROUP(fmt::format(fmt("CAuiEnergyBarT01::Draw {}"), m_name).c_str(), zeus::skCyan);
|
||||
|
||||
CGraphics::SetModelMatrix(x34_worldXF);
|
||||
const_cast<CEnergyBarShader&>(m_energyBarShader).updateModelMatrix();
|
||||
|
||||
float filledT = xe0_maxEnergy > 0.f ? xf8_filledEnergy / xe0_maxEnergy : 0.f;
|
||||
float shadowT = xe0_maxEnergy > 0.f ? xfc_shadowEnergy / xe0_maxEnergy : 0.f;
|
||||
const float filledT = xe0_maxEnergy > 0.f ? xf8_filledEnergy / xe0_maxEnergy : 0.f;
|
||||
const float shadowT = xe0_maxEnergy > 0.f ? xfc_shadowEnergy / xe0_maxEnergy : 0.f;
|
||||
|
||||
zeus::CColor filledColor = xd0_filledColor;
|
||||
filledColor.a() *= drawParms.x0_alphaMod;
|
||||
|
@ -76,7 +77,7 @@ void CAuiEnergyBarT01::Draw(const CGuiWidgetDrawParms& drawParms) const {
|
|||
emptyColor.a() *= drawParms.x0_alphaMod;
|
||||
emptyColor *= xa8_color2;
|
||||
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
for (size_t i = 0; i < m_verts.size(); ++i) {
|
||||
std::vector<CEnergyBarShader::Vertex>& verts = const_cast<CAuiEnergyBarT01&>(*this).m_verts[i];
|
||||
verts.clear();
|
||||
|
||||
|
@ -98,8 +99,9 @@ void CAuiEnergyBarT01::Draw(const CGuiWidgetDrawParms& drawParms) const {
|
|||
break;
|
||||
}
|
||||
|
||||
if (start == end)
|
||||
if (start == end) {
|
||||
continue;
|
||||
}
|
||||
|
||||
std::pair<zeus::CVector3f, zeus::CVector3f> coords = xd8_coordFunc(start);
|
||||
while (start < end) {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
|
@ -16,7 +17,7 @@ class CSimplePool;
|
|||
|
||||
class CAuiEnergyBarT01 : public CGuiWidget {
|
||||
public:
|
||||
typedef std::pair<zeus::CVector3f, zeus::CVector3f> (*FCoordFunc)(float t);
|
||||
using FCoordFunc = std::pair<zeus::CVector3f, zeus::CVector3f> (*)(float t);
|
||||
enum class ESetMode { Normal, Wrapped, Insta };
|
||||
|
||||
private:
|
||||
|
@ -38,7 +39,7 @@ private:
|
|||
float xfc_shadowEnergy = 0.f;
|
||||
float x100_shadowDrainDelayTimer = 0.f;
|
||||
CEnergyBarShader m_energyBarShader;
|
||||
std::vector<CEnergyBarShader::Vertex> m_verts[3];
|
||||
std::array<std::vector<CEnergyBarShader::Vertex>, 3> m_verts;
|
||||
|
||||
public:
|
||||
CAuiEnergyBarT01(const CGuiWidgetParms& parms, CSimplePool* sp, CAssetId txtrId);
|
||||
|
|
|
@ -54,9 +54,9 @@ void CAuiImagePane::Update(float dt) {
|
|||
CAuiImagePane::Filters::Filters(TLockedToken<CTexture>& tex)
|
||||
: m_texId(tex.GetObjectTag()->id)
|
||||
, m_darkenerQuad(EFilterType::Blend, tex)
|
||||
, m_flashQuad{{EFilterType::Add, tex}, {EFilterType::Add, tex}}
|
||||
, m_alphaQuad{{EFilterType::Blend, tex}, {EFilterType::Blend, tex}}
|
||||
, m_addQuad{{EFilterType::Add, tex}, {EFilterType::Add, tex}} {}
|
||||
, m_flashQuad{{{EFilterType::Add, tex}, {EFilterType::Add, tex}}}
|
||||
, m_alphaQuad{{{EFilterType::Blend, tex}, {EFilterType::Blend, tex}}}
|
||||
, m_addQuad{{{EFilterType::Add, tex}, {EFilterType::Add, tex}}} {}
|
||||
|
||||
void CAuiImagePane::DoDrawImagePane(const zeus::CColor& color, const CTexture& tex, int frame, float alpha, bool noBlur,
|
||||
CTexturedQuadFilterAlpha& quad) const {
|
||||
|
@ -66,13 +66,13 @@ void CAuiImagePane::DoDrawImagePane(const zeus::CColor& color, const CTexture& t
|
|||
rstl::reserved_vector<zeus::CVector2f, 4> vec;
|
||||
const rstl::reserved_vector<zeus::CVector2f, 4>* useUVs;
|
||||
if (x138_tileSize != zeus::skZero2f) {
|
||||
zeus::CVector2f res(xb8_tex0Tok->GetWidth(), xb8_tex0Tok->GetHeight());
|
||||
zeus::CVector2f tmp = res / x138_tileSize;
|
||||
zeus::CVector2f tmpRecip = x138_tileSize / res;
|
||||
float x0 = tmpRecip.x() * (frame % int(tmp.x()));
|
||||
float x1 = x0 + tmpRecip.x();
|
||||
float y0 = tmpRecip.y() * (frame % int(tmp.y()));
|
||||
float y1 = y0 + tmpRecip.y();
|
||||
const zeus::CVector2f res(xb8_tex0Tok->GetWidth(), xb8_tex0Tok->GetHeight());
|
||||
const zeus::CVector2f tmp = res / x138_tileSize;
|
||||
const zeus::CVector2f tmpRecip = x138_tileSize / res;
|
||||
const float x0 = tmpRecip.x() * (frame % int(tmp.x()));
|
||||
const float x1 = x0 + tmpRecip.x();
|
||||
const float y0 = tmpRecip.y() * (frame % int(tmp.y()));
|
||||
const float y1 = y0 + tmpRecip.y();
|
||||
vec.push_back(zeus::CVector2f(x0, y0));
|
||||
vec.push_back(zeus::CVector2f(x0, y1));
|
||||
vec.push_back(zeus::CVector2f(x1, y0));
|
||||
|
@ -82,20 +82,22 @@ void CAuiImagePane::DoDrawImagePane(const zeus::CColor& color, const CTexture& t
|
|||
useUVs = &x114_uvs;
|
||||
}
|
||||
|
||||
CTexturedQuadFilter::Vert verts[] = {{xe0_coords[0], (*useUVs)[0] + xd0_uvBias0},
|
||||
{xe0_coords[1], (*useUVs)[1] + xd0_uvBias0},
|
||||
{xe0_coords[3], (*useUVs)[3] + xd0_uvBias0},
|
||||
{xe0_coords[2], (*useUVs)[2] + xd0_uvBias0}};
|
||||
const std::array<CTexturedQuadFilter::Vert, 4> verts{{
|
||||
{xe0_coords[0], (*useUVs)[0] + xd0_uvBias0},
|
||||
{xe0_coords[1], (*useUVs)[1] + xd0_uvBias0},
|
||||
{xe0_coords[3], (*useUVs)[3] + xd0_uvBias0},
|
||||
{xe0_coords[2], (*useUVs)[2] + xd0_uvBias0},
|
||||
}};
|
||||
|
||||
if (noBlur) {
|
||||
quad.drawVerts(useColor, verts);
|
||||
quad.drawVerts(useColor, verts.data());
|
||||
} else if ((x14c_deResFactor == 0.f && alpha == 1.f) || tex.GetNumMips() == 1) {
|
||||
quad.drawVerts(useColor, verts, 0.f);
|
||||
quad.drawVerts(useColor, verts.data(), 0.f);
|
||||
} else {
|
||||
float tmp = (1.f - x14c_deResFactor) * alpha;
|
||||
float tmp3 = 1.f - tmp * tmp * tmp;
|
||||
float mip = tmp3 * (tex.GetNumMips() - 1);
|
||||
quad.drawVerts(useColor, verts, mip);
|
||||
const float tmp = (1.f - x14c_deResFactor) * alpha;
|
||||
const float tmp3 = 1.f - tmp * tmp * tmp;
|
||||
const float mip = tmp3 * (tex.GetNumMips() - 1);
|
||||
quad.drawVerts(useColor, verts.data(), mip);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <array>
|
||||
|
||||
#include "Runtime/CToken.hpp"
|
||||
#include "Runtime/rstl.hpp"
|
||||
#include "Runtime/Graphics/Shaders/CTexturedQuadFilter.hpp"
|
||||
|
@ -33,10 +35,10 @@ class CAuiImagePane : public CGuiWidget {
|
|||
struct Filters {
|
||||
CAssetId m_texId;
|
||||
CTexturedQuadFilterAlpha m_darkenerQuad;
|
||||
CTexturedQuadFilterAlpha m_flashQuad[2];
|
||||
CTexturedQuadFilterAlpha m_alphaQuad[2];
|
||||
CTexturedQuadFilterAlpha m_addQuad[2];
|
||||
Filters(TLockedToken<CTexture>& tex);
|
||||
std::array<CTexturedQuadFilterAlpha, 2> m_flashQuad;
|
||||
std::array<CTexturedQuadFilterAlpha, 2> m_alphaQuad;
|
||||
std::array<CTexturedQuadFilterAlpha, 2> m_addQuad;
|
||||
explicit Filters(TLockedToken<CTexture>& tex);
|
||||
};
|
||||
std::optional<Filters> m_filters;
|
||||
void DoDrawImagePane(const zeus::CColor& color, const CTexture& tex, int frame, float blurAmt, bool noBlur,
|
||||
|
|
Loading…
Reference in New Issue