mirror of https://github.com/AxioDL/metaforce.git
CCompoundTargetReticle: Make use of std::array where applicable
Same behavior, stronger typing. While we're at it, we can eliminate a case of variable shadowing.
This commit is contained in:
parent
c6278c0e9f
commit
e26afe887f
|
@ -71,10 +71,11 @@ CCompoundTargetReticle::CCompoundTargetReticle(const CStateManager& mgr)
|
|||
|
||||
CCompoundTargetReticle::SScanReticuleRenderer::SScanReticuleRenderer() {
|
||||
CGraphics::CommitResources([this](boo::IGraphicsDataFactory::Context& ctx) {
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
for (size_t i = 0; i < m_lineRenderers.size(); ++i) {
|
||||
m_lineRenderers[i].emplace(ctx, CLineRenderer::EPrimitiveMode::Lines, 8, nullptr, true, true);
|
||||
for (int j = 0; j < 4; ++j)
|
||||
m_stripRenderers[i][j].emplace(ctx, CLineRenderer::EPrimitiveMode::LineStrip, 4, nullptr, true, true);
|
||||
for (auto& stripRenderer : m_stripRenderers[i]) {
|
||||
stripRenderer.emplace(ctx, CLineRenderer::EPrimitiveMode::LineStrip, 4, nullptr, true, true);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} BooTrace);
|
||||
|
@ -822,8 +823,8 @@ void CCompoundTargetReticle::DrawNextLockOnGroup(const zeus::CMatrix3f& rot, con
|
|||
float alpha = 0.5f * factor;
|
||||
zeus::CColor color = g_tweakGuiColors->GetScanReticuleColor();
|
||||
color.a() *= alpha;
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
float lineWidth = i ? 2.5f : 1.f;
|
||||
for (size_t i = 0; i < m_scanRetRenderer.m_lineRenderers.size(); ++i) {
|
||||
float lineWidth = i != 0 ? 2.5f : 1.f;
|
||||
auto& rend = *m_scanRetRenderer.m_lineRenderers[i];
|
||||
rend.Reset();
|
||||
rend.AddVertex({-0.5f, 0.f, 0.f}, color, lineWidth);
|
||||
|
@ -836,17 +837,17 @@ void CCompoundTargetReticle::DrawNextLockOnGroup(const zeus::CMatrix3f& rot, con
|
|||
rend.AddVertex({0.f, 0.f, 20.5f}, color, lineWidth);
|
||||
rend.Render();
|
||||
|
||||
for (int j = 0; j < 4; ++j) {
|
||||
for (size_t j = 0; j < m_scanRetRenderer.m_stripRenderers[i].size(); ++j) {
|
||||
float xSign = j < 2 ? -1.f : 1.f;
|
||||
float zSign = (j & 0x1) ? -1.f : 1.f;
|
||||
float zSign = (j & 0x1) != 0 ? -1.f : 1.f;
|
||||
// begin line strip
|
||||
auto& rend = *m_scanRetRenderer.m_stripRenderers[i][j];
|
||||
rend.Reset();
|
||||
rend.AddVertex({0.5f * xSign, 0.f, 0.1f * zSign}, color, lineWidth);
|
||||
rend.AddVertex({0.5f * xSign, 0.f, 0.35f * zSign}, color, lineWidth);
|
||||
rend.AddVertex({0.35f * xSign, 0.f, 0.5f * zSign}, color, lineWidth);
|
||||
rend.AddVertex({0.1f * xSign, 0.f, 0.5f * zSign}, color, lineWidth);
|
||||
rend.Render();
|
||||
auto& stripRend = *m_scanRetRenderer.m_stripRenderers[i][j];
|
||||
stripRend.Reset();
|
||||
stripRend.AddVertex({0.5f * xSign, 0.f, 0.1f * zSign}, color, lineWidth);
|
||||
stripRend.AddVertex({0.5f * xSign, 0.f, 0.35f * zSign}, color, lineWidth);
|
||||
stripRend.AddVertex({0.35f * xSign, 0.f, 0.5f * zSign}, color, lineWidth);
|
||||
stripRend.AddVertex({0.1f * xSign, 0.f, 0.5f * zSign}, color, lineWidth);
|
||||
stripRend.Render();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <vector>
|
||||
|
||||
#include "Runtime/CPlayerState.hpp"
|
||||
|
@ -125,8 +126,8 @@ private:
|
|||
u32 x228_ = 0;
|
||||
|
||||
struct SScanReticuleRenderer {
|
||||
std::optional<CLineRenderer> m_lineRenderers[2];
|
||||
std::optional<CLineRenderer> m_stripRenderers[2][4];
|
||||
std::array<std::optional<CLineRenderer>, 2> m_lineRenderers;
|
||||
std::array<std::array<std::optional<CLineRenderer>, 4>, 2> m_stripRenderers;
|
||||
SScanReticuleRenderer();
|
||||
};
|
||||
SScanReticuleRenderer m_scanRetRenderer;
|
||||
|
|
Loading…
Reference in New Issue