|
|
@@ -72,7 +72,31 @@ void level::add_bullet(bullet b) {
|
|
|
collidables[0].emplace_back(bullets_.back().get());
|
|
|
}
|
|
|
|
|
|
+template <typename T>
|
|
|
+void level::perform_oob_culling_impl(std::vector<std::unique_ptr<T>> & data) {
|
|
|
+ // TODO: Aquire screen size correctly...?
|
|
|
+ math::dim2::rectangle bound{{{0.f, 0.f}}, {{3840.f, 2160.f}}};
|
|
|
+ auto is_oob = [&bound](std::unique_ptr<T> & ptr) {
|
|
|
+ return !math::intersects(ptr->render_info().points, bound);
|
|
|
+ };
|
|
|
+ auto it = std::remove_if(data.begin(), data.end(), is_oob);
|
|
|
+ auto remove_collider = [this](std::unique_ptr<T> & ptr) {
|
|
|
+ // TODO: colliders, use the collision enums.
|
|
|
+ collidables[0].erase(
|
|
|
+ std::remove(collidables[0].begin(), collidables[0].end(), ptr.get()),
|
|
|
+ collidables[0].end());
|
|
|
+ };
|
|
|
+ std::for_each(it, data.end(), remove_collider);
|
|
|
+ data.erase(it, data.end());
|
|
|
+}
|
|
|
+
|
|
|
+void level::perform_oob_culling() {
|
|
|
+ // perform_oob_culling_impl(actors_);
|
|
|
+ perform_oob_culling_impl(bullets_);
|
|
|
+}
|
|
|
+
|
|
|
void level::update(float delta) {
|
|
|
+ perform_oob_culling();
|
|
|
update_waves(delta);
|
|
|
update_object(delta);
|
|
|
check_collisions();
|