Cogs.Core
EnvironmentSystem.cpp
1#include <algorithm>
2#include "EnvironmentSystem.h"
3#include "Resources/TextureManager.h"
4
5namespace {
6 using namespace Cogs::Core;
7
8 void updateLod(unsigned& lods, TextureHandle tex)
9 {
10 if (tex) {
11 if ((tex->description.flags & Cogs::TextureFlags::GenerateMipMaps) != 0) {
12 lods = 1 + static_cast<uint32_t>(std::floor(std::log2((double)std::max(tex->description.width, tex->description.height))));
13 }
14 else {
15 lods = tex->description.levels;
16 }
17 }
18 }
19
20
21}
22
24{
25 for (auto & envComp : pool) {
26 auto & envData = getData(&envComp);
27
28 updateLod(envData.radianceLods, envComp.radiance);
29 updateLod(envData.irradianceLods, envComp.irradiance);
30 updateLod(envData.ambientIrradianceLods, envComp.ambientIrradiance);
31 }
32}
void update()
Updates the system state to that of the current frame.
ComponentPool< ComponentType > pool
Pool of components managed by the system.
A Context instance contains all the services, systems and runtime components needed to use Cogs.
Definition: Context.h:83
Contains the Engine, Renderer, resource managers and other systems needed to run Cogs....
@ GenerateMipMaps
The texture supports automatic mipmap generation performed by the graphics device.
Definition: Flags.h:124