// Copyright (C) 2024 Jérôme "SirLynix" Leclercq (lynix680@gmail.com) // This file is part of the "Nazara Engine - Math module" // For conditions of distribution and use, see copyright notice in Export.hpp #pragma once #ifndef NAZARA_MATH_BOX_HPP #define NAZARA_MATH_BOX_HPP #include #include #include #include #include #include #include namespace Nz { struct SerializationContext; template class Box { public: constexpr Box() = default; constexpr Box(T Width, T Height, T Depth); constexpr Box(T X, T Y, T Z, T Width, T Height, T Depth); constexpr Box(const Rect& rect); constexpr explicit Box(const Vector3& lengths); constexpr explicit Box(const Vector3& pos, const Vector3& lengths); template constexpr explicit Box(const Box& box); constexpr Box(const Box&) = default; constexpr Box(Box&&) = default; ~Box() = default; constexpr bool ApproxEqual(const Box& box, T maxDifference = std::numeric_limits::epsilon()) const; constexpr bool Contains(T X, T Y, T Z) const; constexpr bool Contains(const Box& box) const; constexpr bool Contains(const Vector3& point) const; constexpr Box& ExtendTo(T X, T Y, T Z); constexpr Box& ExtendTo(const Box& box); constexpr Box& ExtendTo(const Vector3& point); constexpr Sphere GetBoundingSphere() const; constexpr Vector3 GetCenter() const; constexpr Vector3 GetCorner(BoxCorner corner) const; constexpr EnumArray> GetCorners() const; constexpr Vector3 GetLengths() const; constexpr Vector3 GetMaximum() const; constexpr Vector3 GetMinimum() const; constexpr Vector3 GetNegativeVertex(const Vector3& normal) const; constexpr Vector3 GetPosition() const; constexpr Vector3 GetPositiveVertex(const Vector3& normal) const; constexpr T GetRadius() const; constexpr Sphere GetSquaredBoundingSphere() const; constexpr T GetSquaredRadius() const; constexpr bool Intersect(const Box& box, Box* intersection = nullptr) const; constexpr bool IsNull() const; constexpr bool IsValid() const; constexpr Box& Scale(T scalar); constexpr Box& Scale(const Vector3& vec); constexpr Box& ScaleAroundCenter(T scalar); constexpr Box& ScaleAroundCenter(const Vector3& vec); std::string ToString() const; Box& Transform(const Matrix4& matrix, bool applyTranslation = true); constexpr Box& Translate(const Vector3& translation); constexpr T& operator[](std::size_t i); constexpr const T& operator[](std::size_t i) const; constexpr Box& operator=(const Box&) = default; constexpr Box& operator=(Box&&) = default; constexpr bool operator==(const Box& box) const; constexpr bool operator!=(const Box& box) const; static constexpr Box ApproxEqual(const Box& lhs, const Box& rhs, T maxDifference = std::numeric_limits::epsilon()); static constexpr Box FromExtents(const Vector3& vec1, const Vector3& vec2); static constexpr Box Lerp(const Box& from, const Box& to, T interpolation); static constexpr Box Invalid(); static constexpr Box Zero(); T x, y, z, width, height, depth; }; using Boxd = Box; using Boxf = Box; using Boxi = Box; using Boxui = Box; using Boxi32 = Box; using Boxui32 = Box; template bool Serialize(SerializationContext& context, const Box& box, TypeTag>); template bool Unserialize(SerializationContext& context, Box* box, TypeTag>); template std::ostream& operator<<(std::ostream& out, const Nz::Box& box); } #include #endif // NAZARA_MATH_BOX_HPP