mirror of https://github.com/AxioDL/metaforce.git
CElementGen: Make use of std::array where applicable
This commit is contained in:
parent
35adfe8abf
commit
9db07b037a
|
@ -249,28 +249,28 @@ void CElementGenShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::Conte
|
||||||
const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> uniforms{gen.m_uniformBuf.get()};
|
const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> uniforms{gen.m_uniformBuf.get()};
|
||||||
|
|
||||||
if (regPipeline != nullptr) {
|
if (regPipeline != nullptr) {
|
||||||
for (size_t i = 0; i < std::size(gen.m_normalDataBind); ++i) {
|
for (size_t i = 0; i < gen.m_normalDataBind.size(); ++i) {
|
||||||
gen.m_normalDataBind[i] =
|
gen.m_normalDataBind[i] =
|
||||||
ctx.newShaderDataBinding((*regPipeline)[i], nullptr, gen.m_instBuf.get(), nullptr, uniforms.size(),
|
ctx.newShaderDataBinding((*regPipeline)[i], nullptr, gen.m_instBuf.get(), nullptr, uniforms.size(),
|
||||||
uniforms.data(), nullptr, texCount, textures.data(), nullptr, nullptr);
|
uniforms.data(), nullptr, texCount, textures.data(), nullptr, nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (regPipelineSub != nullptr) {
|
if (regPipelineSub != nullptr) {
|
||||||
for (size_t i = 0; i < std::size(gen.m_normalSubDataBind); ++i) {
|
for (size_t i = 0; i < gen.m_normalSubDataBind.size(); ++i) {
|
||||||
gen.m_normalSubDataBind[i] =
|
gen.m_normalSubDataBind[i] =
|
||||||
ctx.newShaderDataBinding((*regPipelineSub)[i], nullptr, gen.m_instBuf.get(), nullptr, uniforms.size(),
|
ctx.newShaderDataBinding((*regPipelineSub)[i], nullptr, gen.m_instBuf.get(), nullptr, uniforms.size(),
|
||||||
uniforms.data(), nullptr, texCount, textures.data(), nullptr, nullptr);
|
uniforms.data(), nullptr, texCount, textures.data(), nullptr, nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (redToAlphaPipeline != nullptr) {
|
if (redToAlphaPipeline != nullptr) {
|
||||||
for (size_t i = 0; i < std::size(gen.m_redToAlphaDataBind); ++i) {
|
for (size_t i = 0; i < gen.m_redToAlphaDataBind.size(); ++i) {
|
||||||
gen.m_redToAlphaDataBind[i] =
|
gen.m_redToAlphaDataBind[i] =
|
||||||
ctx.newShaderDataBinding((*redToAlphaPipeline)[i], nullptr, gen.m_instBuf.get(), nullptr, uniforms.size(),
|
ctx.newShaderDataBinding((*redToAlphaPipeline)[i], nullptr, gen.m_instBuf.get(), nullptr, uniforms.size(),
|
||||||
uniforms.data(), nullptr, texCount, textures.data(), nullptr, nullptr);
|
uniforms.data(), nullptr, texCount, textures.data(), nullptr, nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (redToAlphaPipelineSub != nullptr) {
|
if (redToAlphaPipelineSub != nullptr) {
|
||||||
for (size_t i = 0; i < std::size(gen.m_redToAlphaSubDataBind); ++i) {
|
for (size_t i = 0; i < gen.m_redToAlphaSubDataBind.size(); ++i) {
|
||||||
gen.m_redToAlphaSubDataBind[i] = ctx.newShaderDataBinding(
|
gen.m_redToAlphaSubDataBind[i] = ctx.newShaderDataBinding(
|
||||||
(*redToAlphaPipelineSub)[i], nullptr, gen.m_instBuf.get(), nullptr, uniforms.size(), uniforms.data(),
|
(*redToAlphaPipelineSub)[i], nullptr, gen.m_instBuf.get(), nullptr, uniforms.size(), uniforms.data(),
|
||||||
nullptr, texCount, textures.data(), nullptr, nullptr);
|
nullptr, texCount, textures.data(), nullptr, nullptr);
|
||||||
|
@ -283,14 +283,14 @@ void CElementGenShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::Conte
|
||||||
texCount = std::min(texCount, 1);
|
texCount = std::min(texCount, 1);
|
||||||
|
|
||||||
if (regPipelinePmus != nullptr) {
|
if (regPipelinePmus != nullptr) {
|
||||||
for (size_t i = 0; i < std::size(gen.m_normalDataBindPmus); ++i) {
|
for (size_t i = 0; i < gen.m_normalDataBindPmus.size(); ++i) {
|
||||||
gen.m_normalDataBindPmus[i] =
|
gen.m_normalDataBindPmus[i] =
|
||||||
ctx.newShaderDataBinding((*regPipelinePmus)[i], nullptr, gen.m_instBufPmus.get(), nullptr, uniforms.size(),
|
ctx.newShaderDataBinding((*regPipelinePmus)[i], nullptr, gen.m_instBufPmus.get(), nullptr, uniforms.size(),
|
||||||
uniforms.data(), nullptr, texCount, textures.data(), nullptr, nullptr);
|
uniforms.data(), nullptr, texCount, textures.data(), nullptr, nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (redToAlphaPipelinePmus != nullptr) {
|
if (redToAlphaPipelinePmus != nullptr) {
|
||||||
for (size_t i = 0; i < std::size(gen.m_redToAlphaDataBindPmus); ++i) {
|
for (size_t i = 0; i < gen.m_redToAlphaDataBindPmus.size(); ++i) {
|
||||||
gen.m_redToAlphaDataBindPmus[i] = ctx.newShaderDataBinding(
|
gen.m_redToAlphaDataBindPmus[i] = ctx.newShaderDataBinding(
|
||||||
(*redToAlphaPipelinePmus)[i], nullptr, gen.m_instBufPmus.get(), nullptr, uniforms.size(), uniforms.data(),
|
(*redToAlphaPipelinePmus)[i], nullptr, gen.m_instBufPmus.get(), nullptr, uniforms.size(), uniforms.data(),
|
||||||
nullptr, texCount, textures.data(), nullptr, nullptr);
|
nullptr, texCount, textures.data(), nullptr, nullptr);
|
||||||
|
|
|
@ -16,7 +16,15 @@
|
||||||
#define MAX_GLOBAL_PARTICLES 2560
|
#define MAX_GLOBAL_PARTICLES 2560
|
||||||
|
|
||||||
namespace urde {
|
namespace urde {
|
||||||
static logvisor::Module Log("urde::CElementGen");
|
namespace {
|
||||||
|
logvisor::Module Log("urde::CElementGen");
|
||||||
|
|
||||||
|
constexpr std::array ShadClsSizes{
|
||||||
|
sizeof(SParticleInstanceTex),
|
||||||
|
sizeof(SParticleInstanceIndTex),
|
||||||
|
sizeof(SParticleInstanceNoTex),
|
||||||
|
};
|
||||||
|
} // Anonymous namespace
|
||||||
|
|
||||||
u16 CElementGen::g_GlobalSeed = 99;
|
u16 CElementGen::g_GlobalSeed = 99;
|
||||||
bool CElementGen::g_subtractBlend = false;
|
bool CElementGen::g_subtractBlend = false;
|
||||||
|
@ -45,9 +53,6 @@ void CElementGen::Initialize() {
|
||||||
|
|
||||||
void CElementGen::Shutdown() { CElementGenShaders::Shutdown(); }
|
void CElementGen::Shutdown() { CElementGenShaders::Shutdown(); }
|
||||||
|
|
||||||
static const size_t ShadClsSizes[] = {sizeof(SParticleInstanceTex), sizeof(SParticleInstanceIndTex),
|
|
||||||
sizeof(SParticleInstanceNoTex)};
|
|
||||||
|
|
||||||
CElementGen::CElementGen(const TToken<CGenDescription>& gen, EModelOrientationType orientType,
|
CElementGen::CElementGen(const TToken<CGenDescription>& gen, EModelOrientationType orientType,
|
||||||
EOptionalSystemFlags flags)
|
EOptionalSystemFlags flags)
|
||||||
: x1c_genDesc(gen), x2c_orientType(orientType), x27c_randState(x94_randomSeed) {
|
: x1c_genDesc(gen), x2c_orientType(orientType), x27c_randState(x94_randomSeed) {
|
||||||
|
@ -212,11 +217,11 @@ CElementGen::CElementGen(const TToken<CGenDescription>& gen, EModelOrientationTy
|
||||||
|
|
||||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
||||||
if (!x26c_31_LINE) {
|
if (!x26c_31_LINE) {
|
||||||
m_instBuf = ctx.newDynamicBuffer(boo::BufferUse::Vertex, ShadClsSizes[int(m_shaderClass)], maxInsts);
|
m_instBuf = ctx.newDynamicBuffer(boo::BufferUse::Vertex, ShadClsSizes[size_t(m_shaderClass)], maxInsts);
|
||||||
m_uniformBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(SParticleUniforms), 1);
|
m_uniformBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(SParticleUniforms), 1);
|
||||||
}
|
}
|
||||||
if (desc->x45_24_x31_26_PMUS) {
|
if (desc->x45_24_x31_26_PMUS) {
|
||||||
m_instBufPmus = ctx.newDynamicBuffer(boo::BufferUse::Vertex, ShadClsSizes[int(m_shaderClass)], maxInsts);
|
m_instBufPmus = ctx.newDynamicBuffer(boo::BufferUse::Vertex, ShadClsSizes[size_t(m_shaderClass)], maxInsts);
|
||||||
m_uniformBufPmus = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(SParticleUniforms), 1);
|
m_uniformBufPmus = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(SParticleUniforms), 1);
|
||||||
}
|
}
|
||||||
CElementGenShaders::BuildShaderDataBinding(ctx, *this);
|
CElementGenShaders::BuildShaderDataBinding(ctx, *this);
|
||||||
|
@ -366,7 +371,7 @@ void CElementGen::UpdateAdvanceAccessParameters(u32 activeParticleCount, u32 par
|
||||||
adv8->GetValue(particleFrame, arr[7]);
|
adv8->GetValue(particleFrame, arr[7]);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CElementGen::UpdateVelocitySource(u32 idx, u32 particleFrame, CParticle& particle) {
|
bool CElementGen::UpdateVelocitySource(size_t idx, u32 particleFrame, CParticle& particle) {
|
||||||
bool err;
|
bool err;
|
||||||
if (x278_hasVMD[idx]) {
|
if (x278_hasVMD[idx]) {
|
||||||
zeus::CVector3f localVel = x208_orientationInverse * particle.x1c_vel;
|
zeus::CVector3f localVel = x208_orientationInverse * particle.x1c_vel;
|
||||||
|
@ -433,9 +438,10 @@ void CElementGen::UpdateExistingParticles() {
|
||||||
|
|
||||||
++x25c_activeParticleCount;
|
++x25c_activeParticleCount;
|
||||||
|
|
||||||
for (int i = 0; i < 4; ++i) {
|
for (size_t i = 0; i < x280_VELSources.size(); ++i) {
|
||||||
if (!x280_VELSources[i])
|
if (!x280_VELSources[i]) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
UpdateVelocitySource(i, particleFrame, particle);
|
UpdateVelocitySource(i, particleFrame, particle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ private:
|
||||||
int m_maxMAXP = 256;
|
int m_maxMAXP = 256;
|
||||||
u16 x94_randomSeed = g_GlobalSeed;
|
u16 x94_randomSeed = g_GlobalSeed;
|
||||||
float x98_generatorRate = 1.f;
|
float x98_generatorRate = 1.f;
|
||||||
float x9c_externalVars[16] = {};
|
std::array<float, 16> x9c_externalVars{};
|
||||||
|
|
||||||
zeus::CVector3f xdc_translation;
|
zeus::CVector3f xdc_translation;
|
||||||
zeus::CVector3f xe8_globalTranslation;
|
zeus::CVector3f xe8_globalTranslation;
|
||||||
|
@ -110,9 +110,9 @@ private:
|
||||||
int x270_MBSP = 0;
|
int x270_MBSP = 0;
|
||||||
int m_maxMBSP = 0;
|
int m_maxMBSP = 0;
|
||||||
ERglLightBits x274_backupLightActive = ERglLightBits::None;
|
ERglLightBits x274_backupLightActive = ERglLightBits::None;
|
||||||
bool x278_hasVMD[4] = {};
|
std::array<bool, 4> x278_hasVMD{};
|
||||||
CRandom16 x27c_randState;
|
CRandom16 x27c_randState;
|
||||||
CModVectorElement* x280_VELSources[4] = {};
|
std::array<CModVectorElement*, 4> x280_VELSources{};
|
||||||
|
|
||||||
std::vector<std::unique_ptr<CParticleGen>> x290_activePartChildren;
|
std::vector<std::unique_ptr<CParticleGen>> x290_activePartChildren;
|
||||||
int x2a0_CSSD = 0;
|
int x2a0_CSSD = 0;
|
||||||
|
@ -148,15 +148,15 @@ public:
|
||||||
EOptionalSystemFlags flags = EOptionalSystemFlags::One);
|
EOptionalSystemFlags flags = EOptionalSystemFlags::One);
|
||||||
~CElementGen() override;
|
~CElementGen() override;
|
||||||
|
|
||||||
boo::ObjToken<boo::IShaderDataBinding> m_normalDataBind[2];
|
std::array<boo::ObjToken<boo::IShaderDataBinding>, 2> m_normalDataBind;
|
||||||
boo::ObjToken<boo::IShaderDataBinding> m_normalSubDataBind[2];
|
std::array<boo::ObjToken<boo::IShaderDataBinding>, 2> m_normalSubDataBind;
|
||||||
boo::ObjToken<boo::IShaderDataBinding> m_redToAlphaDataBind[2];
|
std::array<boo::ObjToken<boo::IShaderDataBinding>, 2> m_redToAlphaDataBind;
|
||||||
boo::ObjToken<boo::IShaderDataBinding> m_redToAlphaSubDataBind[2];
|
std::array<boo::ObjToken<boo::IShaderDataBinding>, 2> m_redToAlphaSubDataBind;
|
||||||
boo::ObjToken<boo::IGraphicsBufferD> m_instBuf;
|
boo::ObjToken<boo::IGraphicsBufferD> m_instBuf;
|
||||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniformBuf;
|
boo::ObjToken<boo::IGraphicsBufferD> m_uniformBuf;
|
||||||
|
|
||||||
boo::ObjToken<boo::IShaderDataBinding> m_normalDataBindPmus[2];
|
std::array<boo::ObjToken<boo::IShaderDataBinding>, 2> m_normalDataBindPmus;
|
||||||
boo::ObjToken<boo::IShaderDataBinding> m_redToAlphaDataBindPmus[2];
|
std::array<boo::ObjToken<boo::IShaderDataBinding>, 2> m_redToAlphaDataBindPmus;
|
||||||
boo::ObjToken<boo::IGraphicsBufferD> m_instBufPmus;
|
boo::ObjToken<boo::IGraphicsBufferD> m_instBufPmus;
|
||||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniformBufPmus;
|
boo::ObjToken<boo::IGraphicsBufferD> m_uniformBufPmus;
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ public:
|
||||||
static void Shutdown();
|
static void Shutdown();
|
||||||
|
|
||||||
void UpdateAdvanceAccessParameters(u32 activeParticleCount, u32 particleFrame);
|
void UpdateAdvanceAccessParameters(u32 activeParticleCount, u32 particleFrame);
|
||||||
bool UpdateVelocitySource(u32 idx, u32 particleFrame, CParticle& particle);
|
bool UpdateVelocitySource(size_t idx, u32 particleFrame, CParticle& particle);
|
||||||
void UpdateExistingParticles();
|
void UpdateExistingParticles();
|
||||||
void CreateNewParticles(int);
|
void CreateNewParticles(int);
|
||||||
void UpdatePSTranslationAndOrientation();
|
void UpdatePSTranslationAndOrientation();
|
||||||
|
|
Loading…
Reference in New Issue