diff --git a/src/kekengine/cpp/object/light.cpp b/src/kekengine/cpp/object/light.cpp index df4165e..005b3da 100644 --- a/src/kekengine/cpp/object/light.cpp +++ b/src/kekengine/cpp/object/light.cpp @@ -1,3 +1,4 @@ +#include #include #include "constants.h" @@ -80,4 +81,45 @@ void LightList::add(Light *light) { } } +void LightList::remove(PointLight *light) { + auto it = std::find(point.begin(), point.end(), light); + if(it != point.end()) { + point.erase(it); + } + + delete light; +} + +void LightList::remove(DirectionalLight *light) { + auto it = std::find(directional.begin(), directional.end(), light); + if(it != directional.end()) { + directional.erase(it); + } + + delete light; +} + +void LightList::remove(SpotLight *light) { + auto it = std::find(spot.begin(), spot.end(), light); + if(it != spot.end()) { + spot.erase(it); + } + + delete light; +} + +void LightList::remove(Light *light) { + switch(light->getType()) { + case LightType::POINT: + remove((PointLight *) light); + break; + case LightType::DIRECTIONAL: + remove((DirectionalLight *) light); + break; + case LightType::SPOT: + remove((SpotLight *) light); + break; + } +} + } diff --git a/src/kekengine/include/light.h b/src/kekengine/include/light.h index 8022e39..64fd36e 100644 --- a/src/kekengine/include/light.h +++ b/src/kekengine/include/light.h @@ -77,6 +77,11 @@ class LightList { LightList(); void add(Light *light); + + void remove(PointLight *light); + void remove(DirectionalLight *light); + void remove(SpotLight *light); + void remove(Light *light); }; }