Skip to content

Commit

Permalink
Merge pull request #1531 from CesiumGS/shared-assets-tweaks
Browse files Browse the repository at this point in the history
Update cesium-unreal to work with shared-assets-tweaks branch of cesium-native
  • Loading branch information
azrogers authored Oct 10, 2024
2 parents 9a63282 + 1b59597 commit c042a39
Show file tree
Hide file tree
Showing 18 changed files with 186 additions and 190 deletions.
16 changes: 8 additions & 8 deletions Source/CesiumRuntime/Private/Cesium3DTileset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
#include "Cesium3DTilesetLoadFailureDetails.h"
#include "Cesium3DTilesetRoot.h"
#include "CesiumActors.h"
#include "CesiumAsync/SharedAssetDepot.h"
#include "CesiumBoundingVolumeComponent.h"
#include "CesiumCamera.h"
#include "CesiumCameraManager.h"
#include "CesiumCommon.h"
#include "CesiumCustomVersion.h"
#include "CesiumGeospatial/GlobeTransforms.h"
#include "CesiumGltf/ImageCesium.h"
#include "CesiumGltf/ImageAsset.h"
#include "CesiumGltf/Ktx2TranscodeTargets.h"
#include "CesiumGltf/SharedAssetDepot.h"
#include "CesiumGltfComponent.h"
#include "CesiumGltfPointsSceneProxyUpdater.h"
#include "CesiumGltfPrimitiveComponent.h"
Expand All @@ -41,7 +41,7 @@
#include "Engine/TextureRenderTarget2D.h"
#include "Engine/World.h"
#include "EngineUtils.h"
#include "ExtensionImageCesiumUnreal.h"
#include "ExtensionImageAssetUnreal.h"
#include "GameFramework/PlayerController.h"
#include "Kismet/GameplayStatics.h"
#include "LevelSequenceActor.h"
Expand Down Expand Up @@ -867,7 +867,7 @@ class UnrealResourcePreparer
}

virtual void* prepareRasterInLoadThread(
CesiumGltf::ImageCesium& image,
CesiumGltf::ImageAsset& image,
const std::any& rendererOptions) override {
auto ppOptions =
std::any_cast<FRasterOverlayRendererOptions*>(&rendererOptions);
Expand All @@ -893,8 +893,8 @@ class UnrealResourcePreparer
// TODO: sRGB should probably be configurable on the raster overlay.
bool sRGB = true;

const ExtensionImageCesiumUnreal& extension =
ExtensionImageCesiumUnreal::getOrCreate(
const ExtensionImageAssetUnreal& extension =
ExtensionImageAssetUnreal::getOrCreate(
CesiumAsync::AsyncSystem(nullptr), // TODO
image,
sRGB,
Expand Down Expand Up @@ -2045,8 +2045,8 @@ void ACesium3DTileset::updateLastViewUpdateResultState(
}

if (this->LogAssetStats && this->_pTileset) {
const CesiumGltf::SharedAssetDepot<CesiumGltf::ImageCesium>& imageDepot =
this->_pTileset->getSharedAssetSystem().image();
const CesiumAsync::SharedAssetDepot<CesiumGltf::ImageAsset>& imageDepot =
*this->_pTileset->getSharedAssetSystem().pImage;
UE_LOG(
LogCesium,
Display,
Expand Down
24 changes: 12 additions & 12 deletions Source/CesiumRuntime/Private/CesiumEncodedFeaturesMetadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ encodeFeatureIdAttribute(const FCesiumFeatureIdAttribute& attribute) {

std::optional<EncodedFeatureIdSet> encodeFeatureIdTexture(
const FCesiumFeatureIdTexture& texture,
TMap<const CesiumGltf::ImageCesium*, TWeakPtr<LoadedTextureResult>>&
TMap<const CesiumGltf::ImageAsset*, TWeakPtr<LoadedTextureResult>>&
featureIdTextureMap) {
const ECesiumFeatureIdTextureStatus status =
UCesiumFeatureIdTextureBlueprintLibrary::GetFeatureIDTextureStatus(
Expand All @@ -114,7 +114,7 @@ std::optional<EncodedFeatureIdSet> encodeFeatureIdTexture(

const CesiumGltf::FeatureIdTextureView& featureIdTextureView =
texture.getFeatureIdTextureView();
const CesiumGltf::ImageCesium* pFeatureIdImage =
const CesiumGltf::ImageAsset* pFeatureIdImage =
featureIdTextureView.getImage();

TRACE_CPUPROFILER_EVENT_SCOPE(Cesium::EncodeFeatureIdTexture)
Expand Down Expand Up @@ -143,8 +143,8 @@ std::optional<EncodedFeatureIdSet> encodeFeatureIdTexture(
}

// Copy the image, so that we can keep a copy of it in the glTF.
CesiumUtility::IntrusivePointer<CesiumGltf::ImageCesium> pImageCopy =
new CesiumGltf::ImageCesium(*pFeatureIdImage);
CesiumUtility::IntrusivePointer<CesiumGltf::ImageAsset> pImageCopy =
new CesiumGltf::ImageAsset(*pFeatureIdImage);
encodedFeatureIdTexture.pTexture =
MakeShared<LoadedTextureResult>(std::move(*loadTextureAnyThreadPart(
*pImageCopy,
Expand Down Expand Up @@ -177,7 +177,7 @@ EncodedPrimitiveFeatures encodePrimitiveFeaturesAnyThreadPart(

// Not all feature ID sets are necessarily textures, but reserve the max
// amount just in case.
TMap<const CesiumGltf::ImageCesium*, TWeakPtr<LoadedTextureResult>>
TMap<const CesiumGltf::ImageAsset*, TWeakPtr<LoadedTextureResult>>
featureIdTextureMap;
featureIdTextureMap.Reserve(featureIDSetDescriptions.Num());

Expand Down Expand Up @@ -510,8 +510,8 @@ EncodedPropertyTable encodePropertyTableAnyThreadPart(
? floorSqrtFeatureCount
: (floorSqrtFeatureCount + 1);

CesiumUtility::IntrusivePointer<CesiumGltf::ImageCesium> pImage =
new CesiumGltf::ImageCesium();
CesiumUtility::IntrusivePointer<CesiumGltf::ImageAsset> pImage =
new CesiumGltf::ImageAsset();
pImage->width = pImage->height = textureDimension;
pImage->bytesPerChannel = encodedFormat.bytesPerChannel;
pImage->channels = encodedFormat.channels;
Expand Down Expand Up @@ -592,7 +592,7 @@ EncodedPropertyTable encodePropertyTableAnyThreadPart(
EncodedPropertyTexture encodePropertyTextureAnyThreadPart(
const FCesiumPropertyTextureDescription& propertyTextureDescription,
const FCesiumPropertyTexture& propertyTexture,
TMap<const CesiumGltf::ImageCesium*, TWeakPtr<LoadedTextureResult>>&
TMap<const CesiumGltf::ImageAsset*, TWeakPtr<LoadedTextureResult>>&
propertyTexturePropertyMap) {

TRACE_CPUPROFILER_EVENT_SCOPE(Cesium::EncodePropertyTexture)
Expand Down Expand Up @@ -641,7 +641,7 @@ EncodedPropertyTexture encodePropertyTextureAnyThreadPart(
encodedProperty.channels[i] = channels[i];
}

const CesiumGltf::ImageCesium* pImage = property.getImage();
const CesiumGltf::ImageAsset* pImage = property.getImage();

TWeakPtr<LoadedTextureResult>* pMappedUnrealImageIt =
propertyTexturePropertyMap.Find(pImage);
Expand All @@ -658,8 +658,8 @@ EncodedPropertyTexture encodePropertyTextureAnyThreadPart(
}

// Copy the image, so that we can keep a copy of it in the glTF.
CesiumUtility::IntrusivePointer<CesiumGltf::ImageCesium> pImageCopy =
new CesiumGltf::ImageCesium(*pImage);
CesiumUtility::IntrusivePointer<CesiumGltf::ImageAsset> pImageCopy =
new CesiumGltf::ImageAsset(*pImage);
encodedProperty.pTexture =
MakeShared<LoadedTextureResult>(std::move(*loadTextureAnyThreadPart(
*pImageCopy,
Expand Down Expand Up @@ -772,7 +772,7 @@ EncodedModelMetadata encodeModelMetadataAnyThreadPart(
UCesiumModelMetadataBlueprintLibrary::GetPropertyTextures(metadata);
result.propertyTextures.Reserve(propertyTextures.Num());

TMap<const CesiumGltf::ImageCesium*, TWeakPtr<LoadedTextureResult>>
TMap<const CesiumGltf::ImageAsset*, TWeakPtr<LoadedTextureResult>>
propertyTexturePropertyMap;
propertyTexturePropertyMap.Reserve(propertyTextures.Num());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ EncodedPropertyTexture encodePropertyTextureAnyThreadPart(
const FCesiumPropertyTextureDescription& propertyTextureDescription,
const FCesiumPropertyTexture& propertyTexture,
TMap<
const CesiumGltf::ImageCesium*,
const CesiumGltf::ImageAsset*,
TWeakPtr<CesiumTextureUtility::LoadedTextureResult>>&
propertyTexturePropertyMap);

Expand Down
22 changes: 11 additions & 11 deletions Source/CesiumRuntime/Private/CesiumEncodedMetadataUtility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ EncodedMetadataFeatureTable encodeMetadataFeatureTableAnyThreadPart(
? floorSqrtFeatureCount
: (floorSqrtFeatureCount + 1);

CesiumUtility::IntrusivePointer<CesiumGltf::ImageCesium> pImage =
new CesiumGltf::ImageCesium();
CesiumUtility::IntrusivePointer<CesiumGltf::ImageAsset> pImage =
new CesiumGltf::ImageAsset();
pImage->bytesPerChannel = encodedFormat.bytesPerChannel;
pImage->channels = encodedFormat.channels;
pImage->compressedPixelFormat = CesiumGltf::GpuCompressedPixelFormat::NONE;
Expand Down Expand Up @@ -293,7 +293,7 @@ EncodedMetadataFeatureTable encodeMetadataFeatureTableAnyThreadPart(
}

EncodedFeatureTexture encodeFeatureTextureAnyThreadPart(
TMap<const CesiumGltf::ImageCesium*, TWeakPtr<LoadedTextureResult>>&
TMap<const CesiumGltf::ImageAsset*, TWeakPtr<LoadedTextureResult>>&
featureTexturePropertyMap,
const FFeatureTextureDescription& featureTextureDescription,
const FString& featureTextureName,
Expand Down Expand Up @@ -322,7 +322,7 @@ EncodedFeatureTexture encodeFeatureTextureAnyThreadPart(
const FCesiumPropertyTextureProperty& featureTextureProperty =
propertyIt.Value;

const CesiumGltf::ImageCesium* pImage = featureTextureProperty.getImage();
const CesiumGltf::ImageAsset* pImage = featureTextureProperty.getImage();

if (!pImage) {
UE_LOG(
Expand Down Expand Up @@ -411,8 +411,8 @@ EncodedFeatureTexture encodeFeatureTextureAnyThreadPart(
if (pMappedUnrealImageIt) {
encodedFeatureTextureProperty.pTexture = pMappedUnrealImageIt->Pin();
} else {
CesiumUtility::IntrusivePointer<CesiumGltf::ImageCesium> pImageCopy =
new CesiumGltf::ImageCesium(*pImage);
CesiumUtility::IntrusivePointer<CesiumGltf::ImageAsset> pImageCopy =
new CesiumGltf::ImageAsset(*pImage);
encodedFeatureTextureProperty.pTexture =
MakeShared<LoadedTextureResult>(std::move(*loadTextureAnyThreadPart(
*pImageCopy,
Expand Down Expand Up @@ -462,7 +462,7 @@ EncodedMetadataPrimitive encodeMetadataPrimitiveAnyThreadPart(
}
}

TMap<const CesiumGltf::ImageCesium*, TWeakPtr<LoadedTextureResult>>
TMap<const CesiumGltf::ImageAsset*, TWeakPtr<LoadedTextureResult>>
featureIdTextureMap;
featureIdTextureMap.Reserve(featureIdTextures.Num());

Expand Down Expand Up @@ -490,7 +490,7 @@ EncodedMetadataPrimitive encodeMetadataPrimitiveAnyThreadPart(
if (pFeatureIdTexture) {
const CesiumGltf::FeatureIdTextureView& featureIdTextureView =
pFeatureIdTexture->getFeatureIdTextureView();
const CesiumGltf::ImageCesium* pFeatureIdImage =
const CesiumGltf::ImageAsset* pFeatureIdImage =
featureIdTextureView.getImage();

if (!pFeatureIdImage) {
Expand All @@ -517,8 +517,8 @@ EncodedMetadataPrimitive encodeMetadataPrimitiveAnyThreadPart(
if (pMappedUnrealImageIt) {
encodedFeatureIdTexture.pTexture = pMappedUnrealImageIt->Pin();
} else {
CesiumUtility::IntrusivePointer<CesiumGltf::ImageCesium> pImageCopy =
new CesiumGltf::ImageCesium(*pFeatureIdImage);
CesiumUtility::IntrusivePointer<CesiumGltf::ImageAsset> pImageCopy =
new CesiumGltf::ImageAsset(*pFeatureIdImage);
encodedFeatureIdTexture.pTexture = MakeShared<LoadedTextureResult>(
std::move(*loadTextureAnyThreadPart(
*pImageCopy,
Expand Down Expand Up @@ -599,7 +599,7 @@ EncodedMetadata encodeMetadataAnyThreadPart(
const TMap<FString, FCesiumPropertyTexture>& featureTextures =
UCesiumModelMetadataBlueprintLibrary::GetFeatureTextures(metadata);
result.encodedFeatureTextures.Reserve(featureTextures.Num());
TMap<const CesiumGltf::ImageCesium*, TWeakPtr<LoadedTextureResult>>
TMap<const CesiumGltf::ImageAsset*, TWeakPtr<LoadedTextureResult>>
featureTexturePropertyMap;
featureTexturePropertyMap.Reserve(featureTextures.Num());
for (const auto& featureTextureIt : featureTextures) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ EncodedMetadataFeatureTable encodeMetadataFeatureTableAnyThreadPart(

EncodedFeatureTexture encodeFeatureTextureAnyThreadPart(
TMap<
const CesiumGltf::ImageCesium*,
const CesiumGltf::ImageAsset*,
TWeakPtr<CesiumTextureUtility::LoadedTextureResult>>&
featureTexturePropertyMap,
const FFeatureTextureDescription& featureTextureDescription,
Expand Down
6 changes: 3 additions & 3 deletions Source/CesiumRuntime/Private/CesiumGltfTextures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "CesiumRuntime.h"
#include "CesiumTextureResource.h"
#include "CesiumTextureUtility.h"
#include "ExtensionImageCesiumUnreal.h"
#include "ExtensionImageAssetUnreal.h"
#include <CesiumGltf/AccessorView.h>
#include <CesiumGltf/Model.h>
#include <CesiumGltf/VertexAttributeSemantics.h>
Expand Down Expand Up @@ -234,8 +234,8 @@ SharedFuture<void> createTextureInLoadThread(
check(pTexture->source >= 0 && pTexture->source < imageNeedsMipmaps.size());
bool needsMips = imageNeedsMipmaps[pTexture->source];

const ExtensionImageCesiumUnreal& extension =
ExtensionImageCesiumUnreal::getOrCreate(
const ExtensionImageAssetUnreal& extension =
ExtensionImageAssetUnreal::getOrCreate(
asyncSystem,
*pImage->pCesium,
sRGB,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,13 +333,13 @@ const CesiumGltf::Sampler* FCesiumPropertyTextureProperty::getSampler() const {
});
}

const CesiumGltf::ImageCesium*
const CesiumGltf::ImageAsset*
FCesiumPropertyTextureProperty::getImage() const {
return propertyTexturePropertyCallback<const CesiumGltf::ImageCesium*>(
return propertyTexturePropertyCallback<const CesiumGltf::ImageAsset*>(
this->_property,
this->_valueType,
this->_normalized,
[](const auto& view) -> const CesiumGltf::ImageCesium* {
[](const auto& view) -> const CesiumGltf::ImageAsset* {
return view.getImage();
});
}
Expand Down
Loading

0 comments on commit c042a39

Please sign in to comment.