Commit 3bfbb704 authored by Philip Trettner's avatar Philip Trettner
Browse files

Merge branch 'kw/develop' into 'develop'

perspective_reverse_z_directx, clang-format

See merge request !84
parents 645ba9e0 6addb09b
#pragma once
#include <typed-geometry/types/size.hh>
#include <typed-geometry/detail/macros.hh>
#include <typed-geometry/detail/scalar_traits.hh>
#include <typed-geometry/types/size.hh>
namespace tg
{
......
#pragma once
#include <typed-geometry/detail/scalar_traits.hh>
#include <typed-geometry/types/objects/triangle.hh>
#include <typed-geometry/types/size.hh>
#include <typed-geometry/detail/scalar_traits.hh>
namespace tg
{
......
#pragma once
#include <typed-geometry/types/size.hh>
#include <typed-geometry/types/vec.hh>
#include <typed-geometry/detail/macros.hh>
#include <typed-geometry/detail/scalar_traits.hh>
#include <typed-geometry/types/size.hh>
#include <typed-geometry/types/vec.hh>
namespace tg
{
......
#pragma once
#include <typed-geometry/feature/assert.hh>
#include <typed-geometry/detail/utility.hh>
#include <typed-geometry/feature/assert.hh>
namespace tg
{
......
#pragma once
#include <typed-geometry/functions/random/random.hh>
#include <typed-geometry/functions/random/gaussian.hh>
#include <typed-geometry/functions/random/random.hh>
#include <typed-geometry/functions/random/random_choice.hh>
#include <typed-geometry/functions/random/uniform.hh>
......@@ -12,7 +12,7 @@
namespace tg::detail
{
template<>
template <>
inline u128 mul(u64 lhs, u64 rhs)
{
u128 res;
......@@ -25,7 +25,7 @@ inline u128 mul(u64 lhs, u64 rhs)
return res;
}
template<>
template <>
inline u128 mul(u128 lhs, u64 rhs)
{
u128 res;
......@@ -40,7 +40,7 @@ inline u128 mul(u128 lhs, u64 rhs)
return res;
}
template<>
template <>
inline u128 mul(u64 lhs, u128 rhs)
{
u128 res;
......@@ -55,7 +55,7 @@ inline u128 mul(u64 lhs, u128 rhs)
return res;
}
template<>
template <>
inline u128 mul(u128 lhs, u128 rhs)
{
u128 res;
......@@ -72,7 +72,7 @@ inline u128 mul(u128 lhs, u128 rhs)
return res;
}
template<>
template <>
inline u192 mul(u128 lhs, u64 rhs)
{
u192 res;
......@@ -92,7 +92,7 @@ inline u192 mul(u128 lhs, u64 rhs)
return res;
}
template<>
template <>
inline u192 mul(u192 lhs, u64 rhs)
{
u192 res;
......@@ -114,7 +114,7 @@ inline u192 mul(u192 lhs, u64 rhs)
return res;
}
template<>
template <>
inline u192 mul(u64 lhs, u128 rhs)
{
u192 res;
......@@ -134,7 +134,7 @@ inline u192 mul(u64 lhs, u128 rhs)
return res;
}
template<>
template <>
inline u192 mul(u128 lhs, u128 rhs)
{
u192 res;
......@@ -160,7 +160,7 @@ inline u192 mul(u128 lhs, u128 rhs)
return res;
}
template<>
template <>
inline u192 mul(u192 lhs, u128 rhs)
{
u192 res;
......@@ -188,7 +188,7 @@ inline u192 mul(u192 lhs, u128 rhs)
return res;
}
template<>
template <>
inline u192 mul(u64 lhs, u192 rhs)
{
u192 res;
......@@ -210,7 +210,7 @@ inline u192 mul(u64 lhs, u192 rhs)
return res;
}
template<>
template <>
inline u192 mul(u128 lhs, u192 rhs)
{
u192 res;
......@@ -238,7 +238,7 @@ inline u192 mul(u128 lhs, u192 rhs)
return res;
}
template<>
template <>
inline u192 mul(u192 lhs, u192 rhs)
{
u192 res;
......@@ -268,7 +268,7 @@ inline u192 mul(u192 lhs, u192 rhs)
return res;
}
template<>
template <>
inline u256 mul(u192 lhs, u64 rhs)
{
u256 res;
......@@ -295,7 +295,7 @@ inline u256 mul(u192 lhs, u64 rhs)
return res;
}
template<>
template <>
inline u256 mul(u256 lhs, u64 rhs)
{
u256 res;
......@@ -324,7 +324,7 @@ inline u256 mul(u256 lhs, u64 rhs)
return res;
}
template<>
template <>
inline u256 mul(u128 lhs, u128 rhs)
{
u256 res;
......@@ -356,7 +356,7 @@ inline u256 mul(u128 lhs, u128 rhs)
return res;
}
template<>
template <>
inline u256 mul(u192 lhs, u128 rhs)
{
u256 res;
......@@ -394,7 +394,7 @@ inline u256 mul(u192 lhs, u128 rhs)
return res;
}
template<>
template <>
inline u256 mul(u256 lhs, u128 rhs)
{
u256 res;
......@@ -434,7 +434,7 @@ inline u256 mul(u256 lhs, u128 rhs)
return res;
}
template<>
template <>
inline u256 mul(u64 lhs, u192 rhs)
{
u256 res;
......@@ -461,7 +461,7 @@ inline u256 mul(u64 lhs, u192 rhs)
return res;
}
template<>
template <>
inline u256 mul(u128 lhs, u192 rhs)
{
u256 res;
......@@ -499,7 +499,7 @@ inline u256 mul(u128 lhs, u192 rhs)
return res;
}
template<>
template <>
inline u256 mul(u192 lhs, u192 rhs)
{
u256 res;
......@@ -543,7 +543,7 @@ inline u256 mul(u192 lhs, u192 rhs)
return res;
}
template<>
template <>
inline u256 mul(u256 lhs, u192 rhs)
{
u256 res;
......@@ -589,7 +589,7 @@ inline u256 mul(u256 lhs, u192 rhs)
return res;
}
template<>
template <>
inline u256 mul(u64 lhs, u256 rhs)
{
u256 res;
......@@ -618,7 +618,7 @@ inline u256 mul(u64 lhs, u256 rhs)
return res;
}
template<>
template <>
inline u256 mul(u128 lhs, u256 rhs)
{
u256 res;
......@@ -658,7 +658,7 @@ inline u256 mul(u128 lhs, u256 rhs)
return res;
}
template<>
template <>
inline u256 mul(u192 lhs, u256 rhs)
{
u256 res;
......@@ -704,7 +704,7 @@ inline u256 mul(u192 lhs, u256 rhs)
return res;
}
template<>
template <>
inline u256 mul(u256 lhs, u256 rhs)
{
u256 res;
......
#pragma once
#include <typed-geometry/functions/basic/scalar_math.hh>
#include <typed-geometry/detail/utility.hh>
#include <typed-geometry/functions/basic/scalar_math.hh>
#include <typed-geometry/types/mat.hh>
namespace tg
......
#pragma once
#include <typed-geometry/detail/operators/ops_mat.hh>
#include <typed-geometry/detail/scalar_traits.hh>
#include <typed-geometry/types/mat.hh>
#include <typed-geometry/types/vec.hh>
#include <typed-geometry/detail/operators/ops_mat.hh>
#include "determinant.hh"
namespace tg
......
......@@ -89,17 +89,23 @@ template <class ScalarT>
}
template <class ScalarT>
[[nodiscard]] constexpr mat<4, 4, ScalarT> look_at(pos<3, ScalarT> const& eye, dir<3, ScalarT> const& fwd, vec<3, ScalarT> const& ref_up)
[[deprecated("use explicit _opengl or _directx version")]] [[nodiscard]] constexpr mat<4, 4, ScalarT> look_at(pos<3, ScalarT> const& eye,
dir<3, ScalarT> const& fwd,
vec<3, ScalarT> const& ref_up)
{
return look_at_opengl(eye, fwd, ref_up);
}
template <class ScalarT>
[[nodiscard]] constexpr mat<4, 4, ScalarT> look_at(pos<3, ScalarT> const& eye, pos<3, ScalarT> const& target, vec<3, ScalarT> const& ref_up)
[[deprecated("use explicit _opengl or _directx version")]] [[nodiscard]] constexpr mat<4, 4, ScalarT> look_at(pos<3, ScalarT> const& eye,
pos<3, ScalarT> const& target,
vec<3, ScalarT> const& ref_up)
{
return look_at_opengl(eye, normalize(target - eye), ref_up);
}
template <class ScalarT>
[[nodiscard]] constexpr mat<4, 4, ScalarT> look_at(pos<3, ScalarT> const& eye, vec<3, ScalarT> const& fwd, vec<3, ScalarT> const& ref_up)
[[deprecated("use explicit _opengl or _directx version")]] [[nodiscard]] constexpr mat<4, 4, ScalarT> look_at(pos<3, ScalarT> const& eye,
vec<3, ScalarT> const& fwd,
vec<3, ScalarT> const& ref_up)
{
return look_at_opengl(eye, normalize(fwd), ref_up);
}
......
......@@ -10,7 +10,7 @@ namespace tg
{
/// aspect ratio is width / height
template <class ScalarT>
[[nodiscard]] mat<4, 4, ScalarT> perspective_reverse_z(angle_t<ScalarT> horizontal_fov, ScalarT aspect_ratio, ScalarT near_plane)
[[nodiscard]] mat<4, 4, ScalarT> perspective_reverse_z_opengl(angle_t<ScalarT> horizontal_fov, ScalarT aspect_ratio, ScalarT near_plane)
{
TG_CONTRACT(near_plane > 0);
TG_CONTRACT(aspect_ratio > 0);
......@@ -31,6 +31,25 @@ template <class ScalarT>
return m;
}
template <class ScalarT>
[[nodiscard]] mat<4, 4, ScalarT> perspective_reverse_z_directx(angle_t<ScalarT> horizontal_fov, ScalarT aspect_ratio, ScalarT near_plane)
{
TG_CONTRACT(near_plane > 0);
TG_CONTRACT(aspect_ratio > 0);
TG_CONTRACT(horizontal_fov > degree(0));
TG_CONTRACT(horizontal_fov < degree(180));
auto const tan_half_hfov = tan(horizontal_fov / ScalarT(2));
auto m = mat<4, 4, ScalarT>::zero;
m[0][0] = ScalarT(1) / (aspect_ratio * tan_half_hfov);
m[1][1] = ScalarT(1) / tan_half_hfov;
m[2][3] = ScalarT(1);
m[3][2] = near_plane;
return m;
}
template <class ScalarT>
[[nodiscard]] mat<4, 4, ScalarT> perspective_directx(angle_t<ScalarT> horizontal_fov, ScalarT aspect_ratio, ScalarT near_plane, ScalarT far_plane)
{
......@@ -85,8 +104,19 @@ template <class ScalarT>
}
template <class ScalarT>
[[nodiscard]] mat<4, 4, ScalarT> perspective(angle_t<ScalarT> horizontal_fov, ScalarT aspect_ratio, ScalarT near_plane, ScalarT far_plane)
[[deprecated("use explicit _opengl or _directx version")]] [[nodiscard]] mat<4, 4, ScalarT> perspective(angle_t<ScalarT> horizontal_fov,
ScalarT aspect_ratio,
ScalarT near_plane,
ScalarT far_plane)
{
return perspective_opengl(horizontal_fov, aspect_ratio, near_plane, far_plane);
}
template <class ScalarT>
[[deprecated("use explicit _opengl or _directx version")]] [[nodiscard]] mat<4, 4, ScalarT> perspective_reverse_z(angle_t<ScalarT> horizontal_fov,
ScalarT aspect_ratio,
ScalarT near_plane)
{
return perspective_reverse_z_opengl(horizontal_fov, aspect_ratio, near_plane);
}
}
#pragma once
#include <typed-geometry/functions/vector/interpolate.hh>
#include <typed-geometry/functions/vector/distance.hh>
#include <typed-geometry/functions/tests/triangle_tests.hh>
#include <typed-geometry/functions/vector/distance.hh>
#include <typed-geometry/functions/vector/interpolate.hh>
#include <typed-geometry/types/objects/sphere.hh>
#include <typed-geometry/types/objects/triangle.hh>
......
......@@ -189,8 +189,7 @@ template <class ScalarT>
auto limit = eps;
if (eps != ScalarT(0))
{
auto aMax = abs(A0) >= abs(A1) ? (abs(A0) >= abs(A2) ? A0 : A2)
: (abs(A1) >= abs(A2) ? A1 : A2);
auto aMax = abs(A0) >= abs(A1) ? (abs(A0) >= abs(A2) ? A0 : A2) : (abs(A1) >= abs(A2) ? A1 : A2);
limit = -std::copysign(eps, aMax) * sign(eps);
}
......
......@@ -90,7 +90,7 @@ template <int D, class ScalarT>
auto res = p;
auto projectionNeeded = true;
auto closestDist = max<ScalarT>();
auto closestDim = 0; // Will be overwritten
auto closestDim = 0; // Will be overwritten
auto closestDimVal = ScalarT(0); // Will be overwritten
for (auto i = 0; i < D; ++i)
{
......
#pragma once
#include <typed-geometry/functions/basic/scalar_math.hh>
#include <typed-geometry/detail/operators/ops_vec.hh>
#include <typed-geometry/detail/scalar_traits.hh>
#include <typed-geometry/functions/basic/scalar_math.hh>
#include <typed-geometry/types/objects/segment.hh>
#include <typed-geometry/types/vec.hh>
......
#pragma once
#include <typed-geometry/functions/basic/scalar_math.hh>
#include <typed-geometry/detail/macros.hh>
#include <typed-geometry/functions/basic/scalar_math.hh>
#include <typed-geometry/types/color.hh>
#include <typed-geometry/types/comp.hh>
#include <typed-geometry/types/dir.hh>
......
#pragma once
#include <typed-geometry/functions/basic/scalar_math.hh>
#include <typed-geometry/detail/scalar_traits.hh>
#include <typed-geometry/functions/basic/scalar_math.hh>
#include <typed-geometry/types/mat.hh>
#include <typed-geometry/types/vec.hh>
......
#pragma once
#include <typed-geometry/feature/assert.hh>
#include <typed-geometry/detail/utility.hh>
#include <typed-geometry/feature/assert.hh>
namespace tg
{
......
#pragma once
#include <typed-geometry/feature/assert.hh>
#include <typed-geometry/detail/utility.hh>
#include <typed-geometry/feature/assert.hh>
namespace tg
{
......
#pragma once
#include <typed-geometry/types/scalars/default.hh>
#include "../detail/comp_traits.hh"
#include "../detail/macros.hh"
#include "../detail/scalar_traits.hh"
#include "../detail/utility.hh"
#include "fwd.hh"
#include <typed-geometry/types/scalars/default.hh>
namespace tg
{
......
#pragma once
#include "../pos.hh"
#include <typed-geometry/types/scalars/default.hh>
#include "../pos.hh"
#include "../size.hh"
#include "../vec.hh"
#include "traits.hh"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment