Minor refactor of lightprobe related code
This commit is contained in:
parent
8717076d96
commit
04195e8331
4 changed files with 71 additions and 81 deletions
52
src/common/rendering/hwrenderer/data/hw_lightprobe.cpp
Normal file
52
src/common/rendering/hwrenderer/data/hw_lightprobe.cpp
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
#include "hw_lightprobe.h"
|
||||
|
||||
void LightProbeIncrementalBuilder::Step(const TArray<LightProbe>& probes, std::function<void(const LightProbe&, TArray<uint16_t>&, TArray<uint16_t>&)> renderScene, std::function<void(TArray<uint16_t>&&, TArray<uint16_t>&&)> uploadEnv)
|
||||
{
|
||||
if (lastIndex >= probes.size())
|
||||
{
|
||||
lastIndex = 0;
|
||||
|
||||
if (!probes.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
TArray<uint16_t> irradianceMap;
|
||||
TArray<uint16_t> prefilterMap;
|
||||
|
||||
renderScene(probes[lastIndex++], irradianceMap, prefilterMap);
|
||||
++collected;
|
||||
|
||||
this->irradianceMaps.Append(irradianceMap);
|
||||
this->prefilterMaps.Append(prefilterMap);
|
||||
|
||||
if (lastIndex >= probes.size())
|
||||
{
|
||||
if (collected == probes.size())
|
||||
{
|
||||
uploadEnv(std::move(this->irradianceMaps), std::move(this->prefilterMaps));
|
||||
}
|
||||
this->irradianceMaps.Clear();
|
||||
this->prefilterMaps.Clear();
|
||||
collected = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void LightProbeIncrementalBuilder::Full(const TArray<LightProbe>& probes, std::function<void(const LightProbe&, TArray<uint16_t>&, TArray<uint16_t>&)> renderScene, std::function<void(TArray<uint16_t>&&, TArray<uint16_t>&&)> uploadEnv)
|
||||
{
|
||||
if (lastIndex >= probes.size())
|
||||
{
|
||||
lastIndex = 0;
|
||||
|
||||
if (!probes.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
while (lastIndex < probes.size())
|
||||
{
|
||||
Step(probes, renderScene, uploadEnv);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue