Skip to content

Commit

Permalink
Fixed anchors not being cleaned up if not at stage root
Browse files Browse the repository at this point in the history
  • Loading branch information
weegeekps committed Oct 6, 2023
1 parent 896d997 commit db42cd7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/core/include/cesium/omniverse/GlobeAnchorRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class GlobeAnchorRegistry {
std::shared_ptr<OmniGlobeAnchor> createAnchor(const pxr::SdfPath& path, const glm::dmat4& anchorToFixed);
std::optional<std::shared_ptr<OmniGlobeAnchor>> getAnchor(const pxr::SdfPath& path) const;
std::vector<std::shared_ptr<OmniGlobeAnchor>> getAllAnchors() const;
std::vector<std::string> getAllAnchorPaths() const;
bool removeAnchor(const pxr::SdfPath& path);

protected:
Expand Down
13 changes: 12 additions & 1 deletion src/core/src/GlobeAnchorRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,18 @@ std::vector<std::shared_ptr<OmniGlobeAnchor>> GlobeAnchorRegistry::getAllAnchors
result.reserve(_anchors.size());

for (const auto& item : _anchors) {
result.push_back(item.second);
result.emplace_back(item.second);
}

return result;
}

std::vector<std::string> GlobeAnchorRegistry::getAllAnchorPaths() const {
std::vector<std::string> result;
result.reserve(_anchors.size());

for (const auto& item : _anchors) {
result.emplace_back(item.first);
}

return result;
Expand Down
14 changes: 10 additions & 4 deletions src/core/src/UsdNotificationHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,16 @@ void UsdNotificationHandler::onPrimRemoved(const pxr::SdfPath& primPath) {
}
}

const auto& type = getType(primPath);
if (type == ChangedPrimType::CESIUM_GLOBE_ANCHOR) {
_changedPrims.emplace_back(ChangedPrim{primPath, pxr::TfToken(), type, ChangeType::PRIM_REMOVED});
CESIUM_LOG_INFO("Removed prim: {}", primPath.GetText());
const auto& anchors = GlobeAnchorRegistry::getInstance().getAllAnchorPaths();
for (const auto& anchorPath : anchors) {
const auto& path = pxr::SdfPath(anchorPath);
const auto& type = getType(path);
if (type == ChangedPrimType::CESIUM_GLOBE_ANCHOR) {
if (inSubtree(primPath, path)) {
_changedPrims.emplace_back(ChangedPrim{path, pxr::TfToken(), type, ChangeType::PRIM_REMOVED});
CESIUM_LOG_INFO("Removed prim: {}", path.GetText());
}
}
}
}

Expand Down

0 comments on commit db42cd7

Please sign in to comment.