Add LightList::remove

This commit is contained in:
MrLetsplay 2023-09-16 16:51:43 +02:00
parent 2ff8debe8c
commit dec6cdec3f
Signed by: mr
SSH Key Fingerprint: SHA256:92jBH80vpXyaZHjaIl47pjRq+Yt7XGTArqQg1V7hSqg
2 changed files with 47 additions and 0 deletions

View File

@ -1,3 +1,4 @@
#include <algorithm>
#include <vector>
#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;
}
}
}

View File

@ -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);
};
}