Merge pull request #431 from CesiumGS/ue5

Tweaks to cesium-native to improve compatibility with Unreal Engine 5
This commit is contained in:
Nithin Pranesh 2022-02-28 15:29:36 -05:00 committed by GitHub
commit faa92496f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
60 changed files with 493 additions and 474 deletions

View File

@ -27,6 +27,7 @@
- `Token` in `CesiumIonClient` has been updated to match Cesium ion's v2 REST API endpoint, so several fields have been renamed. The `tokens` method also now returns future that resolves to a `TokenList` instead of a plain vector of `Token` instances.
- Renamed `GltfReader::readModel`, `ModelReaderResult`, and `ReadModelOptions` to `GltfReader::readGltf`, `GltfReaderResult`, and `GltfReaderOptions` respectively.
- Removed `writeModelAsEmbeddedBytes`, `writeModelAndExternalFiles`, `WriteModelResult`, `WriteModelOptions`, and `WriteGLTFCallback`. Use `GltfWriter::writeGltf`, `GltfWriter::writeGlb`, `GltfWriterResult`, and `GltfWriterOptions` instead.
- Renamed constants in `CesiumUtility::Math` to use PascalCase instead of SCREAMING_SNAKE_CASE.
##### Additions :tada:

View File

@ -302,14 +302,14 @@ public:
/**
* @brief Gets the tile's geometric error as if by calling
* {@link getGeometricError}, except that if the error is smaller than
* {@link Math::EPSILON5} the returned geometric error is instead computed as
* {@link Math::Epsilon5} the returned geometric error is instead computed as
* half of the parent tile's (non-zero) geometric error.
*
* This is useful for determining when to refine what would ordinarily be a
* leaf tile, for example to attach more detailed raster overlays to it.
*
* If this tile and all of its ancestors have a geometric error less than
* {@link Math::EPSILON5}, returns {@link Math::EPSILON5}.
* {@link Math::Epsilon5}, returns {@link Math::Epsilon5}.
*
* @return The non-zero geometric error.
*/

View File

@ -309,15 +309,15 @@ GltfContent::createRasterOverlayTextureCoordinates(
// gets us closer.
if (glm::abs(
glm::abs(cartographic.value().longitude) -
CesiumUtility::Math::ONE_PI) <
CesiumUtility::Math::EPSILON5 &&
CesiumUtility::Math::OnePi) <
CesiumUtility::Math::Epsilon5 &&
(projectedPosition.x < rectangle.minimumX ||
projectedPosition.x > rectangle.maximumX ||
projectedPosition.y < rectangle.minimumY ||
projectedPosition.y > rectangle.maximumY)) {
const double testLongitude = longitude + longitude < 0.0
? CesiumUtility::Math::TWO_PI
: -CesiumUtility::Math::TWO_PI;
? CesiumUtility::Math::TwoPi
: -CesiumUtility::Math::TwoPi;
const glm::dvec3 projectedPosition2 = projectPosition(
projection,
Cartographic(testLongitude, latitude, ellipsoidHeight));

View File

@ -676,7 +676,7 @@ static std::vector<std::byte> generateNormals(
for (size_t i = 0; i < normals.size(); i += 3) {
glm::vec3 normal(normals[i], normals[i + 1], normals[i + 2]);
if (!Math::equalsEpsilon(glm::dot(normal, normal), 0.0, Math::EPSILON7)) {
if (!Math::equalsEpsilon(glm::dot(normal, normal), 0.0, Math::Epsilon7)) {
normal = glm::normalize(normal);
normals[i] = normal.x;
normals[i + 1] = normal.y;

View File

@ -27,7 +27,7 @@ void rasterizePolygons(
CesiumGltf::ImageCesium& image = loaded.image.emplace();
// create a 1x1 mask if the rectangle is completely inside a polygon
if (Cesium3DTilesSelection::Impl::withinPolygons(
if (Cesium3DTilesSelection::CesiumImpl::withinPolygons(
rectangle,
cartographicPolygons)) {
loaded.moreDetailAvailable = false;

View File

@ -12,7 +12,7 @@ RasterizedPolygonsTileExcluder::RasterizedPolygonsTileExcluder(
bool RasterizedPolygonsTileExcluder::shouldExclude(
const Tile& tile) const noexcept {
return Cesium3DTilesSelection::Impl::withinPolygons(
return Cesium3DTilesSelection::CesiumImpl::withinPolygons(
tile.getBoundingVolume(),
this->_pOverlay->getPolygons());
}

View File

@ -104,7 +104,7 @@ void Tile::createChildTiles(std::vector<Tile>&& children) {
double Tile::getNonZeroGeometricError() const noexcept {
double geometricError = this->getGeometricError();
if (geometricError > Math::EPSILON5) {
if (geometricError > Math::Epsilon5) {
// Tile's geometric error is good.
return geometricError;
}
@ -116,7 +116,7 @@ double Tile::getNonZeroGeometricError() const noexcept {
if (!pParent->getUnconditionallyRefine()) {
divisor *= 2.0;
double ancestorError = pParent->getGeometricError();
if (ancestorError > Math::EPSILON5) {
if (ancestorError > Math::Epsilon5) {
return ancestorError / divisor;
}
}
@ -127,7 +127,7 @@ double Tile::getNonZeroGeometricError() const noexcept {
// No sensible geometric error all the way to the root of the tile tree.
// So just use a tiny geometric error and raster selection will be limited by
// quadtree tile count or texture resolution size.
return Math::EPSILON5;
return Math::Epsilon5;
}
void Tile::setTileID(const TileID& id) noexcept { this->_id = id; }

View File

@ -9,7 +9,7 @@
using namespace CesiumGeospatial;
namespace Cesium3DTilesSelection {
namespace Impl {
namespace CesiumImpl {
bool withinPolygons(
const BoundingVolume& boundingVolume,
@ -132,6 +132,6 @@ bool withinPolygons(
return false;
}
} // namespace Impl
} // namespace CesiumImpl
} // namespace Cesium3DTilesSelection

View File

@ -8,7 +8,7 @@
#include <vector>
namespace Cesium3DTilesSelection {
namespace Impl {
namespace CesiumImpl {
/**
* @brief Returns whether the tile is completely inside a polygon.
@ -33,5 +33,5 @@ bool withinPolygons(
const CesiumGeospatial::GlobeRectangle& rectangle,
const std::vector<CesiumGeospatial::CartographicPolygon>&
cartographicPolygons) noexcept;
} // namespace Impl
} // namespace CesiumImpl
} // namespace Cesium3DTilesSelection

View File

@ -1325,7 +1325,7 @@ static bool anyRasterOverlaysNeedLoading(const Tile& tile) noexcept {
glm::dvec3 tileDirection = boundingVolumeCenter - frustum.getPosition();
const double magnitude = glm::length(tileDirection);
if (magnitude >= CesiumUtility::Math::EPSILON5) {
if (magnitude >= CesiumUtility::Math::Epsilon5) {
tileDirection /= magnitude;
const double loadPriority =
(1.0 - glm::dot(tileDirection, frustum.getDirection())) * distance;

View File

@ -870,21 +870,21 @@ static void addEdge(
if (CesiumUtility::Math::equalsEpsilon(
uv.x,
0.0,
CesiumUtility::Math::EPSILON4)) {
CesiumUtility::Math::Epsilon4)) {
edgeIndices.west.emplace_back(EdgeVertex{clipVertexToIndices[i], uv});
}
if (CesiumUtility::Math::equalsEpsilon(
uv.x,
1.0,
CesiumUtility::Math::EPSILON4)) {
CesiumUtility::Math::Epsilon4)) {
edgeIndices.east.emplace_back(EdgeVertex{clipVertexToIndices[i], uv});
}
if (CesiumUtility::Math::equalsEpsilon(
uv.x,
thresholdU,
CesiumUtility::Math::EPSILON4)) {
CesiumUtility::Math::Epsilon4)) {
if (keepAboveU) {
edgeIndices.west.emplace_back(EdgeVertex{clipVertexToIndices[i], uv});
} else {
@ -895,21 +895,21 @@ static void addEdge(
if (CesiumUtility::Math::equalsEpsilon(
uv.y,
0.0,
CesiumUtility::Math::EPSILON4)) {
CesiumUtility::Math::Epsilon4)) {
edgeIndices.south.emplace_back(EdgeVertex{clipVertexToIndices[i], uv});
}
if (CesiumUtility::Math::equalsEpsilon(
uv.y,
1.0,
CesiumUtility::Math::EPSILON4)) {
CesiumUtility::Math::Epsilon4)) {
edgeIndices.north.emplace_back(EdgeVertex{clipVertexToIndices[i], uv});
}
if (CesiumUtility::Math::equalsEpsilon(
uv.y,
thresholdV,
CesiumUtility::Math::EPSILON4)) {
CesiumUtility::Math::Epsilon4)) {
if (keepAboveV) {
edgeIndices.south.emplace_back(EdgeVertex{clipVertexToIndices[i], uv});
} else {

View File

@ -95,7 +95,7 @@ static double calculateSkirtHeight(
static const double terrainHeightmapQuality = 0.25;
static const uint32_t heightmapWidth = 65;
double levelZeroMaximumGeometricError =
ellipsoid.getMaximumRadius() * CesiumUtility::Math::TWO_PI *
ellipsoid.getMaximumRadius() * CesiumUtility::Math::TwoPi *
terrainHeightmapQuality / (heightmapWidth * tilingScheme.getRootTilesX());
double levelMaximumGeometricError =
@ -409,11 +409,11 @@ void checkGridMesh(
REQUIRE(Math::equalsEpsilon(
uRatio,
static_cast<double>(x) / static_cast<double>(verticesWidth - 1),
Math::EPSILON4));
Math::Epsilon4));
REQUIRE(Math::equalsEpsilon(
vRatio,
static_cast<double>(y) / static_cast<double>(verticesHeight - 1),
Math::EPSILON4));
Math::Epsilon4));
// check grid positions
double longitude = Math::lerp(west, east, uRatio);
@ -428,11 +428,11 @@ void checkGridMesh(
quantizedMesh.header.boundingSphereCenterZ);
REQUIRE(
Math::equalsEpsilon(position.x, expectPosition.x, Math::EPSILON3));
Math::equalsEpsilon(position.x, expectPosition.x, Math::Epsilon3));
REQUIRE(
Math::equalsEpsilon(position.y, expectPosition.y, Math::EPSILON3));
Math::equalsEpsilon(position.y, expectPosition.y, Math::Epsilon3));
REQUIRE(
Math::equalsEpsilon(position.z, expectPosition.z, Math::EPSILON3));
Math::equalsEpsilon(position.z, expectPosition.z, Math::Epsilon3));
++positionIdx;
// check indices
@ -494,9 +494,9 @@ void checkGridMesh(
quantizedMesh.header.boundingSphereCenterX,
quantizedMesh.header.boundingSphereCenterY,
quantizedMesh.header.boundingSphereCenterZ);
REQUIRE(Math::equalsEpsilon(position.x, expectPosition.x, Math::EPSILON3));
REQUIRE(Math::equalsEpsilon(position.y, expectPosition.y, Math::EPSILON3));
REQUIRE(Math::equalsEpsilon(position.z, expectPosition.z, Math::EPSILON3));
REQUIRE(Math::equalsEpsilon(position.x, expectPosition.x, Math::Epsilon3));
REQUIRE(Math::equalsEpsilon(position.y, expectPosition.y, Math::Epsilon3));
REQUIRE(Math::equalsEpsilon(position.z, expectPosition.z, Math::Epsilon3));
}
currentVertexCount += westIndicesCount;
@ -514,9 +514,9 @@ void checkGridMesh(
quantizedMesh.header.boundingSphereCenterX,
quantizedMesh.header.boundingSphereCenterY,
quantizedMesh.header.boundingSphereCenterZ);
REQUIRE(Math::equalsEpsilon(position.x, expectPosition.x, Math::EPSILON3));
REQUIRE(Math::equalsEpsilon(position.y, expectPosition.y, Math::EPSILON3));
REQUIRE(Math::equalsEpsilon(position.z, expectPosition.z, Math::EPSILON3));
REQUIRE(Math::equalsEpsilon(position.x, expectPosition.x, Math::Epsilon3));
REQUIRE(Math::equalsEpsilon(position.y, expectPosition.y, Math::Epsilon3));
REQUIRE(Math::equalsEpsilon(position.z, expectPosition.z, Math::Epsilon3));
}
currentVertexCount += southIndicesCount;
@ -534,9 +534,9 @@ void checkGridMesh(
quantizedMesh.header.boundingSphereCenterX,
quantizedMesh.header.boundingSphereCenterY,
quantizedMesh.header.boundingSphereCenterZ);
REQUIRE(Math::equalsEpsilon(position.x, expectPosition.x, Math::EPSILON3));
REQUIRE(Math::equalsEpsilon(position.y, expectPosition.y, Math::EPSILON2));
REQUIRE(Math::equalsEpsilon(position.z, expectPosition.z, Math::EPSILON3));
REQUIRE(Math::equalsEpsilon(position.x, expectPosition.x, Math::Epsilon3));
REQUIRE(Math::equalsEpsilon(position.y, expectPosition.y, Math::Epsilon2));
REQUIRE(Math::equalsEpsilon(position.z, expectPosition.z, Math::Epsilon3));
}
currentVertexCount += eastIndicesCount;
@ -553,9 +553,9 @@ void checkGridMesh(
quantizedMesh.header.boundingSphereCenterX,
quantizedMesh.header.boundingSphereCenterY,
quantizedMesh.header.boundingSphereCenterZ);
REQUIRE(Math::equalsEpsilon(position.x, expectPosition.x, Math::EPSILON3));
REQUIRE(Math::equalsEpsilon(position.y, expectPosition.y, Math::EPSILON3));
REQUIRE(Math::equalsEpsilon(position.z, expectPosition.z, Math::EPSILON3));
REQUIRE(Math::equalsEpsilon(position.x, expectPosition.x, Math::Epsilon3));
REQUIRE(Math::equalsEpsilon(position.y, expectPosition.y, Math::Epsilon3));
REQUIRE(Math::equalsEpsilon(position.z, expectPosition.z, Math::Epsilon3));
}
}
@ -592,20 +592,20 @@ static void checkGeneratedGridNormal(
if (!Math::equalsEpsilon(
glm::dot(expectedNormals[i], expectedNormals[i]),
0.0,
Math::EPSILON7)) {
Math::Epsilon7)) {
expectedNormal = glm::normalize(expectedNormals[i]);
// make sure normal points to the direction of geodetic normal for grid
// only
REQUIRE(glm::dot(normal, geodeticNormal) >= 0.0);
REQUIRE(Math::equalsEpsilon(normal.x, expectedNormal.x, Math::EPSILON7));
REQUIRE(Math::equalsEpsilon(normal.y, expectedNormal.y, Math::EPSILON7));
REQUIRE(Math::equalsEpsilon(normal.z, expectedNormal.z, Math::EPSILON7));
REQUIRE(Math::equalsEpsilon(normal.x, expectedNormal.x, Math::Epsilon7));
REQUIRE(Math::equalsEpsilon(normal.y, expectedNormal.y, Math::Epsilon7));
REQUIRE(Math::equalsEpsilon(normal.z, expectedNormal.z, Math::Epsilon7));
} else {
REQUIRE(Math::equalsEpsilon(normal.x, expectedNormal.x, Math::EPSILON7));
REQUIRE(Math::equalsEpsilon(normal.y, expectedNormal.y, Math::EPSILON7));
REQUIRE(Math::equalsEpsilon(normal.z, expectedNormal.z, Math::EPSILON7));
REQUIRE(Math::equalsEpsilon(normal.x, expectedNormal.x, Math::Epsilon7));
REQUIRE(Math::equalsEpsilon(normal.y, expectedNormal.y, Math::Epsilon7));
REQUIRE(Math::equalsEpsilon(normal.z, expectedNormal.z, Math::Epsilon7));
}
}
@ -628,9 +628,9 @@ static void checkGeneratedGridNormal(
glm::vec3 normal = normals[int64_t(currentVertexCount + i)];
glm::vec3 expectedNormal =
expectedNormals[index2DTo1D(x, y, verticesWidth)];
REQUIRE(Math::equalsEpsilon(normal.x, expectedNormal.x, Math::EPSILON7));
REQUIRE(Math::equalsEpsilon(normal.y, expectedNormal.y, Math::EPSILON7));
REQUIRE(Math::equalsEpsilon(normal.z, expectedNormal.z, Math::EPSILON7));
REQUIRE(Math::equalsEpsilon(normal.x, expectedNormal.x, Math::Epsilon7));
REQUIRE(Math::equalsEpsilon(normal.y, expectedNormal.y, Math::Epsilon7));
REQUIRE(Math::equalsEpsilon(normal.z, expectedNormal.z, Math::Epsilon7));
++y;
}
@ -642,9 +642,9 @@ static void checkGeneratedGridNormal(
glm::vec3 normal = normals[int64_t(currentVertexCount + i)];
glm::vec3 expectedNormal =
expectedNormals[index2DTo1D(x, y, verticesWidth)];
REQUIRE(Math::equalsEpsilon(normal.x, expectedNormal.x, Math::EPSILON7));
REQUIRE(Math::equalsEpsilon(normal.y, expectedNormal.y, Math::EPSILON7));
REQUIRE(Math::equalsEpsilon(normal.z, expectedNormal.z, Math::EPSILON7));
REQUIRE(Math::equalsEpsilon(normal.x, expectedNormal.x, Math::Epsilon7));
REQUIRE(Math::equalsEpsilon(normal.y, expectedNormal.y, Math::Epsilon7));
REQUIRE(Math::equalsEpsilon(normal.z, expectedNormal.z, Math::Epsilon7));
--x;
}
@ -656,9 +656,9 @@ static void checkGeneratedGridNormal(
glm::vec3 normal = normals[int64_t(currentVertexCount + i)];
glm::vec3 expectedNormal =
expectedNormals[index2DTo1D(x, y, verticesWidth)];
REQUIRE(Math::equalsEpsilon(normal.x, expectedNormal.x, Math::EPSILON7));
REQUIRE(Math::equalsEpsilon(normal.y, expectedNormal.y, Math::EPSILON7));
REQUIRE(Math::equalsEpsilon(normal.z, expectedNormal.z, Math::EPSILON7));
REQUIRE(Math::equalsEpsilon(normal.x, expectedNormal.x, Math::Epsilon7));
REQUIRE(Math::equalsEpsilon(normal.y, expectedNormal.y, Math::Epsilon7));
REQUIRE(Math::equalsEpsilon(normal.z, expectedNormal.z, Math::Epsilon7));
--y;
}
@ -670,9 +670,9 @@ static void checkGeneratedGridNormal(
glm::vec3 normal = normals[int64_t(currentVertexCount + i)];
glm::vec3 expectedNormal =
expectedNormals[index2DTo1D(x, y, verticesWidth)];
REQUIRE(Math::equalsEpsilon(normal.x, expectedNormal.x, Math::EPSILON7));
REQUIRE(Math::equalsEpsilon(normal.y, expectedNormal.y, Math::EPSILON7));
REQUIRE(Math::equalsEpsilon(normal.z, expectedNormal.z, Math::EPSILON7));
REQUIRE(Math::equalsEpsilon(normal.x, expectedNormal.x, Math::Epsilon7));
REQUIRE(Math::equalsEpsilon(normal.y, expectedNormal.y, Math::Epsilon7));
REQUIRE(Math::equalsEpsilon(normal.z, expectedNormal.z, Math::Epsilon7));
++x;
}
@ -1010,9 +1010,9 @@ TEST_CASE("Test converting quantized mesh to gltf with skirt") {
static_cast<size_t>(normals.size()) ==
(verticesWidth * verticesHeight + totalSkirtVerticesCount));
for (int64_t i = 0; i < normals.size(); ++i) {
REQUIRE(Math::equalsEpsilon(normals[i].x, normal.x, Math::EPSILON2));
REQUIRE(Math::equalsEpsilon(normals[i].y, normal.y, Math::EPSILON2));
REQUIRE(Math::equalsEpsilon(normals[i].z, normal.z, Math::EPSILON2));
REQUIRE(Math::equalsEpsilon(normals[i].x, normal.x, Math::Epsilon2));
REQUIRE(Math::equalsEpsilon(normals[i].y, normal.y, Math::Epsilon2));
REQUIRE(Math::equalsEpsilon(normals[i].z, normal.z, Math::Epsilon2));
}
}
}

View File

@ -33,43 +33,43 @@ TEST_CASE("Test converting skirt mesh metadata to gltf extras") {
REQUIRE(Math::equalsEpsilon(
(*pMeshCenter)[0].getSafeNumberOrDefault<double>(0.0),
skirtMeshMetadata.meshCenter.x,
Math::EPSILON7));
Math::Epsilon7));
REQUIRE(Math::equalsEpsilon(
(*pMeshCenter)[1].getSafeNumberOrDefault<double>(0.0),
skirtMeshMetadata.meshCenter.y,
Math::EPSILON7));
Math::Epsilon7));
REQUIRE(Math::equalsEpsilon(
(*pMeshCenter)[2].getSafeNumberOrDefault<double>(0.0),
skirtMeshMetadata.meshCenter.z,
Math::EPSILON7));
Math::Epsilon7));
const auto pSkirtWestHeight =
gltfSkirt.getSafeNumericalValueForKey<double>("skirtWestHeight");
REQUIRE(Math::equalsEpsilon(
pSkirtWestHeight,
skirtMeshMetadata.skirtWestHeight,
Math::EPSILON7));
Math::Epsilon7));
const auto pSkirtSouthHeight =
gltfSkirt.getSafeNumericalValueForKey<double>("skirtSouthHeight");
REQUIRE(Math::equalsEpsilon(
pSkirtSouthHeight,
skirtMeshMetadata.skirtSouthHeight,
Math::EPSILON7));
Math::Epsilon7));
const auto pSkirtEastHeight =
gltfSkirt.getSafeNumericalValueForKey<double>("skirtEastHeight");
REQUIRE(Math::equalsEpsilon(
pSkirtEastHeight,
skirtMeshMetadata.skirtEastHeight,
Math::EPSILON7));
Math::Epsilon7));
const auto pSkirtNorthHeight =
gltfSkirt.getSafeNumericalValueForKey<double>("skirtNorthHeight");
REQUIRE(Math::equalsEpsilon(
pSkirtNorthHeight,
skirtMeshMetadata.skirtNorthHeight,
Math::EPSILON7));
Math::Epsilon7));
}
TEST_CASE("Test converting gltf extras to skirt mesh metadata") {
@ -95,31 +95,31 @@ TEST_CASE("Test converting gltf extras to skirt mesh metadata") {
REQUIRE(Math::equalsEpsilon(
skirtMeshMetadata.meshCenter.x,
1.0,
Math::EPSILON7));
Math::Epsilon7));
REQUIRE(Math::equalsEpsilon(
skirtMeshMetadata.meshCenter.y,
2.0,
Math::EPSILON7));
Math::Epsilon7));
REQUIRE(Math::equalsEpsilon(
skirtMeshMetadata.meshCenter.z,
3.0,
Math::EPSILON7));
Math::Epsilon7));
REQUIRE(Math::equalsEpsilon(
skirtMeshMetadata.skirtWestHeight,
12.4,
Math::EPSILON7));
Math::Epsilon7));
REQUIRE(Math::equalsEpsilon(
skirtMeshMetadata.skirtSouthHeight,
10.0,
Math::EPSILON7));
Math::Epsilon7));
REQUIRE(Math::equalsEpsilon(
skirtMeshMetadata.skirtEastHeight,
2.4,
Math::EPSILON7));
Math::Epsilon7));
REQUIRE(Math::equalsEpsilon(
skirtMeshMetadata.skirtNorthHeight,
1.4,
Math::EPSILON7));
Math::Epsilon7));
}
SECTION("Gltf Extras has incorrect noSkirtRange field") {

View File

@ -31,11 +31,11 @@ static void checkSkirt(
glm::dvec3 skirtPosition =
static_cast<glm::dvec3>(skirtUpsampledPosition) + center;
REQUIRE(
Math::equalsEpsilon(expectedPosition.x, skirtPosition.x, Math::EPSILON7));
Math::equalsEpsilon(expectedPosition.x, skirtPosition.x, Math::Epsilon7));
REQUIRE(
Math::equalsEpsilon(expectedPosition.y, skirtPosition.y, Math::EPSILON7));
Math::equalsEpsilon(expectedPosition.y, skirtPosition.y, Math::Epsilon7));
REQUIRE(
Math::equalsEpsilon(expectedPosition.z, skirtPosition.z, Math::EPSILON7));
Math::equalsEpsilon(expectedPosition.z, skirtPosition.z, Math::Epsilon7));
}
TEST_CASE("Test upsample tile without skirts") {
@ -217,49 +217,49 @@ TEST_CASE("Test upsample tile without skirts") {
glm::epsilonEqual(
p0,
positions[0],
glm::vec3(static_cast<float>(Math::EPSILON7))) == glm::bvec3(true));
glm::vec3(static_cast<float>(Math::Epsilon7))) == glm::bvec3(true));
glm::vec3 p1 = upsampledPosition[1];
REQUIRE(
glm::epsilonEqual(
p1,
(positions[0] + positions[2]) * 0.5f,
glm::vec3(static_cast<float>(Math::EPSILON7))) == glm::bvec3(true));
glm::vec3(static_cast<float>(Math::Epsilon7))) == glm::bvec3(true));
glm::vec3 p2 = upsampledPosition[2];
REQUIRE(
glm::epsilonEqual(
p2,
(upsampledPosition[1] + positions[1]) * 0.5f,
glm::vec3(static_cast<float>(Math::EPSILON7))) == glm::bvec3(true));
glm::vec3(static_cast<float>(Math::Epsilon7))) == glm::bvec3(true));
glm::vec3 p3 = upsampledPosition[3];
REQUIRE(
glm::epsilonEqual(
p3,
(positions[0] + positions[1]) * 0.5f,
glm::vec3(static_cast<float>(Math::EPSILON7))) == glm::bvec3(true));
glm::vec3(static_cast<float>(Math::Epsilon7))) == glm::bvec3(true));
glm::vec3 p4 = upsampledPosition[4];
REQUIRE(
glm::epsilonEqual(
p4,
(positions[0] + positions[2]) * 0.5f,
glm::vec3(static_cast<float>(Math::EPSILON7))) == glm::bvec3(true));
glm::vec3(static_cast<float>(Math::Epsilon7))) == glm::bvec3(true));
glm::vec3 p5 = upsampledPosition[5];
REQUIRE(
glm::epsilonEqual(
p5,
(positions[1] + positions[2]) * 0.5f,
glm::vec3(static_cast<float>(Math::EPSILON7))) == glm::bvec3(true));
glm::vec3(static_cast<float>(Math::Epsilon7))) == glm::bvec3(true));
glm::vec3 p6 = upsampledPosition[6];
REQUIRE(
glm::epsilonEqual(
p6,
(upsampledPosition[4] + positions[1]) * 0.5f,
glm::vec3(static_cast<float>(Math::EPSILON7))) == glm::bvec3(true));
glm::vec3(static_cast<float>(Math::Epsilon7))) == glm::bvec3(true));
}
SECTION("Upsample upper left child") {
@ -287,49 +287,49 @@ TEST_CASE("Test upsample tile without skirts") {
glm::epsilonEqual(
p0,
positions[1],
glm::vec3(static_cast<float>(Math::EPSILON7))) == glm::bvec3(true));
glm::vec3(static_cast<float>(Math::Epsilon7))) == glm::bvec3(true));
glm::vec3 p1 = upsampledPosition[1];
REQUIRE(
glm::epsilonEqual(
p1,
(positions[0] + positions[1]) * 0.5f,
glm::vec3(static_cast<float>(Math::EPSILON7))) == glm::bvec3(true));
glm::vec3(static_cast<float>(Math::Epsilon7))) == glm::bvec3(true));
glm::vec3 p2 = upsampledPosition[2];
REQUIRE(
glm::epsilonEqual(
p2,
(positions[1] + 0.5f * (positions[0] + positions[2])) * 0.5f,
glm::vec3(static_cast<float>(Math::EPSILON7))) == glm::bvec3(true));
glm::vec3(static_cast<float>(Math::Epsilon7))) == glm::bvec3(true));
glm::vec3 p3 = upsampledPosition[3];
REQUIRE(
glm::epsilonEqual(
p3,
(positions[1] + positions[2]) * 0.5f,
glm::vec3(static_cast<float>(Math::EPSILON7))) == glm::bvec3(true));
glm::vec3(static_cast<float>(Math::Epsilon7))) == glm::bvec3(true));
glm::vec3 p4 = upsampledPosition[4];
REQUIRE(
glm::epsilonEqual(
p4,
p2,
glm::vec3(static_cast<float>(Math::EPSILON7))) == glm::bvec3(true));
glm::vec3(static_cast<float>(Math::Epsilon7))) == glm::bvec3(true));
glm::vec3 p5 = upsampledPosition[5];
REQUIRE(
glm::epsilonEqual(
p5,
(positions[1] + positions[2]) * 0.5f,
glm::vec3(static_cast<float>(Math::EPSILON7))) == glm::bvec3(true));
glm::vec3(static_cast<float>(Math::Epsilon7))) == glm::bvec3(true));
glm::vec3 p6 = upsampledPosition[6];
REQUIRE(
glm::epsilonEqual(
p6,
(positions[1] + positions[3]) * 0.5f,
glm::vec3(static_cast<float>(Math::EPSILON7))) == glm::bvec3(true));
glm::vec3(static_cast<float>(Math::Epsilon7))) == glm::bvec3(true));
}
SECTION("Upsample upper right child") {
@ -357,49 +357,49 @@ TEST_CASE("Test upsample tile without skirts") {
glm::epsilonEqual(
p0,
positions[3],
glm::vec3(static_cast<float>(Math::EPSILON7))) == glm::bvec3(true));
glm::vec3(static_cast<float>(Math::Epsilon7))) == glm::bvec3(true));
glm::vec3 p1 = upsampledPosition[1];
REQUIRE(
glm::epsilonEqual(
p1,
(positions[1] + positions[3]) * 0.5f,
glm::vec3(static_cast<float>(Math::EPSILON7))) == glm::bvec3(true));
glm::vec3(static_cast<float>(Math::Epsilon7))) == glm::bvec3(true));
glm::vec3 p2 = upsampledPosition[2];
REQUIRE(
glm::epsilonEqual(
p2,
(positions[2] + 0.5f * (positions[1] + positions[3])) * 0.5f,
glm::vec3(static_cast<float>(Math::EPSILON7))) == glm::bvec3(true));
glm::vec3(static_cast<float>(Math::Epsilon7))) == glm::bvec3(true));
glm::vec3 p3 = upsampledPosition[3];
REQUIRE(
glm::epsilonEqual(
p3,
(positions[3] + positions[2]) * 0.5f,
glm::vec3(static_cast<float>(Math::EPSILON7))) == glm::bvec3(true));
glm::vec3(static_cast<float>(Math::Epsilon7))) == glm::bvec3(true));
glm::vec3 p4 = upsampledPosition[4];
REQUIRE(
glm::epsilonEqual(
p4,
(positions[1] + positions[3]) * 0.5f,
glm::vec3(static_cast<float>(Math::EPSILON7))) == glm::bvec3(true));
glm::vec3(static_cast<float>(Math::Epsilon7))) == glm::bvec3(true));
glm::vec3 p5 = upsampledPosition[5];
REQUIRE(
glm::epsilonEqual(
p5,
(positions[1] + positions[2]) * 0.5f,
glm::vec3(static_cast<float>(Math::EPSILON7))) == glm::bvec3(true));
glm::vec3(static_cast<float>(Math::Epsilon7))) == glm::bvec3(true));
glm::vec3 p6 = upsampledPosition[6];
REQUIRE(
glm::epsilonEqual(
p6,
p2,
glm::vec3(static_cast<float>(Math::EPSILON7))) == glm::bvec3(true));
glm::vec3(static_cast<float>(Math::Epsilon7))) == glm::bvec3(true));
}
SECTION("Upsample bottom right child") {
@ -427,49 +427,49 @@ TEST_CASE("Test upsample tile without skirts") {
glm::epsilonEqual(
p0,
positions[2],
glm::vec3(static_cast<float>(Math::EPSILON7))) == glm::bvec3(true));
glm::vec3(static_cast<float>(Math::Epsilon7))) == glm::bvec3(true));
glm::vec3 p1 = upsampledPosition[1];
REQUIRE(
glm::epsilonEqual(
p1,
(positions[1] + positions[2]) * 0.5f,
glm::vec3(static_cast<float>(Math::EPSILON7))) == glm::bvec3(true));
glm::vec3(static_cast<float>(Math::Epsilon7))) == glm::bvec3(true));
glm::vec3 p2 = upsampledPosition[2];
REQUIRE(
glm::epsilonEqual(
p2,
(positions[0] + positions[2]) * 0.5f,
glm::vec3(static_cast<float>(Math::EPSILON7))) == glm::bvec3(true));
glm::vec3(static_cast<float>(Math::Epsilon7))) == glm::bvec3(true));
glm::vec3 p3 = upsampledPosition[3];
REQUIRE(
glm::epsilonEqual(
p3,
(positions[2] + positions[3]) * 0.5f,
glm::vec3(static_cast<float>(Math::EPSILON7))) == glm::bvec3(true));
glm::vec3(static_cast<float>(Math::Epsilon7))) == glm::bvec3(true));
glm::vec3 p4 = upsampledPosition[4];
REQUIRE(
glm::epsilonEqual(
p4,
(positions[2] + (positions[1] + positions[3]) * 0.5f) * 0.5f,
glm::vec3(static_cast<float>(Math::EPSILON7))) == glm::bvec3(true));
glm::vec3(static_cast<float>(Math::Epsilon7))) == glm::bvec3(true));
glm::vec3 p5 = upsampledPosition[5];
REQUIRE(
glm::epsilonEqual(
p5,
(positions[1] + positions[2]) * 0.5f,
glm::vec3(static_cast<float>(Math::EPSILON7))) == glm::bvec3(true));
glm::vec3(static_cast<float>(Math::Epsilon7))) == glm::bvec3(true));
glm::vec3 p6 = upsampledPosition[6];
REQUIRE(
glm::epsilonEqual(
p6,
p4,
glm::vec3(static_cast<float>(Math::EPSILON7))) == glm::bvec3(true));
glm::vec3(static_cast<float>(Math::Epsilon7))) == glm::bvec3(true));
}
SECTION("Check skirt") {

View File

@ -111,16 +111,19 @@ public:
* @return A future that resolves after the supplied function completes.
*/
template <typename Func>
Impl::ContinuationFutureType_t<Func, void> runInWorkerThread(Func&& f) const {
CesiumImpl::ContinuationFutureType_t<Func, void>
runInWorkerThread(Func&& f) const {
static const char* tracingName = "waiting for worker thread";
CESIUM_TRACE_BEGIN_IN_TRACK(tracingName);
return Impl::ContinuationFutureType_t<Func, void>(
return CesiumImpl::ContinuationFutureType_t<Func, void>(
this->_pSchedulers,
async::spawn(
this->_pSchedulers->workerThread.immediate,
Impl::WithTracing<void>::end(tracingName, std::forward<Func>(f))));
CesiumImpl::WithTracing<void>::end(
tracingName,
std::forward<Func>(f))));
}
/**
@ -138,16 +141,19 @@ public:
* @return A future that resolves after the supplied function completes.
*/
template <typename Func>
Impl::ContinuationFutureType_t<Func, void> runInMainThread(Func&& f) const {
CesiumImpl::ContinuationFutureType_t<Func, void>
runInMainThread(Func&& f) const {
static const char* tracingName = "waiting for main thread";
CESIUM_TRACE_BEGIN_IN_TRACK(tracingName);
return Impl::ContinuationFutureType_t<Func, void>(
return CesiumImpl::ContinuationFutureType_t<Func, void>(
this->_pSchedulers,
async::spawn(
this->_pSchedulers->mainThread.immediate,
Impl::WithTracing<void>::end(tracingName, std::forward<Func>(f))));
CesiumImpl::WithTracing<void>::end(
tracingName,
std::forward<Func>(f))));
}
/**
@ -160,17 +166,19 @@ public:
* @return A future that resolves after the supplied function completes.
*/
template <typename Func>
Impl::ContinuationFutureType_t<Func, void>
CesiumImpl::ContinuationFutureType_t<Func, void>
runInThreadPool(const ThreadPool& threadPool, Func&& f) const {
static const char* tracingName = "waiting for thread pool";
CESIUM_TRACE_BEGIN_IN_TRACK(tracingName);
return Impl::ContinuationFutureType_t<Func, void>(
return CesiumImpl::ContinuationFutureType_t<Func, void>(
this->_pSchedulers,
async::spawn(
threadPool._pScheduler->immediate,
Impl::WithTracing<void>::end(tracingName, std::forward<Func>(f))));
CesiumImpl::WithTracing<void>::end(
tracingName,
std::forward<Func>(f))));
}
/**
@ -300,7 +308,7 @@ private:
return Future<std::vector<T>>(this->_pSchedulers, std::move(task));
}
std::shared_ptr<Impl::AsyncSystemSchedulers> _pSchedulers;
std::shared_ptr<CesiumImpl::AsyncSystemSchedulers> _pSchedulers;
template <typename T> friend class Future;
};

View File

@ -13,12 +13,12 @@
namespace CesiumAsync {
namespace Impl {
namespace CesiumImpl {
template <typename R> struct ParameterizedTaskUnwrapper;
struct TaskUnwrapper;
} // namespace Impl
} // namespace CesiumImpl
/**
* @brief A value that will be available in the future, as produced by
@ -57,7 +57,8 @@ public:
* @return A future that resolves after the supplied function completes.
*/
template <typename Func>
Impl::ContinuationFutureType_t<Func, T> thenInWorkerThread(Func&& f) && {
CesiumImpl::ContinuationFutureType_t<Func, T>
thenInWorkerThread(Func&& f) && {
return std::move(*this).thenWithScheduler(
this->_pSchedulers->workerThread.immediate,
"waiting for worker thread",
@ -83,7 +84,7 @@ public:
* @return A future that resolves after the supplied function completes.
*/
template <typename Func>
Impl::ContinuationFutureType_t<Func, T> thenInMainThread(Func&& f) && {
CesiumImpl::ContinuationFutureType_t<Func, T> thenInMainThread(Func&& f) && {
return std::move(*this).thenWithScheduler(
this->_pSchedulers->mainThread.immediate,
"waiting for main thread",
@ -107,12 +108,12 @@ public:
* @return A future that resolves after the supplied function completes.
*/
template <typename Func>
Impl::ContinuationFutureType_t<Func, T> thenImmediately(Func&& f) && {
return Impl::ContinuationFutureType_t<Func, T>(
CesiumImpl::ContinuationFutureType_t<Func, T> thenImmediately(Func&& f) && {
return CesiumImpl::ContinuationFutureType_t<Func, T>(
this->_pSchedulers,
_task.then(
async::inline_scheduler(),
Impl::WithTracing<T>::end(nullptr, std::forward<Func>(f))));
CesiumImpl::WithTracing<T>::end(nullptr, std::forward<Func>(f))));
}
/**
@ -134,7 +135,7 @@ public:
* @return A future that resolves after the supplied function completes.
*/
template <typename Func>
Impl::ContinuationFutureType_t<Func, T>
CesiumImpl::ContinuationFutureType_t<Func, T>
thenInThreadPool(const ThreadPool& threadPool, Func&& f) && {
return std::move(*this).thenWithScheduler(
threadPool._pScheduler->immediate,
@ -234,12 +235,12 @@ public:
private:
Future(
const std::shared_ptr<Impl::AsyncSystemSchedulers>& pSchedulers,
const std::shared_ptr<CesiumImpl::AsyncSystemSchedulers>& pSchedulers,
async::task<T>&& task) noexcept
: _pSchedulers(pSchedulers), _task(std::move(task)) {}
template <typename Func, typename Scheduler>
Impl::ContinuationFutureType_t<Func, T> thenWithScheduler(
CesiumImpl::ContinuationFutureType_t<Func, T> thenWithScheduler(
Scheduler& scheduler,
const char* tracingName,
Func&& f) && {
@ -252,38 +253,40 @@ private:
// dispatching of the work.
auto task = this->_task.then(
async::inline_scheduler(),
Impl::WithTracing<T>::begin(tracingName, std::forward<Func>(f)));
CesiumImpl::WithTracing<T>::begin(tracingName, std::forward<Func>(f)));
#else
auto& task = this->_task;
#endif
return Impl::ContinuationFutureType_t<Func, T>(
return CesiumImpl::ContinuationFutureType_t<Func, T>(
this->_pSchedulers,
task.then(
scheduler,
Impl::WithTracing<T>::end(tracingName, std::forward<Func>(f))));
CesiumImpl::WithTracing<T>::end(
tracingName,
std::forward<Func>(f))));
}
template <typename Func, typename Scheduler>
Impl::ContinuationFutureType_t<Func, std::exception>
CesiumImpl::ContinuationFutureType_t<Func, std::exception>
catchWithScheduler(Scheduler& scheduler, Func&& f) && {
return Impl::ContinuationFutureType_t<Func, std::exception>(
return CesiumImpl::ContinuationFutureType_t<Func, std::exception>(
this->_pSchedulers,
this->_task.then(
async::inline_scheduler(),
Impl::CatchFunction<Func, T, Scheduler>{
CesiumImpl::CatchFunction<Func, T, Scheduler>{
scheduler,
std::forward<Func>(f)}));
}
std::shared_ptr<Impl::AsyncSystemSchedulers> _pSchedulers;
std::shared_ptr<CesiumImpl::AsyncSystemSchedulers> _pSchedulers;
async::task<T> _task;
friend class AsyncSystem;
template <typename R> friend struct Impl::ParameterizedTaskUnwrapper;
template <typename R> friend struct CesiumImpl::ParameterizedTaskUnwrapper;
friend struct Impl::TaskUnwrapper;
friend struct CesiumImpl::TaskUnwrapper;
template <typename R> friend class Future;
template <typename R> friend class SharedFuture;

View File

@ -8,7 +8,7 @@ namespace CesiumAsync {
class ITaskProcessor;
namespace Impl {
namespace CesiumImpl {
// Begin omitting doxgen warnings for Impl namespace
//! @cond Doxygen_Suppress
@ -23,5 +23,5 @@ public:
//! @endcond
// End omitting doxgen warnings for Impl namespace
} // namespace Impl
} // namespace CesiumImpl
} // namespace CesiumAsync

View File

@ -3,7 +3,7 @@
#include "unwrapFuture.h"
namespace CesiumAsync {
namespace Impl {
namespace CesiumImpl {
// Begin omitting doxgen warnings for Impl namespace
//! @cond Doxygen_Suppress
@ -72,5 +72,5 @@ struct CatchFunction<Func, void, Scheduler, TaskParameter> {
//! @endcond
// End omitting doxgen warnings for Impl namespace
} // namespace Impl
} // namespace CesiumImpl
} // namespace CesiumAsync

View File

@ -7,7 +7,7 @@ namespace CesiumAsync {
template <typename T> class Future;
namespace Impl {
namespace CesiumImpl {
// Begin omitting doxgen warnings for Impl namespace
//! @cond Doxygen_Suppress
@ -21,5 +21,5 @@ using ContinuationFutureType_t = typename ContinuationFutureType<Func, T>::type;
//! @endcond
// End omitting doxgen warnings for Impl namespace
} // namespace Impl
} // namespace CesiumImpl
} // namespace CesiumAsync

View File

@ -3,7 +3,7 @@
#include <type_traits>
namespace CesiumAsync {
namespace Impl {
namespace CesiumImpl {
// Begin omitting doxgen warnings for Impl namespace
//! @cond Doxygen_Suppress
@ -17,5 +17,5 @@ template <typename Func> struct ContinuationReturnType<Func, void> {
//! @endcond
// End omitting doxgen warnings for Impl namespace
} // namespace Impl
} // namespace CesiumImpl
} // namespace CesiumAsync

View File

@ -5,7 +5,7 @@
#include <spdlog/spdlog.h>
namespace CesiumAsync {
namespace Impl {
namespace CesiumImpl {
template <typename TScheduler> class ImmediateScheduler {
public:
@ -87,5 +87,5 @@ private:
}
};
} // namespace Impl
} // namespace CesiumImpl
} // namespace CesiumAsync

View File

@ -4,7 +4,7 @@
#include "cesium-async++.h"
namespace CesiumAsync {
namespace Impl {
namespace CesiumImpl {
class QueuedScheduler {
public:
@ -18,5 +18,5 @@ private:
async::fifo_scheduler _scheduler;
};
} // namespace Impl
} // namespace CesiumImpl
} // namespace CesiumAsync

View File

@ -7,7 +7,7 @@ namespace CesiumAsync {
template <class T> class Future;
template <class T> class SharedFuture;
namespace Impl {
namespace CesiumImpl {
// Begin omitting doxgen warnings for Impl namespace
//! @cond Doxygen_Suppress
@ -31,5 +31,5 @@ template <typename T> struct RemoveFuture<const async::shared_task<T>> {
//! @endcond
// End omitting doxgen warnings for Impl namespace
} // namespace Impl
} // namespace CesiumImpl
} // namespace CesiumAsync

View File

@ -6,7 +6,7 @@
#include <memory>
namespace CesiumAsync {
namespace Impl {
namespace CesiumImpl {
class TaskScheduler {
public:
@ -19,5 +19,5 @@ private:
std::shared_ptr<ITaskProcessor> _pTaskProcessor;
};
} // namespace Impl
} // namespace CesiumImpl
} // namespace CesiumAsync

View File

@ -5,7 +5,7 @@
#include <CesiumUtility/Tracing.h>
namespace CesiumAsync {
namespace Impl {
namespace CesiumImpl {
// Begin omitting doxgen warnings for Impl namespace
//! @cond Doxygen_Suppress
@ -23,7 +23,7 @@ template <typename T> struct WithTracing {
return std::move(result);
};
#else
return Impl::unwrapFuture<Func, T>(std::forward<Func>(f));
return CesiumImpl::unwrapFuture<Func, T>(std::forward<Func>(f));
#endif
}
@ -31,7 +31,7 @@ template <typename T> struct WithTracing {
static auto end([[maybe_unused]] const char* tracingName, Func&& f) {
#if CESIUM_TRACING_ENABLED
return [tracingName,
f = Impl::unwrapFuture<Func, T>(std::forward<Func>(f)),
f = CesiumImpl::unwrapFuture<Func, T>(std::forward<Func>(f)),
CESIUM_TRACE_LAMBDA_CAPTURE_TRACK()](T&& result) mutable {
CESIUM_TRACE_USE_CAPTURED_TRACK();
if (tracingName) {
@ -40,7 +40,7 @@ template <typename T> struct WithTracing {
return f(std::move(result));
};
#else
return Impl::unwrapFuture<Func, T>(std::forward<Func>(f));
return CesiumImpl::unwrapFuture<Func, T>(std::forward<Func>(f));
#endif
}
};
@ -59,7 +59,7 @@ template <typename T> struct WithTracingShared {
return result;
};
#else
return Impl::unwrapSharedFuture<Func, T>(std::forward<Func>(f));
return CesiumImpl::unwrapSharedFuture<Func, T>(std::forward<Func>(f));
#endif
}
@ -67,7 +67,7 @@ template <typename T> struct WithTracingShared {
static auto end([[maybe_unused]] const char* tracingName, Func&& f) {
#if CESIUM_TRACING_ENABLED
return [tracingName,
f = Impl::unwrapSharedFuture<Func, T>(std::forward<Func>(f)),
f = CesiumImpl::unwrapSharedFuture<Func, T>(std::forward<Func>(f)),
CESIUM_TRACE_LAMBDA_CAPTURE_TRACK()](const T& result) mutable {
CESIUM_TRACE_USE_CAPTURED_TRACK();
if (tracingName) {
@ -76,7 +76,7 @@ template <typename T> struct WithTracingShared {
return f(result);
};
#else
return Impl::unwrapSharedFuture<Func, T>(std::forward<Func>(f));
return CesiumImpl::unwrapSharedFuture<Func, T>(std::forward<Func>(f));
#endif
}
};
@ -93,7 +93,7 @@ template <> struct WithTracing<void> {
}
};
#else
return Impl::unwrapFuture<Func>(std::forward<Func>(f));
return CesiumImpl::unwrapFuture<Func>(std::forward<Func>(f));
#endif
}
@ -101,7 +101,7 @@ template <> struct WithTracing<void> {
static auto end([[maybe_unused]] const char* tracingName, Func&& f) {
#if CESIUM_TRACING_ENABLED
return [tracingName,
f = Impl::unwrapFuture<Func>(std::forward<Func>(f)),
f = CesiumImpl::unwrapFuture<Func>(std::forward<Func>(f)),
CESIUM_TRACE_LAMBDA_CAPTURE_TRACK()]() mutable {
CESIUM_TRACE_USE_CAPTURED_TRACK();
if (tracingName) {
@ -110,7 +110,7 @@ template <> struct WithTracing<void> {
return f();
};
#else
return Impl::unwrapFuture<Func>(std::forward<Func>(f));
return CesiumImpl::unwrapFuture<Func>(std::forward<Func>(f));
#endif
}
};
@ -120,5 +120,5 @@ template <> struct WithTracingShared<void> : public WithTracing<void> {};
//! @endcond
// End omitting doxgen warnings for Impl namespace
} // namespace Impl
} // namespace CesiumImpl
} // namespace CesiumAsync

View File

@ -4,7 +4,7 @@
#include "ContinuationReturnType.h"
namespace CesiumAsync {
namespace Impl {
namespace CesiumImpl {
// Begin omitting doxgen warnings for Impl namespace
//! @cond Doxygen_Suppress
@ -73,5 +73,5 @@ template <typename Func> auto unwrapSharedFuture(Func&& f) {
//! @endcond
// End omitting doxgen warnings for Impl namespace
} // namespace Impl
} // namespace CesiumImpl
} // namespace CesiumAsync

View File

@ -57,11 +57,11 @@ public:
private:
Promise(
const std::shared_ptr<Impl::AsyncSystemSchedulers>& pSchedulers,
const std::shared_ptr<CesiumImpl::AsyncSystemSchedulers>& pSchedulers,
const std::shared_ptr<async::event_task<T>>& pEvent) noexcept
: _pSchedulers(pSchedulers), _pEvent(pEvent) {}
std::shared_ptr<Impl::AsyncSystemSchedulers> _pSchedulers;
std::shared_ptr<CesiumImpl::AsyncSystemSchedulers> _pSchedulers;
std::shared_ptr<async::event_task<T>> _pEvent;
friend class AsyncSystem;
@ -83,11 +83,11 @@ public:
private:
Promise(
const std::shared_ptr<Impl::AsyncSystemSchedulers>& pSchedulers,
const std::shared_ptr<CesiumImpl::AsyncSystemSchedulers>& pSchedulers,
const std::shared_ptr<async::event_task<void>>& pEvent) noexcept
: _pSchedulers(pSchedulers), _pEvent(pEvent) {}
std::shared_ptr<Impl::AsyncSystemSchedulers> _pSchedulers;
std::shared_ptr<CesiumImpl::AsyncSystemSchedulers> _pSchedulers;
std::shared_ptr<async::event_task<void>> _pEvent;
friend class AsyncSystem;

View File

@ -12,12 +12,12 @@
namespace CesiumAsync {
namespace Impl {
namespace CesiumImpl {
template <typename R> struct ParameterizedTaskUnwrapper;
struct TaskUnwrapper;
} // namespace Impl
} // namespace CesiumImpl
/**
* @brief A value that will be available in the future, as produced by
@ -48,7 +48,7 @@ public:
* @return A future that resolves after the supplied function completes.
*/
template <typename Func>
Impl::ContinuationFutureType_t<Func, T> thenInWorkerThread(Func&& f) {
CesiumImpl::ContinuationFutureType_t<Func, T> thenInWorkerThread(Func&& f) {
return this->thenWithScheduler(
this->_pSchedulers->workerThread.immediate,
"waiting for worker thread",
@ -74,7 +74,7 @@ public:
* @return A future that resolves after the supplied function completes.
*/
template <typename Func>
Impl::ContinuationFutureType_t<Func, T> thenInMainThread(Func&& f) {
CesiumImpl::ContinuationFutureType_t<Func, T> thenInMainThread(Func&& f) {
return this->thenWithScheduler(
this->_pSchedulers->mainThread.immediate,
"waiting for main thread",
@ -97,12 +97,14 @@ public:
* @return A future that resolves after the supplied function completes.
*/
template <typename Func>
Impl::ContinuationFutureType_t<Func, T> thenImmediately(Func&& f) {
return Impl::ContinuationFutureType_t<Func, T>(
CesiumImpl::ContinuationFutureType_t<Func, T> thenImmediately(Func&& f) {
return CesiumImpl::ContinuationFutureType_t<Func, T>(
this->_pSchedulers,
_task.then(
async::inline_scheduler(),
Impl::WithTracingShared<T>::end(nullptr, std::forward<Func>(f))));
CesiumImpl::WithTracingShared<T>::end(
nullptr,
std::forward<Func>(f))));
}
/**
@ -124,7 +126,7 @@ public:
* @return A future that resolves after the supplied function completes.
*/
template <typename Func>
Impl::ContinuationFutureType_t<Func, T>
CesiumImpl::ContinuationFutureType_t<Func, T>
thenInThreadPool(const ThreadPool& threadPool, Func&& f) {
return this->thenWithScheduler(
threadPool._pScheduler->immediate,
@ -211,12 +213,12 @@ public:
private:
SharedFuture(
const std::shared_ptr<Impl::AsyncSystemSchedulers>& pSchedulers,
const std::shared_ptr<CesiumImpl::AsyncSystemSchedulers>& pSchedulers,
async::shared_task<T>&& task) noexcept
: _pSchedulers(pSchedulers), _task(std::move(task)) {}
template <typename Func, typename Scheduler>
Impl::ContinuationFutureType_t<Func, T>
CesiumImpl::ContinuationFutureType_t<Func, T>
thenWithScheduler(Scheduler& scheduler, const char* tracingName, Func&& f) {
// It would be nice if tracingName were a template parameter instead of a
// function parameter, but that triggers a bug in VS2017. It was previously
@ -227,41 +229,43 @@ private:
// dispatching of the work.
auto task = this->_task.then(
async::inline_scheduler(),
Impl::WithTracingShared<T>::begin(tracingName, std::forward<Func>(f)));
CesiumImpl::WithTracingShared<T>::begin(
tracingName,
std::forward<Func>(f)));
#else
auto& task = this->_task;
#endif
return Impl::ContinuationFutureType_t<Func, T>(
return CesiumImpl::ContinuationFutureType_t<Func, T>(
this->_pSchedulers,
task.then(
scheduler,
Impl::WithTracingShared<T>::end(
CesiumImpl::WithTracingShared<T>::end(
tracingName,
std::forward<Func>(f))));
}
template <typename Func, typename Scheduler>
Impl::ContinuationFutureType_t<Func, std::exception>
CesiumImpl::ContinuationFutureType_t<Func, std::exception>
catchWithScheduler(Scheduler& scheduler, Func&& f) {
return Impl::ContinuationFutureType_t<Func, std::exception>(
return CesiumImpl::ContinuationFutureType_t<Func, std::exception>(
this->_pSchedulers,
this->_task.then(
async::inline_scheduler(),
Impl::
CesiumImpl::
CatchFunction<Func, T, Scheduler, const async::shared_task<T>&>{
scheduler,
std::forward<Func>(f)}));
}
std::shared_ptr<Impl::AsyncSystemSchedulers> _pSchedulers;
std::shared_ptr<CesiumImpl::AsyncSystemSchedulers> _pSchedulers;
async::shared_task<T> _task;
friend class AsyncSystem;
template <typename R> friend struct Impl::ParameterizedTaskUnwrapper;
template <typename R> friend struct CesiumImpl::ParameterizedTaskUnwrapper;
friend struct Impl::TaskUnwrapper;
friend struct CesiumImpl::TaskUnwrapper;
template <typename R> friend class Future;
template <typename R> friend class SharedFuture;

View File

@ -24,7 +24,7 @@ private:
Scheduler(int32_t numberOfThreads);
void schedule(async::task_run_handle t);
Impl::ImmediateScheduler<Scheduler> immediate{this};
CesiumImpl::ImmediateScheduler<Scheduler> immediate{this};
async::threadpool_scheduler scheduler;
};
@ -38,7 +38,7 @@ private:
return []() noexcept { ThreadPool::_scope.reset(); };
}
static thread_local Impl::ImmediateScheduler<Scheduler>::SchedulerScope
static thread_local CesiumImpl::ImmediateScheduler<Scheduler>::SchedulerScope
_scope;
std::shared_ptr<Scheduler> _pScheduler;

View File

@ -8,7 +8,8 @@ namespace CesiumAsync {
AsyncSystem::AsyncSystem(
const std::shared_ptr<ITaskProcessor>& pTaskProcessor) noexcept
: _pSchedulers(
std::make_shared<Impl::AsyncSystemSchedulers>(pTaskProcessor)) {}
std::make_shared<CesiumImpl::AsyncSystemSchedulers>(pTaskProcessor)) {
}
void AsyncSystem::dispatchMainThreadTasks() {
this->_pSchedulers->mainThread.dispatchQueuedContinuations();

View File

@ -1,6 +1,6 @@
#include "CesiumAsync/Impl/QueuedScheduler.h"
using namespace CesiumAsync::Impl;
using namespace CesiumAsync::CesiumImpl;
void QueuedScheduler::schedule(async::task_run_handle t) {
this->_scheduler.schedule(std::move(t));

View File

@ -1,6 +1,6 @@
#include "CesiumAsync/Impl/TaskScheduler.h"
using namespace CesiumAsync::Impl;
using namespace CesiumAsync::CesiumImpl;
TaskScheduler::TaskScheduler(
const std::shared_ptr<CesiumAsync::ITaskProcessor>& pTaskProcessor)

View File

@ -4,7 +4,7 @@ using namespace CesiumAsync;
// Each thread may be enrolled in a single scheduler scope.
// That means the thread is doing work on behalf of the scheduler.
/*static*/ thread_local Impl::ImmediateScheduler<
/*static*/ thread_local CesiumImpl::ImmediateScheduler<
ThreadPool::Scheduler>::SchedulerScope ThreadPool::_scope;
ThreadPool::ThreadPool(int32_t numberOfThreads)

View File

@ -15,7 +15,7 @@ namespace CesiumGeometry {
IntersectionTests::rayPlane(const Ray& ray, const Plane& plane) noexcept {
const double denominator = glm::dot(plane.getNormal(), ray.getDirection());
if (glm::abs(denominator) < Math::EPSILON15) {
if (glm::abs(denominator) < Math::Epsilon15) {
// Ray is parallel to plane. The ray may be in the polygon's plane.
return std::optional<glm::dvec3>();
}

View File

@ -19,7 +19,7 @@ Plane::Plane() noexcept : Plane(glm::dvec3(0.0, 0.0, 1.0), 0.0) {}
Plane::Plane(const glm::dvec3& normal, double distance)
: _normal(normal), _distance(distance) {
//>>includeStart('debug', pragmas.debug);
if (!Math::equalsEpsilon(glm::length(normal), 1.0, Math::EPSILON6)) {
if (!Math::equalsEpsilon(glm::length(normal), 1.0, Math::Epsilon6)) {
throw std::invalid_argument("normal must be normalized.");
}
//>>includeEnd('debug');

View File

@ -13,7 +13,7 @@ namespace CesiumGeometry {
Ray::Ray(const glm::dvec3& origin, const glm::dvec3& direction)
: _origin(origin), _direction(direction) {
//>>includeStart('debug', pragmas.debug);
if (!Math::equalsEpsilon(glm::length(direction), 1.0, Math::EPSILON6)) {
if (!Math::equalsEpsilon(glm::length(direction), 1.0, Math::Epsilon6)) {
throw std::invalid_argument("direction must be normalized.");
}
//>>includeEnd('debug');

View File

@ -44,7 +44,7 @@ TEST_CASE(
CHECK(CesiumUtility::Math::equalsEpsilon(
bs.computeDistanceSquaredToPosition(position),
expected,
CesiumUtility::Math::EPSILON6));
CesiumUtility::Math::Epsilon6));
}
TEST_CASE(

View File

@ -63,7 +63,7 @@ TEST_CASE("Rectangle::computeSignedDistance") {
CHECK(CesiumUtility::Math::equalsEpsilon(
testCase.rectangle.computeSignedDistance(testCase.position),
testCase.expectedResult,
CesiumUtility::Math::EPSILON13));
CesiumUtility::Math::Epsilon13));
}
TEST_CASE("Rectangle::computeUnion") {

View File

@ -53,7 +53,7 @@ public:
1.0 / (radii.x * radii.x),
1.0 / (radii.y * radii.y),
1.0 / (radii.z * radii.z)),
_centerToleranceSquared(CesiumUtility::Math::EPSILON1) {}
_centerToleranceSquared(CesiumUtility::Math::Epsilon1) {}
/**
* @brief Returns the radii in x-, y-, and z-direction.

View File

@ -32,10 +32,10 @@ public:
* from -PI/2 to +PI/2 radians latitude.
*/
static constexpr GlobeRectangle MAXIMUM_GLOBE_RECTANGLE = GlobeRectangle(
-CesiumUtility::Math::ONE_PI,
-CesiumUtility::Math::PI_OVER_TWO,
CesiumUtility::Math::ONE_PI,
CesiumUtility::Math::PI_OVER_TWO);
-CesiumUtility::Math::OnePi,
-CesiumUtility::Math::PiOverTwo,
CesiumUtility::Math::OnePi,
CesiumUtility::Math::PiOverTwo);
/**
* @brief Computes the maximum rectangle that can be covered with this
@ -48,9 +48,9 @@ public:
static constexpr CesiumGeometry::Rectangle computeMaximumProjectedRectangle(
const Ellipsoid& ellipsoid = Ellipsoid::WGS84) noexcept {
const double longitudeValue =
ellipsoid.getMaximumRadius() * CesiumUtility::Math::ONE_PI;
ellipsoid.getMaximumRadius() * CesiumUtility::Math::OnePi;
const double latitudeValue =
ellipsoid.getMaximumRadius() * CesiumUtility::Math::PI_OVER_TWO;
ellipsoid.getMaximumRadius() * CesiumUtility::Math::PiOverTwo;
return CesiumGeometry::Rectangle(
-longitudeValue,
-latitudeValue,

View File

@ -167,7 +167,7 @@ public:
double east = this->_east;
const double west = this->_west;
if (east < west) {
east += CesiumUtility::Math::TWO_PI;
east += CesiumUtility::Math::TwoPi;
}
return east - west;
}

View File

@ -35,7 +35,7 @@ public:
* square. That is, the rectangle is equal in the X and Y directions.
*
* The constant value is computed by calling:
* `CesiumGeospatial::WebMercatorProjection::mercatorAngleToGeodeticLatitude(CesiumUtility::Math::ONE_PI)`
* `CesiumGeospatial::WebMercatorProjection::mercatorAngleToGeodeticLatitude(CesiumUtility::Math::OnePi)`
*/
static const double MAXIMUM_LATITUDE;
@ -57,7 +57,7 @@ public:
static constexpr CesiumGeometry::Rectangle computeMaximumProjectedRectangle(
const Ellipsoid& ellipsoid = Ellipsoid::WGS84) noexcept {
const double value =
ellipsoid.getMaximumRadius() * CesiumUtility::Math::ONE_PI;
ellipsoid.getMaximumRadius() * CesiumUtility::Math::OnePi;
return CesiumGeometry::Rectangle(-value, -value, value, value);
}

View File

@ -62,7 +62,7 @@ BoundingRegion::BoundingRegion(
westernMidpointCartesian - easternMidpointCartesian;
const glm::dvec3 eastWestNormal = glm::normalize(westVector);
if (!Math::equalsEpsilon(glm::length(eastWestNormal), 1.0, Math::EPSILON6)) {
if (!Math::equalsEpsilon(glm::length(eastWestNormal), 1.0, Math::Epsilon6)) {
this->_planesAreInvalid = true;
return;
}
@ -268,7 +268,7 @@ static OrientedBoundingBox fromPlaneExtents(
if (!Math::equalsEpsilon(
ellipsoid.getRadii().x,
ellipsoid.getRadii().y,
Math::EPSILON15)) {
Math::Epsilon15)) {
throw std::runtime_error(
"Ellipsoid must be an ellipsoid of revolution (radii.x == radii.y)");
}
@ -277,7 +277,7 @@ static OrientedBoundingBox fromPlaneExtents(
double minX, maxX, minY, maxY, minZ, maxZ;
Plane plane(glm::dvec3(0.0, 0.0, 1.0), 0.0);
if (rectangle.computeWidth() <= Math::ONE_PI) {
if (rectangle.computeWidth() <= Math::OnePi) {
// The bounding box will be aligned with the tangent plane at the center of
// the rectangle.
const Cartographic tangentPointCartographic = rectangle.computeCenter();
@ -409,8 +409,8 @@ static OrientedBoundingBox fromPlaneExtents(
Cartographic(centerLongitude, latitudeNearestToEquator, maximumHeight));
planeOrigin.z = 0.0; // center the plane on the equator to simpify plane
// normal calculation
const bool isPole = glm::abs(planeOrigin.x) < Math::EPSILON10 &&
glm::abs(planeOrigin.y) < Math::EPSILON10;
const bool isPole = glm::abs(planeOrigin.x) < Math::Epsilon10 &&
glm::abs(planeOrigin.y) < Math::Epsilon10;
const glm::dvec3 planeNormal =
!isPole ? glm::normalize(planeOrigin) : glm::dvec3(1.0, 0.0, 0.0);
const glm::dvec3 planeYAxis(0.0, 0.0, 1.0);
@ -421,7 +421,7 @@ static OrientedBoundingBox fromPlaneExtents(
// extent in the plane's X dimension.
const glm::dvec3 horizonCartesian =
ellipsoid.cartographicToCartesian(Cartographic(
centerLongitude + Math::PI_OVER_TWO,
centerLongitude + Math::PiOverTwo,
latitudeNearestToEquator,
maximumHeight));
maxX = glm::dot(plane.projectPointOntoPlane(horizonCartesian), planeXAxis);

View File

@ -10,7 +10,7 @@ using namespace CesiumUtility;
namespace {
bool isCloseToPole(double latitude, double tolerance) {
return Math::PI_OVER_TWO - glm::abs(latitude) < tolerance;
return Math::PiOverTwo - glm::abs(latitude) < tolerance;
}
} // namespace
@ -18,7 +18,7 @@ bool isCloseToPole(double latitude, double tolerance) {
namespace CesiumGeospatial {
BoundingRegionBuilder::BoundingRegionBuilder() noexcept
: _poleTolerance(Math::EPSILON10),
: _poleTolerance(Math::Epsilon10),
_rectangle(GlobeRectangle::EMPTY),
_minimumHeight(std::numeric_limits<double>::max()),
_maximumHeight(std::numeric_limits<double>::lowest()),
@ -85,8 +85,8 @@ bool BoundingRegionBuilder::expandToIncludePosition(
this->_rectangle.getWest() - position.longitude;
if (positionToWestDistance < 0.0) {
const double antiMeridianToWest =
this->_rectangle.getWest() - (-Math::ONE_PI);
const double positionToAntiMeridian = Math::ONE_PI - position.longitude;
this->_rectangle.getWest() - (-Math::OnePi);
const double positionToAntiMeridian = Math::OnePi - position.longitude;
positionToWestDistance = antiMeridianToWest + positionToAntiMeridian;
}
@ -94,9 +94,9 @@ bool BoundingRegionBuilder::expandToIncludePosition(
position.longitude - this->_rectangle.getEast();
if (eastToPositionDistance < 0.0) {
const double antiMeridianToPosition =
position.longitude - (-Math::ONE_PI);
position.longitude - (-Math::OnePi);
const double eastToAntiMeridian =
Math::ONE_PI - this->_rectangle.getEast();
Math::OnePi - this->_rectangle.getEast();
eastToPositionDistance = antiMeridianToPosition + eastToAntiMeridian;
}

View File

@ -31,11 +31,11 @@ triangulatePolygon(const std::vector<glm::dvec2>& polygon) {
point[1] = cartographic.y;
// check if the difference crosses the antipole
if (glm::abs(point[0]) > CesiumUtility::Math::ONE_PI) {
if (glm::abs(point[0]) > CesiumUtility::Math::OnePi) {
if (point[0] > 0.0) {
point[0] -= CesiumUtility::Math::TWO_PI;
point[0] -= CesiumUtility::Math::TwoPi;
} else {
point[0] += CesiumUtility::Math::TWO_PI;
point[0] += CesiumUtility::Math::TwoPi;
}
}
}
@ -73,7 +73,7 @@ computeBoundingRectangle(const std::vector<glm::dvec2>& polygon) {
const double dif_west = point1.x - west;
// check if the difference crosses the antipole
if (glm::abs(dif_west) > CesiumUtility::Math::ONE_PI) {
if (glm::abs(dif_west) > CesiumUtility::Math::OnePi) {
// east wrapping past the antipole to the west
if (dif_west > 0.0) {
west = point1.x;
@ -86,7 +86,7 @@ computeBoundingRectangle(const std::vector<glm::dvec2>& polygon) {
const double dif_east = point1.x - east;
// check if the difference crosses the antipole
if (glm::abs(dif_east) > CesiumUtility::Math::ONE_PI) {
if (glm::abs(dif_east) > CesiumUtility::Math::OnePi) {
// west wrapping past the antipole to the east
if (dif_east < 0.0) {
east = point1.x;

View File

@ -137,7 +137,7 @@ Ellipsoid::scaleToGeodeticSurface(const glm::dvec3& cartesian) const noexcept {
const double derivative = -2.0 * denominator;
correction = func / derivative;
} while (glm::abs(func) > Math::EPSILON12);
} while (glm::abs(func) > Math::Epsilon12);
return glm::dvec3(
positionX * xMultiplier,

View File

@ -7,10 +7,10 @@ using namespace CesiumUtility;
namespace CesiumGeospatial {
/*static*/ const GlobeRectangle GlobeRectangle::EMPTY{
Math::ONE_PI,
Math::PI_OVER_TWO,
-Math::ONE_PI,
-Math::PI_OVER_TWO};
Math::OnePi,
Math::PiOverTwo,
-Math::OnePi,
-Math::PiOverTwo};
Cartographic GlobeRectangle::computeCenter() const noexcept {
double latitudeCenter = (this->_south + this->_north) * 0.5;
@ -20,19 +20,19 @@ Cartographic GlobeRectangle::computeCenter() const noexcept {
return Cartographic((this->_west + this->_east) * 0.5, latitudeCenter, 0.0);
} else {
// Rectangle crosses the anti-meridian.
double westToAntiMeridian = Math::ONE_PI - this->_west;
double antiMeridianToEast = this->_east - -Math::ONE_PI;
double westToAntiMeridian = Math::OnePi - this->_west;
double antiMeridianToEast = this->_east - -Math::OnePi;
double total = westToAntiMeridian + antiMeridianToEast;
if (westToAntiMeridian >= antiMeridianToEast) {
// Center is in the Eastern hemisphere.
return Cartographic(
glm::min(Math::ONE_PI, this->_west + total * 0.5),
glm::min(Math::OnePi, this->_west + total * 0.5),
latitudeCenter,
0.0);
} else {
// Center is in the Western hemisphere.
return Cartographic(
glm::max(-Math::ONE_PI, this->_east - total * 0.5),
glm::max(-Math::OnePi, this->_east - total * 0.5),
latitudeCenter,
0.0);
}
@ -68,15 +68,15 @@ std::optional<GlobeRectangle> GlobeRectangle::computeIntersection(
double otherRectangleWest = other._west;
if (rectangleEast < rectangleWest && otherRectangleEast > 0.0) {
rectangleEast += CesiumUtility::Math::TWO_PI;
rectangleEast += CesiumUtility::Math::TwoPi;
} else if (otherRectangleEast < otherRectangleWest && rectangleEast > 0.0) {
otherRectangleEast += CesiumUtility::Math::TWO_PI;
otherRectangleEast += CesiumUtility::Math::TwoPi;
}
if (rectangleEast < rectangleWest && otherRectangleWest < 0.0) {
otherRectangleWest += CesiumUtility::Math::TWO_PI;
otherRectangleWest += CesiumUtility::Math::TwoPi;
} else if (otherRectangleEast < otherRectangleWest && rectangleWest < 0.0) {
rectangleWest += CesiumUtility::Math::TWO_PI;
rectangleWest += CesiumUtility::Math::TwoPi;
}
const double west = CesiumUtility::Math::negativePiToPi(
@ -108,15 +108,15 @@ GlobeRectangle::computeUnion(const GlobeRectangle& other) const noexcept {
double otherRectangleWest = other._west;
if (rectangleEast < rectangleWest && otherRectangleEast > 0.0) {
rectangleEast += CesiumUtility::Math::TWO_PI;
rectangleEast += CesiumUtility::Math::TwoPi;
} else if (otherRectangleEast < otherRectangleWest && rectangleEast > 0.0) {
otherRectangleEast += CesiumUtility::Math::TWO_PI;
otherRectangleEast += CesiumUtility::Math::TwoPi;
}
if (rectangleEast < rectangleWest && otherRectangleWest < 0.0) {
otherRectangleWest += CesiumUtility::Math::TWO_PI;
otherRectangleWest += CesiumUtility::Math::TwoPi;
} else if (otherRectangleEast < otherRectangleWest && rectangleWest < 0.0) {
rectangleWest += CesiumUtility::Math::TWO_PI;
rectangleWest += CesiumUtility::Math::TwoPi;
}
const double west = CesiumUtility::Math::convertLongitudeRange(

View File

@ -11,7 +11,7 @@ namespace CesiumGeospatial {
/*static*/ glm::dmat4x4 Transforms::eastNorthUpToFixedFrame(
const glm::dvec3& origin,
const Ellipsoid& ellipsoid /*= Ellipsoid::WGS84*/) noexcept {
if (Math::equalsEpsilon(origin, glm::dvec3(0.0), Math::EPSILON14)) {
if (Math::equalsEpsilon(origin, glm::dvec3(0.0), Math::Epsilon14)) {
// If x, y, and z are zero, use the degenerate local frame, which is a
// special case
return glm::dmat4x4(
@ -20,8 +20,8 @@ namespace CesiumGeospatial {
glm::dvec4(0.0, 0.0, 1.0, 0.0),
glm::dvec4(origin, 1.0));
}
if (Math::equalsEpsilon(origin.x, 0.0, Math::EPSILON14) &&
Math::equalsEpsilon(origin.y, 0.0, Math::EPSILON14)) {
if (Math::equalsEpsilon(origin.x, 0.0, Math::Epsilon14) &&
Math::equalsEpsilon(origin.y, 0.0, Math::Epsilon14)) {
// If x and y are zero, assume origin is at a pole, which is a special case.
const double sign = Math::sign(origin.z);
return glm::dmat4x4(

View File

@ -11,13 +11,13 @@ namespace CesiumGeospatial {
/*static*/ const double WebMercatorProjection::MAXIMUM_LATITUDE =
WebMercatorProjection::mercatorAngleToGeodeticLatitude(
CesiumUtility::Math::ONE_PI);
CesiumUtility::Math::OnePi);
/*static*/ const GlobeRectangle WebMercatorProjection::MAXIMUM_GLOBE_RECTANGLE =
GlobeRectangle(
-CesiumUtility::Math::ONE_PI,
-CesiumUtility::Math::OnePi,
-MAXIMUM_LATITUDE,
CesiumUtility::Math::ONE_PI,
CesiumUtility::Math::OnePi,
MAXIMUM_LATITUDE);
WebMercatorProjection::WebMercatorProjection(
@ -71,7 +71,7 @@ CesiumGeospatial::GlobeRectangle WebMercatorProjection::unproject(
/*static*/ double WebMercatorProjection::mercatorAngleToGeodeticLatitude(
double mercatorAngle) noexcept {
return CesiumUtility::Math::PI_OVER_TWO -
return CesiumUtility::Math::PiOverTwo -
2.0 * glm::atan(glm::exp(-mercatorAngle));
}

View File

@ -44,7 +44,7 @@ TEST_CASE("BoundingRegion") {
auto testCase = GENERATE_COPY(
// Inside bounding region
TestCase{
rectangle.getWest() + Math::EPSILON6,
rectangle.getWest() + Math::Epsilon6,
rectangle.getSouth(),
region.getMinimumHeight(),
0.0},
@ -84,7 +84,7 @@ TEST_CASE("BoundingRegion") {
CHECK(Math::equalsEpsilon(
sqrt(region.computeDistanceSquaredToPosition(position)),
testCase.expectedDistance,
Math::EPSILON6));
Math::Epsilon6));
}
SECTION("computeDistanceSquaredToPosition with degenerate region") {
@ -123,7 +123,7 @@ TEST_CASE("BoundingRegion") {
CHECK(Math::equalsEpsilon(
sqrt(region.computeDistanceSquaredToPosition(position)),
testCase.expectedDistance,
Math::EPSILON6));
Math::Epsilon6));
}
SECTION("intersectPlane") {

View File

@ -25,7 +25,7 @@ TEST_CASE("BoundingRegionBuilder") {
CHECK(!rectangle.contains(Cartographic(0.0, 1.0, 0.0)));
CHECK(!rectangle.contains(Cartographic(0.0, -1.0, 0.0)));
builder.expandToIncludePosition(Cartographic(Math::ONE_PI, 1.0, 0.0));
builder.expandToIncludePosition(Cartographic(Math::OnePi, 1.0, 0.0));
rectangle = builder.toRegion().getRectangle();
CHECK(rectangle.contains(Cartographic(0.0, 0.0, 0.0)));
CHECK(rectangle.contains(Cartographic(1.0, 0.0, 0.0)));

View File

@ -20,30 +20,30 @@ TEST_CASE("GlobeRectangle") {
SECTION("computeCenter") {
GlobeRectangle simple(0.1, 0.2, 0.3, 0.4);
Cartographic center = simple.computeCenter();
CHECK(Math::equalsEpsilon(center.longitude, 0.2, 0.0, Math::EPSILON14));
CHECK(Math::equalsEpsilon(center.latitude, 0.3, 0.0, Math::EPSILON14));
CHECK(Math::equalsEpsilon(center.longitude, 0.2, 0.0, Math::Epsilon14));
CHECK(Math::equalsEpsilon(center.latitude, 0.3, 0.0, Math::Epsilon14));
GlobeRectangle wrapping(3.0, 0.2, -3.1, 0.4);
center = wrapping.computeCenter();
double expectedLongitude =
3.0 + ((Math::ONE_PI - 3.0) + (-3.1 - -Math::ONE_PI)) * 0.5;
3.0 + ((Math::OnePi - 3.0) + (-3.1 - -Math::OnePi)) * 0.5;
CHECK(Math::equalsEpsilon(
center.longitude,
expectedLongitude,
0.0,
Math::EPSILON14));
CHECK(Math::equalsEpsilon(center.latitude, 0.3, 0.0, Math::EPSILON14));
Math::Epsilon14));
CHECK(Math::equalsEpsilon(center.latitude, 0.3, 0.0, Math::Epsilon14));
GlobeRectangle wrapping2(3.1, 0.2, -3.0, 0.4);
center = wrapping2.computeCenter();
expectedLongitude =
-3.0 - ((Math::ONE_PI - 3.1) + (-3.0 - -Math::ONE_PI)) * 0.5;
-3.0 - ((Math::OnePi - 3.1) + (-3.0 - -Math::OnePi)) * 0.5;
CHECK(Math::equalsEpsilon(
center.longitude,
expectedLongitude,
0.0,
Math::EPSILON14));
CHECK(Math::equalsEpsilon(center.latitude, 0.3, 0.0, Math::EPSILON14));
Math::Epsilon14));
CHECK(Math::equalsEpsilon(center.latitude, 0.3, 0.0, Math::Epsilon14));
}
SECTION("contains") {
@ -56,8 +56,8 @@ TEST_CASE("GlobeRectangle") {
CHECK(!simple.contains(Cartographic(0.0, 0.2)));
GlobeRectangle wrapping(3.0, 0.2, -3.1, 0.4);
CHECK(wrapping.contains(Cartographic(Math::ONE_PI, 0.2)));
CHECK(wrapping.contains(Cartographic(-Math::ONE_PI, 0.2)));
CHECK(wrapping.contains(Cartographic(Math::OnePi, 0.2)));
CHECK(wrapping.contains(Cartographic(-Math::OnePi, 0.2)));
CHECK(wrapping.contains(Cartographic(3.14, 0.2)));
CHECK(wrapping.contains(Cartographic(-3.14, 0.2)));
CHECK(!wrapping.contains(Cartographic(0.0, 0.2)));

View File

@ -34,7 +34,7 @@ TEST_CASE("S2CellBoundingVolume") {
glm::sqrt(tileS2Cell.computeDistanceSquaredToPosition(position)),
testDistance,
0.0,
Math::EPSILON7));
Math::Epsilon7));
// Test against the first side plane.
Plane sidePlane0(
@ -50,7 +50,7 @@ TEST_CASE("S2CellBoundingVolume") {
glm::sqrt(tileS2Cell.computeDistanceSquaredToPosition(position)),
testDistance,
0.0,
Math::EPSILON7));
Math::Epsilon7));
}
SECTION("Case II - distanceToCamera works when camera is facing two planes") {
@ -64,7 +64,7 @@ TEST_CASE("S2CellBoundingVolume") {
glm::sqrt(tileS2Cell.computeDistanceSquaredToPosition(position)),
testDistance,
0.0,
Math::EPSILON7));
Math::Epsilon7));
// Test with first and second side planes.
position =
@ -75,7 +75,7 @@ TEST_CASE("S2CellBoundingVolume") {
tileS2Cell.computeDistanceSquaredToPosition(position),
2.0,
0.0,
Math::EPSILON7));
Math::Epsilon7));
// Test with bottom plane and second side plane. Handles the obtuse dihedral
// angle case.
@ -87,7 +87,7 @@ TEST_CASE("S2CellBoundingVolume") {
glm::sqrt(tileS2Cell.computeDistanceSquaredToPosition(position)),
10000.0,
0.0,
Math::EPSILON7));
Math::Epsilon7));
}
SECTION(
@ -97,7 +97,7 @@ TEST_CASE("S2CellBoundingVolume") {
tileS2Cell.computeDistanceSquaredToPosition(position),
3.0,
0.0,
Math::EPSILON7));
Math::Epsilon7));
}
SECTION("Case IV - distanceToCamera works when camera is facing more than "
@ -108,7 +108,7 @@ TEST_CASE("S2CellBoundingVolume") {
Ellipsoid::WGS84.getMaximumRadius() +
tileS2Cell.getBoundingPlanes()[1].getDistance(),
0.0,
Math::EPSILON7));
Math::Epsilon7));
}
SECTION("intersect plane") {

View File

@ -76,96 +76,96 @@ TEST_CASE("S2CellID") {
SECTION("gets correct center of cell") {
Cartographic center = S2CellID::fromToken("1").getCenter();
CHECK(Math::equalsEpsilon(center.longitude, 0.0, 0.0, Math::EPSILON10));
CHECK(Math::equalsEpsilon(center.latitude, 0.0, 0.0, Math::EPSILON10));
CHECK(Math::equalsEpsilon(center.height, 0.0, 0.0, Math::EPSILON10));
CHECK(Math::equalsEpsilon(center.longitude, 0.0, 0.0, Math::Epsilon10));
CHECK(Math::equalsEpsilon(center.latitude, 0.0, 0.0, Math::Epsilon10));
CHECK(Math::equalsEpsilon(center.height, 0.0, 0.0, Math::Epsilon10));
center = S2CellID::fromToken("3").getCenter();
CHECK(Math::equalsEpsilon(
center.longitude,
Math::degreesToRadians(90.0),
0.0,
Math::EPSILON10));
CHECK(Math::equalsEpsilon(center.latitude, 0.0, 0.0, Math::EPSILON10));
CHECK(Math::equalsEpsilon(center.height, 0.0, 0.0, Math::EPSILON10));
Math::Epsilon10));
CHECK(Math::equalsEpsilon(center.latitude, 0.0, 0.0, Math::Epsilon10));
CHECK(Math::equalsEpsilon(center.height, 0.0, 0.0, Math::Epsilon10));
center = S2CellID::fromToken("5").getCenter();
CHECK(Math::equalsEpsilon(
center.longitude,
Math::degreesToRadians(-180.0),
0.0,
Math::EPSILON10));
Math::Epsilon10));
CHECK(Math::equalsEpsilon(
center.latitude,
Math::degreesToRadians(90.0),
0.0,
Math::EPSILON10));
CHECK(Math::equalsEpsilon(center.height, 0.0, 0.0, Math::EPSILON10));
Math::Epsilon10));
CHECK(Math::equalsEpsilon(center.height, 0.0, 0.0, Math::Epsilon10));
center = S2CellID::fromToken("7").getCenter();
CHECK(Math::equalsEpsilon(
center.longitude,
Math::degreesToRadians(-180.0),
0.0,
Math::EPSILON10));
Math::Epsilon10));
CHECK(Math::equalsEpsilon(
center.latitude,
Math::degreesToRadians(0.0),
0.0,
Math::EPSILON10));
CHECK(Math::equalsEpsilon(center.height, 0.0, 0.0, Math::EPSILON10));
Math::Epsilon10));
CHECK(Math::equalsEpsilon(center.height, 0.0, 0.0, Math::Epsilon10));
center = S2CellID::fromToken("9").getCenter();
CHECK(Math::equalsEpsilon(
center.longitude,
Math::degreesToRadians(-90.0),
0.0,
Math::EPSILON10));
Math::Epsilon10));
CHECK(Math::equalsEpsilon(
center.latitude,
Math::degreesToRadians(0.0),
0.0,
Math::EPSILON10));
CHECK(Math::equalsEpsilon(center.height, 0.0, 0.0, Math::EPSILON10));
Math::Epsilon10));
CHECK(Math::equalsEpsilon(center.height, 0.0, 0.0, Math::Epsilon10));
center = S2CellID::fromToken("b").getCenter();
CHECK(Math::equalsEpsilon(
center.longitude,
Math::degreesToRadians(0.0),
0.0,
Math::EPSILON10));
Math::Epsilon10));
CHECK(Math::equalsEpsilon(
center.latitude,
Math::degreesToRadians(-90.0),
0.0,
Math::EPSILON10));
CHECK(Math::equalsEpsilon(center.height, 0.0, 0.0, Math::EPSILON10));
Math::Epsilon10));
CHECK(Math::equalsEpsilon(center.height, 0.0, 0.0, Math::Epsilon10));
center = S2CellID::fromToken("2ef59bd352b93ac3").getCenter();
CHECK(Math::equalsEpsilon(
center.longitude,
Math::degreesToRadians(105.64131803774308),
0.0,
Math::EPSILON10));
Math::Epsilon10));
CHECK(Math::equalsEpsilon(
center.latitude,
Math::degreesToRadians(-10.490091033598308),
0.0,
Math::EPSILON10));
CHECK(Math::equalsEpsilon(center.height, 0.0, 0.0, Math::EPSILON10));
Math::Epsilon10));
CHECK(Math::equalsEpsilon(center.height, 0.0, 0.0, Math::Epsilon10));
center = S2CellID::fromToken("1234567").getCenter();
CHECK(Math::equalsEpsilon(
center.longitude,
Math::degreesToRadians(9.868307318504081),
0.0,
Math::EPSILON10));
Math::Epsilon10));
CHECK(Math::equalsEpsilon(
center.latitude,
Math::degreesToRadians(27.468392925827605),
0.0,
Math::EPSILON10));
CHECK(Math::equalsEpsilon(center.height, 0.0, 0.0, Math::EPSILON10));
Math::Epsilon10));
CHECK(Math::equalsEpsilon(center.height, 0.0, 0.0, Math::Epsilon10));
}
SECTION("gets correct vertices of cell") {
@ -176,45 +176,45 @@ TEST_CASE("S2CellID") {
vertices[0].longitude,
Math::degreesToRadians(105.64131799299665),
0.0,
Math::EPSILON10));
Math::Epsilon10));
CHECK(Math::equalsEpsilon(
vertices[0].latitude,
Math::degreesToRadians(-10.490091077431977),
0.0,
Math::EPSILON10));
Math::Epsilon10));
CHECK(Math::equalsEpsilon(
vertices[1].longitude,
Math::degreesToRadians(105.64131808248949),
0.0,
Math::EPSILON10));
Math::Epsilon10));
CHECK(Math::equalsEpsilon(
vertices[1].latitude,
Math::degreesToRadians(-10.490091072946313),
0.0,
Math::EPSILON10));
Math::Epsilon10));
CHECK(Math::equalsEpsilon(
vertices[2].longitude,
Math::degreesToRadians(105.64131808248948),
0.0,
Math::EPSILON10));
Math::Epsilon10));
CHECK(Math::equalsEpsilon(
vertices[2].latitude,
Math::degreesToRadians(-10.490090989764633),
0.0,
Math::EPSILON10));
Math::Epsilon10));
CHECK(Math::equalsEpsilon(
vertices[3].longitude,
Math::degreesToRadians(105.64131799299665),
0.0,
Math::EPSILON10));
Math::Epsilon10));
CHECK(Math::equalsEpsilon(
vertices[3].latitude,
Math::degreesToRadians(-10.4900909942503),
0.0,
Math::EPSILON10));
Math::Epsilon10));
}
SECTION("fromQuadtreeTileID") {
@ -245,168 +245,168 @@ TEST_CASE("S2CellID") {
GlobeRectangle root0Rect = root0.computeBoundingRectangle();
CHECK(Math::equalsEpsilon(
root0Rect.getWest(),
-Math::ONE_PI / 4.0,
-Math::OnePi / 4.0,
0.0,
Math::EPSILON14));
Math::Epsilon14));
CHECK(Math::equalsEpsilon(
root0Rect.getEast(),
Math::ONE_PI / 4.0,
Math::OnePi / 4.0,
0.0,
Math::EPSILON14));
Math::Epsilon14));
CHECK(Math::equalsEpsilon(
root0Rect.getSouth(),
-Math::ONE_PI / 4.0,
-Math::OnePi / 4.0,
0.0,
Math::EPSILON14));
Math::Epsilon14));
CHECK(Math::equalsEpsilon(
root0Rect.getNorth(),
Math::ONE_PI / 4.0,
Math::OnePi / 4.0,
0.0,
Math::EPSILON14));
Math::Epsilon14));
S2CellID root1 = S2CellID::fromFaceLevelPosition(1, 0, 0);
GlobeRectangle root1Rect = root1.computeBoundingRectangle();
CHECK(Math::equalsEpsilon(
root1Rect.getWest(),
Math::ONE_PI / 4.0,
Math::OnePi / 4.0,
0.0,
Math::EPSILON14));
Math::Epsilon14));
CHECK(Math::equalsEpsilon(
root1Rect.getEast(),
3.0 * Math::ONE_PI / 4.0,
3.0 * Math::OnePi / 4.0,
0.0,
Math::EPSILON14));
Math::Epsilon14));
CHECK(Math::equalsEpsilon(
root1Rect.getSouth(),
-Math::ONE_PI / 4.0,
-Math::OnePi / 4.0,
0.0,
Math::EPSILON14));
Math::Epsilon14));
CHECK(Math::equalsEpsilon(
root1Rect.getNorth(),
Math::ONE_PI / 4.0,
Math::OnePi / 4.0,
0.0,
Math::EPSILON14));
Math::Epsilon14));
S2CellID root2 = S2CellID::fromFaceLevelPosition(2, 0, 0);
GlobeRectangle root2Rect = root2.computeBoundingRectangle();
CHECK(Math::equalsEpsilon(
root2Rect.getWest(),
-Math::ONE_PI,
-Math::OnePi,
0.0,
Math::EPSILON14));
Math::Epsilon14));
CHECK(Math::equalsEpsilon(
root2Rect.getEast(),
Math::ONE_PI,
Math::OnePi,
0.0,
Math::EPSILON14));
Math::Epsilon14));
// The midpoint of the cell edge is at 45 degrees latitude, but the vertices
// extend significantly lower.
CHECK(root2Rect.getSouth() < Math::ONE_PI / 4.0 - Math::ONE_PI / 20.0);
CHECK(root2Rect.getSouth() < Math::OnePi / 4.0 - Math::OnePi / 20.0);
CHECK(Math::equalsEpsilon(
root2Rect.getNorth(),
Math::ONE_PI / 2.0,
Math::OnePi / 2.0,
0.0,
Math::EPSILON14));
Math::Epsilon14));
S2CellID root3 = S2CellID::fromFaceLevelPosition(3, 0, 0);
GlobeRectangle root3Rect = root3.computeBoundingRectangle();
CHECK(Math::equalsEpsilon(
root3Rect.getWest(),
3.0 * Math::ONE_PI / 4.0,
3.0 * Math::OnePi / 4.0,
0.0,
Math::EPSILON14));
Math::Epsilon14));
CHECK(Math::equalsEpsilon(
root3Rect.getEast(),
-3.0 * Math::ONE_PI / 4.0,
-3.0 * Math::OnePi / 4.0,
0.0,
Math::EPSILON14));
Math::Epsilon14));
CHECK(Math::equalsEpsilon(
root3Rect.getSouth(),
-Math::ONE_PI / 4.0,
-Math::OnePi / 4.0,
0.0,
Math::EPSILON14));
Math::Epsilon14));
CHECK(Math::equalsEpsilon(
root3Rect.getNorth(),
Math::ONE_PI / 4.0,
Math::OnePi / 4.0,
0.0,
Math::EPSILON14));
Math::Epsilon14));
S2CellID root4 = S2CellID::fromFaceLevelPosition(4, 0, 0);
GlobeRectangle root4Rect = root4.computeBoundingRectangle();
CHECK(Math::equalsEpsilon(
root4Rect.getWest(),
-3.0 * Math::ONE_PI / 4.0,
-3.0 * Math::OnePi / 4.0,
0.0,
Math::EPSILON14));
Math::Epsilon14));
CHECK(Math::equalsEpsilon(
root4Rect.getEast(),
-Math::ONE_PI / 4.0,
-Math::OnePi / 4.0,
0.0,
Math::EPSILON14));
Math::Epsilon14));
CHECK(Math::equalsEpsilon(
root4Rect.getSouth(),
-Math::ONE_PI / 4.0,
-Math::OnePi / 4.0,
0.0,
Math::EPSILON14));
Math::Epsilon14));
CHECK(Math::equalsEpsilon(
root4Rect.getNorth(),
Math::ONE_PI / 4.0,
Math::OnePi / 4.0,
0.0,
Math::EPSILON14));
Math::Epsilon14));
S2CellID root5 = S2CellID::fromFaceLevelPosition(5, 0, 0);
GlobeRectangle root5Rect = root5.computeBoundingRectangle();
CHECK(Math::equalsEpsilon(
root5Rect.getWest(),
-Math::ONE_PI,
-Math::OnePi,
0.0,
Math::EPSILON14));
Math::Epsilon14));
CHECK(Math::equalsEpsilon(
root5Rect.getEast(),
Math::ONE_PI,
Math::OnePi,
0.0,
Math::EPSILON14));
Math::Epsilon14));
// The midpoint of the cell edge is at -45 degrees latitude, but the
// vertices extend significantly higher.
CHECK(Math::equalsEpsilon(
root5Rect.getSouth(),
-Math::ONE_PI / 2.0,
-Math::OnePi / 2.0,
0.0,
Math::EPSILON14));
CHECK(root5Rect.getNorth() > -Math::ONE_PI / 4.0 + Math::ONE_PI / 20.0);
Math::Epsilon14));
CHECK(root5Rect.getNorth() > -Math::OnePi / 4.0 + Math::OnePi / 20.0);
S2CellID equatorCell = S2CellID::fromFaceLevelPosition(0, 1, 0);
GlobeRectangle equatorRect = equatorCell.computeBoundingRectangle();
CHECK(Math::equalsEpsilon(
equatorRect.getWest(),
-Math::ONE_PI / 4.0,
-Math::OnePi / 4.0,
0.0,
Math::EPSILON14));
Math::Epsilon14));
CHECK(
Math::equalsEpsilon(equatorRect.getEast(), 0.0, 0.0, Math::EPSILON14));
Math::equalsEpsilon(equatorRect.getEast(), 0.0, 0.0, Math::Epsilon14));
CHECK(Math::equalsEpsilon(
equatorRect.getSouth(),
-Math::ONE_PI / 4.0,
-Math::OnePi / 4.0,
0.0,
Math::EPSILON14));
Math::Epsilon14));
CHECK(
Math::equalsEpsilon(equatorRect.getNorth(), 0.0, 0.0, Math::EPSILON14));
Math::equalsEpsilon(equatorRect.getNorth(), 0.0, 0.0, Math::Epsilon14));
S2CellID polarCell = S2CellID::fromFaceLevelPosition(2, 1, 0);
GlobeRectangle polarRect = polarCell.computeBoundingRectangle();
CHECK(Math::equalsEpsilon(polarRect.getWest(), 0.0, 0.0, Math::EPSILON14));
CHECK(Math::equalsEpsilon(polarRect.getWest(), 0.0, 0.0, Math::Epsilon14));
CHECK(Math::equalsEpsilon(
polarRect.getEast(),
Math::ONE_PI / 2.0,
Math::OnePi / 2.0,
0.0,
Math::EPSILON14));
Math::Epsilon14));
// One vertex of the cell at 45 degrees latitude, but the other extends
// significantly lower.
CHECK(root2Rect.getSouth() < Math::ONE_PI / 4.0 - Math::ONE_PI / 20.0);
CHECK(root2Rect.getSouth() < Math::OnePi / 4.0 - Math::OnePi / 20.0);
CHECK(Math::equalsEpsilon(
polarRect.getNorth(),
Math::ONE_PI / 2,
Math::OnePi / 2,
0.0,
Math::EPSILON14));
Math::Epsilon14));
}
}

View File

@ -348,7 +348,7 @@ struct AccessorTypes {
#pragma pack(pop)
};
namespace Impl {
namespace CesiumImpl {
template <typename TCallback, typename TElement>
std::invoke_result_t<TCallback, AccessorView<AccessorTypes::SCALAR<TElement>>>
createAccessorView(
@ -387,7 +387,7 @@ createAccessorView(
return callback(AccessorView<AccessorTypes::SCALAR<TElement>>(
AccessorViewStatus::InvalidComponentType));
}
} // namespace Impl
} // namespace CesiumImpl
/**
* @brief Creates an appropriate {@link AccessorView} for a given accessor.
@ -412,32 +412,32 @@ createAccessorView(
TCallback&& callback) {
switch (accessor.componentType) {
case Accessor::ComponentType::BYTE:
return ::CesiumGltf::Impl::createAccessorView<TCallback, int8_t>(
return ::CesiumGltf::CesiumImpl::createAccessorView<TCallback, int8_t>(
model,
accessor,
std::forward<TCallback>(callback));
case Accessor::ComponentType::UNSIGNED_BYTE:
return ::CesiumGltf::Impl::createAccessorView<TCallback, uint8_t>(
return ::CesiumGltf::CesiumImpl::createAccessorView<TCallback, uint8_t>(
model,
accessor,
std::forward<TCallback>(callback));
case Accessor::ComponentType::SHORT:
return ::CesiumGltf::Impl::createAccessorView<TCallback, int16_t>(
return ::CesiumGltf::CesiumImpl::createAccessorView<TCallback, int16_t>(
model,
accessor,
std::forward<TCallback>(callback));
case Accessor::ComponentType::UNSIGNED_SHORT:
return ::CesiumGltf::Impl::createAccessorView<TCallback, uint16_t>(
return ::CesiumGltf::CesiumImpl::createAccessorView<TCallback, uint16_t>(
model,
accessor,
std::forward<TCallback>(callback));
case Accessor::ComponentType::UNSIGNED_INT:
return ::CesiumGltf::Impl::createAccessorView<TCallback, uint32_t>(
return ::CesiumGltf::CesiumImpl::createAccessorView<TCallback, uint32_t>(
model,
accessor,
std::forward<TCallback>(callback));
case Accessor::ComponentType::FLOAT:
return ::CesiumGltf::Impl::createAccessorView<TCallback, float>(
return ::CesiumGltf::CesiumImpl::createAccessorView<TCallback, float>(
model,
accessor,
std::forward<TCallback>(callback));

View File

@ -12,82 +12,82 @@ namespace CesiumUtility {
class CESIUMUTILITY_API Math final {
public:
/** @brief 0.1 */
static constexpr double EPSILON1 = 1e-1;
static constexpr double Epsilon1 = 1e-1;
/** @brief 0.01 */
static constexpr double EPSILON2 = 1e-2;
static constexpr double Epsilon2 = 1e-2;
/** @brief 0.001 */
static constexpr double EPSILON3 = 1e-3;
static constexpr double Epsilon3 = 1e-3;
/** @brief 0.0001 */
static constexpr double EPSILON4 = 1e-4;
static constexpr double Epsilon4 = 1e-4;
/** @brief 0.00001 */
static constexpr double EPSILON5 = 1e-5;
static constexpr double Epsilon5 = 1e-5;
/** @brief 0.000001 */
static constexpr double EPSILON6 = 1e-6;
static constexpr double Epsilon6 = 1e-6;
/** @brief 0.0000001 */
static constexpr double EPSILON7 = 1e-7;
static constexpr double Epsilon7 = 1e-7;
/** @brief 0.00000001 */
static constexpr double EPSILON8 = 1e-8;
static constexpr double Epsilon8 = 1e-8;
/** @brief 0.000000001 */
static constexpr double EPSILON9 = 1e-9;
static constexpr double Epsilon9 = 1e-9;
/** @brief 0.0000000001 */
static constexpr double EPSILON10 = 1e-10;
static constexpr double Epsilon10 = 1e-10;
/** @brief 0.00000000001 */
static constexpr double EPSILON11 = 1e-11;
static constexpr double Epsilon11 = 1e-11;
/** @brief 0.000000000001 */
static constexpr double EPSILON12 = 1e-12;
static constexpr double Epsilon12 = 1e-12;
/** @brief 0.0000000000001 */
static constexpr double EPSILON13 = 1e-13;
static constexpr double Epsilon13 = 1e-13;
/** @brief 0.00000000000001 */
static constexpr double EPSILON14 = 1e-14;
static constexpr double Epsilon14 = 1e-14;
/** @brief 0.000000000000001 */
static constexpr double EPSILON15 = 1e-15;
static constexpr double Epsilon15 = 1e-15;
/** @brief 0.0000000000000001 */
static constexpr double EPSILON16 = 1e-16;
static constexpr double Epsilon16 = 1e-16;
/** @brief 0.00000000000000001 */
static constexpr double EPSILON17 = 1e-17;
static constexpr double Epsilon17 = 1e-17;
/** @brief 0.000000000000000001 */
static constexpr double EPSILON18 = 1e-18;
static constexpr double Epsilon18 = 1e-18;
/** @brief 0.0000000000000000001 */
static constexpr double EPSILON19 = 1e-19;
static constexpr double Epsilon19 = 1e-19;
/** @brief 0.00000000000000000001 */
static constexpr double EPSILON20 = 1e-20;
static constexpr double Epsilon20 = 1e-20;
/** @brief 0.000000000000000000001 */
static constexpr double EPSILON21 = 1e-21;
static constexpr double Epsilon21 = 1e-21;
/**
* @brief pi
*/
static constexpr double ONE_PI = 3.14159265358979323846;
static constexpr double OnePi = 3.14159265358979323846;
/**
* @brief two times pi
*/
static constexpr double TWO_PI = ONE_PI * 2.0;
static constexpr double TwoPi = OnePi * 2.0;
/**
* @brief pi divded by two
*/
static constexpr double PI_OVER_TWO = ONE_PI / 2.0;
static constexpr double PiOverTwo = OnePi / 2.0;
/**
* @brief Converts a relative to an absolute epsilon, for the epsilon-equality
@ -264,15 +264,15 @@ public:
* equivalent to the provided angle.
*
* @param angle The angle in radians.
* @returns The angle in the range [`-Math::ONE_PI`, `Math::ONE_PI`].
* @returns The angle in the range [`-Math::OnePi`, `Math::OnePi`].
*/
static double negativePiToPi(double angle) noexcept {
if (angle >= -Math::ONE_PI && angle <= Math::ONE_PI) {
if (angle >= -Math::OnePi && angle <= Math::OnePi) {
// Early exit if the input is already inside the range. This avoids
// unnecessary math which could introduce floating point error.
return angle;
}
return Math::zeroToTwoPi(angle + Math::ONE_PI) - Math::ONE_PI;
return Math::zeroToTwoPi(angle + Math::OnePi) - Math::OnePi;
}
/**
@ -280,17 +280,17 @@ public:
* to the provided angle.
*
* @param angle The angle in radians.
* @returns The angle in the range [0, `Math::TWO_PI`].
* @returns The angle in the range [0, `Math::TwoPi`].
*/
static double zeroToTwoPi(double angle) noexcept {
if (angle >= 0 && angle <= Math::TWO_PI) {
if (angle >= 0 && angle <= Math::TwoPi) {
// Early exit if the input is already inside the range. This avoids
// unnecessary math which could introduce floating point error.
return angle;
}
const double mod = Math::mod(angle, Math::TWO_PI);
if (glm::abs(mod) < Math::EPSILON14 && glm::abs(angle) > Math::EPSILON14) {
return Math::TWO_PI;
const double mod = Math::mod(angle, Math::TwoPi);
if (glm::abs(mod) < Math::Epsilon14 && glm::abs(angle) > Math::Epsilon14) {
return Math::TwoPi;
}
return mod;
}
@ -318,7 +318,7 @@ public:
* @returns The corresponding angle in radians.
*/
static constexpr double degreesToRadians(double angleDegrees) noexcept {
return angleDegrees * Math::ONE_PI / 180.0;
return angleDegrees * Math::OnePi / 180.0;
}
/**
@ -328,7 +328,7 @@ public:
* @returns The corresponding angle in degrees.
*/
static constexpr double radiansToDegrees(double angleRadians) noexcept {
return angleRadians * 180.0 / Math::ONE_PI;
return angleRadians * 180.0 / Math::OnePi;
}
/**
@ -387,25 +387,25 @@ public:
}
/**
* Converts a longitude value, in radians, to the range [`-Math::ONE_PI`,
* `Math::ONE_PI`).
* Converts a longitude value, in radians, to the range [`-Math::OnePi`,
* `Math::OnePi`).
*
* @param angle The longitude value, in radians, to convert to the range
* [`-Math::ONE_PI`, `Math::ONE_PI`).
* @returns The equivalent longitude value in the range [`-Math::ONE_PI`,
* `Math::ONE_PI`).
* [`-Math::OnePi`, `Math::OnePi`).
* @returns The equivalent longitude value in the range [`-Math::OnePi`,
* `Math::OnePi`).
*
* @snippet TestMath.cpp convertLongitudeRange
*/
static double convertLongitudeRange(double angle) noexcept {
constexpr double twoPi = Math::TWO_PI;
constexpr double twoPi = Math::TwoPi;
const double simplified = angle - glm::floor(angle / twoPi) * twoPi;
if (simplified < -Math::ONE_PI) {
if (simplified < -Math::OnePi) {
return simplified + twoPi;
}
if (simplified >= Math::ONE_PI) {
if (simplified >= Math::OnePi) {
return simplified - twoPi;
}

View File

@ -42,13 +42,13 @@
* @param filename The path and named of the file in which to record traces.
*/
#define CESIUM_TRACE_INIT(filename) \
CesiumUtility::Impl::Tracer::instance().startTracing(filename)
CesiumUtility::CesiumImpl::Tracer::instance().startTracing(filename)
/**
* @brief Shuts down tracing and closes the JSON tracing file.
*/
#define CESIUM_TRACE_SHUTDOWN() \
CesiumUtility::Impl::Tracer::instance().endTracing()
CesiumUtility::CesiumImpl::Tracer::instance().endTracing()
/**
* @brief Measures and records the time spent in the current scope.
@ -61,7 +61,9 @@
* @param name The name of the measured operation.
*/
#define CESIUM_TRACE(name) \
CesiumUtility::Impl::ScopedTrace TRACE_NAME_AUX2(cesiumTrace, __LINE__)(name)
CesiumUtility::CesiumImpl::ScopedTrace TRACE_NAME_AUX2( \
cesiumTrace, \
__LINE__)(name)
/**
* @brief Begins measuring an operation which may span scope but not threads.
@ -95,7 +97,7 @@
* @param name The name of the measured operation.
*/
#define CESIUM_TRACE_BEGIN(name) \
CesiumUtility::Impl::Tracer::instance().writeAsyncEventBegin(name)
CesiumUtility::CesiumImpl::Tracer::instance().writeAsyncEventBegin(name)
/**
* @brief Ends measuring an operation which may span scopes but not threads.
@ -107,7 +109,7 @@
* @param name The name of the measured operation.
*/
#define CESIUM_TRACE_END(name) \
CesiumUtility::Impl::Tracer::instance().writeAsyncEventEnd(name)
CesiumUtility::CesiumImpl::Tracer::instance().writeAsyncEventEnd(name)
/**
* @brief Begins measuring an operation that may span both scopes and threads.
@ -120,7 +122,7 @@
* @param name The name of the measured operation.
*/
#define CESIUM_TRACE_BEGIN_IN_TRACK(name) \
if (CesiumUtility::Impl::TrackReference::current() != nullptr) { \
if (CesiumUtility::CesiumImpl::TrackReference::current() != nullptr) { \
CESIUM_TRACE_BEGIN(name); \
}
@ -135,7 +137,7 @@
* @param name The name of the measured operation.
*/
#define CESIUM_TRACE_END_IN_TRACK(name) \
if (CesiumUtility::Impl::TrackReference::current() != nullptr) { \
if (CesiumUtility::CesiumImpl::TrackReference::current() != nullptr) { \
CESIUM_TRACE_END(name); \
}
@ -154,7 +156,7 @@
* @param name A human-friendly name for this set of tracks.
*/
#define CESIUM_TRACE_DECLARE_TRACK_SET(id, name) \
CesiumUtility::Impl::TrackSet id { name }
CesiumUtility::CesiumImpl::TrackSet id { name }
/**
* @brief Begins using a track set in this thread.
@ -168,7 +170,7 @@
* {@link CESIUM_TRACE_DECLARE_TRACK_SET}.
*/
#define CESIUM_TRACE_USE_TRACK_SET(id) \
CesiumUtility::Impl::TrackReference TRACE_NAME_AUX2( \
CesiumUtility::CesiumImpl::TrackReference TRACE_NAME_AUX2( \
cesiumTraceEnlistTrack, \
__LINE__)(id);
@ -182,7 +184,7 @@
* {@link CESIUM_TRACE_USE_CAPTURED_TRACK}.
*/
#define CESIUM_TRACE_LAMBDA_CAPTURE_TRACK() \
tracingTrack = CesiumUtility::Impl::LambdaCaptureTrack()
tracingTrack = CesiumUtility::CesiumImpl::LambdaCaptureTrack()
/**
* @brief Uses a captured track for the current thread and the current scope.
@ -195,7 +197,7 @@
CESIUM_TRACE_USE_TRACK_SET(tracingTrack)
namespace CesiumUtility {
namespace Impl {
namespace CesiumImpl {
// The following are internal classes used by the tracing framework, do not use
// directly.
@ -335,7 +337,7 @@ private:
friend class LambdaCaptureTrack;
};
} // namespace Impl
} // namespace CesiumImpl
} // namespace CesiumUtility
#endif // CESIUM_TRACING_ENABLED

View File

@ -6,7 +6,7 @@
#if CESIUM_TRACING_ENABLED
namespace CesiumUtility {
namespace Impl {
namespace CesiumImpl {
Tracer& Tracer::instance() {
static Tracer instance;
@ -333,7 +333,7 @@ void TrackReference::dismissCurrentThread() {
TrackReference::_threadEnlistedTracks.pop_back();
}
} // namespace Impl
} // namespace CesiumImpl
} // namespace CesiumUtility
#endif // CESIUM_TRACING_ENABLED

View File

@ -22,19 +22,19 @@ TEST_CASE("Math::equalsEpsilon example") {
bool a = CesiumUtility::Math::equalsEpsilon(
0.0,
0.01,
CesiumUtility::Math::EPSILON2); // true
CesiumUtility::Math::Epsilon2); // true
bool b = CesiumUtility::Math::equalsEpsilon(
0.0,
0.1,
CesiumUtility::Math::EPSILON2); // false
CesiumUtility::Math::Epsilon2); // false
bool c = CesiumUtility::Math::equalsEpsilon(
3699175.1634344,
3699175.2,
CesiumUtility::Math::EPSILON7); // true
CesiumUtility::Math::Epsilon7); // true
bool d = CesiumUtility::Math::equalsEpsilon(
3699175.1634344,
3699175.2,
CesiumUtility::Math::EPSILON9); // false
CesiumUtility::Math::Epsilon9); // false
//! [equalsEpsilon]
CHECK(a == true);
@ -74,52 +74,52 @@ TEST_CASE("Math::roundUp and roundDown") {
TEST_CASE("Math::negativePitoPi") {
CHECK(Math::negativePiToPi(0.0) == 0.0);
CHECK(Math::negativePiToPi(+Math::ONE_PI) == +Math::ONE_PI);
CHECK(Math::negativePiToPi(-Math::ONE_PI) == -Math::ONE_PI);
CHECK(Math::negativePiToPi(+Math::ONE_PI - 1.0) == (+Math::ONE_PI - 1.0));
CHECK(Math::negativePiToPi(-Math::ONE_PI + 1.0) == (-Math::ONE_PI + 1.0));
CHECK(Math::negativePiToPi(+Math::ONE_PI - 0.1) == (+Math::ONE_PI - 0.1));
CHECK(Math::negativePiToPi(-Math::ONE_PI + 0.1) == (-Math::ONE_PI + 0.1));
CHECK(Math::negativePiToPi(+Math::OnePi) == +Math::OnePi);
CHECK(Math::negativePiToPi(-Math::OnePi) == -Math::OnePi);
CHECK(Math::negativePiToPi(+Math::OnePi - 1.0) == (+Math::OnePi - 1.0));
CHECK(Math::negativePiToPi(-Math::OnePi + 1.0) == (-Math::OnePi + 1.0));
CHECK(Math::negativePiToPi(+Math::OnePi - 0.1) == (+Math::OnePi - 0.1));
CHECK(Math::negativePiToPi(-Math::OnePi + 0.1) == (-Math::OnePi + 0.1));
CHECK(Math::equalsEpsilon(
Math::negativePiToPi(+Math::ONE_PI + 0.1),
-Math::ONE_PI + 0.1,
Math::EPSILON15));
CHECK(Math::negativePiToPi(+2.0 * Math::ONE_PI) == 0.0);
CHECK(Math::negativePiToPi(-2.0 * Math::ONE_PI) == 0.0);
CHECK(Math::negativePiToPi(+3.0 * Math::ONE_PI) == Math::ONE_PI);
CHECK(Math::negativePiToPi(-3.0 * Math::ONE_PI) == Math::ONE_PI);
CHECK(Math::negativePiToPi(+4.0 * Math::ONE_PI) == 0.0);
CHECK(Math::negativePiToPi(-4.0 * Math::ONE_PI) == 0.0);
CHECK(Math::negativePiToPi(+5.0 * Math::ONE_PI) == Math::ONE_PI);
CHECK(Math::negativePiToPi(-5.0 * Math::ONE_PI) == Math::ONE_PI);
CHECK(Math::negativePiToPi(+6.0 * Math::ONE_PI) == 0.0);
CHECK(Math::negativePiToPi(-6.0 * Math::ONE_PI) == 0.0);
Math::negativePiToPi(+Math::OnePi + 0.1),
-Math::OnePi + 0.1,
Math::Epsilon15));
CHECK(Math::negativePiToPi(+2.0 * Math::OnePi) == 0.0);
CHECK(Math::negativePiToPi(-2.0 * Math::OnePi) == 0.0);
CHECK(Math::negativePiToPi(+3.0 * Math::OnePi) == Math::OnePi);
CHECK(Math::negativePiToPi(-3.0 * Math::OnePi) == Math::OnePi);
CHECK(Math::negativePiToPi(+4.0 * Math::OnePi) == 0.0);
CHECK(Math::negativePiToPi(-4.0 * Math::OnePi) == 0.0);
CHECK(Math::negativePiToPi(+5.0 * Math::OnePi) == Math::OnePi);
CHECK(Math::negativePiToPi(-5.0 * Math::OnePi) == Math::OnePi);
CHECK(Math::negativePiToPi(+6.0 * Math::OnePi) == 0.0);
CHECK(Math::negativePiToPi(-6.0 * Math::OnePi) == 0.0);
}
TEST_CASE("Math::zeroToTwoPi") {
CHECK(Math::zeroToTwoPi(0.0) == 0.0);
CHECK(Math::zeroToTwoPi(+Math::ONE_PI) == +Math::ONE_PI);
CHECK(Math::zeroToTwoPi(-Math::ONE_PI) == +Math::ONE_PI);
CHECK(Math::zeroToTwoPi(+Math::ONE_PI - 1.0) == (+Math::ONE_PI - 1.0));
CHECK(Math::zeroToTwoPi(+Math::OnePi) == +Math::OnePi);
CHECK(Math::zeroToTwoPi(-Math::OnePi) == +Math::OnePi);
CHECK(Math::zeroToTwoPi(+Math::OnePi - 1.0) == (+Math::OnePi - 1.0));
CHECK(Math::equalsEpsilon(
Math::zeroToTwoPi(-Math::ONE_PI + 1.0),
+Math::ONE_PI + 1.0,
Math::EPSILON15));
CHECK(Math::zeroToTwoPi(+Math::ONE_PI - 0.1) == (+Math::ONE_PI - 0.1));
Math::zeroToTwoPi(-Math::OnePi + 1.0),
+Math::OnePi + 1.0,
Math::Epsilon15));
CHECK(Math::zeroToTwoPi(+Math::OnePi - 0.1) == (+Math::OnePi - 0.1));
CHECK(Math::equalsEpsilon(
Math::zeroToTwoPi(-Math::ONE_PI + 0.1),
+Math::ONE_PI + 0.1,
Math::EPSILON15));
CHECK(Math::zeroToTwoPi(+2.0 * Math::ONE_PI) == (2.0 * Math::ONE_PI));
CHECK(Math::zeroToTwoPi(-2.0 * Math::ONE_PI) == (2.0 * Math::ONE_PI));
CHECK(Math::zeroToTwoPi(+3.0 * Math::ONE_PI) == Math::ONE_PI);
CHECK(Math::zeroToTwoPi(-3.0 * Math::ONE_PI) == Math::ONE_PI);
CHECK(Math::zeroToTwoPi(+4.0 * Math::ONE_PI) == (2.0 * Math::ONE_PI));
CHECK(Math::zeroToTwoPi(-4.0 * Math::ONE_PI) == (2.0 * Math::ONE_PI));
CHECK(Math::zeroToTwoPi(+5.0 * Math::ONE_PI) == Math::ONE_PI);
CHECK(Math::zeroToTwoPi(-5.0 * Math::ONE_PI) == Math::ONE_PI);
CHECK(Math::zeroToTwoPi(+6.0 * Math::ONE_PI) == (2.0 * Math::ONE_PI));
CHECK(Math::zeroToTwoPi(-6.0 * Math::ONE_PI) == (2.0 * Math::ONE_PI));
Math::zeroToTwoPi(-Math::OnePi + 0.1),
+Math::OnePi + 0.1,
Math::Epsilon15));
CHECK(Math::zeroToTwoPi(+2.0 * Math::OnePi) == (2.0 * Math::OnePi));
CHECK(Math::zeroToTwoPi(-2.0 * Math::OnePi) == (2.0 * Math::OnePi));
CHECK(Math::zeroToTwoPi(+3.0 * Math::OnePi) == Math::OnePi);
CHECK(Math::zeroToTwoPi(-3.0 * Math::OnePi) == Math::OnePi);
CHECK(Math::zeroToTwoPi(+4.0 * Math::OnePi) == (2.0 * Math::OnePi));
CHECK(Math::zeroToTwoPi(-4.0 * Math::OnePi) == (2.0 * Math::OnePi));
CHECK(Math::zeroToTwoPi(+5.0 * Math::OnePi) == Math::OnePi);
CHECK(Math::zeroToTwoPi(-5.0 * Math::OnePi) == Math::OnePi);
CHECK(Math::zeroToTwoPi(+6.0 * Math::OnePi) == (2.0 * Math::OnePi));
CHECK(Math::zeroToTwoPi(-6.0 * Math::OnePi) == (2.0 * Math::OnePi));
}
TEST_CASE("Math::mod") {
@ -127,20 +127,20 @@ TEST_CASE("Math::mod") {
CHECK(Math::mod(0.1, 1.0) == 0.1);
CHECK(Math::mod(0.5, 1.0) == 0.5);
CHECK(Math::mod(1.0, 1.0) == 0.0);
CHECK(Math::equalsEpsilon(Math::mod(1.1, 1.0), 0.1, Math::EPSILON15));
CHECK(Math::equalsEpsilon(Math::mod(1.1, 1.0), 0.1, Math::Epsilon15));
CHECK(Math::mod(-0.0, 1.0) == 0.0);
CHECK(Math::mod(-0.1, 1.0) == 0.9);
CHECK(Math::mod(-0.5, 1.0) == 0.5);
CHECK(Math::mod(-1.0, 1.0) == 0.0);
CHECK(Math::equalsEpsilon(Math::mod(-1.1, 1.0), 0.9, Math::EPSILON15));
CHECK(Math::equalsEpsilon(Math::mod(-1.1, 1.0), 0.9, Math::Epsilon15));
CHECK(Math::mod(0.0, -1.0) == -0.0);
CHECK(Math::mod(0.1, -1.0) == -0.9);
CHECK(Math::mod(0.5, -1.0) == -0.5);
CHECK(Math::mod(1.0, -1.0) == -0.0);
CHECK(Math::equalsEpsilon(Math::mod(1.1, -1.0), -0.9, Math::EPSILON15));
CHECK(Math::equalsEpsilon(Math::mod(1.1, -1.0), -0.9, Math::Epsilon15));
CHECK(Math::mod(-0.0, -1.0) == -0.0);
CHECK(Math::mod(-0.1, -1.0) == -0.1);
CHECK(Math::mod(-0.5, -1.0) == -0.5);
CHECK(Math::mod(-1.0, -1.0) == -0.0);
CHECK(Math::equalsEpsilon(Math::mod(-1.1, -1.0), -0.1, Math::EPSILON15));
CHECK(Math::equalsEpsilon(Math::mod(-1.1, -1.0), -0.1, Math::Epsilon15));
}

@ -1 +1 @@
Subproject commit 172ca3f8e0df1b3f7f5ee8b8244e4ac67258b0d8
Subproject commit 756893feb9e69c098225d5a454a668a2c139e4be