Minor fixes

This commit is contained in:
SirLynix
2023-07-30 19:46:01 +02:00
parent a7eba496fb
commit e2808192aa
12 changed files with 22 additions and 28 deletions

View File

@@ -16,7 +16,7 @@ namespace Nz
struct ModuleConfigHasOverride<T, std::void_t<decltype(std::declval<T>().Override(std::declval<const CommandLineParameters&>()))>> : std::true_type {};
template<typename T>
auto OverrideModuleConfig(T&& module, const CommandLineParameters& params)
decltype(auto) OverrideModuleConfig(T&& module, const CommandLineParameters& params)
{
if constexpr (!std::is_const_v<T> && ModuleConfigHasOverride<T>::value)
module.Override(params);
@@ -28,7 +28,7 @@ namespace Nz
struct Pick
{
template<typename First, typename... Args>
static auto Get(First&& first, Args&&... args)
static decltype(auto) Get(First&& first, Args&&... args)
{
if constexpr (std::is_same_v<T, std::decay_t<First>>)
return std::forward<First>(first);
@@ -40,7 +40,7 @@ namespace Nz
}
template<typename First, typename... Args>
static auto Get(const CommandLineParameters& parameters, First&& first, Args&&... args)
static decltype(auto) Get(const CommandLineParameters& parameters, First&& first, Args&&... args)
{
if constexpr (std::is_same_v<T, std::decay_t<First>>)
return OverrideModuleConfig<First>(first, parameters);
@@ -51,7 +51,7 @@ namespace Nz
}
}
static auto Get()
static T Get()
{
return T{};
}

View File

@@ -31,9 +31,9 @@ namespace Nz
constexpr bool ApproxEqual(const Sphere& sphere, T maxDifference = std::numeric_limits<T>::epsilon()) const;
constexpr bool Contains(T X, T Y, T Z) const;
constexpr bool Contains(const Box<T>& box) const;
constexpr bool Contains(const Vector3<T>& point) const;
constexpr bool Contains(T X, T Y, T Z, T epsilon = std::numeric_limits<T>::epsilon()) const;
constexpr bool Contains(const Box<T>& box, T epsilon = std::numeric_limits<T>::epsilon()) const;
constexpr bool Contains(const Vector3<T>& point, T epsilon = std::numeric_limits<T>::epsilon()) const;
T Distance(T X, T Y, T Z) const;
T Distance(const Vector3<T>& point) const;

View File

@@ -95,9 +95,9 @@ namespace Nz
* \see Contains
*/
template<typename T>
constexpr bool Sphere<T>::Contains(T X, T Y, T Z) const
constexpr bool Sphere<T>::Contains(T X, T Y, T Z, T epsilon) const
{
return Contains(Vector3<T>(X, Y, Z));
return Contains(Vector3<T>(X, Y, Z), epsilon);
}
/*!
@@ -109,9 +109,9 @@ namespace Nz
* \see Contains
*/
template<typename T>
constexpr bool Sphere<T>::Contains(const Box<T>& box) const
constexpr bool Sphere<T>::Contains(const Box<T>& box, T epsilon) const
{
if (Contains(box.GetMinimum()) && Contains(box.GetMaximum()))
if (Contains(box.GetMinimum(), epsilon) && Contains(box.GetMaximum(), epsilon))
return true;
return false;
@@ -124,9 +124,9 @@ namespace Nz
* \param point Position of the point
*/
template<typename T>
constexpr bool Sphere<T>::Contains(const Vector3<T>& point) const
constexpr bool Sphere<T>::Contains(const Vector3<T>& point, T epsilon) const
{
return GetPosition().SquaredDistance(point) <= radius * radius;
return (GetPosition().SquaredDistance(point) - radius * radius) <= epsilon;
}
/*!