Skip to content

Commit

Permalink
Add missing paths for BoundingCylinder
Browse files Browse the repository at this point in the history
  • Loading branch information
j9liu committed Dec 20, 2024
1 parent 21a6672 commit 119a6da
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class S2CellBoundingVolume;

namespace CesiumGeometry {
class OrientedBoundingBox;
class BoundingCylinder;
}

namespace Cesium3DTiles {
Expand Down
7 changes: 4 additions & 3 deletions Cesium3DTilesContent/src/ImplicitTilingUtilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,16 @@ Cesium3DTiles::BoundingVolume computeBoundingVolumeInternal(
}

std::optional<BoundingCylinder> maybeCylinder =
TileBoundingVolumes::getBoundingCylinder(rootBoundingVolume, ellipsoid);
TileBoundingVolumes::getBoundingCylinder(rootBoundingVolume);
if (maybeCylinder) {
BoundingCylinder cylinder =
ImplicitTilingUtilities::computeBoundingVolume(*maybeCylinder tileID);
TileBoundingVolumes::setBoundingCylinder(result, maybeCylinder);
ImplicitTilingUtilities::computeBoundingVolume(*maybeCylinder, tileID);
TileBoundingVolumes::setBoundingCylinder(result, cylinder);
}

return result;
}

} // namespace

Cesium3DTiles::BoundingVolume ImplicitTilingUtilities::computeBoundingVolume(
Expand Down
6 changes: 6 additions & 0 deletions Cesium3DTilesSelection/src/ImplicitOctreeLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ struct BoundingVolumeSubdivision {
return ImplicitTilingUtilities::computeBoundingVolume(obb, this->tileID);
}

BoundingVolume operator()(const CesiumGeometry::BoundingCylinder& cylinder) {
return ImplicitTilingUtilities::computeBoundingVolume(
cylinder,
this->tileID);
}

const CesiumGeometry::OctreeTileID& tileID;
const CesiumGeospatial::Ellipsoid& ellipsoid;
};
Expand Down
4 changes: 3 additions & 1 deletion Cesium3DTilesSelection/src/ImplicitOctreeLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <Cesium3DTilesContent/SubtreeAvailability.h>
#include <Cesium3DTilesSelection/TilesetContentLoader.h>
#include <CesiumGeometry/BoundingCylinder.h>
#include <CesiumGeometry/OctreeTileID.h>
#include <CesiumGeometry/OrientedBoundingBox.h>
#include <CesiumGeospatial/BoundingRegion.h>
Expand All @@ -15,7 +16,8 @@
namespace Cesium3DTilesSelection {
using ImplicitOctreeBoundingVolume = std::variant<
CesiumGeospatial::BoundingRegion,
CesiumGeometry::OrientedBoundingBox>;
CesiumGeometry::OrientedBoundingBox,
CesiumGeometry::BoundingCylinder>;

class ImplicitOctreeLoader : public TilesetContentLoader {
public:
Expand Down
7 changes: 7 additions & 0 deletions Cesium3DTilesSelection/src/TilesetHeightQuery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ bool boundingVolumeContainsCoordinate(
return s2Cell.computeBoundingRegion(ellipsoid).getRectangle().contains(
coordinate);
}

bool operator()(const BoundingCylinder& cylinder) noexcept {
std::optional<double> t = IntersectionTests::rayOBBParametric(
ray,
OrientedBoundingBox::fromCylinder(cylinder));
return t && t.value() >= 0;
}
};

return std::visit(Operation{ray, coordinate, ellipsoid}, boundingVolume);
Expand Down
13 changes: 13 additions & 0 deletions Cesium3DTilesSelection/src/TilesetJsonLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <Cesium3DTilesSelection/TileID.h>
#include <CesiumAsync/AsyncSystem.h>
#include <CesiumAsync/IAssetResponse.h>
#include <CesiumGeometry/BoundingCylinder.h>
#include <CesiumGeometry/BoundingSphere.h>
#include <CesiumGeometry/OrientedBoundingBox.h>
#include <CesiumGeospatial/BoundingRegion.h>
Expand Down Expand Up @@ -295,6 +296,8 @@ void createImplicitOctreeLoader(
std::get_if<CesiumGeospatial::BoundingRegion>(&boundingVolume);
const CesiumGeometry::OrientedBoundingBox* pBox =
std::get_if<CesiumGeometry::OrientedBoundingBox>(&boundingVolume);
const CesiumGeometry::BoundingCylinder* pCylinder =
std::get_if<CesiumGeometry::BoundingCylinder>(&boundingVolume);

// the implicit loader will be the child loader of this tileset json loader
TilesetContentLoader* pImplicitLoader = nullptr;
Expand All @@ -318,6 +321,16 @@ void createImplicitOctreeLoader(
*pBox);
pImplicitLoader = pLoader.get();
currentLoader.addChildLoader(std::move(pLoader));
} else if (pCylinder) {
auto pLoader = std::make_unique<ImplicitOctreeLoader>(
currentLoader.getBaseUrl(),
contentUriTemplate,
subtreeUriTemplate,
subtreeLevels,
availableLevels,
*pCylinder);
pImplicitLoader = pLoader.get();
currentLoader.addChildLoader(std::move(pLoader));
}

// create an implicit root to associate with the above implicit loader
Expand Down
10 changes: 10 additions & 0 deletions Cesium3DTilesSelection/src/ViewState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ bool ViewState::isBoundingVolumeVisible(
s2Cell,
viewState._cullingVolume);
}

bool operator()(const BoundingCylinder& cylinder) noexcept {
return Cesium3DTilesSelection::isBoundingVolumeVisible(
cylinder,
viewState._cullingVolume);
}
};

return std::visit(Operation{*this}, boundingVolume);
Expand Down Expand Up @@ -165,6 +171,10 @@ double ViewState::computeDistanceSquaredToBoundingVolume(
double operator()(const S2CellBoundingVolume& s2Cell) noexcept {
return s2Cell.computeDistanceSquaredToPosition(viewState._position);
}

double operator()(const BoundingCylinder& cylinder) noexcept {
return cylinder.computeDistanceSquaredToPosition(viewState._position);
}
};

return std::visit(Operation{*this}, boundingVolume);
Expand Down

0 comments on commit 119a6da

Please sign in to comment.