初始提交: UE5.3项目基础框架
This commit is contained in:
213
Plugins/CesiumForUnreal/Source/ThirdParty/include/CesiumGeometry/Availability.h
vendored
Normal file
213
Plugins/CesiumForUnreal/Source/ThirdParty/include/CesiumGeometry/Availability.h
vendored
Normal file
@ -0,0 +1,213 @@
|
||||
#pragma once
|
||||
|
||||
#include "Library.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <span>
|
||||
#include <utility>
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
|
||||
namespace CesiumGeometry {
|
||||
|
||||
namespace AvailabilityUtilities {
|
||||
uint8_t countOnesInByte(uint8_t _byte);
|
||||
uint32_t countOnesInBuffer(std::span<const std::byte> buffer);
|
||||
} // namespace AvailabilityUtilities
|
||||
|
||||
/**
|
||||
* @brief An availability value that is a constant boolean value.
|
||||
*/
|
||||
struct CESIUMGEOMETRY_API ConstantAvailability {
|
||||
/**
|
||||
* @brief The constant value.
|
||||
*/
|
||||
bool constant;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief An availability value that needs to be obtained using an offset into a
|
||||
* buffer.
|
||||
*/
|
||||
struct CESIUMGEOMETRY_API SubtreeBufferView {
|
||||
/**
|
||||
* @brief The offset into the buffer to read from.
|
||||
*/
|
||||
uint32_t byteOffset;
|
||||
/**
|
||||
* @brief The number of bytes after the offset to read until.
|
||||
*/
|
||||
uint32_t byteLength;
|
||||
/**
|
||||
* @brief The index into \ref AvailabilitySubtree::buffers that this \ref
|
||||
* SubtreeBufferView corresponds to.
|
||||
*/
|
||||
uint8_t buffer;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A view into availability information for part of the availability
|
||||
* tree. This could be either a constant boolean value or a descriptor pointing
|
||||
* to a buffer in an \ref AvailabilitySubtree where the information will be
|
||||
* looked up.
|
||||
*
|
||||
* Instead of using this type directly, \ref AvailabilityAccessor can be used to
|
||||
* work with it safely.
|
||||
*/
|
||||
typedef std::variant<ConstantAvailability, SubtreeBufferView> AvailabilityView;
|
||||
|
||||
/**
|
||||
* @brief The subtree data for an \ref AvailabilityNode, containing information
|
||||
* on tile, content, and subtree availability.
|
||||
*/
|
||||
struct CESIUMGEOMETRY_API AvailabilitySubtree {
|
||||
/**
|
||||
* @brief The availability information corresponding to \ref
|
||||
* TileAvailabilityFlags::TILE_AVAILABLE.
|
||||
*/
|
||||
AvailabilityView tileAvailability;
|
||||
/**
|
||||
* @brief The availability information corresponding to \ref
|
||||
* TileAvailabilityFlags::CONTENT_AVAILABLE.
|
||||
*/
|
||||
AvailabilityView contentAvailability;
|
||||
/**
|
||||
* @brief The availability information corresponding to \ref
|
||||
* TileAvailabilityFlags::SUBTREE_AVAILABLE and \ref
|
||||
* TileAvailabilityFlags::SUBTREE_LOADED.
|
||||
*/
|
||||
AvailabilityView subtreeAvailability;
|
||||
/**
|
||||
* @brief Subtree buffers that may be referenced by a \ref SubtreeBufferView.
|
||||
*/
|
||||
std::vector<std::vector<std::byte>> buffers;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Availability nodes wrap \ref AvailabilitySubtree objects and link them
|
||||
* together to form a downwardly traversable availability tree.
|
||||
*/
|
||||
struct CESIUMGEOMETRY_API AvailabilityNode {
|
||||
/**
|
||||
* @brief The subtree data for this node.
|
||||
*
|
||||
* If a node exists but its subtree does not exist, it indicates that the
|
||||
* subtree is known to be available and is actively in the process of loading.
|
||||
*/
|
||||
std::optional<AvailabilitySubtree> subtree;
|
||||
|
||||
/**
|
||||
* @brief The child nodes for this subtree node.
|
||||
*/
|
||||
std::vector<std::unique_ptr<AvailabilityNode>> childNodes;
|
||||
|
||||
/**
|
||||
* @brief Creates an empty instance;
|
||||
*/
|
||||
AvailabilityNode() noexcept;
|
||||
|
||||
/**
|
||||
* @brief Sets the loaded subtree for this availability node.
|
||||
*
|
||||
* @param subtree_ The loaded subtree to set for this node.
|
||||
* @param maxChildrenSubtrees The maximum number of children this subtree
|
||||
* could possible have if all of them happen to be available.
|
||||
*/
|
||||
void setLoadedSubtree(
|
||||
AvailabilitySubtree&& subtree_,
|
||||
uint32_t maxChildrenSubtrees) noexcept;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A downwardly-traversable tree of \ref AvailabilityNode objects.
|
||||
*/
|
||||
struct CESIUMGEOMETRY_API AvailabilityTree {
|
||||
/**
|
||||
* @brief The root \ref AvailabilityNode of this tree.
|
||||
*/
|
||||
std::unique_ptr<AvailabilityNode> pRoot;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Accessor for use with \ref AvailabilityView in order to safely obtain
|
||||
* the contents of the view.
|
||||
*/
|
||||
class CESIUMGEOMETRY_API AvailabilityAccessor {
|
||||
public:
|
||||
/**
|
||||
* @brief Creates a new AvailabilityAccessor.
|
||||
*
|
||||
* @param view The view whose contents will be accessed by this accessor.
|
||||
* @param subtree The subtree that corresponds to the view.
|
||||
*/
|
||||
AvailabilityAccessor(
|
||||
const AvailabilityView& view,
|
||||
const AvailabilitySubtree& subtree) noexcept;
|
||||
|
||||
/**
|
||||
* @brief Is this \ref AvailabilityAccessor accessing a \ref
|
||||
* SubtreeBufferView?
|
||||
*
|
||||
* @returns True if the \ref AvailabilityView is a \ref SubtreeBufferView with
|
||||
* a valid index, offset, and length, or false otherwise.
|
||||
*/
|
||||
bool isBufferView() const noexcept {
|
||||
return pBufferView != nullptr && bufferAccessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Is this \ref AvailabilityAccessor accessing a \ref
|
||||
* ConstantAvailability?
|
||||
*
|
||||
* @returns True if the \ref AvailabilityView is a \ref ConstantAvailability,
|
||||
* false otherwise.
|
||||
*/
|
||||
bool isConstant() const noexcept { return pConstant != nullptr; }
|
||||
|
||||
/**
|
||||
* @brief Obtains the constant value of the \ref AvailabilityView.
|
||||
*
|
||||
* @warning Unsafe to use if isConstant is false.
|
||||
* @returns The constant value.
|
||||
*/
|
||||
bool getConstant() const { return pConstant->constant; }
|
||||
|
||||
/**
|
||||
* @brief Obtains an accessor to the buffer used by the \ref AvailabilityView.
|
||||
*
|
||||
* @warning Unsafe to use if isBufferView is false.
|
||||
* @returns A reference to the span representing the range of the buffer
|
||||
* specified by the \ref SubtreeBufferView.
|
||||
*/
|
||||
const std::span<const std::byte>& getBufferAccessor() const {
|
||||
return *bufferAccessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Obtains the byte at the given index from the buffer used by the \ref
|
||||
* AvailabilityView.
|
||||
*
|
||||
* @warning Unsafe to use if isBufferView is false.
|
||||
* @returns The byte at the given index of the buffer accessor.
|
||||
*/
|
||||
const std::byte& operator[](size_t i) const {
|
||||
return bufferAccessor.value()[i];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Obtains the size of the buffer used by the \ref AvailabilityView.
|
||||
*
|
||||
* @warning Unsafe to use if isBufferView is false.
|
||||
* @returns The \ref SubtreeBufferView::byteLength "byteLength" property of
|
||||
* the \ref SubtreeBufferView.
|
||||
*/
|
||||
size_t size() const { return pBufferView->byteLength; }
|
||||
|
||||
private:
|
||||
const SubtreeBufferView* pBufferView;
|
||||
const ConstantAvailability* pConstant;
|
||||
std::optional<std::span<const std::byte>> bufferAccessor;
|
||||
};
|
||||
} // namespace CesiumGeometry
|
||||
26
Plugins/CesiumForUnreal/Source/ThirdParty/include/CesiumGeometry/Axis.h
vendored
Normal file
26
Plugins/CesiumForUnreal/Source/ThirdParty/include/CesiumGeometry/Axis.h
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include "Library.h"
|
||||
|
||||
namespace CesiumGeometry {
|
||||
|
||||
/**
|
||||
* @brief An enum describing the x, y, and z axes
|
||||
*/
|
||||
enum class CESIUMGEOMETRY_API Axis {
|
||||
/**
|
||||
* @brief The x-axis
|
||||
*/
|
||||
X,
|
||||
|
||||
/**
|
||||
* @brief The y-axis
|
||||
*/
|
||||
Y,
|
||||
|
||||
/**
|
||||
* @brief The z-axis
|
||||
*/
|
||||
Z
|
||||
};
|
||||
} // namespace CesiumGeometry
|
||||
125
Plugins/CesiumForUnreal/Source/ThirdParty/include/CesiumGeometry/AxisAlignedBox.h
vendored
Normal file
125
Plugins/CesiumForUnreal/Source/ThirdParty/include/CesiumGeometry/AxisAlignedBox.h
vendored
Normal file
@ -0,0 +1,125 @@
|
||||
#pragma once
|
||||
|
||||
#include "Library.h"
|
||||
|
||||
#include <glm/vec3.hpp>
|
||||
|
||||
namespace CesiumGeometry {
|
||||
|
||||
/**
|
||||
* @brief An Axis-Aligned Bounding Box (AABB), where the axes of the box are
|
||||
* aligned with the axes of the coordinate system.
|
||||
*/
|
||||
struct CESIUMGEOMETRY_API AxisAlignedBox final {
|
||||
|
||||
/**
|
||||
* @brief Creates an empty AABB with a length, width, and height of zero,
|
||||
* with the center located at (0, 0, 0).
|
||||
*/
|
||||
constexpr AxisAlignedBox() noexcept
|
||||
: minimumX(0.0),
|
||||
minimumY(0.0),
|
||||
minimumZ(0.0),
|
||||
maximumX(0.0),
|
||||
maximumY(0.0),
|
||||
maximumZ(0.0),
|
||||
lengthX(0.0),
|
||||
lengthY(0.0),
|
||||
lengthZ(0.0),
|
||||
center(0.0) {}
|
||||
|
||||
/**
|
||||
* @brief Creates a new AABB using the range of coordinates the box covers.
|
||||
*
|
||||
* @param minimumX_ The minimum X coordinate within the box.
|
||||
* @param minimumY_ The minimum Y coordinate within the box.
|
||||
* @param minimumZ_ The minimum Z coordinate within the box.
|
||||
* @param maximumX_ The maximum X coordinate within the box.
|
||||
* @param maximumY_ The maximum Y coordinate within the box.
|
||||
* @param maximumZ_ The maximum Z coordinate within the box.
|
||||
*/
|
||||
constexpr AxisAlignedBox(
|
||||
double minimumX_,
|
||||
double minimumY_,
|
||||
double minimumZ_,
|
||||
double maximumX_,
|
||||
double maximumY_,
|
||||
double maximumZ_) noexcept
|
||||
: minimumX(minimumX_),
|
||||
minimumY(minimumY_),
|
||||
minimumZ(minimumZ_),
|
||||
maximumX(maximumX_),
|
||||
maximumY(maximumY_),
|
||||
maximumZ(maximumZ_),
|
||||
lengthX(maximumX - minimumX),
|
||||
lengthY(maximumY - minimumY),
|
||||
lengthZ(maximumZ - minimumZ),
|
||||
center(
|
||||
0.5 * (maximumX + minimumX),
|
||||
0.5 * (maximumY + minimumY),
|
||||
0.5 * (maximumZ + minimumZ)) {}
|
||||
|
||||
/**
|
||||
* @brief The minimum x-coordinate.
|
||||
*/
|
||||
double minimumX;
|
||||
|
||||
/**
|
||||
* @brief The minimum y-coordinate.
|
||||
*/
|
||||
double minimumY;
|
||||
|
||||
/**
|
||||
* @brief The minimum z-coordinate.
|
||||
*/
|
||||
double minimumZ;
|
||||
|
||||
/**
|
||||
* @brief The maximum x-coordinate.
|
||||
*/
|
||||
double maximumX;
|
||||
|
||||
/**
|
||||
* @brief The maximum y-coordinate.
|
||||
*/
|
||||
double maximumY;
|
||||
|
||||
/**
|
||||
* @brief The maximum z-coordinate.
|
||||
*/
|
||||
double maximumZ;
|
||||
|
||||
/**
|
||||
* @brief The length of the box on the x-axis.
|
||||
*/
|
||||
double lengthX;
|
||||
|
||||
/**
|
||||
* @brief The length of the box on the y-axis.
|
||||
*/
|
||||
double lengthY;
|
||||
|
||||
/**
|
||||
* @brief The length of the box on the z-axis.
|
||||
*/
|
||||
double lengthZ;
|
||||
|
||||
/**
|
||||
* @brief The center of the box.
|
||||
*/
|
||||
glm::dvec3 center;
|
||||
|
||||
/**
|
||||
* @brief Checks if this AABB contains the given position.
|
||||
*
|
||||
* @param position The position to check.
|
||||
* @returns True if this AABB contains the position, false otherwise.
|
||||
*/
|
||||
constexpr bool contains(const glm::dvec3& position) const noexcept {
|
||||
return position.x >= this->minimumX && position.x <= this->maximumX &&
|
||||
position.y >= this->minimumY && position.y <= this->maximumY &&
|
||||
position.z >= this->minimumZ && position.z <= this->maximumZ;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace CesiumGeometry
|
||||
91
Plugins/CesiumForUnreal/Source/ThirdParty/include/CesiumGeometry/BoundingSphere.h
vendored
Normal file
91
Plugins/CesiumForUnreal/Source/ThirdParty/include/CesiumGeometry/BoundingSphere.h
vendored
Normal file
@ -0,0 +1,91 @@
|
||||
#pragma once
|
||||
|
||||
#include "CullingResult.h"
|
||||
#include "Library.h"
|
||||
|
||||
#include <glm/fwd.hpp>
|
||||
#include <glm/vec3.hpp>
|
||||
|
||||
namespace CesiumGeometry {
|
||||
|
||||
class Plane;
|
||||
|
||||
/**
|
||||
* @brief A bounding sphere with a center and a radius.
|
||||
*/
|
||||
class CESIUMGEOMETRY_API BoundingSphere final {
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a new instance.
|
||||
*
|
||||
* @param center The center of the bounding sphere.
|
||||
* @param radius The radius of the bounding sphere.
|
||||
*/
|
||||
constexpr BoundingSphere(const glm::dvec3& center, double radius) noexcept
|
||||
: _center(center), _radius(radius) {}
|
||||
|
||||
/**
|
||||
* @brief Gets the center of the bounding sphere.
|
||||
*/
|
||||
constexpr const glm::dvec3& getCenter() const noexcept {
|
||||
return this->_center;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the radius of the bounding sphere.
|
||||
*/
|
||||
constexpr double getRadius() const noexcept { return this->_radius; }
|
||||
|
||||
/**
|
||||
* @brief Determines on which side of a plane this boundings sphere is
|
||||
* located.
|
||||
*
|
||||
* @param plane The plane to test against.
|
||||
* @return The {@link CullingResult}:
|
||||
* * `Inside` if the entire sphere is on the side of the plane the normal is
|
||||
* pointing.
|
||||
* * `Outside` if the entire sphere is on the opposite side.
|
||||
* * `Intersecting` if the sphere intersects the plane.
|
||||
*/
|
||||
CullingResult intersectPlane(const Plane& plane) const noexcept;
|
||||
|
||||
/**
|
||||
* @brief Computes the distance squared from a position to the closest point
|
||||
* on this bounding sphere. Returns 0 if the point is inside the sphere.
|
||||
*
|
||||
* @param position The position.
|
||||
* @return The distance squared from the position to the closest point on this
|
||||
* bounding sphere.
|
||||
*
|
||||
* @snippet TestBoundingSphere.cpp distanceSquaredTo
|
||||
*/
|
||||
double
|
||||
computeDistanceSquaredToPosition(const glm::dvec3& position) const noexcept;
|
||||
|
||||
/**
|
||||
* @brief Computes whether the given position is contained within the bounding
|
||||
* sphere.
|
||||
*
|
||||
* @param position The position.
|
||||
* @return Whether the position is contained within the bounding sphere.
|
||||
*/
|
||||
bool contains(const glm::dvec3& position) const noexcept;
|
||||
|
||||
/**
|
||||
* @brief Transforms this bounding sphere to another coordinate system using a
|
||||
* 4x4 matrix.
|
||||
*
|
||||
* If the transformation has non-uniform scale, the bounding sphere's radius
|
||||
* is scaled by the largest scale value among the transformation's axes.
|
||||
*
|
||||
* @param transformation The transformation.
|
||||
* @return The bounding sphere in the new coordinate system.
|
||||
*/
|
||||
BoundingSphere transform(const glm::dmat4& transformation) const noexcept;
|
||||
|
||||
private:
|
||||
glm::dvec3 _center;
|
||||
double _radius;
|
||||
};
|
||||
|
||||
} // namespace CesiumGeometry
|
||||
31
Plugins/CesiumForUnreal/Source/ThirdParty/include/CesiumGeometry/CullingResult.h
vendored
Normal file
31
Plugins/CesiumForUnreal/Source/ThirdParty/include/CesiumGeometry/CullingResult.h
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
#include "Library.h"
|
||||
|
||||
namespace CesiumGeometry {
|
||||
|
||||
/**
|
||||
* @brief The result of culling an object.
|
||||
*/
|
||||
enum class CESIUMGEOMETRY_API CullingResult {
|
||||
/**
|
||||
* @brief Indicates that an object lies completely outside the culling volume.
|
||||
*/
|
||||
Outside = -1,
|
||||
|
||||
/**
|
||||
* @brief Indicates that an object intersects with the boundary of the culling
|
||||
* volume.
|
||||
*
|
||||
* This means that the object is partially inside and partially outside the
|
||||
* culling volume.
|
||||
*/
|
||||
Intersecting = 0,
|
||||
|
||||
/**
|
||||
* @brief Indicates that an object lies completely inside the culling volume.
|
||||
*/
|
||||
Inside = 1
|
||||
};
|
||||
|
||||
} // namespace CesiumGeometry
|
||||
61
Plugins/CesiumForUnreal/Source/ThirdParty/include/CesiumGeometry/CullingVolume.h
vendored
Normal file
61
Plugins/CesiumForUnreal/Source/ThirdParty/include/CesiumGeometry/CullingVolume.h
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
#pragma once
|
||||
|
||||
#include "Plane.h"
|
||||
|
||||
namespace Cesium3DTilesSelection {
|
||||
|
||||
/**
|
||||
* @brief A culling volume, defined by four planes.
|
||||
*
|
||||
* The planes describe the culling volume that may be created for
|
||||
* the view frustum of a camera. The normals of these planes will
|
||||
* point inwards.
|
||||
*/
|
||||
struct CullingVolume final {
|
||||
|
||||
/**
|
||||
* @brief The left plane of the culling volume.
|
||||
*
|
||||
* Defaults to (0,0,1), with a distance of 0.
|
||||
*/
|
||||
CesiumGeometry::Plane leftPlane{glm::dvec3(0.0, 0.0, 1.0), 0.0};
|
||||
|
||||
/**
|
||||
* @brief The right plane of the culling volume.
|
||||
*
|
||||
* Defaults to (0,0,1), with a distance of 0.
|
||||
*/
|
||||
CesiumGeometry::Plane rightPlane{glm::dvec3(0.0, 0.0, 1.0), 0.0};
|
||||
|
||||
/**
|
||||
* @brief The top plane of the culling volume.
|
||||
*
|
||||
* Defaults to (0,0,1), with a distance of 0.
|
||||
*/
|
||||
CesiumGeometry::Plane topPlane{glm::dvec3(0.0, 0.0, 1.0), 0.0};
|
||||
|
||||
/**
|
||||
* @brief The bottom plane of the culling volume.
|
||||
*
|
||||
* Defaults to (0,0,1), with a distance of 0.
|
||||
*/
|
||||
CesiumGeometry::Plane bottomPlane{glm::dvec3(0.0, 0.0, 1.0), 0.0};
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Creates a {@link CullingVolume} for a perspective frustum.
|
||||
*
|
||||
* @param position The eye position
|
||||
* @param direction The viewing direction
|
||||
* @param up The up-vector of the frustum
|
||||
* @param fovx The horizontal Field-Of-View angle, in radians
|
||||
* @param fovy The vertical Field-Of-View angle, in radians
|
||||
* @return The {@link CullingVolume}
|
||||
*/
|
||||
CullingVolume createCullingVolume(
|
||||
const glm::dvec3& position,
|
||||
const glm::dvec3& direction,
|
||||
const glm::dvec3& up,
|
||||
double fovx,
|
||||
double fovy) noexcept;
|
||||
} // namespace Cesium3DTilesSelection
|
||||
229
Plugins/CesiumForUnreal/Source/ThirdParty/include/CesiumGeometry/IntersectionTests.h
vendored
Normal file
229
Plugins/CesiumForUnreal/Source/ThirdParty/include/CesiumGeometry/IntersectionTests.h
vendored
Normal file
@ -0,0 +1,229 @@
|
||||
#pragma once
|
||||
|
||||
#include "Library.h"
|
||||
|
||||
#include <glm/vec2.hpp>
|
||||
#include <glm/vec3.hpp>
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace CesiumGeometry {
|
||||
class Ray;
|
||||
class Plane;
|
||||
struct AxisAlignedBox;
|
||||
class OrientedBoundingBox;
|
||||
class BoundingSphere;
|
||||
|
||||
/**
|
||||
* @brief Functions for computing the intersection between geometries such as
|
||||
* rays, planes, triangles, and ellipsoids.
|
||||
*/
|
||||
class CESIUMGEOMETRY_API IntersectionTests final {
|
||||
public:
|
||||
/**
|
||||
* @brief Computes the intersection of a ray and a plane.
|
||||
*
|
||||
* @param ray The ray.
|
||||
* @param plane The plane.
|
||||
* @return The point of intersection, or `std::nullopt` if there is no
|
||||
* intersection.
|
||||
*/
|
||||
static std::optional<glm::dvec3>
|
||||
rayPlane(const Ray& ray, const Plane& plane) noexcept;
|
||||
|
||||
/**
|
||||
* @brief Computes the intersection of a ray and an ellipsoid with the given
|
||||
* radii, centered at the origin.
|
||||
*
|
||||
* Returns false if any of the radii are 0.
|
||||
*
|
||||
* @param ray The ray.
|
||||
* @param radii The radii of ellipsoid.
|
||||
* @return The distances along the ray where it intersects the ellipsoid, or
|
||||
* `std::nullopt` if there are no intersections. X is the entry, and y is the
|
||||
* exit.
|
||||
*
|
||||
*/
|
||||
static std::optional<glm::dvec2>
|
||||
rayEllipsoid(const Ray& ray, const glm::dvec3& radii) noexcept;
|
||||
|
||||
/**
|
||||
* @brief Determines whether a given point is completely inside a triangle
|
||||
* defined by three 2D points.
|
||||
*
|
||||
* This function does not check for degeneracy of the triangle.
|
||||
*
|
||||
* @param point The point to check.
|
||||
* @param triangleVertA The first vertex of the triangle.
|
||||
* @param triangleVertB The second vertex of the triangle.
|
||||
* @param triangleVertC The third vertex of the triangle.
|
||||
* @return Whether the point is within the triangle.
|
||||
*/
|
||||
static bool pointInTriangle(
|
||||
const glm::dvec2& point,
|
||||
const glm::dvec2& triangleVertA,
|
||||
const glm::dvec2& triangleVertB,
|
||||
const glm::dvec2& triangleVertC) noexcept;
|
||||
|
||||
/**
|
||||
* @brief Determines whether a given point is completely inside a triangle
|
||||
* defined by three 3D points.
|
||||
*
|
||||
* Returns false for degenerate triangles.
|
||||
*
|
||||
* @param point The point to check.
|
||||
* @param triangleVertA The first vertex of the triangle.
|
||||
* @param triangleVertB The second vertex of the triangle.
|
||||
* @param triangleVertC The third vertex of the triangle.
|
||||
* @return Whether the point is within the triangle.
|
||||
*/
|
||||
static bool pointInTriangle(
|
||||
const glm::dvec3& point,
|
||||
const glm::dvec3& triangleVertA,
|
||||
const glm::dvec3& triangleVertB,
|
||||
const glm::dvec3& triangleVertC) noexcept;
|
||||
|
||||
/**
|
||||
* @brief Determines whether the point is completely inside a triangle defined
|
||||
* by three 3D points. If the point is inside, this also outputs the
|
||||
* barycentric coordinates for the point.
|
||||
*
|
||||
* Returns false for degenerate triangles.
|
||||
*
|
||||
* @param point The point to check.
|
||||
* @param triangleVertA The first vertex of the triangle.
|
||||
* @param triangleVertB The second vertex of the triangle.
|
||||
* @param triangleVertC The third vertex of the triangle.
|
||||
* @param barycentricCoordinates The barycentric coordinates for the point, if
|
||||
* the point is inside the triangle.
|
||||
* @return Whether the point is within the triangle.
|
||||
*/
|
||||
static bool pointInTriangle(
|
||||
const glm::dvec3& point,
|
||||
const glm::dvec3& triangleVertA,
|
||||
const glm::dvec3& triangleVertB,
|
||||
const glm::dvec3& triangleVertC,
|
||||
glm::dvec3& barycentricCoordinates) noexcept;
|
||||
|
||||
/**
|
||||
* @brief Tests if a ray hits a triangle and returns the hit point.
|
||||
*
|
||||
* @param ray The ray.
|
||||
* @param p0 The first vertex of the triangle.
|
||||
* @param p1 The second vertex of the triangle.
|
||||
* @param p2 The third vertex of the triangle.
|
||||
* @param cullBackFaces Ignore triangles that face away from ray. Front faces
|
||||
* use CCW winding order.
|
||||
* @return The point of intersection, or `std::nullopt` if there is no
|
||||
* intersection.
|
||||
*/
|
||||
static std::optional<glm::dvec3> rayTriangle(
|
||||
const Ray& ray,
|
||||
const glm::dvec3& p0,
|
||||
const glm::dvec3& p1,
|
||||
const glm::dvec3& p2,
|
||||
bool cullBackFaces = false);
|
||||
|
||||
/**
|
||||
* @brief Tests if an infinite ray hits a triangle and returns the parametric
|
||||
* hit position.
|
||||
*
|
||||
* The return parameter is positive if the intersection point is in front of
|
||||
* the ray origin, negative if it is behind it, or zero if the two points
|
||||
* coincide.
|
||||
*
|
||||
* @param ray The ray.
|
||||
* @param p0 The first vertex of the triangle.
|
||||
* @param p1 The second vertex of the triangle.
|
||||
* @param p2 The third vertex of the triangle.
|
||||
* @param cullBackFaces Ignore triangles that face away from ray. Front faces
|
||||
* use CCW winding order.
|
||||
* @return optional hit parametric value, if one is detected.
|
||||
*/
|
||||
static std::optional<double> rayTriangleParametric(
|
||||
const Ray& ray,
|
||||
const glm::dvec3& p0,
|
||||
const glm::dvec3& p1,
|
||||
const glm::dvec3& p2,
|
||||
bool cullBackFaces = false);
|
||||
|
||||
/**
|
||||
* @brief Computes the intersection of a ray and an axis aligned bounding box.
|
||||
*
|
||||
* @param ray The ray.
|
||||
* @param aabb The axis aligned bounding box.
|
||||
* @return The point of intersection, or `std::nullopt` if there is no
|
||||
* intersection.
|
||||
*/
|
||||
static std::optional<glm::dvec3>
|
||||
rayAABB(const Ray& ray, const AxisAlignedBox& aabb);
|
||||
|
||||
/**
|
||||
* @brief Computes the intersection of an infinite ray and an axis aligned
|
||||
* bounding box and returns the parametric hit position.
|
||||
*
|
||||
* The return value is positive if the intersection point is in front of the
|
||||
* ray origin, negative if it is behind it, or zero if the two points
|
||||
* coincide.
|
||||
*
|
||||
* @param ray The ray.
|
||||
* @param aabb The axis aligned bounding box.
|
||||
* @return optional hit parametric value, if one is detected.
|
||||
*/
|
||||
static std::optional<double>
|
||||
rayAABBParametric(const Ray& ray, const AxisAlignedBox& aabb);
|
||||
|
||||
/**
|
||||
* @brief Computes the intersection of a ray and an oriented bounding box.
|
||||
*
|
||||
* @param ray The ray.
|
||||
* @param obb The oriented bounding box.
|
||||
* @return The point of intersection, or `std::nullopt` if there is no
|
||||
* intersection.
|
||||
*/
|
||||
static std::optional<glm::dvec3>
|
||||
rayOBB(const Ray& ray, const OrientedBoundingBox& obb);
|
||||
|
||||
/**
|
||||
* @brief Computes the intersection of an infinite ray and an oriented
|
||||
* bounding box and returns the parametric hit position.
|
||||
*
|
||||
* The return parameter is positive if the intersection point is in front of
|
||||
* the ray origin, negative if it is behind it, or zero if the two points
|
||||
* coincide.
|
||||
*
|
||||
* @param ray The ray.
|
||||
* @param obb The oriented bounding box.
|
||||
* @return optional hit parametric value, if one is detected.
|
||||
*/
|
||||
static std::optional<double>
|
||||
rayOBBParametric(const Ray& ray, const OrientedBoundingBox& obb);
|
||||
|
||||
/**
|
||||
* @brief Computes the intersection of a ray and a bounding sphere.
|
||||
*
|
||||
* @param ray The ray.
|
||||
* @param sphere The bounding sphere.
|
||||
* @return The point of intersection, or `std::nullopt` if there is no
|
||||
* intersection.
|
||||
*/
|
||||
static std::optional<glm::dvec3>
|
||||
raySphere(const Ray& ray, const BoundingSphere& sphere);
|
||||
|
||||
/**
|
||||
* @brief Computes the intersection of an infinite ray and a bounding sphere
|
||||
* and returns the parametric hit position.
|
||||
*
|
||||
* The return parameter is positive if the intersection point is in front of
|
||||
* the ray origin, negative if it is behind it, or zero if the two points
|
||||
* coincide.
|
||||
*
|
||||
* @param ray The ray.
|
||||
* @param sphere The bounding sphere.
|
||||
* @return optional hit parametric value, if one is detected.
|
||||
*/
|
||||
static std::optional<double>
|
||||
raySphereParametric(const Ray& ray, const BoundingSphere& sphere);
|
||||
};
|
||||
|
||||
} // namespace CesiumGeometry
|
||||
18
Plugins/CesiumForUnreal/Source/ThirdParty/include/CesiumGeometry/Library.h
vendored
Normal file
18
Plugins/CesiumForUnreal/Source/ThirdParty/include/CesiumGeometry/Library.h
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @brief Basic geometry classes for Cesium
|
||||
*
|
||||
* @mermaid-interactive{dependencies/CesiumGeometry}
|
||||
*/
|
||||
namespace CesiumGeometry {}
|
||||
|
||||
#if defined(_WIN32) && defined(CESIUM_SHARED)
|
||||
#ifdef CESIUMGEOMETRY_BUILDING
|
||||
#define CESIUMGEOMETRY_API __declspec(dllexport)
|
||||
#else
|
||||
#define CESIUMGEOMETRY_API __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define CESIUMGEOMETRY_API
|
||||
#endif
|
||||
173
Plugins/CesiumForUnreal/Source/ThirdParty/include/CesiumGeometry/OctreeAvailability.h
vendored
Normal file
173
Plugins/CesiumForUnreal/Source/ThirdParty/include/CesiumGeometry/OctreeAvailability.h
vendored
Normal file
@ -0,0 +1,173 @@
|
||||
#pragma once
|
||||
|
||||
#include "Availability.h"
|
||||
#include "Library.h"
|
||||
#include "OctreeTileID.h"
|
||||
#include "TileAvailabilityFlags.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <memory>
|
||||
#include <span>
|
||||
#include <vector>
|
||||
|
||||
namespace CesiumGeometry {
|
||||
|
||||
/**
|
||||
* @brief An availability tree for an octree, where availability can be stored
|
||||
* and computed based on \ref OctreeTileID.
|
||||
*/
|
||||
class CESIUMGEOMETRY_API OctreeAvailability final {
|
||||
public:
|
||||
/**
|
||||
* @brief Constructs a new instance.
|
||||
*
|
||||
* @param subtreeLevels The number of levels in each subtree.
|
||||
* @param maximumLevel The index of the maximum level in this tileset.
|
||||
*/
|
||||
OctreeAvailability(uint32_t subtreeLevels, uint32_t maximumLevel) noexcept;
|
||||
|
||||
/**
|
||||
* @brief Determines the currently known availability status of the given
|
||||
* tile.
|
||||
*
|
||||
* @param tileID The {@link CesiumGeometry::OctreeTileID} for the tile.
|
||||
*
|
||||
* @return The {@link TileAvailabilityFlags} for this tile encoded into a
|
||||
* uint8_t.
|
||||
*/
|
||||
uint8_t computeAvailability(const OctreeTileID& tileID) const noexcept;
|
||||
|
||||
/**
|
||||
* @brief Attempts to add an availability subtree into the existing overall
|
||||
* availability tree.
|
||||
*
|
||||
* @param tileID The {@link CesiumGeometry::OctreeTileID} for the tile.
|
||||
* @param newSubtree The {@link CesiumGeometry::AvailabilitySubtree} to add.
|
||||
*
|
||||
* @return Whether the insertion was successful.
|
||||
*/
|
||||
bool addSubtree(
|
||||
const OctreeTileID& tileID,
|
||||
AvailabilitySubtree&& newSubtree) noexcept;
|
||||
|
||||
/**
|
||||
* @brief Determines the currently known availability status of the given
|
||||
* tile.
|
||||
*
|
||||
* Priming with a known parent subtree node avoids the need to traverse the
|
||||
* entire availability tree so far. The node must have a loaded subtree
|
||||
*
|
||||
* @param tileID The tile ID to get the availability for.
|
||||
* @param pNode The subtree node to look for the tileID in. The tileID should
|
||||
* be within this subtree node.
|
||||
*
|
||||
* @return The {@link TileAvailabilityFlags} for this tile encoded into a
|
||||
* uint8_t.
|
||||
*/
|
||||
uint8_t computeAvailability(
|
||||
const OctreeTileID& tileID,
|
||||
const AvailabilityNode* pNode) const noexcept;
|
||||
|
||||
/**
|
||||
* @brief Attempts to add a child subtree node onto the given parent node.
|
||||
*
|
||||
* Priming with a known parent subtree node avoids the need to traverse the
|
||||
* entire availability tree so far. If the parent node is nullptr and the
|
||||
* tile ID indicates this is the root tile, the subtree will be attached to
|
||||
* the root.
|
||||
*
|
||||
* @param tileID The root tile's ID of the subtree we are trying to add.
|
||||
* @param pParentNode The parent subtree node. The tileID should fall exactly
|
||||
* at the end of this parent subtree.
|
||||
*
|
||||
* @return The newly created node if the insertion was successful, nullptr
|
||||
* otherwise.
|
||||
*/
|
||||
AvailabilityNode*
|
||||
addNode(const OctreeTileID& tileID, AvailabilityNode* pParentNode) noexcept;
|
||||
|
||||
/**
|
||||
* @brief Attempts to add a loaded subtree onto the given node.
|
||||
*
|
||||
* The node must have been created earlier from a call to addNode.
|
||||
*
|
||||
* @param pNode The node on which to add the subtree.
|
||||
* @param newSubtree The new subtree to add.
|
||||
*
|
||||
* @return Whether the insertion was successful.
|
||||
*/
|
||||
bool addLoadedSubtree(
|
||||
AvailabilityNode* pNode,
|
||||
AvailabilitySubtree&& newSubtree) noexcept;
|
||||
/**
|
||||
* @brief Find the child node index corresponding to this tile ID and parent
|
||||
* node.
|
||||
*
|
||||
* Attempts to find the child node for the tile with the given ID and parent
|
||||
* node. The parent node is used to speed up the search significantly. Note
|
||||
* that if the given tile ID does not correspond exactly to an immediate
|
||||
* child node of the parent node, nullptr will be returned. If a tileID
|
||||
* outside the given parent node's subtree is given, an incorrect child index
|
||||
* may be returned.
|
||||
*
|
||||
* @param tileID The tile ID of the child node we are looking for.
|
||||
* @param pParentNode The immediate parent to the child node we are looking
|
||||
* for.
|
||||
* @return The child node index if found, std::nullopt otherwise.
|
||||
*/
|
||||
std::optional<uint32_t> findChildNodeIndex(
|
||||
const OctreeTileID& tileID,
|
||||
const AvailabilityNode* pParentNode) const;
|
||||
|
||||
/**
|
||||
* @brief Find the child node corresponding to this tile ID and parent node.
|
||||
*
|
||||
* Attempts to find the child node for the tile with the given ID and parent
|
||||
* node. The parent node is used to speed up the search significantly. Note
|
||||
* that if the given tile ID does not correspond exactly to an immediate
|
||||
* child node of the parent node, nullptr will be returned. If a tileID
|
||||
* outside the given parent node's subtree is given, an incorrect child index
|
||||
* may be returned.
|
||||
*
|
||||
* @param tileID The tile ID of the child node we are looking for.
|
||||
* @param pParentNode The immediate parent to the child node we are looking
|
||||
* for.
|
||||
* @return The child node if found, nullptr otherwise.
|
||||
*/
|
||||
AvailabilityNode* findChildNode(
|
||||
const OctreeTileID& tileID,
|
||||
AvailabilityNode* pParentNode) const;
|
||||
|
||||
/**
|
||||
* @brief Gets the number of levels in each subtree.
|
||||
*
|
||||
* @returns The number of levels in each subtree.
|
||||
*/
|
||||
constexpr inline uint32_t getSubtreeLevels() const noexcept {
|
||||
return this->_subtreeLevels;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the index of the maximum level in this implicit tileset.
|
||||
*
|
||||
* @returns The index of the maximum level.
|
||||
*/
|
||||
constexpr inline uint32_t getMaximumLevel() const noexcept {
|
||||
return this->_maximumLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets a pointer to the root subtree node of this implicit tileset.
|
||||
*
|
||||
* @returns The root node of the availability tree.
|
||||
*/
|
||||
AvailabilityNode* getRootNode() noexcept { return this->_pRoot.get(); }
|
||||
|
||||
private:
|
||||
uint32_t _subtreeLevels;
|
||||
uint32_t _maximumLevel;
|
||||
uint32_t _maximumChildrenSubtrees;
|
||||
std::unique_ptr<AvailabilityNode> _pRoot;
|
||||
};
|
||||
|
||||
} // namespace CesiumGeometry
|
||||
76
Plugins/CesiumForUnreal/Source/ThirdParty/include/CesiumGeometry/OctreeTileID.h
vendored
Normal file
76
Plugins/CesiumForUnreal/Source/ThirdParty/include/CesiumGeometry/OctreeTileID.h
vendored
Normal file
@ -0,0 +1,76 @@
|
||||
#pragma once
|
||||
|
||||
#include "Library.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace CesiumGeometry {
|
||||
|
||||
/**
|
||||
* @brief A structure serving as a unique identifier for a node in an octree.
|
||||
*
|
||||
* This is one form of a {@link Cesium3DTilesSelection::TileID}.
|
||||
*
|
||||
* The identifier is composed of the level (with 0 being the level of the root
|
||||
* tile), the x-, y-, and z-coordinate of the tile, referring to a grid
|
||||
* coordinate system at the respective level.
|
||||
*/
|
||||
struct CESIUMGEOMETRY_API OctreeTileID {
|
||||
|
||||
/**
|
||||
* @brief Creates a new instance.
|
||||
*/
|
||||
constexpr OctreeTileID() : level(0), x(0), y(0), z(0){};
|
||||
|
||||
/**
|
||||
* @brief Creates a new instance.
|
||||
*
|
||||
* @param level_ The level of the node, with 0 being the root.
|
||||
* @param x_ The x-coordinate of the tile.
|
||||
* @param y_ The y-coordinate of the tile.
|
||||
* @param z_ The z-coordinate of the tile.
|
||||
*/
|
||||
constexpr OctreeTileID(
|
||||
uint32_t level_,
|
||||
uint32_t x_,
|
||||
uint32_t y_,
|
||||
uint32_t z_) noexcept
|
||||
: level(level_), x(x_), y(y_), z(z_) {}
|
||||
|
||||
/**
|
||||
* @brief Returns `true` if two identifiers are equal.
|
||||
*/
|
||||
constexpr bool operator==(const OctreeTileID& other) const noexcept {
|
||||
return this->level == other.level && this->x == other.x &&
|
||||
this->y == other.y && this->z == other.z;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns `true` if two identifiers are *not* equal.
|
||||
*/
|
||||
constexpr bool operator!=(const OctreeTileID& other) const noexcept {
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief The level of this tile ID, with 0 being the root tile.
|
||||
*/
|
||||
uint32_t level;
|
||||
|
||||
/**
|
||||
* @brief The x-coordinate of this tile ID.
|
||||
*/
|
||||
uint32_t x;
|
||||
|
||||
/**
|
||||
* @brief The y-coordinate of this tile ID.
|
||||
*/
|
||||
uint32_t y;
|
||||
|
||||
/**
|
||||
* @brief The z-coordinate of this tile ID.
|
||||
*/
|
||||
uint32_t z;
|
||||
};
|
||||
|
||||
} // namespace CesiumGeometry
|
||||
109
Plugins/CesiumForUnreal/Source/ThirdParty/include/CesiumGeometry/OctreeTilingScheme.h
vendored
Normal file
109
Plugins/CesiumForUnreal/Source/ThirdParty/include/CesiumGeometry/OctreeTilingScheme.h
vendored
Normal file
@ -0,0 +1,109 @@
|
||||
#pragma once
|
||||
|
||||
#include "CesiumGeometry/AxisAlignedBox.h"
|
||||
#include "CesiumGeometry/Library.h"
|
||||
#include "CesiumGeometry/OctreeTileID.h"
|
||||
|
||||
#include <glm/vec3.hpp>
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace CesiumGeometry {
|
||||
|
||||
/**
|
||||
* @brief Defines how an {@link AxisAlignedBox} is divided into octree
|
||||
* tiles.
|
||||
*/
|
||||
class CESIUMGEOMETRY_API OctreeTilingScheme {
|
||||
public:
|
||||
/**
|
||||
* @brief Constructs a new instance.
|
||||
*
|
||||
* @param box The overall box that is tiled, expressed in projected
|
||||
* coordinates.
|
||||
* @param rootTilesX The number of tiles at the root of the quadtree in the X
|
||||
* direction.
|
||||
* @param rootTilesY The nubmer of tiles at the root of the quadtree in the Y
|
||||
* direction.
|
||||
* @param rootTilesZ The number of tiles at the root of the quadtree in the Z
|
||||
* direction.
|
||||
*/
|
||||
OctreeTilingScheme(
|
||||
const AxisAlignedBox& box,
|
||||
uint32_t rootTilesX,
|
||||
uint32_t rootTilesY,
|
||||
uint32_t rootTilesZ) noexcept;
|
||||
|
||||
/**
|
||||
* @brief Return the overall box that is tiled.
|
||||
*/
|
||||
const AxisAlignedBox& getBox() const noexcept { return this->_box; }
|
||||
|
||||
/**
|
||||
* @brief Returns the number of root tiles, in x-direction.
|
||||
*/
|
||||
uint32_t getRootTilesX() const noexcept { return this->_rootTilesX; }
|
||||
|
||||
/**
|
||||
* @brief Returns the number of root tiles, in y-direction.
|
||||
*/
|
||||
uint32_t getRootTilesY() const noexcept { return this->_rootTilesY; }
|
||||
|
||||
/**
|
||||
* @brief Returns the number of root tiles, in z-direction.
|
||||
*/
|
||||
uint32_t getRootTilesZ() const noexcept { return this->_rootTilesZ; }
|
||||
|
||||
/**
|
||||
* @brief Returns the number of tiles, in x-direction, at the given level.
|
||||
*/
|
||||
uint32_t getNumberOfXTilesAtLevel(uint32_t level) const noexcept;
|
||||
|
||||
/**
|
||||
* @brief Returns the number of tiles, in y-direction, at the given level.
|
||||
*/
|
||||
uint32_t getNumberOfYTilesAtLevel(uint32_t level) const noexcept;
|
||||
|
||||
/**
|
||||
* @brief Returns the number of tiles, in z-direction, at the given level.
|
||||
*/
|
||||
uint32_t getNumberOfZTilesAtLevel(uint32_t level) const noexcept;
|
||||
|
||||
/**
|
||||
* @brief Computes the {@link CesiumGeometry::OctreeTileID} for a given
|
||||
* position and level.
|
||||
*
|
||||
* If the projected position is within the {@link getBox} of this tiling
|
||||
* scheme, then this will compute the octree tile ID for the tile that
|
||||
* contains the given position at the given level. Otherwise, `nullopt` is
|
||||
* returned.
|
||||
*
|
||||
* @param position The position in projected coordinates.
|
||||
* @param level The level
|
||||
* @return The tile ID, or `nullopt`.
|
||||
*/
|
||||
std::optional<CesiumGeometry::OctreeTileID>
|
||||
positionToTile(const glm::dvec3& position, uint32_t level) const noexcept;
|
||||
|
||||
/**
|
||||
* @brief Returns the {@link AxisAlignedBox} that is
|
||||
* covered by the specified tile.
|
||||
*
|
||||
* The volume that is covered by the tile that is identified with
|
||||
* the given {@link CesiumGeometry::OctreeTileID} will be computed,
|
||||
* based on the {@link getBox} of this tiling scheme.
|
||||
*
|
||||
* @param tileID The tile ID
|
||||
* @return The box
|
||||
*/
|
||||
AxisAlignedBox
|
||||
tileToBox(const CesiumGeometry::OctreeTileID& tileID) const noexcept;
|
||||
|
||||
private:
|
||||
AxisAlignedBox _box;
|
||||
uint32_t _rootTilesX;
|
||||
uint32_t _rootTilesY;
|
||||
uint32_t _rootTilesZ;
|
||||
};
|
||||
|
||||
} // namespace CesiumGeometry
|
||||
150
Plugins/CesiumForUnreal/Source/ThirdParty/include/CesiumGeometry/OrientedBoundingBox.h
vendored
Normal file
150
Plugins/CesiumForUnreal/Source/ThirdParty/include/CesiumGeometry/OrientedBoundingBox.h
vendored
Normal file
@ -0,0 +1,150 @@
|
||||
#pragma once
|
||||
|
||||
#include "AxisAlignedBox.h"
|
||||
#include "BoundingSphere.h"
|
||||
#include "CullingResult.h"
|
||||
#include "Library.h"
|
||||
|
||||
#include <glm/mat3x3.hpp>
|
||||
#include <glm/vec3.hpp>
|
||||
|
||||
namespace CesiumGeometry {
|
||||
|
||||
class Plane;
|
||||
|
||||
/**
|
||||
* @brief A bounding volume defined as a closed and convex cuboid with any
|
||||
* orientation.
|
||||
*
|
||||
* @see BoundingSphere
|
||||
* @see BoundingRegion
|
||||
*/
|
||||
class CESIUMGEOMETRY_API OrientedBoundingBox final {
|
||||
public:
|
||||
/**
|
||||
* @brief Constructs a new instance.
|
||||
*
|
||||
* @param center The center of the box.
|
||||
* @param halfAxes The three orthogonal half-axes of the bounding box.
|
||||
* Equivalently, the transformation matrix to rotate and scale a 2x2x2 cube
|
||||
* centered at the origin.
|
||||
*
|
||||
* @snippet TestOrientedBoundingBox.cpp Constructor
|
||||
*/
|
||||
OrientedBoundingBox(
|
||||
const glm::dvec3& center,
|
||||
const glm::dmat3& halfAxes) noexcept
|
||||
: _center(center),
|
||||
_halfAxes(halfAxes),
|
||||
// TODO: what should we do if halfAxes is singular?
|
||||
_inverseHalfAxes(glm::inverse(halfAxes)),
|
||||
_lengths(
|
||||
2.0 * glm::length(_halfAxes[0]),
|
||||
2.0 * glm::length(_halfAxes[1]),
|
||||
2.0 * glm::length(_halfAxes[2])) {}
|
||||
|
||||
/**
|
||||
* @brief Gets the center of the box.
|
||||
*/
|
||||
constexpr const glm::dvec3& getCenter() const noexcept {
|
||||
return this->_center;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the three orthogonal half-axes of the bounding box.
|
||||
* Equivalently, the transformation matrix to rotate and scale a 2x2x2 cube
|
||||
* centered at the origin.
|
||||
*/
|
||||
constexpr const glm::dmat3& getHalfAxes() const noexcept {
|
||||
return this->_halfAxes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the inverse transformation matrix, to rotate from world space
|
||||
* to local space relative to the box.
|
||||
*/
|
||||
constexpr const glm::dmat3& getInverseHalfAxes() const noexcept {
|
||||
return this->_inverseHalfAxes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the lengths of the box on each local axis respectively.
|
||||
*/
|
||||
constexpr const glm::dvec3& getLengths() const noexcept {
|
||||
return this->_lengths;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Determines on which side of a plane the bounding box is located.
|
||||
*
|
||||
* @param plane The plane to test against.
|
||||
* @return The {@link CullingResult}:
|
||||
* * `Inside` if the entire box is on the side of the plane the normal is
|
||||
* pointing.
|
||||
* * `Outside` if the entire box is on the opposite side.
|
||||
* * `Intersecting` if the box intersects the plane.
|
||||
*/
|
||||
CullingResult intersectPlane(const Plane& plane) const noexcept;
|
||||
|
||||
/**
|
||||
* @brief Computes the distance squared from a given position to the closest
|
||||
* point on this bounding volume. The bounding volume and the position must be
|
||||
* expressed in the same coordinate system.
|
||||
*
|
||||
* @param position The position
|
||||
* @return The estimated distance squared from the bounding box to the point.
|
||||
*
|
||||
* @snippet TestOrientedBoundingBox.cpp distanceSquaredTo
|
||||
*/
|
||||
double
|
||||
computeDistanceSquaredToPosition(const glm::dvec3& position) const noexcept;
|
||||
|
||||
/**
|
||||
* @brief Computes whether the given position is contained within the bounding
|
||||
* box.
|
||||
*
|
||||
* @param position The position.
|
||||
* @return Whether the position is contained within the bounding box.
|
||||
*/
|
||||
bool contains(const glm::dvec3& position) const noexcept;
|
||||
|
||||
/**
|
||||
* @brief Transforms this bounding box to another coordinate system using a
|
||||
* 4x4 matrix.
|
||||
*
|
||||
* @param transformation The transformation.
|
||||
* @return The oriented bounding box in the new coordinate system.
|
||||
*/
|
||||
OrientedBoundingBox
|
||||
transform(const glm::dmat4& transformation) const noexcept;
|
||||
|
||||
/**
|
||||
* @brief Converts this oriented bounding box to an axis-aligned bounding box.
|
||||
*/
|
||||
AxisAlignedBox toAxisAligned() const noexcept;
|
||||
|
||||
/**
|
||||
* @brief Converts this oriented bounding box to a bounding sphere.
|
||||
*/
|
||||
BoundingSphere toSphere() const noexcept;
|
||||
|
||||
/**
|
||||
* @brief Creates an oriented bounding box from the given axis-aligned
|
||||
* bounding box.
|
||||
*/
|
||||
static OrientedBoundingBox
|
||||
fromAxisAligned(const AxisAlignedBox& axisAligned) noexcept;
|
||||
|
||||
/**
|
||||
* @brief Creates an oriented bounding box from the given bounding sphere.
|
||||
*/
|
||||
static OrientedBoundingBox fromSphere(const BoundingSphere& sphere) noexcept;
|
||||
|
||||
private:
|
||||
glm::dvec3 _center;
|
||||
glm::dmat3 _halfAxes;
|
||||
glm::dmat3 _inverseHalfAxes;
|
||||
glm::dvec3 _lengths;
|
||||
};
|
||||
|
||||
} // namespace CesiumGeometry
|
||||
111
Plugins/CesiumForUnreal/Source/ThirdParty/include/CesiumGeometry/Plane.h
vendored
Normal file
111
Plugins/CesiumForUnreal/Source/ThirdParty/include/CesiumGeometry/Plane.h
vendored
Normal file
@ -0,0 +1,111 @@
|
||||
#pragma once
|
||||
|
||||
#include "Library.h"
|
||||
|
||||
#include <glm/vec3.hpp>
|
||||
|
||||
namespace CesiumGeometry {
|
||||
|
||||
/**
|
||||
* @brief A plane in Hessian Normal Format.
|
||||
*/
|
||||
class CESIUMGEOMETRY_API Plane final {
|
||||
public:
|
||||
/**
|
||||
* @brief The XY plane passing through the origin, with normal in positive Z.
|
||||
*/
|
||||
static const Plane ORIGIN_XY_PLANE;
|
||||
|
||||
/**
|
||||
* @brief The YZ plane passing through the origin, with normal in positive X.
|
||||
*/
|
||||
static const Plane ORIGIN_YZ_PLANE;
|
||||
|
||||
/**
|
||||
* @brief The ZX plane passing through the origin, with normal in positive Y.
|
||||
*/
|
||||
static const Plane ORIGIN_ZX_PLANE;
|
||||
|
||||
/**
|
||||
* @brief Constructs a new plane with a +Z normal and a distance of 0.0.
|
||||
*/
|
||||
Plane() noexcept;
|
||||
|
||||
/**
|
||||
* @brief Constructs a new plane from a normal and a distance from the origin.
|
||||
*
|
||||
* The plane is defined by:
|
||||
* ```
|
||||
* ax + by + cz + d = 0
|
||||
* ```
|
||||
* where (a, b, c) is the plane's `normal`, d is the signed
|
||||
* `distance` to the plane, and (x, y, z) is any point on
|
||||
* the plane.
|
||||
*
|
||||
* @param normal The plane's normal (normalized).
|
||||
* @param distance The shortest distance from the origin to the plane. The
|
||||
* sign of `distance` determines which side of the plane the origin is on. If
|
||||
* `distance` is positive, the origin is in the half-space in the direction of
|
||||
* the normal; if negative, the origin is in the half-space opposite to the
|
||||
* normal; if zero, the plane passes through the origin.
|
||||
*
|
||||
* @exception std::exception `normal` must be normalized.
|
||||
*
|
||||
* Example:
|
||||
* @snippet TestPlane.cpp constructor-normal-distance
|
||||
*/
|
||||
Plane(const glm::dvec3& normal, double distance);
|
||||
|
||||
/**
|
||||
* @brief Construct a new plane from a point in the plane and the plane's
|
||||
* normal.
|
||||
*
|
||||
* @param point The point on the plane.
|
||||
* @param normal The plane's normal (normalized).
|
||||
*
|
||||
* @exception std::exception `normal` must be normalized.
|
||||
*
|
||||
* Example:
|
||||
* @snippet TestPlane.cpp constructor-point-normal
|
||||
*/
|
||||
Plane(const glm::dvec3& point, const glm::dvec3& normal);
|
||||
|
||||
/**
|
||||
* @brief Gets the plane's normal.
|
||||
*/
|
||||
const glm::dvec3& getNormal() const noexcept { return this->_normal; }
|
||||
|
||||
/**
|
||||
* @brief Gets the signed shortest distance from the origin to the plane.
|
||||
* The sign of `distance` determines which side of the plane the origin
|
||||
* is on. If `distance` is positive, the origin is in the half-space
|
||||
* in the direction of the normal; if negative, the origin is in the
|
||||
* half-space opposite to the normal; if zero, the plane passes through the
|
||||
* origin.
|
||||
*/
|
||||
double getDistance() const noexcept { return this->_distance; }
|
||||
|
||||
/**
|
||||
* @brief Computes the signed shortest distance of a point to this plane.
|
||||
* The sign of the distance determines which side of the plane the point
|
||||
* is on. If the distance is positive, the point is in the half-space
|
||||
* in the direction of the normal; if negative, the point is in the half-space
|
||||
* opposite to the normal; if zero, the plane passes through the point.
|
||||
*
|
||||
* @param point The point.
|
||||
* @returns The signed shortest distance of the point to the plane.
|
||||
*/
|
||||
double getPointDistance(const glm::dvec3& point) const noexcept;
|
||||
|
||||
/**
|
||||
* @brief Projects a point onto this plane.
|
||||
* @param point The point to project onto the plane.
|
||||
* @returns The projected point.
|
||||
*/
|
||||
glm::dvec3 projectPointOntoPlane(const glm::dvec3& point) const noexcept;
|
||||
|
||||
private:
|
||||
glm::dvec3 _normal;
|
||||
double _distance;
|
||||
};
|
||||
} // namespace CesiumGeometry
|
||||
168
Plugins/CesiumForUnreal/Source/ThirdParty/include/CesiumGeometry/QuadtreeAvailability.h
vendored
Normal file
168
Plugins/CesiumForUnreal/Source/ThirdParty/include/CesiumGeometry/QuadtreeAvailability.h
vendored
Normal file
@ -0,0 +1,168 @@
|
||||
#pragma once
|
||||
|
||||
#include "Availability.h"
|
||||
#include "Library.h"
|
||||
#include "QuadtreeTileID.h"
|
||||
#include "TileAvailabilityFlags.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <memory>
|
||||
#include <span>
|
||||
#include <vector>
|
||||
|
||||
namespace CesiumGeometry {
|
||||
|
||||
/**
|
||||
* @brief An availability tree for a quadtree, where availability can be stored
|
||||
* and computed based on \ref QuadtreeTileID.
|
||||
*/
|
||||
class CESIUMGEOMETRY_API QuadtreeAvailability final {
|
||||
public:
|
||||
/**
|
||||
* @brief Constructs a new instance.
|
||||
*
|
||||
* @param subtreeLevels The number of levels in each subtree.
|
||||
* @param maximumLevel The index of the maximum level in this tileset.
|
||||
*/
|
||||
QuadtreeAvailability(uint32_t subtreeLevels, uint32_t maximumLevel) noexcept;
|
||||
|
||||
/**
|
||||
* @brief Determines the currently known availability status of the given
|
||||
* tile.
|
||||
*
|
||||
* @param tileID The {@link CesiumGeometry::QuadtreeTileID} for the tile.
|
||||
*
|
||||
* @return The {@link TileAvailabilityFlags} for this tile encoded into a
|
||||
* uint8_t.
|
||||
*/
|
||||
uint8_t computeAvailability(const QuadtreeTileID& tileID) const noexcept;
|
||||
|
||||
/**
|
||||
* @brief Attempts to add an availability subtree into the existing overall
|
||||
* availability tree.
|
||||
*
|
||||
* @param tileID The {@link CesiumGeometry::QuadtreeTileID} for the tile.
|
||||
* @param newSubtree The {@link CesiumGeometry::AvailabilitySubtree} to add.
|
||||
*
|
||||
* @return Whether the insertion was successful.
|
||||
*/
|
||||
bool addSubtree(
|
||||
const QuadtreeTileID& tileID,
|
||||
AvailabilitySubtree&& newSubtree) noexcept;
|
||||
|
||||
/**
|
||||
* @brief Determines the currently known availability status of the given
|
||||
* tile.
|
||||
*
|
||||
* Priming with a known parent subtree node avoids the need to traverse the
|
||||
* entire availability tree so far. The node must have a loaded subtree
|
||||
*
|
||||
* @param tileID The tile ID to get the availability for.
|
||||
* @param pNode The subtree node to look for the tileID in. The tileID should
|
||||
* be within this subtree node.
|
||||
*
|
||||
* @return The {@link TileAvailabilityFlags} for this tile encoded into a
|
||||
* uint8_t.
|
||||
*/
|
||||
uint8_t computeAvailability(
|
||||
const QuadtreeTileID& tileID,
|
||||
const AvailabilityNode* pNode) const noexcept;
|
||||
|
||||
/**
|
||||
* @brief Attempts to add a child subtree node onto the given parent node.
|
||||
*
|
||||
* Priming with a known parent subtree node avoids the need to traverse the
|
||||
* entire availability tree so far. If the parent node is nullptr and the
|
||||
* tile ID indicates this is the root tile, the subtree will be attached to
|
||||
* the root.
|
||||
*
|
||||
* @param tileID The root tile's ID of the subtree we are trying to add.
|
||||
* @param pParentNode The parent subtree node. The tileID should fall exactly
|
||||
* at the end of this parent subtree.
|
||||
*
|
||||
* @return The newly created node if the insertion was successful, nullptr
|
||||
* otherwise.
|
||||
*/
|
||||
AvailabilityNode*
|
||||
addNode(const QuadtreeTileID& tileID, AvailabilityNode* pParentNode) noexcept;
|
||||
|
||||
/**
|
||||
* @brief Attempts to add a loaded subtree onto the given node.
|
||||
*
|
||||
* The node must have been created earlier from a call to addNode.
|
||||
*
|
||||
* @param pNode The node on which to add the subtree.
|
||||
* @param newSubtree The new subtree to add.
|
||||
*
|
||||
* @return Whether the insertion was successful.
|
||||
*/
|
||||
bool addLoadedSubtree(
|
||||
AvailabilityNode* pNode,
|
||||
AvailabilitySubtree&& newSubtree) noexcept;
|
||||
|
||||
/**
|
||||
* @brief Find the child node index corresponding to this tile ID and parent
|
||||
* node.
|
||||
*
|
||||
* Attempts to find the child node for the tile with the given ID and parent
|
||||
* node. The parent node is used to speed up the search significantly. Note
|
||||
* that if the given tile ID does not correspond exactly to an immediate
|
||||
* child node of the parent node, nullptr will be returned. If a tileID
|
||||
* outside the given parent node's subtree is given, an incorrect child index
|
||||
* may be returned.
|
||||
*
|
||||
* @param tileID The tile ID of the child node we are looking for.
|
||||
* @param pParentNode The immediate parent to the child node we are looking
|
||||
* for.
|
||||
* @return The child node index if found, std::nullopt otherwise.
|
||||
*/
|
||||
std::optional<uint32_t> findChildNodeIndex(
|
||||
const QuadtreeTileID& tileID,
|
||||
const AvailabilityNode* pParentNode) const;
|
||||
|
||||
/**
|
||||
* @brief Find the child node corresponding to this tile ID and parent node.
|
||||
*
|
||||
* Attempts to find the child node for the tile with the given ID and parent
|
||||
* node. The parent node is used to speed up the search significantly. Note
|
||||
* that if the given tile ID does not correspond exactly to an immediate
|
||||
* child node of the parent node, nullptr will be returned. If a tileID
|
||||
* outside the given parent node's subtree is given, an incorrect child index
|
||||
* may be returned.
|
||||
*
|
||||
* @param tileID The tile ID of the child node we are looking for.
|
||||
* @param pParentNode The immediate parent to the child node we are looking
|
||||
* for.
|
||||
* @return The child node if found, nullptr otherwise.
|
||||
*/
|
||||
AvailabilityNode* findChildNode(
|
||||
const QuadtreeTileID& tileID,
|
||||
AvailabilityNode* pParentNode) const;
|
||||
|
||||
/**
|
||||
* @brief Gets the number of levels in each subtree.
|
||||
*/
|
||||
constexpr inline uint32_t getSubtreeLevels() const noexcept {
|
||||
return this->_subtreeLevels;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the index of the maximum level in this implicit tileset.
|
||||
*/
|
||||
constexpr inline uint32_t getMaximumLevel() const noexcept {
|
||||
return this->_maximumLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets a pointer to the root subtree node of this implicit tileset.
|
||||
*/
|
||||
AvailabilityNode* getRootNode() noexcept { return this->_pRoot.get(); }
|
||||
|
||||
private:
|
||||
uint32_t _subtreeLevels;
|
||||
uint32_t _maximumLevel;
|
||||
uint32_t _maximumChildrenSubtrees;
|
||||
std::unique_ptr<AvailabilityNode> _pRoot;
|
||||
};
|
||||
|
||||
} // namespace CesiumGeometry
|
||||
121
Plugins/CesiumForUnreal/Source/ThirdParty/include/CesiumGeometry/QuadtreeRectangleAvailability.h
vendored
Normal file
121
Plugins/CesiumForUnreal/Source/ThirdParty/include/CesiumGeometry/QuadtreeRectangleAvailability.h
vendored
Normal file
@ -0,0 +1,121 @@
|
||||
#pragma once
|
||||
|
||||
#include "Library.h"
|
||||
#include "QuadtreeTileRectangularRange.h"
|
||||
#include "QuadtreeTilingScheme.h"
|
||||
#include "Rectangle.h"
|
||||
|
||||
#include <glm/vec2.hpp>
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace CesiumGeometry {
|
||||
|
||||
/**
|
||||
* @brief Manages information about the availability of tiles in a quadtree.
|
||||
*/
|
||||
class CESIUMGEOMETRY_API QuadtreeRectangleAvailability final {
|
||||
public:
|
||||
/**
|
||||
* @brief Creates a new instance.
|
||||
*
|
||||
* @param tilingScheme The {@link QuadtreeTilingScheme}.
|
||||
* @param maximumLevel The maximum level (height of the tree) for which
|
||||
* the availability should be tracked.
|
||||
*/
|
||||
QuadtreeRectangleAvailability(
|
||||
const QuadtreeTilingScheme& tilingScheme,
|
||||
uint32_t maximumLevel) noexcept;
|
||||
|
||||
/**
|
||||
* @brief Adds the specified range to the set of available tiles.
|
||||
*
|
||||
* @param range The {@link QuadtreeTileRectangularRange} that describes
|
||||
* the range of available tiles.
|
||||
*/
|
||||
void
|
||||
addAvailableTileRange(const QuadtreeTileRectangularRange& range) noexcept;
|
||||
|
||||
/**
|
||||
* @brief Computes the maximum level for the given 2D position.
|
||||
*
|
||||
* This will compute the maximum level of any available tile for
|
||||
* the given position. The position refers to the 2D space that
|
||||
* is covered by the nodes of the quadtree.
|
||||
*
|
||||
* @param position The 2D position.
|
||||
* @return The maximum level at the given position. This may be 0 if
|
||||
* the position is not covered by the quadtree at all.
|
||||
*/
|
||||
uint32_t
|
||||
computeMaximumLevelAtPosition(const glm::dvec2& position) const noexcept;
|
||||
|
||||
/**
|
||||
* @brief Returns whether a certain tile is available.
|
||||
*
|
||||
* This checks the availability of the tile that is described by the
|
||||
* given {@link QuadtreeTileID}, which consists of the level and
|
||||
* the x- and y- coordinates of the queried tile.
|
||||
*
|
||||
* @param id The quadtree tile ID.
|
||||
* @returns The {@link CesiumGeometry::TileAvailabilityFlags} for this tile,
|
||||
* encoded into an uint8_t.
|
||||
*/
|
||||
uint8_t isTileAvailable(const QuadtreeTileID& id) const noexcept;
|
||||
|
||||
private:
|
||||
struct RectangleWithLevel {
|
||||
uint32_t level;
|
||||
Rectangle rectangle;
|
||||
};
|
||||
|
||||
struct QuadtreeNode {
|
||||
QuadtreeNode(
|
||||
const QuadtreeTileID& id_,
|
||||
const Rectangle& extent_,
|
||||
QuadtreeNode* pParent_) noexcept
|
||||
: id(id_),
|
||||
extent(extent_),
|
||||
pParent(pParent_),
|
||||
ll(),
|
||||
lr(),
|
||||
ul(),
|
||||
ur(),
|
||||
rectangles() {}
|
||||
|
||||
QuadtreeTileID id;
|
||||
|
||||
CesiumGeometry::Rectangle extent;
|
||||
|
||||
QuadtreeNode* pParent;
|
||||
std::unique_ptr<QuadtreeNode> ll;
|
||||
std::unique_ptr<QuadtreeNode> lr;
|
||||
std::unique_ptr<QuadtreeNode> ul;
|
||||
std::unique_ptr<QuadtreeNode> ur;
|
||||
|
||||
std::vector<RectangleWithLevel> rectangles;
|
||||
};
|
||||
|
||||
QuadtreeTilingScheme _tilingScheme;
|
||||
uint32_t _maximumLevel;
|
||||
std::vector<std::unique_ptr<QuadtreeNode>> _rootNodes;
|
||||
|
||||
static void putRectangleInQuadtree(
|
||||
const QuadtreeTilingScheme& tilingScheme,
|
||||
uint32_t maximumLevel,
|
||||
QuadtreeRectangleAvailability::QuadtreeNode& node,
|
||||
const QuadtreeRectangleAvailability::RectangleWithLevel&
|
||||
rectangle) noexcept;
|
||||
static bool rectangleLevelComparator(
|
||||
const QuadtreeRectangleAvailability::RectangleWithLevel& a,
|
||||
const QuadtreeRectangleAvailability::RectangleWithLevel& b) noexcept;
|
||||
static uint32_t findMaxLevelFromNode(
|
||||
QuadtreeNode* pStopNode,
|
||||
QuadtreeNode& node,
|
||||
const glm::dvec2& position) noexcept;
|
||||
static void createNodeChildrenIfNecessary(
|
||||
QuadtreeNode& node,
|
||||
const QuadtreeTilingScheme& tilingScheme) noexcept;
|
||||
};
|
||||
} // namespace CesiumGeometry
|
||||
116
Plugins/CesiumForUnreal/Source/ThirdParty/include/CesiumGeometry/QuadtreeTileID.h
vendored
Normal file
116
Plugins/CesiumForUnreal/Source/ThirdParty/include/CesiumGeometry/QuadtreeTileID.h
vendored
Normal file
@ -0,0 +1,116 @@
|
||||
#pragma once
|
||||
|
||||
#include "Library.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
|
||||
namespace CesiumGeometry {
|
||||
class QuadtreeTilingScheme;
|
||||
|
||||
/**
|
||||
* @brief Uniquely identifies a node in a quadtree.
|
||||
*
|
||||
* This is one form of a {@link Cesium3DTilesSelection::TileID}.
|
||||
*
|
||||
* The identifier is composed of the level (with 0 being the level of the root
|
||||
* tile), the x- and y-coordinate of the tile, referring to a grid coordinate
|
||||
* system at the respective level.
|
||||
*/
|
||||
struct CESIUMGEOMETRY_API QuadtreeTileID final {
|
||||
|
||||
/**
|
||||
* @brief Creates a new instance.
|
||||
*
|
||||
* @param level_ The level of the node, with 0 being the root
|
||||
* @param x_ The x-coordinate of the tile
|
||||
* @param y_ The y-coordinate of the tile
|
||||
*/
|
||||
constexpr QuadtreeTileID(uint32_t level_, uint32_t x_, uint32_t y_) noexcept
|
||||
: level(level_), x(x_), y(y_) {}
|
||||
|
||||
/**
|
||||
* @brief Returns `true` if two identifiers are equal.
|
||||
*/
|
||||
constexpr bool operator==(const QuadtreeTileID& other) const noexcept {
|
||||
return this->level == other.level && this->x == other.x &&
|
||||
this->y == other.y;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns `true` if two identifiers are *not* equal.
|
||||
*/
|
||||
constexpr bool operator!=(const QuadtreeTileID& other) const noexcept {
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Computes the inverse y-coordinate of this tile ID.
|
||||
*
|
||||
* This will compute the inverse y-coordinate of this tile ID, based
|
||||
* on the given tiling scheme, which provides the number of tiles
|
||||
* in y-direction for the level of this tile ID.
|
||||
*
|
||||
* @param tilingScheme The {@link QuadtreeTilingScheme}.
|
||||
* @return The inverted y-coordinate.
|
||||
*/
|
||||
uint32_t
|
||||
computeInvertedY(const QuadtreeTilingScheme& tilingScheme) const noexcept;
|
||||
|
||||
/**
|
||||
* @brief Gets the ID of the parent of the tile with this ID.
|
||||
*
|
||||
* If this method is called on a level zero tile, it returns itself.
|
||||
*
|
||||
* @return The ID of the parent tile.
|
||||
*/
|
||||
constexpr QuadtreeTileID getParent() const noexcept {
|
||||
if (this->level == 0) {
|
||||
return *this;
|
||||
}
|
||||
return QuadtreeTileID(this->level - 1, this->x >> 1, this->y >> 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief The level of this tile ID, with 0 being the root tile.
|
||||
*/
|
||||
uint32_t level;
|
||||
|
||||
/**
|
||||
* @brief The x-coordinate of this tile ID.
|
||||
*/
|
||||
uint32_t x;
|
||||
|
||||
/**
|
||||
* @brief The y-coordinate of this tile ID.
|
||||
*/
|
||||
uint32_t y;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A node of a tile hierarchy that was created by upsampling the tile
|
||||
* content of a parent node.
|
||||
*/
|
||||
struct CESIUMGEOMETRY_API UpsampledQuadtreeNode final {
|
||||
|
||||
/**
|
||||
* @brief The {@link QuadtreeTileID} for this tree node.
|
||||
*/
|
||||
QuadtreeTileID tileID;
|
||||
};
|
||||
} // namespace CesiumGeometry
|
||||
|
||||
namespace std {
|
||||
|
||||
/**
|
||||
* @brief A hash function for {@link CesiumGeometry::QuadtreeTileID} objects.
|
||||
*/
|
||||
template <> struct hash<CesiumGeometry::QuadtreeTileID> {
|
||||
|
||||
/**
|
||||
* @brief A specialization of the `std::hash` template for
|
||||
* {@link CesiumGeometry::QuadtreeTileID} objects.
|
||||
*/
|
||||
size_t operator()(const CesiumGeometry::QuadtreeTileID& key) const noexcept;
|
||||
};
|
||||
} // namespace std
|
||||
39
Plugins/CesiumForUnreal/Source/ThirdParty/include/CesiumGeometry/QuadtreeTileRectangularRange.h
vendored
Normal file
39
Plugins/CesiumForUnreal/Source/ThirdParty/include/CesiumGeometry/QuadtreeTileRectangularRange.h
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace CesiumGeometry {
|
||||
|
||||
/**
|
||||
* @brief A rectangular range of tiles at a particular level of a quadtree.
|
||||
*/
|
||||
struct QuadtreeTileRectangularRange {
|
||||
|
||||
/**
|
||||
* @brief The level in the tree at which this rectangle is located, with 0
|
||||
* being the root.
|
||||
*/
|
||||
uint32_t level;
|
||||
|
||||
/**
|
||||
* @brief The minimum x-coordinate of the range, *inclusive*.
|
||||
*/
|
||||
uint32_t minimumX;
|
||||
|
||||
/**
|
||||
* @brief The minimum y-coordinate of the range, *inclusive*.
|
||||
*/
|
||||
uint32_t minimumY;
|
||||
|
||||
/**
|
||||
* @brief The maximum x-coordinate of the range, *inclusive*.
|
||||
*/
|
||||
uint32_t maximumX;
|
||||
|
||||
/**
|
||||
* @brief The maximum y-coordinate of the range, *inclusive*.
|
||||
*/
|
||||
uint32_t maximumY;
|
||||
};
|
||||
|
||||
} // namespace CesiumGeometry
|
||||
98
Plugins/CesiumForUnreal/Source/ThirdParty/include/CesiumGeometry/QuadtreeTilingScheme.h
vendored
Normal file
98
Plugins/CesiumForUnreal/Source/ThirdParty/include/CesiumGeometry/QuadtreeTilingScheme.h
vendored
Normal file
@ -0,0 +1,98 @@
|
||||
#pragma once
|
||||
|
||||
#include "Library.h"
|
||||
#include "QuadtreeTileID.h"
|
||||
#include "Rectangle.h"
|
||||
|
||||
#include <glm/vec2.hpp>
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace CesiumGeometry {
|
||||
|
||||
/**
|
||||
* @brief Defines how a rectangular region is divided into quadtree tiles.
|
||||
*/
|
||||
class CESIUMGEOMETRY_API QuadtreeTilingScheme final {
|
||||
public:
|
||||
/**
|
||||
* @brief Constructs a new instance.
|
||||
*
|
||||
* @param rectangle The overall rectangle that is tiled, expressed in
|
||||
* projected coordinates.
|
||||
* @param rootTilesX The number of tiles at the root of the quadtree in the X
|
||||
* direction.
|
||||
* @param rootTilesY The number of tiles at the root of the quadtree in the Y
|
||||
* direction.
|
||||
*/
|
||||
QuadtreeTilingScheme(
|
||||
const CesiumGeometry::Rectangle& rectangle,
|
||||
uint32_t rootTilesX,
|
||||
uint32_t rootTilesY) noexcept;
|
||||
|
||||
/**
|
||||
* @brief Return the overall rectangle that is tiled.
|
||||
*
|
||||
* The rectangle is expressed in projected coordinates.
|
||||
*/
|
||||
const CesiumGeometry::Rectangle& getRectangle() const noexcept {
|
||||
return this->_rectangle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns the number of root tiles, in x-direction.
|
||||
*/
|
||||
uint32_t getRootTilesX() const noexcept { return this->_rootTilesX; }
|
||||
|
||||
/**
|
||||
* @brief Returns the number of root tiles, in y-direction.
|
||||
*/
|
||||
uint32_t getRootTilesY() const noexcept { return this->_rootTilesY; }
|
||||
|
||||
/**
|
||||
* @brief Returns the number of tiles, in x-direction, at the given level.
|
||||
*/
|
||||
uint32_t getNumberOfXTilesAtLevel(uint32_t level) const noexcept;
|
||||
|
||||
/**
|
||||
* @brief Returns the number of tiles, in y-direction, at the given level.
|
||||
*/
|
||||
uint32_t getNumberOfYTilesAtLevel(uint32_t level) const noexcept;
|
||||
|
||||
/**
|
||||
* @brief Computes the {@link CesiumGeometry::QuadtreeTileID} for a given
|
||||
* position and level.
|
||||
*
|
||||
* If the given position is within the {@link getRectangle} of this tiling
|
||||
* scheme, then this will compute the quadtree tile ID for the tile that
|
||||
* contains the given position at the given level. Otherwise, `nullopt`
|
||||
* is returned.
|
||||
*
|
||||
* @param position The 2D position
|
||||
* @param level The level
|
||||
* @return The tile ID, or `nullopt`.
|
||||
*/
|
||||
std::optional<CesiumGeometry::QuadtreeTileID>
|
||||
positionToTile(const glm::dvec2& position, uint32_t level) const noexcept;
|
||||
|
||||
/**
|
||||
* @brief Returns the {@link CesiumGeometry::Rectangle} that is covered by the
|
||||
* specified tile.
|
||||
*
|
||||
* The rectangle that is covered by the tile that is identified with
|
||||
* the given {@link CesiumGeometry::QuadtreeTileID} will be computed,
|
||||
* based on the {@link getRectangle} of this tiling scheme.
|
||||
*
|
||||
* @param tileID The tile ID
|
||||
* @return The rectangle
|
||||
*/
|
||||
CesiumGeometry::Rectangle
|
||||
tileToRectangle(const CesiumGeometry::QuadtreeTileID& tileID) const noexcept;
|
||||
|
||||
private:
|
||||
CesiumGeometry::Rectangle _rectangle;
|
||||
uint32_t _rootTilesX;
|
||||
uint32_t _rootTilesY;
|
||||
};
|
||||
|
||||
} // namespace CesiumGeometry
|
||||
63
Plugins/CesiumForUnreal/Source/ThirdParty/include/CesiumGeometry/Ray.h
vendored
Normal file
63
Plugins/CesiumForUnreal/Source/ThirdParty/include/CesiumGeometry/Ray.h
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
#pragma once
|
||||
|
||||
#include "Library.h"
|
||||
|
||||
#include <glm/fwd.hpp>
|
||||
#include <glm/vec3.hpp>
|
||||
|
||||
namespace CesiumGeometry {
|
||||
|
||||
/**
|
||||
* @brief A ray that extends infinitely from the provided origin in the provided
|
||||
* direction.
|
||||
*/
|
||||
class CESIUMGEOMETRY_API Ray final {
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a new ray.
|
||||
*
|
||||
* @param origin The origin of the ray.
|
||||
* @param direction The direction of the ray (normalized).
|
||||
*
|
||||
* @exception std::exception `direction` must be normalized.
|
||||
*/
|
||||
Ray(const glm::dvec3& origin, const glm::dvec3& direction);
|
||||
|
||||
/**
|
||||
* @brief Gets the origin of the ray.
|
||||
*/
|
||||
const glm::dvec3& getOrigin() const noexcept { return this->_origin; }
|
||||
|
||||
/**
|
||||
* @brief Gets the direction of the ray.
|
||||
*/
|
||||
const glm::dvec3& getDirection() const noexcept { return this->_direction; }
|
||||
|
||||
/**
|
||||
* @brief Calculates a point on the ray that corresponds to the given
|
||||
* distance from origin. Can be positive, negative, or 0.
|
||||
*
|
||||
* @param distance Desired distance from origin
|
||||
* @return The point along the ray.
|
||||
*/
|
||||
glm::dvec3 pointFromDistance(double distance) const noexcept;
|
||||
|
||||
/**
|
||||
* @brief Transforms the ray using a given 4x4 transformation matrix.
|
||||
*
|
||||
* @param transformation The 4x4 transformation matrix used to transform the
|
||||
* ray.
|
||||
* @return The transformed ray.
|
||||
*/
|
||||
Ray transform(const glm::dmat4x4& transformation) const noexcept;
|
||||
|
||||
/**
|
||||
* @brief Constructs a new ray with its direction opposite this one.
|
||||
*/
|
||||
Ray operator-() const noexcept;
|
||||
|
||||
private:
|
||||
glm::dvec3 _origin;
|
||||
glm::dvec3 _direction;
|
||||
};
|
||||
} // namespace CesiumGeometry
|
||||
202
Plugins/CesiumForUnreal/Source/ThirdParty/include/CesiumGeometry/Rectangle.h
vendored
Normal file
202
Plugins/CesiumForUnreal/Source/ThirdParty/include/CesiumGeometry/Rectangle.h
vendored
Normal file
@ -0,0 +1,202 @@
|
||||
#pragma once
|
||||
|
||||
#include "Library.h"
|
||||
|
||||
#include <glm/vec2.hpp>
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace CesiumGeometry {
|
||||
|
||||
/**
|
||||
* @brief A 2D rectangle
|
||||
*/
|
||||
struct CESIUMGEOMETRY_API Rectangle final {
|
||||
/**
|
||||
* @brief Creates a new instance with all coordinate values set to 0.0.
|
||||
*/
|
||||
constexpr Rectangle() noexcept
|
||||
: minimumX(0.0), minimumY(0.0), maximumX(0.0), maximumY(0.0) {}
|
||||
|
||||
/**
|
||||
* @brief Creates a new instance.
|
||||
*
|
||||
* Creates a new rectangle from the given coordinates. This implicitly
|
||||
* assumes that the given coordinates form a valid rectangle, meaning
|
||||
* that `minimumX <= maximumX` and `minimumY <= maximumY`.
|
||||
*
|
||||
* @param minimumX_ The minimum x-coordinate.
|
||||
* @param minimumY_ The minimum y-coordinate.
|
||||
* @param maximumX_ The maximum x-coordinate.
|
||||
* @param maximumY_ The maximum y-coordinate.
|
||||
*/
|
||||
constexpr Rectangle(
|
||||
double minimumX_,
|
||||
double minimumY_,
|
||||
double maximumX_,
|
||||
double maximumY_) noexcept
|
||||
: minimumX(minimumX_),
|
||||
minimumY(minimumY_),
|
||||
maximumX(maximumX_),
|
||||
maximumY(maximumY_) {}
|
||||
|
||||
/**
|
||||
* @brief The minimum x-coordinate.
|
||||
*/
|
||||
double minimumX;
|
||||
|
||||
/**
|
||||
* @brief The minimum y-coordinate.
|
||||
*/
|
||||
double minimumY;
|
||||
|
||||
/**
|
||||
* @brief The maximum x-coordinate.
|
||||
*/
|
||||
double maximumX;
|
||||
|
||||
/**
|
||||
* @brief The maximum y-coordinate.
|
||||
*/
|
||||
double maximumY;
|
||||
|
||||
/**
|
||||
* @brief Checks whether this rectangle contains the given position.
|
||||
*
|
||||
* This means that the `x`- and `y` coordinates of the given position
|
||||
* are not smaller than the minimum and not larger than the maximum
|
||||
* coordinates of this rectangle.
|
||||
*
|
||||
* @param position The position.
|
||||
* @returns Whether this rectangle contains the given position.
|
||||
*/
|
||||
bool contains(const glm::dvec2& position) const noexcept;
|
||||
|
||||
/**
|
||||
* @brief Checks whether this rectangle overlaps the given rectangle.
|
||||
*
|
||||
* This means that this rectangle and the given rectangle have
|
||||
* a non-empty intersection. If either of the rectangles is empty,
|
||||
* then this will always return `false`.
|
||||
*
|
||||
* @param other The other rectangle.
|
||||
* @returns Whether this rectangle overlaps the given rectangle.
|
||||
*/
|
||||
bool overlaps(const Rectangle& other) const noexcept;
|
||||
|
||||
/**
|
||||
* @brief Checks whether this rectangle fully contains the given rectangle.
|
||||
*
|
||||
* This means that this rectangle contains all four corner points
|
||||
* of the given rectangle, as defined in {@link Rectangle::contains}.
|
||||
*
|
||||
* @param other The other rectangle.
|
||||
* @returns Whether this rectangle fully contains the given rectangle.
|
||||
*/
|
||||
bool fullyContains(const Rectangle& other) const noexcept;
|
||||
|
||||
/**
|
||||
* @brief Computes the signed distance from a position to the edge of the
|
||||
* rectangle.
|
||||
*
|
||||
* If the position is inside the rectangle, the distance is negative. If it is
|
||||
* outside the rectangle, it is positive.
|
||||
*
|
||||
* @param position The position.
|
||||
* @return The signed distance.
|
||||
*/
|
||||
double computeSignedDistance(const glm::dvec2& position) const noexcept;
|
||||
|
||||
/**
|
||||
* @brief Returns a point at the lower left of this rectangle.
|
||||
*
|
||||
* This is the point that consists of the minimum x- and y-coordinate.
|
||||
*
|
||||
* @returns The lower left point.
|
||||
*/
|
||||
constexpr glm::dvec2 getLowerLeft() const noexcept {
|
||||
return glm::dvec2(this->minimumX, this->minimumY);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns a point at the lower right of this rectangle.
|
||||
*
|
||||
* This is the point that consists of the maximum x- and minimum y-coordinate.
|
||||
*
|
||||
* @returns The lower right point.
|
||||
*/
|
||||
constexpr glm::dvec2 getLowerRight() const noexcept {
|
||||
return glm::dvec2(this->maximumX, this->minimumY);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns a point at the upper left of this rectangle.
|
||||
*
|
||||
* This is the point that consists of the minimum x- and maximum y-coordinate.
|
||||
*
|
||||
* @returns The upper left point.
|
||||
*/
|
||||
constexpr glm::dvec2 getUpperLeft() const noexcept {
|
||||
return glm::dvec2(this->minimumX, this->maximumY);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns a point at the upper right of this rectangle.
|
||||
*
|
||||
* This is the point that consists of the maximum x- and y-coordinate.
|
||||
*
|
||||
* @returns The upper right point.
|
||||
*/
|
||||
constexpr glm::dvec2 getUpperRight() const noexcept {
|
||||
return glm::dvec2(this->maximumX, this->maximumY);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns a point at the center of this rectangle.
|
||||
*
|
||||
* @returns The center point.
|
||||
*/
|
||||
constexpr glm::dvec2 getCenter() const noexcept {
|
||||
return glm::dvec2(
|
||||
(this->minimumX + this->maximumX) * 0.5,
|
||||
(this->minimumY + this->maximumY) * 0.5);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Computes the width of this rectangle.
|
||||
*
|
||||
* @returns The width.
|
||||
*/
|
||||
constexpr double computeWidth() const noexcept {
|
||||
return this->maximumX - this->minimumX;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Computes the height of this rectangle.
|
||||
*
|
||||
* @returns The height.
|
||||
*/
|
||||
constexpr double computeHeight() const noexcept {
|
||||
return this->maximumY - this->minimumY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes the intersection of this rectangle with another.
|
||||
*
|
||||
* @param other The other rectangle to intersect with this one.
|
||||
* @returns The intersection rectangle, or `std::nullopt` if there is no
|
||||
* intersection.
|
||||
*/
|
||||
std::optional<Rectangle>
|
||||
computeIntersection(const Rectangle& other) const noexcept;
|
||||
|
||||
/**
|
||||
* @brief Computes the union of this rectangle with another.
|
||||
*
|
||||
* @param other The other rectangle to union with this one.
|
||||
* @return The union rectangle, which fully contains both rectangles.
|
||||
*/
|
||||
Rectangle computeUnion(const Rectangle& other) const noexcept;
|
||||
};
|
||||
|
||||
} // namespace CesiumGeometry
|
||||
43
Plugins/CesiumForUnreal/Source/ThirdParty/include/CesiumGeometry/TileAvailabilityFlags.h
vendored
Normal file
43
Plugins/CesiumForUnreal/Source/ThirdParty/include/CesiumGeometry/TileAvailabilityFlags.h
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
#pragma once
|
||||
|
||||
#include "Library.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace CesiumGeometry {
|
||||
|
||||
/**
|
||||
* @brief A bitmask representing the availability state of a tile.
|
||||
*/
|
||||
enum CESIUMGEOMETRY_API TileAvailabilityFlags {
|
||||
/**
|
||||
* @brief The tile is known to be available.
|
||||
*/
|
||||
TILE_AVAILABLE = 1U,
|
||||
|
||||
/**
|
||||
* @brief The tile's content is known to be available.
|
||||
*/
|
||||
CONTENT_AVAILABLE = 2U,
|
||||
|
||||
/**
|
||||
* @brief This tile has a subtree that is known to be available.
|
||||
*/
|
||||
SUBTREE_AVAILABLE = 4U,
|
||||
|
||||
/**
|
||||
* @brief This tile has a subtree that is loaded.
|
||||
*/
|
||||
SUBTREE_LOADED = 8U,
|
||||
|
||||
// TODO: is REACHABLE needed? Reevaluate after implementation
|
||||
/**
|
||||
* @brief The tile is reachable through the tileset availability tree.
|
||||
*
|
||||
* If a tile is not reachable, the above flags being false may simply
|
||||
* indicate that a subtree needed to reach this tile has not yet been loaded.
|
||||
*/
|
||||
REACHABLE = 16U
|
||||
};
|
||||
|
||||
} // namespace CesiumGeometry
|
||||
100
Plugins/CesiumForUnreal/Source/ThirdParty/include/CesiumGeometry/Transforms.h
vendored
Normal file
100
Plugins/CesiumForUnreal/Source/ThirdParty/include/CesiumGeometry/Transforms.h
vendored
Normal file
@ -0,0 +1,100 @@
|
||||
#pragma once
|
||||
|
||||
#include "Axis.h"
|
||||
#include "Library.h"
|
||||
|
||||
#include <glm/fwd.hpp>
|
||||
|
||||
namespace CesiumGeometry {
|
||||
|
||||
/**
|
||||
* @brief Coordinate system matrix constructions helpers.
|
||||
*/
|
||||
struct CESIUMGEOMETRY_API Transforms final {
|
||||
|
||||
/**
|
||||
* @brief A matrix to convert from y-up to z-up orientation,
|
||||
* by rotating about PI/2 around the x-axis
|
||||
*/
|
||||
static const glm::dmat4 Y_UP_TO_Z_UP;
|
||||
|
||||
/**
|
||||
* @brief A matrix to convert from z-up to y-up orientation,
|
||||
* by rotating about -PI/2 around the x-axis
|
||||
*/
|
||||
static const glm::dmat4 Z_UP_TO_Y_UP;
|
||||
|
||||
/**
|
||||
* @brief A matrix to convert from x-up to z-up orientation,
|
||||
* by rotating about -PI/2 around the y-axis
|
||||
*/
|
||||
static const glm::dmat4 X_UP_TO_Z_UP;
|
||||
|
||||
/**
|
||||
* @brief A matrix to convert from z-up to x-up orientation,
|
||||
* by rotating about PI/2 around the y-axis
|
||||
*/
|
||||
static const glm::dmat4 Z_UP_TO_X_UP;
|
||||
|
||||
/**
|
||||
* @brief A matrix to convert from x-up to y-up orientation,
|
||||
* by rotating about PI/2 around the z-axis
|
||||
*/
|
||||
static const glm::dmat4 X_UP_TO_Y_UP;
|
||||
|
||||
/**
|
||||
* @brief A matrix to convert from y-up to x-up orientation,
|
||||
* by rotating about -PI/2 around the z-axis
|
||||
*/
|
||||
static const glm::dmat4 Y_UP_TO_X_UP;
|
||||
|
||||
/**
|
||||
* @brief Creates a translation-rotation-scale matrix, equivalent to
|
||||
* `translation * rotation * scale`. So if a vector is multiplied with the
|
||||
* resulting matrix, it will be first scaled, then rotated, then translated.
|
||||
*
|
||||
* @param translation The translation.
|
||||
* @param rotation The rotation.
|
||||
* @param scale The scale.
|
||||
*/
|
||||
static glm::dmat4 createTranslationRotationScaleMatrix(
|
||||
const glm::dvec3& translation,
|
||||
const glm::dquat& rotation,
|
||||
const glm::dvec3& scale);
|
||||
|
||||
/**
|
||||
* @brief Decomposes a matrix into translation, rotation, and scale
|
||||
* components. This is the reverse of
|
||||
* {@link createTranslationRotationScaleMatrix}.
|
||||
*
|
||||
* The scale may be negative (i.e. when switching from a right-handed to a
|
||||
* left-handed system), but skew and other funny business will result in
|
||||
* undefined behavior.
|
||||
*
|
||||
* @param matrix The matrix to decompose.
|
||||
* @param pTranslation A pointer to the vector in which to store the
|
||||
* translation, or nullptr if the translation is not needed.
|
||||
* @param pRotation A pointer to the quaternion in which to store the
|
||||
* rotation, or nullptr if the rotation is not needed.
|
||||
* @param pScale A pointer to the vector in which to store the scale, or
|
||||
* nullptr if the scale is not needed.
|
||||
*/
|
||||
static void computeTranslationRotationScaleFromMatrix(
|
||||
const glm::dmat4& matrix,
|
||||
glm::dvec3* pTranslation,
|
||||
glm::dquat* pRotation,
|
||||
glm::dvec3* pScale);
|
||||
|
||||
/**
|
||||
* @brief Gets a transform that converts from one up axis to another.
|
||||
*
|
||||
* @param from The up axis to convert from.
|
||||
* @param to The up axis to convert to.
|
||||
*
|
||||
* @returns The up axis transform.
|
||||
*/
|
||||
static const glm::dmat4&
|
||||
getUpAxisTransform(CesiumGeometry::Axis from, CesiumGeometry::Axis to);
|
||||
};
|
||||
|
||||
} // namespace CesiumGeometry
|
||||
@ -0,0 +1,104 @@
|
||||
#pragma once
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
|
||||
namespace CesiumGeometry {
|
||||
|
||||
/**
|
||||
* @brief A structure describing a vertex that results from interpolating two
|
||||
* other vertices.
|
||||
*
|
||||
* The vertices to interpolate between are given via their indices. This is
|
||||
* used as one representation of a vertex in a {@link TriangleClipVertex}.
|
||||
*/
|
||||
struct InterpolatedVertex {
|
||||
/**
|
||||
* @brief The index of the first vertex to interpolate between.
|
||||
*/
|
||||
int first;
|
||||
|
||||
/**
|
||||
* @brief The index of the second vertex to interpolate between.
|
||||
*/
|
||||
int second;
|
||||
|
||||
/**
|
||||
* @brief The fraction of the distance from {@link first} to {@link second} at
|
||||
* which to interpolate.
|
||||
*/
|
||||
double t;
|
||||
|
||||
/**
|
||||
* @brief Compares this \ref InterpolatedVertex against another.
|
||||
*
|
||||
* Two \ref InterpolatedVertex instances are considered equivalent if their
|
||||
* \ref first and \ref second fields are equivalent and the difference between
|
||||
* their \ref t fields is less than `std::numeric_limits<double>::epsilon()`.
|
||||
*/
|
||||
constexpr bool operator==(const InterpolatedVertex& other) const noexcept {
|
||||
return this->first == other.first && this->second == other.second &&
|
||||
std::fabs(this->t - other.t) <=
|
||||
std::numeric_limits<double>::epsilon();
|
||||
}
|
||||
|
||||
/** @brief The inverse of \ref InterpolatedVertex::operator== */
|
||||
constexpr bool operator!=(const InterpolatedVertex& other) const noexcept {
|
||||
return !(*this == other);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A vertex resulting from clipping a triangle against a threshold.
|
||||
*
|
||||
* It may either be a simple index referring to an existing vertex,
|
||||
* or an interpolation between two vertices.
|
||||
*/
|
||||
using TriangleClipVertex = std::variant<int, InterpolatedVertex>;
|
||||
|
||||
/**
|
||||
* @brief Splits a 2D triangle at given axis-aligned threshold value and returns
|
||||
* the resulting polygon on a given side of the threshold.
|
||||
*
|
||||
* The resulting polygon may have 0, 1, 2, 3, or 4 vertices.
|
||||
*
|
||||
* @param threshold The threshold coordinate value at which to clip the
|
||||
* triangle.
|
||||
* @param keepAbove true to keep the portion of the triangle above the
|
||||
* threshold, or false to keep the portion below.
|
||||
* @param i0 The index of the first vertex in the triangle in counter-clockwise
|
||||
* order, used only to construct the TriangleClipVertex result.
|
||||
* @param i1 The index of the second vertex in the triangle in counter-clockwise
|
||||
* order, used only to construct the TriangleClipVertex result.
|
||||
* @param i2 The index of the third vertex in the triangle in counter-clockwise
|
||||
* order, used only to construct the TriangleClipVertex result.
|
||||
* @param u0 The coordinate of the first vertex in the triangle, in
|
||||
* counter-clockwise order.
|
||||
* @param u1 The coordinate of the second vertex in the triangle, in
|
||||
* counter-clockwise order.
|
||||
* @param u2 The coordinate of the third vertex in the triangle, in
|
||||
* counter-clockwise order.
|
||||
* @param result On return, contains the polygon that results after the clip,
|
||||
* specified as a list of vertices. If this vector already contains elements,
|
||||
* the result is pushed onto the end of the vector.
|
||||
*
|
||||
* ```
|
||||
* TODO port this CesiumJS example to cesium-native
|
||||
* var result = Cesium.Intersections2D.clipTriangleAtAxisAlignedThreshold(0.5,
|
||||
* false, 0.2, 0.6, 0.4);
|
||||
* // result === [2, 0, -1, 1, 0, 0.25, -1, 1, 2, 0.5]
|
||||
* ```
|
||||
*/
|
||||
void clipTriangleAtAxisAlignedThreshold(
|
||||
double threshold,
|
||||
bool keepAbove,
|
||||
int i0,
|
||||
int i1,
|
||||
int i2,
|
||||
double u0,
|
||||
double u1,
|
||||
double u2,
|
||||
std::vector<TriangleClipVertex>& result) noexcept;
|
||||
} // namespace CesiumGeometry
|
||||
Reference in New Issue
Block a user