Skip to content

Commit

Permalink
Merge branch 'main' into add-additional-raster-overlay-settings
Browse files Browse the repository at this point in the history
  • Loading branch information
lilleyse authored Feb 14, 2024
2 parents 3743ec8 + e74b1c6 commit 83bd9e2
Show file tree
Hide file tree
Showing 24 changed files with 59 additions and 183 deletions.
1 change: 1 addition & 0 deletions .vscode/cesium-omniverse-linux.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
"${workspaceFolder}/extern/nvidia/_build/target-deps/kit-sdk/exts/omni.kit.audio.test.usd",
"${workspaceFolder}/extern/nvidia/_build/target-deps/kit-sdk/exts/omni.kit.autocapture",
"${workspaceFolder}/extern/nvidia/_build/target-deps/kit-sdk/exts/omni.kit.capture",
"${workspaceFolder}/extern/nvidia/_build/target-deps/kit-sdk/exts/omni.kit.capture.viewport",
"${workspaceFolder}/extern/nvidia/_build/target-deps/kit-sdk/exts/omni.kit.clipboard",
"${workspaceFolder}/extern/nvidia/_build/target-deps/kit-sdk/exts/omni.kit.collaboration.channel_manager",
"${workspaceFolder}/extern/nvidia/_build/target-deps/kit-sdk/exts/omni.kit.collaboration.presence_layer",
Expand Down
1 change: 1 addition & 0 deletions .vscode/cesium-omniverse-windows.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
"${workspaceFolder}/extern/nvidia/_build/target-deps/kit-sdk/exts/omni.kit.audiodeviceenum",
"${workspaceFolder}/extern/nvidia/_build/target-deps/kit-sdk/exts/omni.kit.autocapture",
"${workspaceFolder}/extern/nvidia/_build/target-deps/kit-sdk/exts/omni.kit.capture",
"${workspaceFolder}/extern/nvidia/_build/target-deps/kit-sdk/exts/omni.kit.capture.viewport",
"${workspaceFolder}/extern/nvidia/_build/target-deps/kit-sdk/exts/omni.kit.clipboard",
"${workspaceFolder}/extern/nvidia/_build/target-deps/kit-sdk/exts/omni.kit.collaboration.channel_manager",
"${workspaceFolder}/extern/nvidia/_build/target-deps/kit-sdk/exts/omni.kit.collaboration.presence_layer",
Expand Down
7 changes: 5 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@

### v0.18.0 - 2024-03-01

* **Breaking change:** removed deprecated properties `projectDefaultIonAccessToken` and `projectDefaultIonAccessToken` from `CesiumDataPrim`. `CesiumIonServerPrim` should be used instead.
* Added support for globe anchors on non-georeferenced tilesets.
* Fixed zooming to tileset extents when tileset prims have non identity transformation.
* Fixed crash when updating tilesets shader inputs.
* Fixed crash when setting certain `/Cesium` debug options at runtime.
* Fixed crash when disabling and re-enabling the extension.
* Fixed a bug where save stage dialog would appear when reloading Fabric stage at startup.
* Fixed crash when removing USD prims in certain order.
* Fixed issue where Cesium ion session would not resume on reload.
* Added support for WMS raster overlays
* Added raster overlay options: maximumScreenSpaceError , maximumTextureSize, maximumSimultaneousTileLoads, subTileCacheBytes
* The movie capture tool now waits for tilesets to complete loading before it captures a frame.
* Added support for WMS raster overlays.
* Added raster overlay options: `maximumScreenSpaceError`, `maximumTextureSize`, `maximumSimultaneousTileLoads`, `subTileCacheBytes`.

### v0.17.0 - 2024-02-01

Expand Down
18 changes: 10 additions & 8 deletions exts/cesium.omniverse/cesium/omniverse/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from typing import List, Optional, Callable
from .ui.credits_viewport_controller import CreditsViewportController
from cesium.usd.plugins.CesiumUsdSchemas import Data as CesiumData, IonServer as CesiumIonServer
from omni.kit.capture.viewport import CaptureExtension

CESIUM_DATA_PRIM_PATH = "/Cesium"

Expand Down Expand Up @@ -70,6 +71,7 @@ def __init__(self) -> None:
self._logger: logging.Logger = logging.getLogger(__name__)
self._menus = []
self._num_credits_viewport_frames: int = 0
self._capture_instance = None

perform_vendor_install()

Expand Down Expand Up @@ -171,6 +173,8 @@ def on_startup(self):
add_raster_overlay_event, self._on_add_raster_overlay_to_tileset
)

self._capture_instance = CaptureExtension.get_instance()

def on_shutdown(self):
self._menus.clear()

Expand Down Expand Up @@ -235,6 +239,8 @@ def on_shutdown(self):
self._add_menu_controller.destroy()
self._add_menu_controller = None

self._capture_instance = None

self._destroy_credits_viewport_frames()

self._logger.info("CesiumOmniverse shutdown")
Expand All @@ -261,7 +267,10 @@ def _on_update_frame(self, _):
self._setup_credits_viewport_frames()
self._num_credits_viewport_frames = len(viewports)

_cesium_omniverse_interface.on_update_frame(viewports)
wait_for_loading_tiles = (
self._capture_instance.progress.capture_status == omni.kit.capture.viewport.CaptureStatus.CAPTURING
)
_cesium_omniverse_interface.on_update_frame(viewports, wait_for_loading_tiles)

def _on_stage_event(self, event):
if _cesium_omniverse_interface is None:
Expand Down Expand Up @@ -498,10 +507,3 @@ def _setup_ion_server_prims(self):

data_prim: CesiumData = CesiumData.Get(stage, CESIUM_DATA_PRIM_PATH)
data_prim.GetSelectedIonServerRel().AddTarget(path)

# For backwards compatibility. Add access token from CesiumData prim.
defaultAccessToken = data_prim.GetProjectDefaultIonAccessTokenAttr().Get()
defaultAccessTokenId = data_prim.GetProjectDefaultIonAccessTokenIdAttr().Get()

prim.GetProjectDefaultIonAccessTokenAttr().Set(defaultAccessToken)
prim.GetProjectDefaultIonAccessTokenIdAttr().Set(defaultAccessTokenId)
6 changes: 5 additions & 1 deletion exts/cesium.omniverse/cesium/omniverse/usdUtils/usdUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,11 @@ def get_path_to_current_ion_server() -> Optional[str]:
def set_path_to_current_ion_server(path: str) -> None:
data = get_or_create_cesium_data()
rel = data.GetSelectedIonServerRel()
rel.SetTargets([path])

# This check helps avoid sending unnecessary USD notifications
# See https://github.com/CesiumGS/cesium-omniverse/issues/640
if get_path_to_current_ion_server() != path:
rel.SetTargets([path])


def get_tileset_paths() -> List[str]:
Expand Down
1 change: 1 addition & 0 deletions exts/cesium.omniverse/config/extension.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ python = false
"omni.kit.viewport.utility" = {}
"omni.kit.property.usd" = {}
"omni.kit.menu.utils" = {}
"omni.kit.capture.viewport" = {}

# Main python module this extension provides, it will be publicly available as "import cesium.omniverse"
[[python.module]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ class Data(pxr.Usd.Typed):
@classmethod
def CreateDebugTexturePoolInitialCapacityAttr(cls, *args, **kwargs) -> Any: ...
@classmethod
def CreateProjectDefaultIonAccessTokenAttr(cls, *args, **kwargs) -> Any: ...
@classmethod
def CreateProjectDefaultIonAccessTokenIdAttr(cls, *args, **kwargs) -> Any: ...
@classmethod
def CreateSelectedIonServerRel(cls, *args, **kwargs) -> Any: ...
@classmethod
def Define(cls, *args, **kwargs) -> Any: ...
Expand All @@ -61,10 +57,6 @@ class Data(pxr.Usd.Typed):
@classmethod
def GetDebugTexturePoolInitialCapacityAttr(cls, *args, **kwargs) -> Any: ...
@classmethod
def GetProjectDefaultIonAccessTokenAttr(cls, *args, **kwargs) -> Any: ...
@classmethod
def GetProjectDefaultIonAccessTokenIdAttr(cls, *args, **kwargs) -> Any: ...
@classmethod
def GetSchemaAttributeNames(cls, *args, **kwargs) -> Any: ...
@classmethod
def GetSelectedIonServerRel(cls, *args, **kwargs) -> Any: ...
Expand Down
16 changes: 0 additions & 16 deletions exts/cesium.usd.plugins/schemas/cesium_schemas.usda
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,6 @@ class CesiumDataPrim "CesiumDataPrim" (
doc = "The current ion Server prim used in the Cesium for Omniverse UI."
)

string cesium:projectDefaultIonAccessToken = "" (
customData = {
string apiName = "projectDefaultIonAccessToken"
}
displayName = "Project default ion Access Token"
doc = "DEPRECATED: A string representing the token for accessing Cesium ion assets. Moved to CesiumIonServerPrim. Will be removed in a future version."
)

string cesium:projectDefaultIonAccessTokenId = "" (
customData = {
string apiName = "projectDefaultIonAccessTokenId"
}
displayName = "Project default ion Access Token ID"
doc = "DEPRECATED: A string representing the token ID for accessing Cesium ion assets. Moved to CesiumIonServerPrim. Will be removed in a future version."
)

bool cesium:debug:disableMaterials = false (
customData = {
string apiName = "debugDisableMaterials"
Expand Down
10 changes: 5 additions & 5 deletions genStubs.bat
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ set CESIUM_TESTS_STUB_PATH=%PROJECT_ROOT%\exts\cesium.omniverse.cpp.tests\cesium

set PYTHONPATH=%NVIDIA_USD_PYTHON_LIBS%;%PYTHONPATH%

echo "Ensuring mypy is installed"
%NVIDIA_PYTHON_EXECUTABLE% -m pip install mypy==1.6.1
echo "Ensuring mypy and black are installed"
%NVIDIA_PYTHON_EXECUTABLE% -m pip install mypy==1.6.1 black==23.1.0

echo "Building lib files flat in temp dir"
cmake -B build-stubs
Expand All @@ -45,9 +45,9 @@ copy out\_CesiumUsdSchemas.pyi %CESIUM_USD_STUB_PATH%
copy out\CesiumOmniverseCppTestsPythonBindings.pyi %CESIUM_TESTS_STUB_PATH%

echo "Formatting stubs"
black %CESIUM_OMNI_STUB_PATH%
black %CESIUM_USD_STUB_PATH%
black %CESIUM_TESTS_STUB_PATH%
%NVIDIA_PYTHON_EXECUTABLE% -m black %CESIUM_OMNI_STUB_PATH%
%NVIDIA_PYTHON_EXECUTABLE% -m black %CESIUM_USD_STUB_PATH%
%NVIDIA_PYTHON_EXECUTABLE% -m black %CESIUM_TESTS_STUB_PATH%

echo "Cleaning up temp dir"
cd %PROJECT_ROOT%
Expand Down
10 changes: 5 additions & 5 deletions genStubs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ CESIUM_TESTS_STUB_PATH="$PROJECT_ROOT/exts/cesium.omniverse.cpp.tests/cesium/omn

export PYTHONPATH="$NVIDIA_USD_PYTHON_LIBS:$PYTHONPATH"

echo "Ensuring mypy is installed"
$NVIDIA_PYTHON_EXECUTABLE -m pip install mypy==1.6.1
echo "Ensuring mypy and black are installed"
$NVIDIA_PYTHON_EXECUTABLE -m pip install mypy==1.6.1 black==23.1.0

echo "Building lib files flat in temp dir"
cmake -B build
Expand All @@ -45,9 +45,9 @@ cp "out/_CesiumUsdSchemas.pyi" $CESIUM_USD_STUB_PATH
cp "out/CesiumOmniverseCppTestsPythonBindings.pyi" $CESIUM_TESTS_STUB_PATH

echo "Formatting stubs"
black $CESIUM_OMNI_STUB_PATH
black $CESIUM_USD_STUB_PATH
black $CESIUM_TESTS_STUB_PATH
$NVIDIA_PYTHON_EXECUTABLE -m black $CESIUM_OMNI_STUB_PATH
$NVIDIA_PYTHON_EXECUTABLE -m black $CESIUM_USD_STUB_PATH
$NVIDIA_PYTHON_EXECUTABLE -m black $CESIUM_TESTS_STUB_PATH

echo "Cleaning up temp dir"
rm -rf $FLAT_LIBRARIES_DIR
6 changes: 4 additions & 2 deletions include/cesium/omniverse/CesiumOmniverse.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@ class ICesiumOmniverseInterface {
/**
* @brief Updates all tilesets this frame.
*
* @param viewports A list of viewports.
* @param viewports The viewports.
* @param count The number of viewports.
* @param waitForLoadingTiles Whether to wait for all tiles to load before continuing.
*/
virtual void onUpdateFrame(const ViewportApi* viewports, uint64_t count) noexcept = 0;
virtual void onUpdateFrame(const ViewportApi* viewports, uint64_t count, bool waitForLoadingTiles) noexcept = 0;

/**
* @brief Updates the reference to the USD stage for the C++ layer.
Expand Down
4 changes: 2 additions & 2 deletions src/bindings/PythonBindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ PYBIND11_MODULE(CesiumOmniversePythonBindings, m) {
.def("on_startup", &ICesiumOmniverseInterface::onStartup)
.def("on_shutdown", &ICesiumOmniverseInterface::onShutdown)
.def("reload_tileset", &ICesiumOmniverseInterface::reloadTileset)
.def("on_update_frame", [](ICesiumOmniverseInterface& interface, const std::vector<ViewportPythonBinding>& viewports) {
return interface.onUpdateFrame(reinterpret_cast<const ViewportApi*>(viewports.data()), viewports.size());
.def("on_update_frame", [](ICesiumOmniverseInterface& interface, const std::vector<ViewportPythonBinding>& viewports, bool waitForLoadingTiles) {
return interface.onUpdateFrame(reinterpret_cast<const ViewportApi*>(viewports.data()), viewports.size(), waitForLoadingTiles);
})
.def("on_stage_change", &ICesiumOmniverseInterface::onUsdStageChanged)
.def("connect_to_ion", &ICesiumOmniverseInterface::connectToIon)
Expand Down
2 changes: 1 addition & 1 deletion src/core/include/cesium/omniverse/AssetRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class AssetRegistry {
AssetRegistry(AssetRegistry&&) noexcept = delete;
AssetRegistry& operator=(AssetRegistry&&) noexcept = delete;

void onUpdateFrame(const gsl::span<const Viewport>& viewports);
void onUpdateFrame(const gsl::span<const Viewport>& viewports, bool waitForLoadingTiles);

OmniData& addData(const pxr::SdfPath& path);
void removeData(const pxr::SdfPath& path);
Expand Down
2 changes: 1 addition & 1 deletion src/core/include/cesium/omniverse/Context.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class Context {
void clearStage();
void reloadStage();

void onUpdateFrame(const gsl::span<const Viewport>& viewports);
void onUpdateFrame(const gsl::span<const Viewport>& viewports, bool waitForLoadingTiles);
void onUsdStageChanged(int64_t stageId);

[[nodiscard]] const pxr::UsdStageWeakPtr& getUsdStage() const;
Expand Down
4 changes: 2 additions & 2 deletions src/core/include/cesium/omniverse/OmniTileset.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ class OmniTileset {
void updateDisplayColorAndOpacity();
void addRasterOverlayIfExists(const OmniRasterOverlay* overlay);

void onUpdateFrame(const gsl::span<const Viewport>& viewports);
void onUpdateFrame(const gsl::span<const Viewport>& viewports, bool waitForLoadingTiles);

private:
void updateTransform();
void updateView(const gsl::span<const Viewport>& viewports);
void updateView(const gsl::span<const Viewport>& viewports, bool waitForLoadingTiles);
[[nodiscard]] bool updateExtent();
void updateLoadStatus();

Expand Down
4 changes: 2 additions & 2 deletions src/core/src/AssetRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ AssetRegistry::AssetRegistry(Context* pContext)

AssetRegistry::~AssetRegistry() = default;

void AssetRegistry::onUpdateFrame(const gsl::span<const Viewport>& viewports) {
void AssetRegistry::onUpdateFrame(const gsl::span<const Viewport>& viewports, bool waitForLoadingTiles) {
for (const auto& pTileset : _tilesets) {
pTileset->onUpdateFrame(viewports);
pTileset->onUpdateFrame(viewports, waitForLoadingTiles);
}
}

Expand Down
6 changes: 2 additions & 4 deletions src/core/src/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,6 @@ void Context::clearStage() {
}

void Context::reloadStage() {
const auto defaultIonServerPath = pxr::SdfPath("/CesiumServers/IonOfficial");

clearStage();

// Populate the asset registry from prims already on the stage
Expand All @@ -156,9 +154,9 @@ void Context::reloadStage() {
}
}

void Context::onUpdateFrame(const gsl::span<const Viewport>& viewports) {
void Context::onUpdateFrame(const gsl::span<const Viewport>& viewports, bool waitForLoadingTiles) {
_pUsdNotificationHandler->onUpdateFrame();
_pAssetRegistry->onUpdateFrame(viewports);
_pAssetRegistry->onUpdateFrame(viewports, waitForLoadingTiles);
_pCesiumIonServerManager->onUpdateFrame();
}

Expand Down
12 changes: 8 additions & 4 deletions src/core/src/OmniTileset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -635,15 +635,15 @@ void OmniTileset::updateShaderInput(const pxr::SdfPath& shaderPath, const pxr::T
});
}

void OmniTileset::onUpdateFrame(const gsl::span<const Viewport>& viewports) {
void OmniTileset::onUpdateFrame(const gsl::span<const Viewport>& viewports, bool waitForLoadingTiles) {
if (!UsdUtil::primExists(_pContext->getUsdStage(), _path)) {
// TfNotice can be slow, and sometimes we get a frame or two before we actually get a chance to react on it.
// This guard prevents us from crashing if the prim no longer exists.
return;
}

updateTransform();
updateView(viewports);
updateView(viewports, waitForLoadingTiles);

if (!_extentSet) {
_extentSet = updateExtent();
Expand Down Expand Up @@ -672,7 +672,7 @@ void OmniTileset::updateTransform() {
}
}

void OmniTileset::updateView(const gsl::span<const Viewport>& viewports) {
void OmniTileset::updateView(const gsl::span<const Viewport>& viewports, bool waitForLoadingTiles) {
const auto visible = UsdUtil::isPrimVisible(_pContext->getUsdStage(), _path);

if (visible && !getSuspendUpdate()) {
Expand All @@ -684,7 +684,11 @@ void OmniTileset::updateView(const gsl::span<const Viewport>& viewports) {
_viewStates.push_back(UsdUtil::computeViewState(*_pContext, georeferencePath, _path, viewport));
}

_pViewUpdateResult = &_pTileset->updateView(_viewStates);
if (waitForLoadingTiles) {
_pViewUpdateResult = &_pTileset->updateViewOffline(_viewStates);
} else {
_pViewUpdateResult = &_pTileset->updateView(_viewStates);
}
}

if (!_pViewUpdateResult) {
Expand Down
8 changes: 0 additions & 8 deletions src/plugins/CesiumUsdSchemas/generatedSchema.usda.in
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,6 @@ class CesiumDataPrim "CesiumDataPrim" (
displayName = "Texture Pool Initial Capacity"
doc = "Debug option that controls the initial capacity of the texture pool."
)
string cesium:projectDefaultIonAccessToken = "" (
displayName = "Project default ion Access Token"
doc = "DEPRECATED: A string representing the token for accessing Cesium ion assets. Moved to CesiumIonServerPrim. Will be removed in a future version."
)
string cesium:projectDefaultIonAccessTokenId = "" (
displayName = "Project default ion Access Token ID"
doc = "DEPRECATED: A string representing the token ID for accessing Cesium ion assets. Moved to CesiumIonServerPrim. Will be removed in a future version."
)
rel cesium:selectedIonServer (
displayName = "Selected ion Server context"
doc = "The current ion Server prim used in the Cesium for Omniverse UI."
Expand Down
Loading

0 comments on commit 83bd9e2

Please sign in to comment.