-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:CesiumGS/cesium-native into fix-mis…
…sing-ellipsoid
- Loading branch information
Showing
14 changed files
with
366 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,101 @@ | ||
#include "CesiumGeometry/Axis.h" | ||
#include "CesiumGeometry/Transforms.h" | ||
|
||
#include <CesiumUtility/Math.h> | ||
|
||
#include <catch2/catch.hpp> | ||
#include <glm/mat4x4.hpp> | ||
|
||
using namespace CesiumGeometry; | ||
|
||
TEST_CASE("Transforms convert the axes correctly") { | ||
|
||
glm::dvec4 X_AXIS{1.0, 0.0, 0.0, 0.0}; | ||
glm::dvec4 Y_AXIS{0.0, 1.0, 0.0, 0.0}; | ||
glm::dvec4 Z_AXIS{0.0, 0.0, 1.0, 0.0}; | ||
|
||
SECTION("Y_UP_TO_Z_UP transforms X to X, Y to -Z, and Z to Y") { | ||
REQUIRE(X_AXIS * CesiumGeometry::Transforms::Y_UP_TO_Z_UP == X_AXIS); | ||
REQUIRE(Y_AXIS * CesiumGeometry::Transforms::Y_UP_TO_Z_UP == -Z_AXIS); | ||
REQUIRE(Z_AXIS * CesiumGeometry::Transforms::Y_UP_TO_Z_UP == Y_AXIS); | ||
REQUIRE(X_AXIS * Transforms::Y_UP_TO_Z_UP == X_AXIS); | ||
REQUIRE(Y_AXIS * Transforms::Y_UP_TO_Z_UP == -Z_AXIS); | ||
REQUIRE(Z_AXIS * Transforms::Y_UP_TO_Z_UP == Y_AXIS); | ||
} | ||
SECTION("Z_UP_TO_Y_UP transforms X to X, Y to Z, and Z to -Y") { | ||
REQUIRE(X_AXIS * CesiumGeometry::Transforms::Z_UP_TO_Y_UP == X_AXIS); | ||
REQUIRE(Y_AXIS * CesiumGeometry::Transforms::Z_UP_TO_Y_UP == Z_AXIS); | ||
REQUIRE(Z_AXIS * CesiumGeometry::Transforms::Z_UP_TO_Y_UP == -Y_AXIS); | ||
REQUIRE(X_AXIS * Transforms::Z_UP_TO_Y_UP == X_AXIS); | ||
REQUIRE(Y_AXIS * Transforms::Z_UP_TO_Y_UP == Z_AXIS); | ||
REQUIRE(Z_AXIS * Transforms::Z_UP_TO_Y_UP == -Y_AXIS); | ||
} | ||
|
||
SECTION("X_UP_TO_Z_UP transforms X to -Z, Y to Y, and Z to X") { | ||
REQUIRE(X_AXIS * CesiumGeometry::Transforms::X_UP_TO_Z_UP == -Z_AXIS); | ||
REQUIRE(Y_AXIS * CesiumGeometry::Transforms::X_UP_TO_Z_UP == Y_AXIS); | ||
REQUIRE(Z_AXIS * CesiumGeometry::Transforms::X_UP_TO_Z_UP == X_AXIS); | ||
REQUIRE(X_AXIS * Transforms::X_UP_TO_Z_UP == -Z_AXIS); | ||
REQUIRE(Y_AXIS * Transforms::X_UP_TO_Z_UP == Y_AXIS); | ||
REQUIRE(Z_AXIS * Transforms::X_UP_TO_Z_UP == X_AXIS); | ||
} | ||
SECTION("Z_UP_TO_X_UP transforms X to Z, Y to Y, and Z to -X") { | ||
REQUIRE(X_AXIS * CesiumGeometry::Transforms::Z_UP_TO_X_UP == Z_AXIS); | ||
REQUIRE(Y_AXIS * CesiumGeometry::Transforms::Z_UP_TO_X_UP == Y_AXIS); | ||
REQUIRE(Z_AXIS * CesiumGeometry::Transforms::Z_UP_TO_X_UP == -X_AXIS); | ||
REQUIRE(X_AXIS * Transforms::Z_UP_TO_X_UP == Z_AXIS); | ||
REQUIRE(Y_AXIS * Transforms::Z_UP_TO_X_UP == Y_AXIS); | ||
REQUIRE(Z_AXIS * Transforms::Z_UP_TO_X_UP == -X_AXIS); | ||
} | ||
|
||
SECTION("X_UP_TO_Y_UP transforms X to -Y, Y to X, and Z to Z") { | ||
REQUIRE(X_AXIS * CesiumGeometry::Transforms::X_UP_TO_Y_UP == -Y_AXIS); | ||
REQUIRE(Y_AXIS * CesiumGeometry::Transforms::X_UP_TO_Y_UP == X_AXIS); | ||
REQUIRE(Z_AXIS * CesiumGeometry::Transforms::X_UP_TO_Y_UP == Z_AXIS); | ||
REQUIRE(X_AXIS * Transforms::X_UP_TO_Y_UP == -Y_AXIS); | ||
REQUIRE(Y_AXIS * Transforms::X_UP_TO_Y_UP == X_AXIS); | ||
REQUIRE(Z_AXIS * Transforms::X_UP_TO_Y_UP == Z_AXIS); | ||
} | ||
SECTION("Y_UP_TO_X_UP transforms X to Y, Y to -X, and Z to Z") { | ||
REQUIRE(X_AXIS * CesiumGeometry::Transforms::Y_UP_TO_X_UP == Y_AXIS); | ||
REQUIRE(Y_AXIS * CesiumGeometry::Transforms::Y_UP_TO_X_UP == -X_AXIS); | ||
REQUIRE(Z_AXIS * CesiumGeometry::Transforms::Y_UP_TO_X_UP == Z_AXIS); | ||
REQUIRE(X_AXIS * Transforms::Y_UP_TO_X_UP == Y_AXIS); | ||
REQUIRE(Y_AXIS * Transforms::Y_UP_TO_X_UP == -X_AXIS); | ||
REQUIRE(Z_AXIS * Transforms::Y_UP_TO_X_UP == Z_AXIS); | ||
} | ||
} | ||
|
||
TEST_CASE("Gets up axis transform") { | ||
const glm::dmat4 Identity(1.0); | ||
|
||
SECTION("Gets X-up to X-up transform") { | ||
CHECK(Transforms::getUpAxisTransform(Axis::X, Axis::X) == Identity); | ||
} | ||
|
||
SECTION("Gets X-up to Y-up transform") { | ||
CHECK( | ||
Transforms::getUpAxisTransform(Axis::X, Axis::Y) == | ||
Transforms::X_UP_TO_Y_UP); | ||
} | ||
|
||
SECTION("Gets X-up to Z-up transform") { | ||
CHECK( | ||
Transforms::getUpAxisTransform(Axis::X, Axis::Z) == | ||
Transforms::X_UP_TO_Z_UP); | ||
} | ||
|
||
SECTION("Gets Y-up to X-up transform") { | ||
CHECK( | ||
Transforms::getUpAxisTransform(Axis::Y, Axis::X) == | ||
Transforms::Y_UP_TO_X_UP); | ||
} | ||
|
||
SECTION("Gets Y-up to Y-up transform") { | ||
CHECK(Transforms::getUpAxisTransform(Axis::Y, Axis::Y) == Identity); | ||
} | ||
|
||
SECTION("Gets Y-up to Z-up transform") { | ||
CHECK( | ||
Transforms::getUpAxisTransform(Axis::Y, Axis::Z) == | ||
Transforms::Y_UP_TO_Z_UP); | ||
} | ||
|
||
SECTION("Gets Z-up to X-up transform") { | ||
CHECK( | ||
Transforms::getUpAxisTransform(Axis::Z, Axis::X) == | ||
Transforms::Z_UP_TO_X_UP); | ||
} | ||
|
||
SECTION("Gets Z-up to Y-up transform") { | ||
CHECK( | ||
Transforms::getUpAxisTransform(Axis::Z, Axis::Y) == | ||
Transforms::Z_UP_TO_Y_UP); | ||
} | ||
|
||
SECTION("Gets Z-up to Z-up transform") { | ||
CHECK(Transforms::getUpAxisTransform(Axis::Z, Axis::Z) == Identity); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#pragma once | ||
#include <gsl/span> | ||
|
||
#include <vector> | ||
|
||
namespace CesiumUtility { | ||
|
||
/** | ||
* @brief Checks whether the data is gzipped. | ||
* | ||
* @param data The data. | ||
* | ||
* @returns Whether the data is gzipped | ||
*/ | ||
bool isGzip(const gsl::span<const std::byte>& data); | ||
|
||
/** | ||
* @brief Gzips data. | ||
* | ||
* If successful, it will return true and the result will be in the | ||
* provided vector. | ||
* | ||
* @param data The data to gzip. | ||
* @param out The gzipped data. | ||
* | ||
* @returns True if successful, false otherwise. | ||
*/ | ||
bool gzip(const gsl::span<const std::byte>& data, std::vector<std::byte>& out); | ||
|
||
/** | ||
* @brief Gunzips data. | ||
* | ||
* If successful, it will return true and the result will be in the | ||
* provided vector. | ||
* | ||
* @param data The data to gunzip. | ||
* @param out The gunzipped data. | ||
* | ||
* @returns True if successful, false otherwise. | ||
*/ | ||
bool gunzip( | ||
const gsl::span<const std::byte>& data, | ||
std::vector<std::byte>& out); | ||
|
||
} // namespace CesiumUtility |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.