Add LightList::remove
This commit is contained in:
parent
2ff8debe8c
commit
dec6cdec3f
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user