初始提交: UE5.3项目基础框架

This commit is contained in:
2025-10-14 11:14:54 +08:00
commit 721d9fd98e
5334 changed files with 316782 additions and 0 deletions

View File

@ -0,0 +1,56 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <CesiumQuantizedMeshTerrain/Library.h>
#include <CesiumUtility/ExtensibleObject.h>
#include <cstdint>
namespace CesiumQuantizedMeshTerrain {
/**
* @brief A rectangle of tile availability.
*/
struct CESIUMQUANTIZEDMESHTERRAIN_API AvailabilityRectangle final
: public CesiumUtility::ExtensibleObject {
/**
* @brief The original name of this type.
*/
static constexpr const char* TypeName = "AvailabilityRectangle";
/**
* @brief The index of the start tile in the X direction.
*/
int64_t startX = int64_t();
/**
* @brief The index of the start tile in the Y direction.
*/
int64_t startY = int64_t();
/**
* @brief The index of the end tile in the X direction.
*/
int64_t endX = int64_t();
/**
* @brief The index of the end tile in the Y direction.
*/
int64_t endY = int64_t();
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += int64_t(sizeof(AvailabilityRectangle));
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
int64_t(sizeof(CesiumUtility::ExtensibleObject));
return accum;
}
};
} // namespace CesiumQuantizedMeshTerrain

View File

@ -0,0 +1,77 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <CesiumJsonReader/JsonReader.h>
#include <CesiumJsonReader/JsonReaderOptions.h>
#include <CesiumQuantizedMeshTerrain/AvailabilityRectangle.h>
#include <CesiumQuantizedMeshTerrain/Library.h>
#include <rapidjson/fwd.h>
#include <span>
#include <vector>
namespace CesiumQuantizedMeshTerrain {
struct AvailabilityRectangle;
} // namespace CesiumQuantizedMeshTerrain
namespace CesiumQuantizedMeshTerrain {
/**
* @brief Reads \ref CesiumQuantizedMeshTerrain::AvailabilityRectangle
* "AvailabilityRectangle" instances from JSON.
*/
class CESIUMQUANTIZEDMESHTERRAIN_API AvailabilityRectangleReader {
public:
/**
* @brief Constructs a new instance.
*/
AvailabilityRectangleReader();
/**
* @brief Gets the options controlling how the JSON is read.
*/
CesiumJsonReader::JsonReaderOptions& getOptions();
/**
* @brief Gets the options controlling how the JSON is read.
*/
const CesiumJsonReader::JsonReaderOptions& getOptions() const;
/**
* @brief Reads an instance of AvailabilityRectangle from a byte buffer.
*
* @param data The buffer from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<
CesiumQuantizedMeshTerrain::AvailabilityRectangle>
readFromJson(const std::span<const std::byte>& data) const;
/**
* @brief Reads an instance of AvailabilityRectangle from a rapidJson::Value.
*
* @param value The value from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<
CesiumQuantizedMeshTerrain::AvailabilityRectangle>
readFromJson(const rapidjson::Value& value) const;
/**
* @brief Reads an array of instances of AvailabilityRectangle from a
* rapidJson::Value.
*
* @param value The value from which to read the array of instances.
* @return The result of reading the array of instances.
*/
CesiumJsonReader::ReadJsonResult<
std::vector<CesiumQuantizedMeshTerrain::AvailabilityRectangle>>
readArrayFromJson(const rapidjson::Value& value) const;
private:
CesiumJsonReader::JsonReaderOptions _options;
};
} // namespace CesiumQuantizedMeshTerrain

View File

@ -0,0 +1,53 @@
#pragma once
#include "Library.h"
#include <CesiumGeometry/QuadtreeTilingScheme.h>
#include <CesiumGeospatial/BoundingRegion.h>
#include <CesiumGeospatial/Projection.h>
#include <CesiumQuantizedMeshTerrain/LayerSpec.h>
#include <optional>
namespace CesiumQuantizedMeshTerrain {
/**
* @brief A quantized-mesh terrain layer.json.
*/
struct Layer : public LayerSpec {
/**
* @brief Gets the projection specified by this layer.json.
*
* @return The projection, or std::nullopt if this layer.json does not specify
* a valid projection.
*/
std::optional<CesiumGeospatial::Projection>
getProjection(const CesiumGeospatial::Ellipsoid& ellipsoid
CESIUM_DEFAULT_ELLIPSOID) const noexcept;
/**
* @brief Gets the tiling scheme specified by this layer.json.
*
* @return The tiling scheme, or std::nullopt if this layer.json does not
* specify a tiling scheme.
*/
std::optional<CesiumGeometry::QuadtreeTilingScheme>
getTilingScheme(const CesiumGeospatial::Ellipsoid& ellipsoid
CESIUM_DEFAULT_ELLIPSOID) const noexcept;
/**
* @brief Gets the bounding region for the root tile.
*
* The rectangle will be the maximum rectangle for the terrain's projection
* (geographic or web mercator). The heights will range from -1000.0 to
* 9000.0.
*
* @return The bounding rectangle, or std::nullopt if the bounding region
* cannot be determined from this layer.json.
*/
std::optional<CesiumGeospatial::BoundingRegion>
getRootBoundingRegion(const CesiumGeospatial::Ellipsoid& ellipsoid
CESIUM_DEFAULT_ELLIPSOID) const noexcept;
};
} // namespace CesiumQuantizedMeshTerrain

View File

@ -0,0 +1,74 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <CesiumJsonReader/JsonReader.h>
#include <CesiumJsonReader/JsonReaderOptions.h>
#include <CesiumQuantizedMeshTerrain/Layer.h>
#include <CesiumQuantizedMeshTerrain/Library.h>
#include <rapidjson/fwd.h>
#include <span>
#include <vector>
namespace CesiumQuantizedMeshTerrain {
struct Layer;
} // namespace CesiumQuantizedMeshTerrain
namespace CesiumQuantizedMeshTerrain {
/**
* @brief Reads \ref CesiumQuantizedMeshTerrain::Layer "Layer" instances from
* JSON.
*/
class CESIUMQUANTIZEDMESHTERRAIN_API LayerReader {
public:
/**
* @brief Constructs a new instance.
*/
LayerReader();
/**
* @brief Gets the options controlling how the JSON is read.
*/
CesiumJsonReader::JsonReaderOptions& getOptions();
/**
* @brief Gets the options controlling how the JSON is read.
*/
const CesiumJsonReader::JsonReaderOptions& getOptions() const;
/**
* @brief Reads an instance of Layer from a byte buffer.
*
* @param data The buffer from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<CesiumQuantizedMeshTerrain::Layer>
readFromJson(const std::span<const std::byte>& data) const;
/**
* @brief Reads an instance of Layer from a rapidJson::Value.
*
* @param value The value from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<CesiumQuantizedMeshTerrain::Layer>
readFromJson(const rapidjson::Value& value) const;
/**
* @brief Reads an array of instances of Layer from a rapidJson::Value.
*
* @param value The value from which to read the array of instances.
* @return The result of reading the array of instances.
*/
CesiumJsonReader::ReadJsonResult<
std::vector<CesiumQuantizedMeshTerrain::Layer>>
readArrayFromJson(const rapidjson::Value& value) const;
private:
CesiumJsonReader::JsonReaderOptions _options;
};
} // namespace CesiumQuantizedMeshTerrain

View File

@ -0,0 +1,156 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <CesiumQuantizedMeshTerrain/AvailabilityRectangle.h>
#include <CesiumQuantizedMeshTerrain/Library.h>
#include <CesiumUtility/ExtensibleObject.h>
#include <cstdint>
#include <optional>
#include <string>
#include <vector>
namespace CesiumQuantizedMeshTerrain {
/**
* @brief A quantized-mesh terrain layer.json.
*/
struct CESIUMQUANTIZEDMESHTERRAIN_API LayerSpec
: public CesiumUtility::ExtensibleObject {
/**
* @brief The original name of this type.
*/
static constexpr const char* TypeName = "Layer";
/**
* @brief The attribution (credit) string for the terrain.
*/
std::string attribution;
/**
* @brief The tile availability information. The outer array is indexed by
* tile level. The inner array is a list of rectangles of availability at that
* level. Tiles themselves may also contain further availability information
* for their subtree.
*/
std::vector<std::vector<CesiumQuantizedMeshTerrain::AvailabilityRectangle>>
available;
/**
* @brief The bounding box of the terrain, expressed as west, south, east,
* north in degrees.
*/
std::vector<double> bounds = {-180, -90, 180, 90};
/**
* @brief The description of this terrain tileset.
*/
std::string description;
/**
* @brief The extensions available for this tileset.
*/
std::vector<std::string> extensionsProperty;
/**
* @brief The format of the terrain tiles. Should be `"quantized-mesh-1.0"`.
*/
std::string format = "quantized-mesh-1.0";
/**
* @brief The maximum level for which there are any available tiles.
*/
int64_t maxzoom = int64_t();
/**
* @brief The minimum level for which there are any available tiles.
*/
int64_t minzoom = 0;
/**
* @brief The levels at metadata is found in tiles. For example, if this value
* is 10, then metadata is found at levels 0, 10, 20, etc.
*/
std::optional<int64_t> metadataAvailability;
/**
* @brief The name of this terrain tileset.
*/
std::string name = "Terrain";
/**
* @brief The URL of the parent layer.json that this one is layered on top of.
*/
std::optional<std::string> parentUrl;
/**
* @brief The map projection of this tileset. Valid values are `"EPSG:4326"`
* and `"EPSG:3857"`.
*/
std::string projection = "EPSG:4326";
/**
* @brief The tiling scheme. The only valid value is `"tms"`.
*/
std::string scheme = "tms";
/**
* @brief The URL templates from which to obtain tiles.
*/
std::vector<std::string> tiles;
/**
* @brief The version of this tileset.
*/
std::string version = "1.0.0";
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += int64_t(sizeof(LayerSpec));
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
int64_t(sizeof(CesiumUtility::ExtensibleObject));
accum += int64_t(this->attribution.capacity() * sizeof(char));
accum += int64_t(
sizeof(std::vector<CesiumQuantizedMeshTerrain::AvailabilityRectangle>) *
this->available.capacity());
for (const std::vector<CesiumQuantizedMeshTerrain::AvailabilityRectangle>&
valueOuter : this->available) {
accum += int64_t(
sizeof(CesiumQuantizedMeshTerrain::AvailabilityRectangle) *
valueOuter.capacity());
for (const CesiumQuantizedMeshTerrain::AvailabilityRectangle& value :
valueOuter) {
accum +=
value.getSizeBytes() -
int64_t(sizeof(CesiumQuantizedMeshTerrain::AvailabilityRectangle));
}
}
accum += int64_t(sizeof(double) * this->bounds.capacity());
accum += int64_t(this->description.capacity() * sizeof(char));
accum += int64_t(sizeof(std::string) * this->extensionsProperty.capacity());
accum += int64_t(this->format.capacity() * sizeof(char));
accum += int64_t(this->name.capacity() * sizeof(char));
if (this->parentUrl) {
accum += int64_t(this->parentUrl->capacity() * sizeof(char));
}
accum += int64_t(this->projection.capacity() * sizeof(char));
accum += int64_t(this->scheme.capacity() * sizeof(char));
accum += int64_t(sizeof(std::string) * this->tiles.capacity());
accum += int64_t(this->version.capacity() * sizeof(char));
return accum;
}
protected:
/**
* @brief This class is not meant to be instantiated directly. Use {@link Layer} instead.
*/
LayerSpec() = default;
friend struct Layer;
};
} // namespace CesiumQuantizedMeshTerrain

View File

@ -0,0 +1,83 @@
#pragma once
#include "CesiumQuantizedMeshTerrain/Library.h"
#include <CesiumJsonWriter/ExtensionWriterContext.h>
#include <span>
// forward declarations
namespace CesiumQuantizedMeshTerrain {
struct Layer;
}
namespace CesiumQuantizedMeshTerrain {
/**
* @brief The result of writing a layer.json with {@link LayerWriter::write}.
*/
struct CESIUMQUANTIZEDMESHTERRAIN_API LayerWriterResult {
/**
* @brief The final generated std::vector<std::byte> of the layer.json.
*/
std::vector<std::byte> bytes;
/**
* @brief Errors, if any, that occurred during the write process.
*/
std::vector<std::string> errors;
/**
* @brief Warnings, if any, that occurred during the write process.
*/
std::vector<std::string> warnings;
};
/**
* @brief Options for how to write a layer.json.
*/
struct CESIUMQUANTIZEDMESHTERRAIN_API LayerWriterOptions {
/**
* @brief If the layer.json should be pretty printed.
*/
bool prettyPrint = false;
};
/**
* @brief Writes layer.json.
*/
class CESIUMQUANTIZEDMESHTERRAIN_API LayerWriter {
public:
/**
* @brief Constructs a new instance.
*/
LayerWriter();
/**
* @brief Gets the context used to control how layer.json extensions are
* written.
*/
CesiumJsonWriter::ExtensionWriterContext& getExtensions();
/**
* @brief Gets the context used to control how layer.json extensions are
* written.
*/
const CesiumJsonWriter::ExtensionWriterContext& getExtensions() const;
/**
* @brief Serializes the provided `Layer` into a layer.json byte vector.
*
* @param layer The layer.
* @param options Options for how to write the layer.json.
* @return The result of writing the layer.json.
*/
LayerWriterResult write(
const CesiumQuantizedMeshTerrain::Layer& layer,
const LayerWriterOptions& options = LayerWriterOptions()) const;
private:
CesiumJsonWriter::ExtensionWriterContext _context;
};
} // namespace CesiumQuantizedMeshTerrain

View File

@ -0,0 +1,19 @@
#pragma once
/**
* @brief Classes for accessing terrain based on layer.json and
* quantized-mesh-1.0.
*
* @mermaid-interactive{dependencies/CesiumQuantizedMeshTerrain}
*/
namespace CesiumQuantizedMeshTerrain {}
#if defined(_WIN32) && defined(CESIUM_SHARED)
#ifdef CESIUMQUANTIZEDMESHTERRAIN_BUILDING
#define CESIUMQUANTIZEDMESHTERRAIN_API __declspec(dllexport)
#else
#define CESIUMQUANTIZEDMESHTERRAIN_API __declspec(dllimport)
#endif
#else
#define CESIUMQUANTIZEDMESHTERRAIN_API
#endif

View File

@ -0,0 +1,140 @@
#pragma once
#include "Library.h"
#include <CesiumGeometry/QuadtreeTileID.h>
#include <CesiumGeometry/QuadtreeTileRectangularRange.h>
#include <CesiumGeospatial/BoundingRegion.h>
#include <CesiumGeospatial/Ellipsoid.h>
#include <CesiumGltf/Model.h>
#include <CesiumUtility/ErrorList.h>
#include <rapidjson/document.h>
#include <cstddef>
#include <memory>
#include <optional>
#include <span>
#include <vector>
namespace CesiumAsync {
class IAssetRequest;
}
namespace CesiumQuantizedMeshTerrain {
/**
* @brief The results of a \ref QuantizedMeshLoader::load operation, containing
* either the loaded model, an improved bounding region for the tile, and
* available quadtree tiles discovered, if the load succeeded - or the request
* made and the errors that were returned, if the load failed.
*/
struct QuantizedMeshLoadResult {
/**
* @brief The glTF model to be rendered for this tile.
*
* If this is `std::nullopt`, the tile cannot be rendered.
* If it has a value but the model is blank, the tile can
* be "rendered", but it is rendered as nothing.
*/
std::optional<CesiumGltf::Model> model;
/**
* @brief An improved bounding region for this tile.
*
* If this is available, then it is more accurate than the one the tile used
* originally.
*/
std::optional<CesiumGeospatial::BoundingRegion> updatedBoundingVolume{};
/**
* @brief Available quadtree tiles discovered as a result of loading this
* tile.
*/
std::vector<CesiumGeometry::QuadtreeTileRectangularRange>
availableTileRectangles{};
/**
* @brief The request that was used to download the tile content, if any.
*
* This field is only populated when there are request-related errors.
*/
std::shared_ptr<CesiumAsync::IAssetRequest> pRequest;
/**
* @brief The errors and warnings reported while loading this tile.
*/
CesiumUtility::ErrorList errors;
};
/**
* @brief The metadata of a Quantized Mesh tile, returned by \ref
* QuantizedMeshLoader::loadMetadata.
*/
struct QuantizedMeshMetadataResult {
/**
* @brief Information about the availability of child tiles.
*/
std::vector<CesiumGeometry::QuadtreeTileRectangularRange> availability;
/**
* @brief The errors and warnings reported while loading this tile, if any.
*/
CesiumUtility::ErrorList errors;
};
/**
* @brief Loads `quantized-mesh-1.0` terrain data.
*/
class CESIUMQUANTIZEDMESHTERRAIN_API QuantizedMeshLoader final {
public:
/**
* @brief Create a {@link QuantizedMeshLoadResult} from the given data.
*
* @param tileID The tile ID.
* @param tileBoundingVolume The tile bounding volume.
* @param url The URL from which the data was loaded.
* @param data The actual tile data.
* @param enableWaterMask If true, will attempt to load a water mask from the
* quantized mesh data.
* @param ellipsoid The ellipsoid to use for this quantized mesh.
* @return The {@link QuantizedMeshLoadResult}
*/
static QuantizedMeshLoadResult load(
const CesiumGeometry::QuadtreeTileID& tileID,
const CesiumGeospatial::BoundingRegion& tileBoundingVolume,
const std::string& url,
const std::span<const std::byte>& data,
bool enableWaterMask,
const CesiumGeospatial::Ellipsoid& ellipsoid CESIUM_DEFAULT_ELLIPSOID);
/**
* @brief Parses the metadata (tile availability) from the given
* quantized-mesh terrain tile data.
*
* @param data The actual tile data.
* @param tileID The tile ID.
* @return The parsed metadata.
*/
static QuantizedMeshMetadataResult loadMetadata(
const std::span<const std::byte>& data,
const CesiumGeometry::QuadtreeTileID& tileID);
/**
* @brief Extracts tile availability information from a parsed layer.json
* or tile metadata extension.
*
* The actual availability information will be found in a property called
* `available`.
*
* @param layerJson The RapidJSON document containing the layer.json.
* @param startingLevel The first tile level number to which the availability
* information applies.
* @return The availability.
*/
static QuantizedMeshMetadataResult loadAvailabilityRectangles(
const rapidjson::Document& layerJson,
uint32_t startingLevel);
};
} // namespace CesiumQuantizedMeshTerrain