#pragma once
#include "vertex.hpp"
#include "object.hpp"
#include "light.hpp"
#include "common.hpp"
#include <vector>


class Scene {
    private:
        typedef std::vector<const Object*> obj_lru_t;

        std::vector<const Light*> lights;
        Lights* lighting;

        mutable std::vector<const Object*> objects;
        mutable std::vector<const Object*> light_objects;
        bool cleanup; // whether objects and lights should be destructed
        vertex_t bound_min, bound_max;

    public:
        Scene();
        ~Scene();

        bool push(Object* o);
        bool push(Light* o);
        void finalize();

        const Object* intersect(ray_t& ray, const vertex_t&, vertex_t& hitpoint, vertex_t& normal, LightValue&, Img::rgb_t* col) const;
        static bool intersect(const ray_t& ray, std::vector<const Object*>&);
        bool intersect(const ray_t& ray) const;

        void get_light(const Object*, const vertex_t& hit, const vertex_t& ray, const vertex_t& raynrm, const vertex_t& nrm, LightValue&) const;

        const Scene* getSMPcopy() const;
};