Fix translation bug, try to appease clang-tidy
This commit is contained in:
parent
2dca62180f
commit
116743cc0b
|
|
@ -7,6 +7,7 @@
|
|||
#include <CesiumGeometry/OctreeTileID.h>
|
||||
#include <CesiumGeometry/OrientedBoundingBox.h>
|
||||
#include <CesiumGeometry/QuadtreeTileID.h>
|
||||
#include <CesiumGeometry/Transforms.h>
|
||||
#include <CesiumGeospatial/BoundingRegion.h>
|
||||
#include <CesiumGeospatial/Ellipsoid.h>
|
||||
#include <CesiumGeospatial/GlobeRectangle.h>
|
||||
|
|
@ -15,7 +16,7 @@
|
|||
#include <CesiumUtility/Uri.h>
|
||||
|
||||
#include <glm/ext/matrix_double3x3.hpp>
|
||||
#include <glm/ext/matrix_transform.hpp>
|
||||
#include <glm/ext/vector_double2.hpp>
|
||||
#include <glm/ext/vector_double3.hpp>
|
||||
#include <libmorton/morton.h>
|
||||
|
||||
|
|
@ -403,16 +404,32 @@ ImplicitTilingUtilities::computeBoundingVolume(
|
|||
|
||||
// Due to the smaller height, the region has to be translated along its local
|
||||
// height axis.
|
||||
glm::dvec3 heightOffset(
|
||||
0.0,
|
||||
0.0,
|
||||
0.5 * (-rootHeight + heightDim * double(tileID.z + 1)));
|
||||
// Start at the center of the bottommost tiles:
|
||||
double heightOffset = -0.5 * rootHeight + 0.5 * heightDim;
|
||||
// Then offset according to tileID.z.
|
||||
heightOffset += heightDim * double(tileID.z);
|
||||
|
||||
// However, this translation needs to be done before the previous translation
|
||||
// or rotation are applied.
|
||||
glm::dmat4 transform =
|
||||
CesiumGeometry::Transforms::createTranslationRotationScaleMatrix(
|
||||
rootBoundingVolume.getTranslation(),
|
||||
rootBoundingVolume.getRotation(),
|
||||
glm::dvec3(1.0)) *
|
||||
glm::translate(glm::dmat4(1.0), glm::dvec3(0.0, 0.0, heightOffset));
|
||||
|
||||
glm::dvec3 translation(0.0);
|
||||
glm::dquat rotation(1.0, 0.0, 0.0, 0.0);
|
||||
|
||||
CesiumGeometry::Transforms::computeTranslationRotationScaleFromMatrix(
|
||||
transform,
|
||||
&translation,
|
||||
&rotation,
|
||||
nullptr);
|
||||
|
||||
// However, this translation needs to be done before the previous translation / rotation are applied...
|
||||
// TODO glm::translate(glm::dmat4(1.0), heightOffset);
|
||||
return CesiumGeometry::BoundingCylinderRegion(
|
||||
rootBoundingVolume.getTranslation(),
|
||||
rootBoundingVolume.getRotation(),
|
||||
translation,
|
||||
rotation,
|
||||
heightDim,
|
||||
glm::dvec2(minRadius, minRadius + radiusDim),
|
||||
glm::dvec2(minAngle, minAngle + angleDim));
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include <Cesium3DTiles/BoundingVolume.h>
|
||||
#include <Cesium3DTiles/Extension3dTilesBoundingVolumeCylinder.h>
|
||||
#include <Cesium3DTiles/Extension3dTilesBoundingVolumeS2.h>
|
||||
#include <CesiumGeometry/BoundingCylinderRegion.h>
|
||||
#include <CesiumGeometry/BoundingSphere.h>
|
||||
#include <CesiumGeometry/OrientedBoundingBox.h>
|
||||
#include <CesiumGeometry/Transforms.h>
|
||||
|
|
@ -11,7 +12,7 @@
|
|||
#include <CesiumGeospatial/S2CellBoundingVolume.h>
|
||||
#include <CesiumGeospatial/S2CellID.h>
|
||||
|
||||
#include <glm/gtx/quaternion.hpp>
|
||||
#include <glm/ext/quaternion_double.hpp>
|
||||
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include <CesiumGeometry/OctreeTileID.h>
|
||||
#include <CesiumGeometry/OrientedBoundingBox.h>
|
||||
#include <CesiumGeometry/QuadtreeTileID.h>
|
||||
#include <CesiumGeometry/Transforms.h>
|
||||
#include <CesiumGeospatial/BoundingRegion.h>
|
||||
#include <CesiumGeospatial/Ellipsoid.h>
|
||||
#include <CesiumGeospatial/S2CellBoundingVolume.h>
|
||||
|
|
@ -463,6 +464,126 @@ TEST_CASE("ImplicitTilingUtilities::computeBoundingVolume") {
|
|||
}
|
||||
}
|
||||
|
||||
SUBCASE("BoundingCylinderRegion") {
|
||||
BoundingCylinderRegion root(
|
||||
glm::dvec3(1.0, 2.0, 3.0),
|
||||
glm::dquat(CesiumGeometry::Transforms::Z_UP_TO_Y_UP),
|
||||
2.0,
|
||||
glm::dvec2(0.0, 1.0));
|
||||
|
||||
SUBCASE("quadtree") {
|
||||
BoundingCylinderRegion l1x0y0 =
|
||||
ImplicitTilingUtilities::computeBoundingVolume(
|
||||
root,
|
||||
QuadtreeTileID(1, 0, 0));
|
||||
|
||||
CHECK(l1x0y0.getHeight() == root.getHeight());
|
||||
CHECK(l1x0y0.getRadialBounds() == glm::dvec2(0.0, 0.5));
|
||||
CHECK(
|
||||
l1x0y0.getAngularBounds() ==
|
||||
glm::dvec2(-CesiumUtility::Math::OnePi, 0.0));
|
||||
CHECK(l1x0y0.getRotation() == root.getRotation());
|
||||
CHECK(l1x0y0.getTranslation() == root.getTranslation());
|
||||
|
||||
BoundingCylinderRegion l1x1y0 =
|
||||
ImplicitTilingUtilities::computeBoundingVolume(
|
||||
root,
|
||||
QuadtreeTileID(1, 1, 0));
|
||||
|
||||
CHECK(l1x1y0.getHeight() == root.getHeight());
|
||||
CHECK(l1x1y0.getRadialBounds() == glm::dvec2(0.5, 1.0));
|
||||
CHECK(
|
||||
l1x1y0.getAngularBounds() ==
|
||||
glm::dvec2(-CesiumUtility::Math::OnePi, 0.0));
|
||||
CHECK(l1x1y0.getRotation() == root.getRotation());
|
||||
CHECK(l1x1y0.getTranslation() == root.getTranslation());
|
||||
|
||||
BoundingCylinderRegion l1x0y1 =
|
||||
ImplicitTilingUtilities::computeBoundingVolume(
|
||||
root,
|
||||
QuadtreeTileID(1, 0, 1));
|
||||
CHECK(l1x0y1.getHeight() == root.getHeight());
|
||||
CHECK(l1x0y1.getRadialBounds() == glm::dvec2(0.0, 0.5));
|
||||
CHECK(
|
||||
l1x0y1.getAngularBounds() ==
|
||||
glm::dvec2(0.0, CesiumUtility::Math::OnePi));
|
||||
CHECK(l1x0y1.getRotation() == root.getRotation());
|
||||
CHECK(l1x0y1.getTranslation() == root.getTranslation());
|
||||
}
|
||||
|
||||
SUBCASE("octree") {
|
||||
double expectedHeight = 0.5 * root.getHeight();
|
||||
|
||||
BoundingCylinderRegion l1x0y0z0 =
|
||||
ImplicitTilingUtilities::computeBoundingVolume(
|
||||
root,
|
||||
OctreeTileID(1, 0, 0, 0));
|
||||
{
|
||||
CHECK(l1x0y0z0.getHeight() == expectedHeight);
|
||||
CHECK(l1x0y0z0.getRadialBounds() == glm::dvec2(0.0, 0.5));
|
||||
CHECK(
|
||||
l1x0y0z0.getAngularBounds() ==
|
||||
glm::dvec2(-CesiumUtility::Math::OnePi, 0.0));
|
||||
CHECK(l1x0y0z0.getRotation() == root.getRotation());
|
||||
|
||||
glm::dvec3 expectedTranslation =
|
||||
root.getTranslation() + glm::dvec3(0.0, -0.5 * expectedHeight, 0.0);
|
||||
CHECK(l1x0y0z0.getTranslation() == expectedTranslation);
|
||||
}
|
||||
|
||||
BoundingCylinderRegion l1x1y0z0 =
|
||||
ImplicitTilingUtilities::computeBoundingVolume(
|
||||
root,
|
||||
OctreeTileID(1, 1, 0, 0));
|
||||
{
|
||||
CHECK(l1x1y0z0.getHeight() == expectedHeight);
|
||||
CHECK(l1x1y0z0.getRadialBounds() == glm::dvec2(0.5, 1.0));
|
||||
CHECK(
|
||||
l1x1y0z0.getAngularBounds() ==
|
||||
glm::dvec2(-CesiumUtility::Math::OnePi, 0.0));
|
||||
CHECK(l1x1y0z0.getRotation() == root.getRotation());
|
||||
|
||||
glm::dvec3 expectedTranslation =
|
||||
root.getTranslation() + glm::dvec3(0.0, -0.5 * expectedHeight, 0.0);
|
||||
CHECK(l1x1y0z0.getTranslation() == expectedTranslation);
|
||||
}
|
||||
|
||||
BoundingCylinderRegion l1x0y1z0 =
|
||||
ImplicitTilingUtilities::computeBoundingVolume(
|
||||
root,
|
||||
OctreeTileID(1, 0, 1, 0));
|
||||
{
|
||||
CHECK(l1x0y1z0.getHeight() == expectedHeight);
|
||||
CHECK(l1x0y1z0.getRadialBounds() == glm::dvec2(0.0, 0.5));
|
||||
CHECK(
|
||||
l1x0y1z0.getAngularBounds() ==
|
||||
glm::dvec2(0.0, CesiumUtility::Math::OnePi));
|
||||
CHECK(l1x0y1z0.getRotation() == root.getRotation());
|
||||
|
||||
glm::dvec3 expectedTranslation =
|
||||
root.getTranslation() + glm::dvec3(0.0, -0.5 * expectedHeight, 0.0);
|
||||
CHECK(l1x0y1z0.getTranslation() == expectedTranslation);
|
||||
}
|
||||
|
||||
BoundingCylinderRegion l1x0y0z1 =
|
||||
ImplicitTilingUtilities::computeBoundingVolume(
|
||||
root,
|
||||
OctreeTileID(1, 0, 0, 1));
|
||||
{
|
||||
CHECK(l1x0y0z1.getHeight() == expectedHeight);
|
||||
CHECK(l1x0y0z1.getRadialBounds() == glm::dvec2(0.0, 0.5));
|
||||
CHECK(
|
||||
l1x0y0z1.getAngularBounds() ==
|
||||
glm::dvec2(-CesiumUtility::Math::OnePi, 0.0));
|
||||
CHECK(l1x0y0z1.getRotation() == root.getRotation());
|
||||
|
||||
glm::dvec3 expectedTranslation =
|
||||
root.getTranslation() + glm::dvec3(0.0, 0.5 * expectedHeight, 0.0);
|
||||
CHECK(l1x0y0z1.getTranslation() == expectedTranslation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SUBCASE("BoundingVolume") {
|
||||
SUBCASE("quadtree") {
|
||||
BoundingVolume root{};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include "Cesium3DTilesSelection/BoundingVolume.h"
|
||||
|
||||
#include <CesiumGeometry/BoundingCylinderRegion.h>
|
||||
#include <CesiumGeometry/BoundingSphere.h>
|
||||
#include <CesiumGeometry/OrientedBoundingBox.h>
|
||||
#include <CesiumGeospatial/BoundingRegion.h>
|
||||
|
|
@ -268,7 +269,8 @@ OrientedBoundingBox getOrientedBoundingBoxFromBoundingVolume(
|
|||
return s2.computeBoundingRegion(ellipsoid).getBoundingBox();
|
||||
}
|
||||
|
||||
OrientedBoundingBox operator()(const BoundingCylinderRegion& cylinderRegion) const {
|
||||
OrientedBoundingBox
|
||||
operator()(const BoundingCylinderRegion& cylinderRegion) const {
|
||||
return cylinderRegion.toOrientedBoundingBox();
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -36,11 +36,15 @@
|
|||
#include <CesiumUtility/Assert.h>
|
||||
#include <CesiumUtility/ErrorList.h>
|
||||
#include <CesiumUtility/JsonHelpers.h>
|
||||
#include <CesiumUtility/Math.h>
|
||||
#include <CesiumUtility/Uri.h>
|
||||
|
||||
#include <fmt/format.h>
|
||||
#include <glm/common.hpp>
|
||||
#include <glm/detail/setup.hpp>
|
||||
#include <glm/ext/matrix_double4x4.hpp>
|
||||
#include <glm/ext/quaternion_double.hpp>
|
||||
#include <glm/ext/vector_double3.hpp>
|
||||
#include <glm/geometric.hpp>
|
||||
#include <glm/gtx/quaternion.hpp>
|
||||
#include <rapidjson/document.h>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include <Cesium3DTilesSelection/BoundingVolume.h>
|
||||
#include <Cesium3DTilesSelection/ViewState.h>
|
||||
#include <CesiumGeometry/BoundingCylinderRegion.h>
|
||||
#include <CesiumGeometry/BoundingSphere.h>
|
||||
#include <CesiumGeometry/CullingResult.h>
|
||||
#include <CesiumGeometry/CullingVolume.h>
|
||||
|
|
|
|||
|
|
@ -2,13 +2,19 @@
|
|||
|
||||
#include "CesiumGeometry/AxisAlignedBox.h"
|
||||
#include "CesiumGeometry/CullingResult.h"
|
||||
#include "CesiumGeometry/OrientedBoundingBox.h"
|
||||
#include "CesiumGeometry/Plane.h"
|
||||
#include "CesiumGeometry/Transforms.h"
|
||||
#include "CesiumUtility/Math.h"
|
||||
|
||||
#include <glm/detail/func_matrix.inl>
|
||||
#include <glm/ext/matrix_double4x4.hpp>
|
||||
#include <glm/ext/matrix_transform.hpp>
|
||||
#include <glm/mat3x3.hpp>
|
||||
#include <glm/mat4x4.hpp>
|
||||
#include <glm/vec3.hpp>
|
||||
#include <glm/ext/vector_double2.hpp>
|
||||
#include <glm/ext/vector_double3.hpp>
|
||||
#include <glm/gtc/quaternion.hpp>
|
||||
|
||||
#include <cmath>
|
||||
|
||||
namespace CesiumGeometry {
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue