Skip to content

Commit

Permalink
Merge branch 'main' into globe-anchors
Browse files Browse the repository at this point in the history
  • Loading branch information
weegeekps committed Jul 14, 2023
2 parents 4e516ca + f20c002 commit 2d95d23
Show file tree
Hide file tree
Showing 83 changed files with 1,934 additions and 981 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,14 @@ exts/cesium.omniverse/certs/cacert.pem
# Test output
_testoutput

# Test utils header has components generated by CMake
tests/testUtils.h

# Packman user files
*.user

# Tracing files
cesium-trace-*.json

# Carb settings from Cesium Power Tools extensions
carb_settings.txt
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ find_package(cpr)
find_package(doctest)
find_package(stb)
find_package(ZLIB)
find_package(yaml-cpp)

# So that the installed libraries can find shared libraries in the same directory
set(CMAKE_INSTALL_RPATH $ORIGIN)
Expand Down
9 changes: 9 additions & 0 deletions ThirdParty.extra.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,14 @@
],
"version": "0.15.0",
"url": "https://github.com/CesiumGS/cesium-native"
},
{
"name": "glTF-Asset-Generator",
"license": [
"MIT"
],
"version": "0.6.1",
"url": "https://github.com/KhronosGroup/glTF-Asset-Generator",
"notes": "A selection of test models from this generator are used for testing."
}
]
17 changes: 17 additions & 0 deletions ThirdParty.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@
"version": "1.9.0",
"url": "https://docs.libcpr.org/"
},
{
"name": "glTF-Asset-Generator",
"license": [
"MIT"
],
"version": "0.6.1",
"url": "https://github.com/KhronosGroup/glTF-Asset-Generator",
"notes": "A selection of test models from this generator are used for testing."
},
{
"name": "libcurl",
"license": [
Expand Down Expand Up @@ -56,6 +65,14 @@
"version": "cci.20220909",
"url": "https://github.com/nothings/stb"
},
{
"name": "yaml-cpp",
"license": [
"MIT"
],
"version": "0.7.0",
"url": "https://github.com/jbeder/yaml-cpp"
},
{
"name": "zlib",
"license": [
Expand Down
1 change: 1 addition & 0 deletions cmake/AddConanDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ set(REQUIRES
"pybind11/2.10.1@#561736204506dad955276aaab438aab4"
"stb/cci.20220909@#1c47474f095ef8cd9e4959558525b827"
"zlib/1.2.13@#13c96f538b52e1600c40b88994de240f"
"yaml-cpp/0.7.0@#85b409c274a53d226b71f1bdb9cb4f8b"
"libcurl/7.86.0@#88506b3234d553b90af1ceefc3dd1652"
"nasm/2.15.05@#799d63b1672a337584b09635b0f22fc1")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
from typing import Callable, Optional, List
from cesium.omniverse.ui import CesiumOmniverseDebugWindow
from .georefhelper.georef_helper_window import CesiumGeorefHelperWindow
from .utils import extend_far_plane
from .utils import extend_far_plane, save_carb_settings
import os
from functools import partial

powertools_extension_location = os.path.join(os.path.dirname(__file__), "../../")


class PowertoolsAction:
Expand Down Expand Up @@ -39,6 +43,7 @@ def __init__(self, **kwargs):
PowertoolsAction("Open Cesium Debugging Window", CesiumOmniverseDebugWindow.show_window),
PowertoolsAction("Open Cesium Georeference Helper Window", CesiumGeorefHelperWindow.create_window),
PowertoolsAction("Extend Far Plane", extend_far_plane),
PowertoolsAction("Save Carb Settings", partial(save_carb_settings, powertools_extension_location)),
]

self.frame.set_build_fn(self._build_fn)
Expand Down
9 changes: 9 additions & 0 deletions exts/cesium.powertools/cesium/powertools/utils/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import omni.usd
from omni.kit.viewport.utility import get_active_viewport
from pxr import Gf, UsdGeom
import json
import carb.settings
import os


# Modified version of ScopedEdit in _build_viewport_cameras in omni.kit.widget.viewport
Expand Down Expand Up @@ -38,3 +41,9 @@ def extend_far_plane():

scoped_edit = ScopedEdit(stage) # noqa: F841
camera.GetClippingRangeAttr().Set(Gf.Vec2f(1.0, 10000000000.0))


def save_carb_settings(powertools_extension_location: str):
carb_settings_path = os.path.join(powertools_extension_location, "carb_settings.txt")
with open(carb_settings_path, "w") as fh:
fh.write(json.dumps(carb.settings.get_settings().get("/"), indent=2))
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class Data(pxr.Usd.Typed):
@classmethod
def CreateDebugDisableMaterialsAttr(cls, *args, **kwargs) -> Any: ...
@classmethod
def CreateDebugDisableTexturePoolAttr(cls, *args, **kwargs) -> Any: ...
@classmethod
def CreateDebugDisableTexturesAttr(cls, *args, **kwargs) -> Any: ...
@classmethod
def CreateDebugGeometryPoolInitialCapacityAttr(cls, *args, **kwargs) -> Any: ...
Expand All @@ -25,6 +27,8 @@ class Data(pxr.Usd.Typed):
@classmethod
def CreateDebugRandomColorsAttr(cls, *args, **kwargs) -> Any: ...
@classmethod
def CreateDebugTexturePoolInitialCapacityAttr(cls, *args, **kwargs) -> Any: ...
@classmethod
def CreateProjectDefaultIonAccessTokenAttr(cls, *args, **kwargs) -> Any: ...
@classmethod
def CreateProjectDefaultIonAccessTokenIdAttr(cls, *args, **kwargs) -> Any: ...
Expand All @@ -37,6 +41,8 @@ class Data(pxr.Usd.Typed):
@classmethod
def GetDebugDisableMaterialsAttr(cls, *args, **kwargs) -> Any: ...
@classmethod
def GetDebugDisableTexturePoolAttr(cls, *args, **kwargs) -> Any: ...
@classmethod
def GetDebugDisableTexturesAttr(cls, *args, **kwargs) -> Any: ...
@classmethod
def GetDebugGeometryPoolInitialCapacityAttr(cls, *args, **kwargs) -> Any: ...
Expand All @@ -45,6 +51,8 @@ class Data(pxr.Usd.Typed):
@classmethod
def GetDebugRandomColorsAttr(cls, *args, **kwargs) -> Any: ...
@classmethod
def GetDebugTexturePoolInitialCapacityAttr(cls, *args, **kwargs) -> Any: ...
@classmethod
def GetProjectDefaultIonAccessTokenAttr(cls, *args, **kwargs) -> Any: ...
@classmethod
def GetProjectDefaultIonAccessTokenIdAttr(cls, *args, **kwargs) -> Any: ...
Expand Down Expand Up @@ -296,6 +304,8 @@ class Tokens(Boost.Python.instance):
@property
def cesiumDebugDisableMaterials(self) -> Any: ...
@property
def cesiumDebugDisableTexturePool(self) -> Any: ...
@property
def cesiumDebugDisableTextures(self) -> Any: ...
@property
def cesiumDebugGeometryPoolInitialCapacity(self) -> Any: ...
Expand All @@ -304,6 +314,8 @@ class Tokens(Boost.Python.instance):
@property
def cesiumDebugRandomColors(self) -> Any: ...
@property
def cesiumDebugTexturePoolInitialCapacity(self) -> Any: ...
@property
def cesiumEcefToUsdTransform(self) -> Any: ...
@property
def cesiumEnableFogCulling(self) -> Any: ...
Expand Down
18 changes: 17 additions & 1 deletion exts/cesium.usd.plugins/schemas/cesium_schemas.usda
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ class CesiumDataPrim "CesiumDataPrim" (
doc = "Debug option that disables material pooling."
)

bool cesium:debug:disableTexturePool = false (
customData = {
string apiName = "debugDisableTexturePool"
}
displayName = "Disable Texture Pool"
doc = "Debug option that disables texture pooling."
)

uint64 cesium:debug:geometryPoolInitialCapacity = 2048 (
customData = {
string apiName = "debugGeometryPoolInitialCapacity"
Expand All @@ -90,6 +98,14 @@ class CesiumDataPrim "CesiumDataPrim" (
doc = "Debug option that controls the initial capacity of the material pool."
)

uint64 cesium:debug:texturePoolInitialCapacity = 2048 (
customData = {
string apiName = "debugTexturePoolInitialCapacity"
}
displayName = "Texture Pool Initial Capacity"
doc = "Debug option that controls the initial capacity of the texture pool."
)

bool cesium:debug:randomColors = false (
customData = {
string apiName = "debugRandomColors"
Expand Down Expand Up @@ -149,7 +165,7 @@ class CesiumGeoreferencePrim "CesiumGeoreferencePrim" (

class CesiumTilesetPrim "CesiumTilesetPrim" (
doc = """A prim representing a tileset."""
inherits = </Boundable>
inherits = </Gprim>
customData = {
string className = "Tileset"

Expand Down
2 changes: 1 addition & 1 deletion src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ setup_lib(
CesiumUsdSchemas
CesiumIonClient
Cesium3DTilesSelection
CesiumAsync
CesiumGeospatial
CesiumGeometry
CesiumGltf
CesiumGltfReader
CesiumAsync
CesiumJsonReader
CesiumUtility
async++
Expand Down
4 changes: 2 additions & 2 deletions src/core/include/cesium/omniverse/Context.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ class Context {

int64_t getContextId() const;
int64_t getNextTilesetId() const;
int64_t getNextTileId() const;

const CesiumGeospatial::Cartographic getGeoreferenceOrigin() const;
void setGeoreferenceOrigin(const CesiumGeospatial::Cartographic& origin);
Expand Down Expand Up @@ -143,8 +142,10 @@ class Context {
bool getDebugDisableTextures() const;
bool getDebugDisableGeometryPool() const;
bool getDebugDisableMaterialPool() const;
bool getDebugDisableTexturePool() const;
uint64_t getDebugGeometryPoolInitialCapacity() const;
uint64_t getDebugMaterialPoolInitialCapacity() const;
uint64_t getDebugTexturePoolInitialCapacity() const;
bool getDebugRandomColors() const;

std::shared_ptr<TaskProcessor> _taskProcessor;
Expand All @@ -167,7 +168,6 @@ class Context {
int64_t _contextId;

mutable std::atomic<int64_t> _tilesetId{};
mutable std::atomic<int64_t> _tileId{};

std::filesystem::path _cesiumExtensionLocation;
std::filesystem::path _certificatePath;
Expand Down
5 changes: 2 additions & 3 deletions src/core/include/cesium/omniverse/FabricGeometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ class FabricGeometry {
bool debugRandomColors);
~FabricGeometry();

void setTile(
void setGeometry(
int64_t tilesetId,
int64_t tileId,
const glm::dmat4& ecefToUsdTransform,
const glm::dmat4& gltfToEcefTransform,
const glm::dmat4& nodeTransform,
Expand All @@ -40,7 +39,7 @@ class FabricGeometry {
[[nodiscard]] omni::fabric::Path getPathFabric() const;
[[nodiscard]] const FabricGeometryDefinition& getGeometryDefinition() const;

void assignMaterial(const std::shared_ptr<FabricMaterial>& material);
void setMaterial(const omni::fabric::Path& materialPath);

private:
void initialize();
Expand Down
6 changes: 1 addition & 5 deletions src/core/include/cesium/omniverse/FabricGeometryDefinition.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@ class FabricGeometryDefinition {
FabricGeometryDefinition(
const CesiumGltf::Model& model,
const CesiumGltf::MeshPrimitive& primitive,
bool smoothNormals,
bool hasImagery,
bool disableMaterials);
bool smoothNormals);

[[nodiscard]] bool hasMaterial() const;
[[nodiscard]] bool hasTexcoords() const;
[[nodiscard]] bool hasNormals() const;
[[nodiscard]] bool hasVertexColors() const;
Expand All @@ -27,7 +24,6 @@ class FabricGeometryDefinition {
bool operator==(const FabricGeometryDefinition& other) const;

private:
bool _hasMaterial{false};
bool _hasTexcoords{false};
bool _hasNormals{false};
bool _hasVertexColors{false};
Expand Down
30 changes: 16 additions & 14 deletions src/core/include/cesium/omniverse/FabricMaterial.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#pragma once

#include "cesium/omniverse/FabricMaterialDefinition.h"
#include "cesium/omniverse/GltfUtil.h"

#include <omni/fabric/IPath.h>
#include <pxr/usd/sdf/assetPath.h>
#include <pxr/usd/sdf/path.h>

namespace omni::ui {
Expand All @@ -17,22 +19,21 @@ struct Model;

namespace cesium::omniverse {

class FabricTexture;

class FabricMaterial {
public:
FabricMaterial(pxr::SdfPath path, const FabricMaterialDefinition& materialDefinition);
FabricMaterial(
pxr::SdfPath path,
const FabricMaterialDefinition& materialDefinition,
pxr::SdfAssetPath defaultTextureAssetPath);
~FabricMaterial();

void setTile(
int64_t tilesetId,
int64_t tileId,
const CesiumGltf::Model& model,
const CesiumGltf::MeshPrimitive& primitive);
void setMaterial(int64_t tilesetId, const MaterialInfo& materialInfo);

void setBaseColorTexture(const std::shared_ptr<FabricTexture>& texture, const TextureInfo& textureInfo);

void setImagery(
const CesiumGltf::ImageCesium* imagery,
const glm::dvec2& imageryTexcoordTranslation,
const glm::dvec2& imageryTexcoordScale,
uint64_t imageryTexcoordSetIndex);
void clearBaseColorTexture();

void setActive(bool active);

Expand All @@ -42,15 +43,16 @@ class FabricMaterial {
private:
void initialize(pxr::SdfPath path, const FabricMaterialDefinition& materialDefinition);
void reset();
void setInitialValues(const FabricMaterialDefinition& materialDefinition);
void setTilesetId(int64_t tilesetId);
void setMaterialValues(const MaterialInfo& materialInfo);
void setBaseColorTextureValues(const pxr::SdfAssetPath& textureAssetPath, const TextureInfo& textureInfo);

const FabricMaterialDefinition _materialDefinition;
const pxr::SdfAssetPath _defaultTextureAssetPath;

omni::fabric::Path _materialPathFabric;
omni::fabric::Path _shaderPathFabric;
omni::fabric::Path _baseColorTexPathFabric;

std::unique_ptr<omni::ui::DynamicTextureProvider> _baseColorTexture;
};

} // namespace cesium::omniverse
8 changes: 3 additions & 5 deletions src/core/include/cesium/omniverse/FabricMaterialDefinition.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@ struct Model;

namespace cesium::omniverse {

struct MaterialInfo;

class FabricMaterialDefinition {
public:
FabricMaterialDefinition(
const CesiumGltf::Model& model,
const CesiumGltf::MeshPrimitive& primitive,
bool hasImagery,
bool disableTextures);
FabricMaterialDefinition(const MaterialInfo& materialInfo, bool hasImagery, bool disableTextures);

[[nodiscard]] bool hasBaseColorTexture() const;
[[nodiscard]] bool hasVertexColors() const;
Expand Down
9 changes: 8 additions & 1 deletion src/core/include/cesium/omniverse/FabricMaterialPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@
#include "cesium/omniverse/FabricMaterialDefinition.h"
#include "cesium/omniverse/ObjectPool.h"

#include <pxr/usd/sdf/assetPath.h>

namespace cesium::omniverse {

class FabricMaterialPool final : public ObjectPool<FabricMaterial> {
public:
FabricMaterialPool(int64_t poolId, const FabricMaterialDefinition& materialDefinition, uint64_t initialCapacity);
FabricMaterialPool(
int64_t poolId,
const FabricMaterialDefinition& materialDefinition,
uint64_t initialCapacity,
pxr::SdfAssetPath defaultTextureAssetPath);

[[nodiscard]] const FabricMaterialDefinition& getMaterialDefinition() const;

Expand All @@ -19,6 +25,7 @@ class FabricMaterialPool final : public ObjectPool<FabricMaterial> {
private:
const int64_t _poolId;
const FabricMaterialDefinition _materialDefinition;
const pxr::SdfAssetPath _defaultTextureAssetPath;
};

} // namespace cesium::omniverse
Loading

0 comments on commit 2d95d23

Please sign in to comment.