Program Listing for File collision.hpp

Return to documentation for file (inexor/vulkan-renderer/world/collision.hpp)

#pragma once

#include <glm/vec3.hpp>

#include <string>
#include <tuple>

namespace inexor::vulkan_renderer::world {

template <typename T>
class RayCubeCollision {
    const T &m_cube;

    glm::vec3 m_intersection;
    glm::vec3 m_selected_face;
    glm::vec3 m_nearest_corner;
    glm::vec3 m_nearest_edge;

public:
    RayCubeCollision(const T &cube, glm::vec3 ray_pos, glm::vec3 ray_dir);

    RayCubeCollision(const RayCubeCollision &) = delete;

    RayCubeCollision(RayCubeCollision &&other) noexcept;

    ~RayCubeCollision() = default;

    RayCubeCollision &operator=(const RayCubeCollision &) = delete;
    RayCubeCollision &operator=(RayCubeCollision &&) = delete;

    [[nodiscard]] const T &cube() const noexcept {
        return m_cube;
    }

    [[nodiscard]] const glm::vec3 &intersection() const noexcept {
        return m_intersection;
    }

    [[nodiscard]] const glm::vec3 &face() const noexcept {
        return m_selected_face;
    }

    [[nodiscard]] const glm::vec3 &corner() const noexcept {
        return m_nearest_corner;
    }

    [[nodiscard]] const glm::vec3 &edge() const noexcept {
        return m_nearest_edge;
    }
};

} // namespace inexor::vulkan_renderer::world