.. _program_listing_file_Src_GraphicsEngineOpenGL_scene_ViewFrustumCulling.hpp: Program Listing for File ViewFrustumCulling.hpp =============================================== |exhale_lsh| :ref:`Return to documentation for file ` (``Src/GraphicsEngineOpenGL/scene/ViewFrustumCulling.hpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp #pragma once #include #include #include #include #include #include #include "camera/Camera.hpp" #include "hostDevice/GlobalValues.hpp" #include "scene/AABB.hpp" #include "scene/texture/Texture.hpp" class ViewFrustumCulling { public: ViewFrustumCulling(); bool is_inside(GLfloat ratio, std::shared_ptr main_camera, std::shared_ptr bounding_box, glm::mat4 model); void render_view_frustum(); ~ViewFrustumCulling(); private: // render view frustum unsigned int VBO, VAO, EBO; unsigned int m_drawCount; // we get that as input GLfloat near_plane, far_plane, fov, ratio; // calculate as soon as we become params GLfloat tan, near_height, near_width, far_height, far_width; std::shared_ptr main_camera; glm::vec3 dir, near_center, far_center; // all corners of the frustum // near plane glm::vec3 near_top_left, near_top_right, near_bottom_left, near_bottom_right; // far plane glm::vec3 far_top_left, far_top_right, far_bottom_left, far_bottom_right; // planes in Hesse normal form // layout: [0]: near plane, [1] far plane, [2] front, [3] bottom, [4]: left, // [5]: right struct frustum_plane { glm::vec3 normal; glm::vec3 position; }; frustum_plane frustum_planes[NUM_FRUSTUM_PLANES]; void init(std::vector frustum_corner); bool corners_outside_plane(std::vector aabb_corners, frustum_plane plane, GLuint outcode_pattern); GLfloat plane_point_distance(frustum_plane plane, glm::vec3 corner); void update_frustum_param(GLfloat near_plane, GLfloat far_plane, GLfloat fov, GLfloat ratio, std::shared_ptr main_camera); };