Radium Engine  1.5.0
DefaultLightManager.cpp
1 #include <Engine/Scene/DefaultLightManager.hpp>
2 
3 #include <Engine/RadiumEngine.hpp>
4 
5 namespace Ra {
6 namespace Engine {
7 namespace Scene {
8 
9 DefaultLightManager::DefaultLightManager() {
10  m_data = std::make_unique<DefaultLightStorage>();
11 }
12 
13 const Scene::Light* DefaultLightManager::getLight( size_t li ) const {
14  return ( *m_data )[li];
15 }
16 
18  m_data->add( li );
19 }
20 
21 DefaultLightStorage::DefaultLightStorage() = default;
22 
24 
26  m_lights.emplace( li->getType(), li );
27 }
28 
30  auto range = m_lights.equal_range( li->getType() );
31  for ( auto i = range.first; i != range.second; ++i ) {
32  if ( i->second == li ) {
33  m_lights.erase( i );
34  break;
35  }
36  }
37 }
38 
39 size_t DefaultLightStorage::size() const {
40  return m_lights.size();
41 }
42 
44  m_lights.clear();
45 }
46 
48  auto iterator = m_lights.begin();
49  std::advance( iterator, n );
50  return iterator->second;
51 }
52 } // namespace Scene
53 } // namespace Engine
54 } // namespace Ra
const Scene::Light * getLight(size_t li) const override
Get a pointer to the li-th Light.
void addLight(const Scene::Light *li) override
void add(const Scene::Light *i) override
Add a Light to the container.
size_t size() const override
Returns the container size.
void remove(const Scene::Light *li) override
Remove a Light from the container.
const Scene::Light * operator[](unsigned int n) override
Access the container.
void clear() override
Clear the container.
std::unique_ptr< LightStorage > m_data
Stores the object that stores the lights...
const LightType & getType() const
Definition: Light.hpp:82
Definition: Cage.cpp:3