From 26c1953bc0e2382edfd8bb0648190d7a9807fec4 Mon Sep 17 00:00:00 2001 From: Brett Date: Wed, 1 May 2024 20:56:47 -0400 Subject: [PATCH] fold --- CMakeLists.txt | 2 +- include/blt/gfx/raycast.h | 35 +++++++++++++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0bb1e51..9c77e3f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.25) -set(BLT_GRAPHICS_VERSION 0.12.3) +set(BLT_GRAPHICS_VERSION 0.12.4) set(BLT_GRAPHICS_TEST_VERSION 0.0.1) project(BLT_WITH_GRAPHICS VERSION ${BLT_GRAPHICS_VERSION}) diff --git a/include/blt/gfx/raycast.h b/include/blt/gfx/raycast.h index b7f1762..e0b87af 100644 --- a/include/blt/gfx/raycast.h +++ b/include/blt/gfx/raycast.h @@ -21,15 +21,46 @@ #include #include +#include namespace blt::gfx { - + template + inline const bool not_float_v = (std::is_arithmetic_v && ...) && (!std::is_same_v && ...); + blt::vec3 calculateRay3D(float mx, float my, float width, float height, const blt::mat4x4& view, const blt::mat4x4& proj); + blt::vec3 calculateRay3D(float width, float height, const blt::mat4x4& view, const blt::mat4x4& proj); + blt::vec3 calculateRay2D(float mx, float my, float width, float height, const blt::vec3 scale, const blt::mat4x4& view, const blt::mat4x4& proj); + blt::vec3 calculateRay2D(float width, float height, const blt::vec3 scale, const blt::mat4x4& view, const blt::mat4x4& proj); + template, bool> = true> + inline blt::vec3 calculateRay2D(T width, G height, const blt::vec3& scale, const blt::mat4x4& view, const blt::mat4x4& proj) + { + return calculateRay2D(static_cast(width), static_cast(height), scale, view, proj); + } + + template, bool> = true> + inline blt::vec3 calculateRay2D(T mx, G my, V width, N height, const blt::vec3& scale, const blt::mat4x4& view, const blt::mat4x4& proj) + { + return calculateRay2D(static_cast(mx), static_cast(my), + static_cast(width), static_cast(height), scale, view, proj); + } + + template, bool> = true> + inline blt::vec3 calculateRay3D(T width, G height, const blt::mat4x4& view, const blt::mat4x4& proj) + { + return calculateRay3D(static_cast(width), static_cast(height), view, proj); + } + + template, bool> = true> + inline blt::vec3 calculateRay3D(T mx, G my, V width, N height, const blt::mat4x4& view, const blt::mat4x4& proj) + { + return calculateRay3D(static_cast(mx), static_cast(my), static_cast(width), static_cast(height), view, proj); + } + namespace detail { blt::vec3 toWorldCoords(const blt::vec4& eyeCoords, const blt::mat4x4& view); @@ -43,7 +74,7 @@ namespace blt::gfx return blt::vec2(x, y); } } - + } #endif //BLT_GRAPHICS_RAYCAST_H