#pragma once #include #include "../CollabList.hpp" #include "../DrawComponents/DrawComponent.hpp" class DrawingProgramCache { public: typedef CollabList, ServerClientID> CollabListType; void update(const std::vector& components); void erase_component(const CollabListType::ObjectInfoPtr& c); void add_component(const CollabListType::ObjectInfoPtr& c); struct BVHNode { SCollision::AABB bounds; std::vector components; std::vector children; }; void traverse_bvh_run_function(const SCollision::AABB& aabb, std::function* bounds, const std::vector& components)> f); // Run before actually updating the component void preupdate_component(DrawComponent* c); private: void build(std::vector components); void traverse_bvh_run_function_recursive(BVHNode& bvhNode, const SCollision::AABB& aabb, std::function* bounds, const std::vector& components)> f); std::pair::iterator> get_bvh_node_fully_containing_recursive(BVHNode& bvhNode, DrawComponent* c); void build_bvh_node(BVHNode& node, std::vector components); BVHNode bvhRoot; std::vector unsortedComponents; };