From fc60c1e92d7bedf86cf31bacdb8d7f94952b7515 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Thu, 10 Oct 2024 22:20:23 +1100 Subject: [PATCH 1/2] Update cesium-native. --- Source/CesiumRuntime/Private/Cesium3DTileset.cpp | 6 +++--- Source/CesiumRuntime/Private/CesiumTextureResource.h | 2 +- Source/CesiumRuntime/Private/CesiumTextureUtility.h | 2 +- Source/CesiumRuntime/Private/Tests/Cesium3DTileset.spec.cpp | 2 +- extern/cesium-native | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Source/CesiumRuntime/Private/Cesium3DTileset.cpp b/Source/CesiumRuntime/Private/Cesium3DTileset.cpp index e73c2b4f3..54d32122a 100644 --- a/Source/CesiumRuntime/Private/Cesium3DTileset.cpp +++ b/Source/CesiumRuntime/Private/Cesium3DTileset.cpp @@ -11,6 +11,7 @@ #include "Cesium3DTilesetLoadFailureDetails.h" #include "Cesium3DTilesetRoot.h" #include "CesiumActors.h" +#include "CesiumAsync/SharedAssetDepot.h" #include "CesiumBoundingVolumeComponent.h" #include "CesiumCamera.h" #include "CesiumCameraManager.h" @@ -19,7 +20,6 @@ #include "CesiumGeospatial/GlobeTransforms.h" #include "CesiumGltf/ImageCesium.h" #include "CesiumGltf/Ktx2TranscodeTargets.h" -#include "CesiumGltf/SharedAssetDepot.h" #include "CesiumGltfComponent.h" #include "CesiumGltfPointsSceneProxyUpdater.h" #include "CesiumGltfPrimitiveComponent.h" @@ -2045,8 +2045,8 @@ void ACesium3DTileset::updateLastViewUpdateResultState( } if (this->LogAssetStats && this->_pTileset) { - const CesiumGltf::SharedAssetDepot& imageDepot = - this->_pTileset->getSharedAssetSystem().image(); + const CesiumAsync::SharedAssetDepot& imageDepot = + *this->_pTileset->getSharedAssetSystem().pImage; UE_LOG( LogCesium, Display, diff --git a/Source/CesiumRuntime/Private/CesiumTextureResource.h b/Source/CesiumRuntime/Private/CesiumTextureResource.h index 4cbd8521a..567abec86 100644 --- a/Source/CesiumRuntime/Private/CesiumTextureResource.h +++ b/Source/CesiumRuntime/Private/CesiumTextureResource.h @@ -5,8 +5,8 @@ #include "CesiumCommon.h" #include "Engine/Texture.h" #include "TextureResource.h" +#include #include -#include class FCesiumTextureResource; diff --git a/Source/CesiumRuntime/Private/CesiumTextureUtility.h b/Source/CesiumRuntime/Private/CesiumTextureUtility.h index 401643d41..bcb835db4 100644 --- a/Source/CesiumRuntime/Private/CesiumTextureUtility.h +++ b/Source/CesiumRuntime/Private/CesiumTextureUtility.h @@ -2,8 +2,8 @@ #pragma once +#include "CesiumAsync/SharedAssetDepot.h" #include "CesiumGltf/Model.h" -#include "CesiumGltf/SharedAssetDepot.h" #include "CesiumGltf/Texture.h" #include "CesiumMetadataValueType.h" #include "CesiumTextureResource.h" diff --git a/Source/CesiumRuntime/Private/Tests/Cesium3DTileset.spec.cpp b/Source/CesiumRuntime/Private/Tests/Cesium3DTileset.spec.cpp index 23de71875..da746bd60 100644 --- a/Source/CesiumRuntime/Private/Tests/Cesium3DTileset.spec.cpp +++ b/Source/CesiumRuntime/Private/Tests/Cesium3DTileset.spec.cpp @@ -72,7 +72,7 @@ static void setupForSharedImages(SceneGenerationContext& context) { void tilesetPass( SceneGenerationContext& context, TestPass::TestingParameter parameter) { - CesiumGltf::SharedAssetSystem& assetSystem = + CesiumGltfReader::GltfSharedAssetSystem& assetSystem = context.tilesets[0]->GetTileset()->getSharedAssetSystem(); assert(assetDepot.getImagesCount() == 2); } diff --git a/extern/cesium-native b/extern/cesium-native index 924b000e0..526e66068 160000 --- a/extern/cesium-native +++ b/extern/cesium-native @@ -1 +1 @@ -Subproject commit 924b000e00fc9054d60591bae494c71532a8ec61 +Subproject commit 526e660687d64d98b3f1aea3b8338dafbac0b1db From 1b59597d65d60bffecb94efd9e434e94401247da Mon Sep 17 00:00:00 2001 From: Ashley Rogers Date: Thu, 10 Oct 2024 15:45:04 -0400 Subject: [PATCH 2/2] Rename ImageCesium --- .../CesiumRuntime/Private/Cesium3DTileset.cpp | 12 +-- .../Private/CesiumEncodedFeaturesMetadata.cpp | 24 +++--- .../Private/CesiumEncodedFeaturesMetadata.h | 2 +- .../Private/CesiumEncodedMetadataUtility.cpp | 22 +++--- .../Private/CesiumEncodedMetadataUtility.h | 2 +- .../Private/CesiumGltfTextures.cpp | 6 +- .../Private/CesiumPropertyTextureProperty.cpp | 6 +- .../Private/CesiumTextureResource.cpp | 44 +++++------ .../Private/CesiumTextureResource.h | 8 +- .../Private/CesiumTextureUtility.cpp | 22 +++--- .../Private/CesiumTextureUtility.h | 14 ++-- ...real.cpp => ExtensionImageAssetUnreal.cpp} | 38 +++++---- ...umUnreal.h => ExtensionImageAssetUnreal.h} | 24 +++--- .../CesiumPropertyTextureProperty.spec.cpp | 78 +++++++++---------- .../Tests/CesiumTextureUtility.spec.cpp | 60 +++++++------- .../Public/CesiumPropertyTextureProperty.h | 2 +- extern/cesium-native | 2 +- 17 files changed, 181 insertions(+), 185 deletions(-) rename Source/CesiumRuntime/Private/{ExtensionImageCesiumUnreal.cpp => ExtensionImageAssetUnreal.cpp} (68%) rename Source/CesiumRuntime/Private/{ExtensionImageCesiumUnreal.h => ExtensionImageAssetUnreal.h} (82%) diff --git a/Source/CesiumRuntime/Private/Cesium3DTileset.cpp b/Source/CesiumRuntime/Private/Cesium3DTileset.cpp index 54d32122a..1be3fbf0d 100644 --- a/Source/CesiumRuntime/Private/Cesium3DTileset.cpp +++ b/Source/CesiumRuntime/Private/Cesium3DTileset.cpp @@ -18,7 +18,7 @@ #include "CesiumCommon.h" #include "CesiumCustomVersion.h" #include "CesiumGeospatial/GlobeTransforms.h" -#include "CesiumGltf/ImageCesium.h" +#include "CesiumGltf/ImageAsset.h" #include "CesiumGltf/Ktx2TranscodeTargets.h" #include "CesiumGltfComponent.h" #include "CesiumGltfPointsSceneProxyUpdater.h" @@ -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" @@ -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(&rendererOptions); @@ -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, @@ -2045,7 +2045,7 @@ void ACesium3DTileset::updateLastViewUpdateResultState( } if (this->LogAssetStats && this->_pTileset) { - const CesiumAsync::SharedAssetDepot& imageDepot = + const CesiumAsync::SharedAssetDepot& imageDepot = *this->_pTileset->getSharedAssetSystem().pImage; UE_LOG( LogCesium, diff --git a/Source/CesiumRuntime/Private/CesiumEncodedFeaturesMetadata.cpp b/Source/CesiumRuntime/Private/CesiumEncodedFeaturesMetadata.cpp index 77d1d5b53..9528d8734 100644 --- a/Source/CesiumRuntime/Private/CesiumEncodedFeaturesMetadata.cpp +++ b/Source/CesiumRuntime/Private/CesiumEncodedFeaturesMetadata.cpp @@ -99,7 +99,7 @@ encodeFeatureIdAttribute(const FCesiumFeatureIdAttribute& attribute) { std::optional encodeFeatureIdTexture( const FCesiumFeatureIdTexture& texture, - TMap>& + TMap>& featureIdTextureMap) { const ECesiumFeatureIdTextureStatus status = UCesiumFeatureIdTextureBlueprintLibrary::GetFeatureIDTextureStatus( @@ -114,7 +114,7 @@ std::optional encodeFeatureIdTexture( const CesiumGltf::FeatureIdTextureView& featureIdTextureView = texture.getFeatureIdTextureView(); - const CesiumGltf::ImageCesium* pFeatureIdImage = + const CesiumGltf::ImageAsset* pFeatureIdImage = featureIdTextureView.getImage(); TRACE_CPUPROFILER_EVENT_SCOPE(Cesium::EncodeFeatureIdTexture) @@ -143,8 +143,8 @@ std::optional encodeFeatureIdTexture( } // Copy the image, so that we can keep a copy of it in the glTF. - CesiumUtility::IntrusivePointer pImageCopy = - new CesiumGltf::ImageCesium(*pFeatureIdImage); + CesiumUtility::IntrusivePointer pImageCopy = + new CesiumGltf::ImageAsset(*pFeatureIdImage); encodedFeatureIdTexture.pTexture = MakeShared(std::move(*loadTextureAnyThreadPart( *pImageCopy, @@ -177,7 +177,7 @@ EncodedPrimitiveFeatures encodePrimitiveFeaturesAnyThreadPart( // Not all feature ID sets are necessarily textures, but reserve the max // amount just in case. - TMap> + TMap> featureIdTextureMap; featureIdTextureMap.Reserve(featureIDSetDescriptions.Num()); @@ -510,8 +510,8 @@ EncodedPropertyTable encodePropertyTableAnyThreadPart( ? floorSqrtFeatureCount : (floorSqrtFeatureCount + 1); - CesiumUtility::IntrusivePointer pImage = - new CesiumGltf::ImageCesium(); + CesiumUtility::IntrusivePointer pImage = + new CesiumGltf::ImageAsset(); pImage->width = pImage->height = textureDimension; pImage->bytesPerChannel = encodedFormat.bytesPerChannel; pImage->channels = encodedFormat.channels; @@ -592,7 +592,7 @@ EncodedPropertyTable encodePropertyTableAnyThreadPart( EncodedPropertyTexture encodePropertyTextureAnyThreadPart( const FCesiumPropertyTextureDescription& propertyTextureDescription, const FCesiumPropertyTexture& propertyTexture, - TMap>& + TMap>& propertyTexturePropertyMap) { TRACE_CPUPROFILER_EVENT_SCOPE(Cesium::EncodePropertyTexture) @@ -641,7 +641,7 @@ EncodedPropertyTexture encodePropertyTextureAnyThreadPart( encodedProperty.channels[i] = channels[i]; } - const CesiumGltf::ImageCesium* pImage = property.getImage(); + const CesiumGltf::ImageAsset* pImage = property.getImage(); TWeakPtr* pMappedUnrealImageIt = propertyTexturePropertyMap.Find(pImage); @@ -658,8 +658,8 @@ EncodedPropertyTexture encodePropertyTextureAnyThreadPart( } // Copy the image, so that we can keep a copy of it in the glTF. - CesiumUtility::IntrusivePointer pImageCopy = - new CesiumGltf::ImageCesium(*pImage); + CesiumUtility::IntrusivePointer pImageCopy = + new CesiumGltf::ImageAsset(*pImage); encodedProperty.pTexture = MakeShared(std::move(*loadTextureAnyThreadPart( *pImageCopy, @@ -772,7 +772,7 @@ EncodedModelMetadata encodeModelMetadataAnyThreadPart( UCesiumModelMetadataBlueprintLibrary::GetPropertyTextures(metadata); result.propertyTextures.Reserve(propertyTextures.Num()); - TMap> + TMap> propertyTexturePropertyMap; propertyTexturePropertyMap.Reserve(propertyTextures.Num()); diff --git a/Source/CesiumRuntime/Private/CesiumEncodedFeaturesMetadata.h b/Source/CesiumRuntime/Private/CesiumEncodedFeaturesMetadata.h index 31ec20866..0bb838505 100644 --- a/Source/CesiumRuntime/Private/CesiumEncodedFeaturesMetadata.h +++ b/Source/CesiumRuntime/Private/CesiumEncodedFeaturesMetadata.h @@ -476,7 +476,7 @@ EncodedPropertyTexture encodePropertyTextureAnyThreadPart( const FCesiumPropertyTextureDescription& propertyTextureDescription, const FCesiumPropertyTexture& propertyTexture, TMap< - const CesiumGltf::ImageCesium*, + const CesiumGltf::ImageAsset*, TWeakPtr>& propertyTexturePropertyMap); diff --git a/Source/CesiumRuntime/Private/CesiumEncodedMetadataUtility.cpp b/Source/CesiumRuntime/Private/CesiumEncodedMetadataUtility.cpp index f5c8d9b0f..28f6fa3d1 100644 --- a/Source/CesiumRuntime/Private/CesiumEncodedMetadataUtility.cpp +++ b/Source/CesiumRuntime/Private/CesiumEncodedMetadataUtility.cpp @@ -205,8 +205,8 @@ EncodedMetadataFeatureTable encodeMetadataFeatureTableAnyThreadPart( ? floorSqrtFeatureCount : (floorSqrtFeatureCount + 1); - CesiumUtility::IntrusivePointer pImage = - new CesiumGltf::ImageCesium(); + CesiumUtility::IntrusivePointer pImage = + new CesiumGltf::ImageAsset(); pImage->bytesPerChannel = encodedFormat.bytesPerChannel; pImage->channels = encodedFormat.channels; pImage->compressedPixelFormat = CesiumGltf::GpuCompressedPixelFormat::NONE; @@ -293,7 +293,7 @@ EncodedMetadataFeatureTable encodeMetadataFeatureTableAnyThreadPart( } EncodedFeatureTexture encodeFeatureTextureAnyThreadPart( - TMap>& + TMap>& featureTexturePropertyMap, const FFeatureTextureDescription& featureTextureDescription, const FString& featureTextureName, @@ -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( @@ -411,8 +411,8 @@ EncodedFeatureTexture encodeFeatureTextureAnyThreadPart( if (pMappedUnrealImageIt) { encodedFeatureTextureProperty.pTexture = pMappedUnrealImageIt->Pin(); } else { - CesiumUtility::IntrusivePointer pImageCopy = - new CesiumGltf::ImageCesium(*pImage); + CesiumUtility::IntrusivePointer pImageCopy = + new CesiumGltf::ImageAsset(*pImage); encodedFeatureTextureProperty.pTexture = MakeShared(std::move(*loadTextureAnyThreadPart( *pImageCopy, @@ -462,7 +462,7 @@ EncodedMetadataPrimitive encodeMetadataPrimitiveAnyThreadPart( } } - TMap> + TMap> featureIdTextureMap; featureIdTextureMap.Reserve(featureIdTextures.Num()); @@ -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) { @@ -517,8 +517,8 @@ EncodedMetadataPrimitive encodeMetadataPrimitiveAnyThreadPart( if (pMappedUnrealImageIt) { encodedFeatureIdTexture.pTexture = pMappedUnrealImageIt->Pin(); } else { - CesiumUtility::IntrusivePointer pImageCopy = - new CesiumGltf::ImageCesium(*pFeatureIdImage); + CesiumUtility::IntrusivePointer pImageCopy = + new CesiumGltf::ImageAsset(*pFeatureIdImage); encodedFeatureIdTexture.pTexture = MakeShared( std::move(*loadTextureAnyThreadPart( *pImageCopy, @@ -599,7 +599,7 @@ EncodedMetadata encodeMetadataAnyThreadPart( const TMap& featureTextures = UCesiumModelMetadataBlueprintLibrary::GetFeatureTextures(metadata); result.encodedFeatureTextures.Reserve(featureTextures.Num()); - TMap> + TMap> featureTexturePropertyMap; featureTexturePropertyMap.Reserve(featureTextures.Num()); for (const auto& featureTextureIt : featureTextures) { diff --git a/Source/CesiumRuntime/Private/CesiumEncodedMetadataUtility.h b/Source/CesiumRuntime/Private/CesiumEncodedMetadataUtility.h index 070f2b00c..84c4b3d23 100644 --- a/Source/CesiumRuntime/Private/CesiumEncodedMetadataUtility.h +++ b/Source/CesiumRuntime/Private/CesiumEncodedMetadataUtility.h @@ -106,7 +106,7 @@ EncodedMetadataFeatureTable encodeMetadataFeatureTableAnyThreadPart( EncodedFeatureTexture encodeFeatureTextureAnyThreadPart( TMap< - const CesiumGltf::ImageCesium*, + const CesiumGltf::ImageAsset*, TWeakPtr>& featureTexturePropertyMap, const FFeatureTextureDescription& featureTextureDescription, diff --git a/Source/CesiumRuntime/Private/CesiumGltfTextures.cpp b/Source/CesiumRuntime/Private/CesiumGltfTextures.cpp index 2101c8790..bc52d55bf 100644 --- a/Source/CesiumRuntime/Private/CesiumGltfTextures.cpp +++ b/Source/CesiumRuntime/Private/CesiumGltfTextures.cpp @@ -4,7 +4,7 @@ #include "CesiumRuntime.h" #include "CesiumTextureResource.h" #include "CesiumTextureUtility.h" -#include "ExtensionImageCesiumUnreal.h" +#include "ExtensionImageAssetUnreal.h" #include #include #include @@ -234,8 +234,8 @@ SharedFuture 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, diff --git a/Source/CesiumRuntime/Private/CesiumPropertyTextureProperty.cpp b/Source/CesiumRuntime/Private/CesiumPropertyTextureProperty.cpp index 0cd8653fa..cc96ff84b 100644 --- a/Source/CesiumRuntime/Private/CesiumPropertyTextureProperty.cpp +++ b/Source/CesiumRuntime/Private/CesiumPropertyTextureProperty.cpp @@ -333,13 +333,13 @@ const CesiumGltf::Sampler* FCesiumPropertyTextureProperty::getSampler() const { }); } -const CesiumGltf::ImageCesium* +const CesiumGltf::ImageAsset* FCesiumPropertyTextureProperty::getImage() const { - return propertyTexturePropertyCallback( + return propertyTexturePropertyCallback( this->_property, this->_valueType, this->_normalized, - [](const auto& view) -> const CesiumGltf::ImageCesium* { + [](const auto& view) -> const CesiumGltf::ImageAsset* { return view.getImage(); }); } diff --git a/Source/CesiumRuntime/Private/CesiumTextureResource.cpp b/Source/CesiumRuntime/Private/CesiumTextureResource.cpp index ae9438bfd..e86e79986 100644 --- a/Source/CesiumRuntime/Private/CesiumTextureResource.cpp +++ b/Source/CesiumRuntime/Private/CesiumTextureResource.cpp @@ -65,7 +65,7 @@ class FCesiumUseExistingTextureResource : public FCesiumTextureResource { class FCesiumCreateNewTextureResource : public FCesiumTextureResource { public: FCesiumCreateNewTextureResource( - CesiumGltf::ImageCesium&& image, + CesiumGltf::ImageAsset&& image, TextureGroup textureGroup, uint32 width, uint32 height, @@ -81,7 +81,7 @@ class FCesiumCreateNewTextureResource : public FCesiumTextureResource { virtual FTextureRHIRef InitializeTextureRHI() override; private: - CesiumGltf::ImageCesium _image; + CesiumGltf::ImageAsset _image; }; ESamplerFilter convertFilter(TextureFilter filter) { @@ -126,7 +126,7 @@ void CopyMip( void* pDest, uint32 destPitch, EPixelFormat format, - const CesiumGltf::ImageCesium& src, + const CesiumGltf::ImageAsset& src, uint32 mipIndex) { size_t byteOffset = 0; size_t byteSize = 0; @@ -134,7 +134,7 @@ void CopyMip( byteOffset = 0; byteSize = src.pixelData.size(); } else { - const CesiumGltf::ImageCesiumMipPosition& mipPos = + const CesiumGltf::ImageAssetMipPosition& mipPos = src.mipPositions[mipIndex]; byteOffset = mipPos.byteOffset; byteSize = mipPos.byteSize; @@ -245,7 +245,7 @@ FTexture2DRHIRef createAsyncTextureAndWait( * @return The RHI texture reference. */ FTexture2DRHIRef CreateRHITexture2D_Async( - const CesiumGltf::ImageCesium& image, + const CesiumGltf::ImageAsset& image, EPixelFormat format, bool sRGB) { check(GRHISupportsAsyncTextureCreation); @@ -271,7 +271,7 @@ FTexture2DRHIRef CreateRHITexture2D_Async( void* mipsData[16]; for (size_t i = 0; i < mipCount; ++i) { - const CesiumGltf::ImageCesiumMipPosition& mipPos = image.mipPositions[i]; + const CesiumGltf::ImageAssetMipPosition& mipPos = image.mipPositions[i]; mipsData[i] = (void*)(&image.pixelData[mipPos.byteOffset]); } @@ -303,7 +303,7 @@ void FCesiumTextureResourceDeleter::operator()(FCesiumTextureResource* p) { } /*static*/ FCesiumTextureResourceUniquePtr FCesiumTextureResource::CreateNew( - CesiumGltf::ImageCesium& imageCesium, + CesiumGltf::ImageAsset& imageCesium, TextureGroup textureGroup, const std::optional& overridePixelFormat, TextureFilter filter, @@ -328,7 +328,7 @@ void FCesiumTextureResourceDeleter::operator()(FCesiumTextureResource* p) { } std::optional maybePixelFormat = - CesiumTextureUtility::getPixelFormatForImageCesium( + CesiumTextureUtility::getPixelFormatForImageAsset( imageCesium, overridePixelFormat); if (!maybePixelFormat) { @@ -379,7 +379,7 @@ void FCesiumTextureResourceDeleter::operator()(FCesiumTextureResource* p) { std::vector pixelData; imageCesium.pixelData.swap(pixelData); - std::vector mipPositions; + std::vector mipPositions; imageCesium.mipPositions.swap(mipPositions); return pResult; @@ -519,18 +519,16 @@ void FCesiumTextureResource::InitRHI() { CalcMipMapExtent(this->_width, this->_height, this->_format, 0); const FRHIResourceCreateInfo CreateInfo(this->_platformExtData); - FDynamicRHI::FRHICalcTextureSizeResult result = RHICalcTexturePlatformSize( - FRHITextureDesc::Create2D( - MipExtents, - this->_format, - CreateInfo.ClearValueBinding, - textureFlags, - this->GetCurrentMipCount(), - 1, - CreateInfo.ExtData), - 0); - - this->_textureSize = result.Size; + uint32 alignment; + this->_textureSize = RHICalcTexture2DPlatformSize( + MipExtents.X, + MipExtents.Y, + this->_format, + this->GetCurrentMipCount(), + 1, + textureFlags, + FRHIResourceCreateInfo(this->_platformExtData), + alignment); INC_DWORD_STAT_BY(STAT_TextureMemory, this->_textureSize); INC_DWORD_STAT_FNAME_BY(this->_lodGroupStatName, this->_textureSize); @@ -643,7 +641,7 @@ FTextureRHIRef FCesiumUseExistingTextureResource::InitializeTextureRHI() { } FCesiumCreateNewTextureResource::FCesiumCreateNewTextureResource( - CesiumGltf::ImageCesium&& image, + CesiumGltf::ImageAsset&& image, TextureGroup textureGroup, uint32 width, uint32 height, @@ -732,7 +730,7 @@ FTextureRHIRef FCesiumCreateNewTextureResource::InitializeTextureRHI() { std::vector pixelData; this->_image.pixelData.swap(pixelData); - std::vector mipPositions; + std::vector mipPositions; this->_image.mipPositions.swap(mipPositions); return rhiTexture; diff --git a/Source/CesiumRuntime/Private/CesiumTextureResource.h b/Source/CesiumRuntime/Private/CesiumTextureResource.h index 567abec86..4e7906c18 100644 --- a/Source/CesiumRuntime/Private/CesiumTextureResource.h +++ b/Source/CesiumRuntime/Private/CesiumTextureResource.h @@ -6,7 +6,7 @@ #include "Engine/Texture.h" #include "TextureResource.h" #include -#include +#include class FCesiumTextureResource; @@ -25,7 +25,7 @@ using FCesiumTextureResourceUniquePtr = class FCesiumTextureResource : public FTextureResource { public: /** - * Create a new FCesiumTextureResource from an ImageCesium and the given + * Create a new FCesiumTextureResource from an `ImageAsset` and the given * sampling parameters. This method is intended to be called from a worker * thread, not from the game or render thread. * @@ -34,7 +34,7 @@ class FCesiumTextureResource : public FTextureResource { * `sizeBytes` will be set to its previous size. * @param textureGroup The texture group in which to create this texture. * @param overridePixelFormat Overrides the pixel format. If std::nullopt, the - * format is inferred from the `ImageCesium`. + * format is inferred from the `ImageAsset`. * @param filter The texture filtering to use when sampling this texture. * @param addressX The X texture addressing mode to use when sampling this * texture. @@ -48,7 +48,7 @@ class FCesiumTextureResource : public FTextureResource { * created. */ static FCesiumTextureResourceUniquePtr CreateNew( - CesiumGltf::ImageCesium& imageCesium, + CesiumGltf::ImageAsset& imageCesium, TextureGroup textureGroup, const std::optional& overridePixelFormat, TextureFilter filter, diff --git a/Source/CesiumRuntime/Private/CesiumTextureUtility.cpp b/Source/CesiumRuntime/Private/CesiumTextureUtility.cpp index 9c0ba9b00..603b6bde9 100644 --- a/Source/CesiumRuntime/Private/CesiumTextureUtility.cpp +++ b/Source/CesiumRuntime/Private/CesiumTextureUtility.cpp @@ -10,7 +10,7 @@ #include "CesiumTextureResource.h" #include "Containers/ResourceArray.h" #include "DynamicRHI.h" -#include "ExtensionImageCesiumUnreal.h" +#include "ExtensionImageAssetUnreal.h" #include "GenericPlatform/GenericPlatformProcess.h" #include "PixelFormat.h" #include "RHICommandList.h" @@ -23,7 +23,7 @@ #include "UObject/Package.h" #include #include -#include +#include #include #include #include @@ -109,7 +109,7 @@ FTexture2DRHIRef createAsyncTextureAndWaitOld( * @return The RHI texture reference. */ FTexture2DRHIRef CreateRHITexture2D_AsyncOld( - const CesiumGltf::ImageCesium& image, + const CesiumGltf::ImageAsset& image, EPixelFormat format, bool sRGB) { check(GRHISupportsAsyncTextureCreation); @@ -135,7 +135,7 @@ FTexture2DRHIRef CreateRHITexture2D_AsyncOld( void* mipsData[16]; for (size_t i = 0; i < mipCount; ++i) { - const CesiumGltf::ImageCesiumMipPosition& mipPos = image.mipPositions[i]; + const CesiumGltf::ImageAssetMipPosition& mipPos = image.mipPositions[i]; mipsData[i] = (void*)(&image.pixelData[mipPos.byteOffset]); } @@ -369,7 +369,7 @@ bool getUseMipmapsIfAvailableFromSampler(const CesiumGltf::Sampler& sampler) { } TUniquePtr loadTextureFromImageAndSamplerAnyThreadPart( - CesiumGltf::ImageCesium& image, + CesiumGltf::ImageAsset& image, const CesiumGltf::Sampler& sampler, bool sRGB) { return loadTextureAnyThreadPart( @@ -414,7 +414,7 @@ static UTexture2D* CreateTexture2D(LoadedTextureResult* pHalfLoadedTexture) { } TUniquePtr loadTextureAnyThreadPart( - CesiumGltf::ImageCesium& image, + CesiumGltf::ImageAsset& image, TextureAddress addressX, TextureAddress addressY, TextureFilter filter, @@ -422,10 +422,10 @@ TUniquePtr loadTextureAnyThreadPart( TextureGroup group, bool sRGB, std::optional overridePixelFormat) { - // The FCesiumTextureResource for the ImageCesium should already be created at + // The FCesiumTextureResource for the ImageAsset should already be created at // this point, if it can be. - const ExtensionImageCesiumUnreal& extension = - ExtensionImageCesiumUnreal::getOrCreate( + const ExtensionImageAssetUnreal& extension = + ExtensionImageAssetUnreal::getOrCreate( CesiumAsync::AsyncSystem(nullptr), image, sRGB, @@ -546,8 +546,8 @@ TextureAddress convertGltfWrapTToUnreal(int32_t wrapT) { } } -std::optional getPixelFormatForImageCesium( - const ImageCesium& imageCesium, +std::optional getPixelFormatForImageAsset( + const ImageAsset& imageCesium, const std::optional overridePixelFormat) { if (imageCesium.compressedPixelFormat != GpuCompressedPixelFormat::NONE) { switch (imageCesium.compressedPixelFormat) { diff --git a/Source/CesiumRuntime/Private/CesiumTextureUtility.h b/Source/CesiumRuntime/Private/CesiumTextureUtility.h index bcb835db4..3c1b9d8e5 100644 --- a/Source/CesiumRuntime/Private/CesiumTextureUtility.h +++ b/Source/CesiumRuntime/Private/CesiumTextureUtility.h @@ -17,7 +17,7 @@ #include namespace CesiumGltf { -struct ImageCesium; +struct ImageAsset; struct Texture; } // namespace CesiumGltf @@ -118,15 +118,15 @@ TUniquePtr loadTextureFromModelAnyThreadPart( * and can be empty. */ TUniquePtr loadTextureFromImageAndSamplerAnyThreadPart( - CesiumGltf::ImageCesium& image, + CesiumGltf::ImageAsset& image, const CesiumGltf::Sampler& sampler, bool sRGB); /** * @brief Does the asynchronous part of renderer resource preparation for * a texture.The given image _must_ be prepared before calling this method by - * calling {@link ExtensionImageCesiumUnreal::getOrCreate} and then waiting - * for {@link ExtensionImageCesiumUnreal::getFuture} to resolve. This method + * calling {@link ExtensionImageAssetUnreal::getOrCreate} and then waiting + * for {@link ExtensionImageAssetUnreal::getFuture} to resolve. This method * should be called in a background thread. * * @param imageCesium The image. @@ -142,7 +142,7 @@ TUniquePtr loadTextureFromImageAndSamplerAnyThreadPart( * @return The loaded texture. */ TUniquePtr loadTextureAnyThreadPart( - CesiumGltf::ImageCesium& image, + CesiumGltf::ImageAsset& image, TextureAddress addressX, TextureAddress addressY, TextureFilter filter, @@ -198,8 +198,8 @@ TextureAddress convertGltfWrapSToUnreal(int32_t wrapS); */ TextureAddress convertGltfWrapTToUnreal(int32_t wrapT); -std::optional getPixelFormatForImageCesium( - const CesiumGltf::ImageCesium& imageCesium, +std::optional getPixelFormatForImageAsset( + const CesiumGltf::ImageAsset& imageCesium, const std::optional overridePixelFormat); std::optional diff --git a/Source/CesiumRuntime/Private/ExtensionImageCesiumUnreal.cpp b/Source/CesiumRuntime/Private/ExtensionImageAssetUnreal.cpp similarity index 68% rename from Source/CesiumRuntime/Private/ExtensionImageCesiumUnreal.cpp rename to Source/CesiumRuntime/Private/ExtensionImageAssetUnreal.cpp index f1081af7e..9f2120a9b 100644 --- a/Source/CesiumRuntime/Private/ExtensionImageCesiumUnreal.cpp +++ b/Source/CesiumRuntime/Private/ExtensionImageAssetUnreal.cpp @@ -1,7 +1,7 @@ -#include "ExtensionImageCesiumUnreal.h" +#include "ExtensionImageAssetUnreal.h" #include "CesiumRuntime.h" #include "CesiumTextureUtility.h" -#include +#include #include using namespace CesiumAsync; @@ -12,17 +12,15 @@ namespace { std::mutex createExtensionMutex; -std::pair>> -getOrCreateImageFuture( - const AsyncSystem& asyncSystem, - ImageCesium& imageCesium); +std::pair>> +getOrCreateImageFuture(const AsyncSystem& asyncSystem, ImageAsset& imageCesium); } // namespace -/*static*/ const ExtensionImageCesiumUnreal& -ExtensionImageCesiumUnreal::getOrCreate( +/*static*/ const ExtensionImageAssetUnreal& +ExtensionImageAssetUnreal::getOrCreate( const CesiumAsync::AsyncSystem& asyncSystem, - CesiumGltf::ImageCesium& imageCesium, + CesiumGltf::ImageAsset& imageCesium, bool sRGB, bool needsMipMaps, const std::optional& overridePixelFormat) { @@ -55,43 +53,43 @@ ExtensionImageCesiumUnreal::getOrCreate( return extension; } -ExtensionImageCesiumUnreal::ExtensionImageCesiumUnreal( +ExtensionImageAssetUnreal::ExtensionImageAssetUnreal( const CesiumAsync::SharedFuture& future) : _pTextureResource(nullptr), _futureCreateResource(future) {} const TSharedPtr& -ExtensionImageCesiumUnreal::getTextureResource() const { +ExtensionImageAssetUnreal::getTextureResource() const { return this->_pTextureResource; } -CesiumAsync::SharedFuture& ExtensionImageCesiumUnreal::getFuture() { +CesiumAsync::SharedFuture& ExtensionImageAssetUnreal::getFuture() { return this->_futureCreateResource; } const CesiumAsync::SharedFuture& -ExtensionImageCesiumUnreal::getFuture() const { +ExtensionImageAssetUnreal::getFuture() const { return this->_futureCreateResource; } namespace { -// Returns the ExtensionImageCesiumUnreal, which is created if it does not +// Returns the ExtensionImageAssetUnreal, which is created if it does not // already exist. It _may_ also return a Promise, in which case the calling // thread is responsible for doing the loading and should resolve the Promise // when it's done. -std::pair>> +std::pair>> getOrCreateImageFuture( const AsyncSystem& asyncSystem, - ImageCesium& imageCesium) { + ImageAsset& imageCesium) { std::scoped_lock lock(createExtensionMutex); - ExtensionImageCesiumUnreal* pExtension = - imageCesium.getExtension(); + ExtensionImageAssetUnreal* pExtension = + imageCesium.getExtension(); if (!pExtension) { // This thread will work on this image. Promise promise = asyncSystem.createPromise(); - ExtensionImageCesiumUnreal& extension = - imageCesium.addExtension( + ExtensionImageAssetUnreal& extension = + imageCesium.addExtension( promise.getFuture().share()); return {extension, std::move(promise)}; } else { diff --git a/Source/CesiumRuntime/Private/ExtensionImageCesiumUnreal.h b/Source/CesiumRuntime/Private/ExtensionImageAssetUnreal.h similarity index 82% rename from Source/CesiumRuntime/Private/ExtensionImageCesiumUnreal.h rename to Source/CesiumRuntime/Private/ExtensionImageAssetUnreal.h index 133361c94..824bc4d27 100644 --- a/Source/CesiumRuntime/Private/ExtensionImageCesiumUnreal.h +++ b/Source/CesiumRuntime/Private/ExtensionImageAssetUnreal.h @@ -9,14 +9,14 @@ #include namespace CesiumGltf { -struct ImageCesium; +struct ImageAsset; } /** - * @brief An extension attached to an ImageCesium in order to hold + * @brief An extension attached to an ImageAsset in order to hold * Unreal-specific information about it. * - * ImageCesium instances are shared between multiple textures on a single model, + * ImageAsset instances are shared between multiple textures on a single model, * and even between models in some cases, but we strive to have only one copy of * the image bytes in GPU memory. * @@ -31,29 +31,29 @@ struct ImageCesium; * Because we'll never be sampling from this texture resource, the texture * filtering and addressing parameters have default values. */ -struct ExtensionImageCesiumUnreal { - static inline constexpr const char* TypeName = "ExtensionImageCesiumUnreal"; +struct ExtensionImageAssetUnreal { + static inline constexpr const char* TypeName = "ExtensionImageAssetUnreal"; static inline constexpr const char* ExtensionName = - "PRIVATE_ImageCesium_Unreal"; + "PRIVATE_ImageAsset_Unreal"; /** - * @brief Gets an Unreal texture resource from the given `ImageCesium`, + * @brief Gets an Unreal texture resource from the given `ImageAsset`, * creating it if necessary. * * When this function is called for the first time on a particular - * `ImageCesium`, the asynchronous process to create an Unreal + * `ImageAsset`, the asynchronous process to create an Unreal * `FTextureResource` from it is kicked off. On successive invocations * (perhaps from other threads), the existing instance is returned. It is safe - * to call this method on the same `ImageCesium` instance from multiple + * to call this method on the same `ImageAsset` instance from multiple * threads simultaneously as long as no other thread is modifying the instance * at the same time. * * To determine if the asynchronous `FTextureResource` creation process has * completed, use {@link getFuture}. */ - static const ExtensionImageCesiumUnreal& getOrCreate( + static const ExtensionImageAssetUnreal& getOrCreate( const CesiumAsync::AsyncSystem& asyncSystem, - CesiumGltf::ImageCesium& imageCesium, + CesiumGltf::ImageAsset& imageCesium, bool sRGB, bool needsMipMaps, const std::optional& overridePixelFormat); @@ -64,7 +64,7 @@ struct ExtensionImageCesiumUnreal { * @param future The future that will resolve when loading of the * {@link getTextureResource} is complete. */ - ExtensionImageCesiumUnreal(const CesiumAsync::SharedFuture& future); + ExtensionImageAssetUnreal(const CesiumAsync::SharedFuture& future); /** * Gets the created texture resource. This resource should not be accessed or diff --git a/Source/CesiumRuntime/Private/Tests/CesiumPropertyTextureProperty.spec.cpp b/Source/CesiumRuntime/Private/Tests/CesiumPropertyTextureProperty.spec.cpp index d9361976c..d20bc855c 100644 --- a/Source/CesiumRuntime/Private/Tests/CesiumPropertyTextureProperty.spec.cpp +++ b/Source/CesiumRuntime/Private/Tests/CesiumPropertyTextureProperty.spec.cpp @@ -81,7 +81,7 @@ void FCesiumPropertyTexturePropertySpec::Define() { classProperty.componentType = ClassProperty::ComponentType::UINT8; Sampler sampler; - ImageCesium image; + ImageAsset image; image.width = 2; image.height = 2; image.channels = 1; @@ -170,7 +170,7 @@ void FCesiumPropertyTexturePropertySpec::Define() { classProperty.normalized = true; Sampler sampler; - ImageCesium image; + ImageAsset image; image.width = 2; image.height = 2; image.channels = 1; @@ -235,7 +235,7 @@ void FCesiumPropertyTexturePropertySpec::Define() { classProperty.count = 2; Sampler sampler; - ImageCesium image; + ImageAsset image; image.width = 2; image.height = 2; image.channels = 2; @@ -312,7 +312,7 @@ void FCesiumPropertyTexturePropertySpec::Define() { classProperty.defaultProperty = defaultValue; Sampler sampler; - ImageCesium image; + ImageAsset image; image.width = 2; image.height = 2; image.channels = 1; @@ -434,7 +434,7 @@ void FCesiumPropertyTexturePropertySpec::Define() { classProperty.componentType = ClassProperty::ComponentType::UINT8; Sampler sampler; - ImageCesium image; + ImageAsset image; image.width = 2; image.height = 2; image.channels = 1; @@ -472,7 +472,7 @@ void FCesiumPropertyTexturePropertySpec::Define() { classProperty.componentType = ClassProperty::ComponentType::INT16; Sampler sampler; - ImageCesium image; + ImageAsset image; image.width = 2; image.height = 2; image.channels = 2; @@ -526,7 +526,7 @@ void FCesiumPropertyTexturePropertySpec::Define() { classProperty.defaultProperty = defaultValue; Sampler sampler; - ImageCesium image; + ImageAsset image; image.width = 2; image.height = 2; image.channels = 1; @@ -590,7 +590,7 @@ void FCesiumPropertyTexturePropertySpec::Define() { classProperty.componentType = ClassProperty::ComponentType::INT32; Sampler sampler; - ImageCesium image; + ImageAsset image; image.width = 2; image.height = 2; image.channels = 4; @@ -634,7 +634,7 @@ void FCesiumPropertyTexturePropertySpec::Define() { classProperty.componentType = ClassProperty::ComponentType::FLOAT32; Sampler sampler; - ImageCesium image; + ImageAsset image; image.width = 2; image.height = 2; image.channels = 4; @@ -688,7 +688,7 @@ void FCesiumPropertyTexturePropertySpec::Define() { classProperty.defaultProperty = defaultValue; Sampler sampler; - ImageCesium image; + ImageAsset image; image.width = 2; image.height = 2; image.channels = 4; @@ -758,7 +758,7 @@ void FCesiumPropertyTexturePropertySpec::Define() { classProperty.componentType = ClassProperty::ComponentType::FLOAT32; Sampler sampler; - ImageCesium image; + ImageAsset image; image.width = 2; image.height = 2; image.channels = 4; @@ -804,7 +804,7 @@ void FCesiumPropertyTexturePropertySpec::Define() { classProperty.componentType = ClassProperty::ComponentType::UINT8; Sampler sampler; - ImageCesium image; + ImageAsset image; image.width = 2; image.height = 2; image.channels = 1; @@ -848,7 +848,7 @@ void FCesiumPropertyTexturePropertySpec::Define() { classProperty.scale = scale; Sampler sampler; - ImageCesium image; + ImageAsset image; image.width = 2; image.height = 2; image.channels = 4; @@ -912,7 +912,7 @@ void FCesiumPropertyTexturePropertySpec::Define() { classProperty.normalized = true; Sampler sampler; - ImageCesium image; + ImageAsset image; image.width = 2; image.height = 2; image.channels = 1; @@ -955,7 +955,7 @@ void FCesiumPropertyTexturePropertySpec::Define() { classProperty.componentType = ClassProperty::ComponentType::FLOAT32; Sampler sampler; - ImageCesium image; + ImageAsset image; image.width = 2; image.height = 2; image.channels = 4; @@ -1008,7 +1008,7 @@ void FCesiumPropertyTexturePropertySpec::Define() { classProperty.scale = scale; Sampler sampler; - ImageCesium image; + ImageAsset image; image.width = 2; image.height = 2; image.channels = 1; @@ -1066,7 +1066,7 @@ void FCesiumPropertyTexturePropertySpec::Define() { classProperty.componentType = ClassProperty::ComponentType::INT8; Sampler sampler; - ImageCesium image; + ImageAsset image; image.width = 2; image.height = 2; image.channels = 2; @@ -1110,7 +1110,7 @@ void FCesiumPropertyTexturePropertySpec::Define() { classProperty.componentType = ClassProperty::ComponentType::FLOAT32; Sampler sampler; - ImageCesium image; + ImageAsset image; image.width = 2; image.height = 2; image.channels = 4; @@ -1168,7 +1168,7 @@ void FCesiumPropertyTexturePropertySpec::Define() { classProperty.defaultProperty = {defaultValue[0], defaultValue[1]}; Sampler sampler; - ImageCesium image; + ImageAsset image; image.width = 2; image.height = 2; image.channels = 2; @@ -1239,7 +1239,7 @@ void FCesiumPropertyTexturePropertySpec::Define() { classProperty.normalized = true; Sampler sampler; - ImageCesium image; + ImageAsset image; image.width = 2; image.height = 2; image.channels = 2; @@ -1290,7 +1290,7 @@ void FCesiumPropertyTexturePropertySpec::Define() { classProperty.componentType = ClassProperty::ComponentType::UINT8; Sampler sampler; - ImageCesium image; + ImageAsset image; image.width = 2; image.height = 2; image.channels = 2; @@ -1342,7 +1342,7 @@ void FCesiumPropertyTexturePropertySpec::Define() { classProperty.scale = {scale[0], scale[1]}; Sampler sampler; - ImageCesium image; + ImageAsset image; image.width = 2; image.height = 2; image.channels = 2; @@ -1409,7 +1409,7 @@ void FCesiumPropertyTexturePropertySpec::Define() { classProperty.componentType = ClassProperty::ComponentType::INT8; Sampler sampler; - ImageCesium image; + ImageAsset image; image.width = 2; image.height = 2; image.channels = 3; @@ -1453,7 +1453,7 @@ void FCesiumPropertyTexturePropertySpec::Define() { classProperty.componentType = ClassProperty::ComponentType::FLOAT32; Sampler sampler; - ImageCesium image; + ImageAsset image; image.width = 2; image.height = 2; image.channels = 4; @@ -1514,7 +1514,7 @@ void FCesiumPropertyTexturePropertySpec::Define() { defaultValue[2]}; Sampler sampler; - ImageCesium image; + ImageAsset image; image.width = 2; image.height = 2; image.channels = 3; @@ -1585,7 +1585,7 @@ void FCesiumPropertyTexturePropertySpec::Define() { classProperty.normalized = true; Sampler sampler; - ImageCesium image; + ImageAsset image; image.width = 2; image.height = 2; image.channels = 3; @@ -1637,7 +1637,7 @@ void FCesiumPropertyTexturePropertySpec::Define() { classProperty.componentType = ClassProperty::ComponentType::INT8; Sampler sampler; - ImageCesium image; + ImageAsset image; image.width = 2; image.height = 2; image.channels = 3; @@ -1689,7 +1689,7 @@ void FCesiumPropertyTexturePropertySpec::Define() { classProperty.scale = {scale[0], scale[1], scale[2]}; Sampler sampler; - ImageCesium image; + ImageAsset image; image.width = 2; image.height = 2; image.channels = 3; @@ -1757,7 +1757,7 @@ void FCesiumPropertyTexturePropertySpec::Define() { classProperty.normalized = true; Sampler sampler; - ImageCesium image; + ImageAsset image; image.width = 2; image.height = 2; image.channels = 4; @@ -1814,7 +1814,7 @@ void FCesiumPropertyTexturePropertySpec::Define() { classProperty.componentType = ClassProperty::ComponentType::INT8; Sampler sampler; - ImageCesium image; + ImageAsset image; image.width = 2; image.height = 2; image.channels = 4; @@ -1872,7 +1872,7 @@ void FCesiumPropertyTexturePropertySpec::Define() { classProperty.scale = {scale[0], scale[1], scale[2], scale[3]}; Sampler sampler; - ImageCesium image; + ImageAsset image; image.width = 2; image.height = 2; image.channels = 4; @@ -1923,7 +1923,7 @@ void FCesiumPropertyTexturePropertySpec::Define() { classProperty.componentType = ClassProperty::ComponentType::INT32; Sampler sampler; - ImageCesium image; + ImageAsset image; image.width = 2; image.height = 2; image.channels = 4; @@ -1999,7 +1999,7 @@ void FCesiumPropertyTexturePropertySpec::Define() { classProperty.count = 2; Sampler sampler; - ImageCesium image; + ImageAsset image; image.width = 2; image.height = 2; image.channels = 2; @@ -2067,7 +2067,7 @@ void FCesiumPropertyTexturePropertySpec::Define() { classProperty.noData = {0, 0}; Sampler sampler; - ImageCesium image; + ImageAsset image; image.width = 2; image.height = 2; image.channels = 2; @@ -2155,7 +2155,7 @@ void FCesiumPropertyTexturePropertySpec::Define() { classProperty.defaultProperty = {10, 20}; Sampler sampler; - ImageCesium image; + ImageAsset image; image.width = 2; image.height = 2; image.channels = 2; @@ -2256,7 +2256,7 @@ void FCesiumPropertyTexturePropertySpec::Define() { classProperty.componentType = ClassProperty::ComponentType::INT32; Sampler sampler; - ImageCesium image; + ImageAsset image; image.width = 2; image.height = 2; image.channels = 4; @@ -2316,7 +2316,7 @@ void FCesiumPropertyTexturePropertySpec::Define() { classProperty.scale = scale; Sampler sampler; - ImageCesium image; + ImageAsset image; image.width = 2; image.height = 2; image.channels = 4; @@ -2373,7 +2373,7 @@ void FCesiumPropertyTexturePropertySpec::Define() { classProperty.noData = noData; Sampler sampler; - ImageCesium image; + ImageAsset image; image.width = 2; image.height = 2; image.channels = 4; @@ -2441,7 +2441,7 @@ void FCesiumPropertyTexturePropertySpec::Define() { classProperty.defaultProperty = defaultValue; Sampler sampler; - ImageCesium image; + ImageAsset image; image.width = 2; image.height = 2; image.channels = 4; diff --git a/Source/CesiumRuntime/Private/Tests/CesiumTextureUtility.spec.cpp b/Source/CesiumRuntime/Private/Tests/CesiumTextureUtility.spec.cpp index 975275d66..c5dbd9862 100644 --- a/Source/CesiumRuntime/Private/Tests/CesiumTextureUtility.spec.cpp +++ b/Source/CesiumRuntime/Private/Tests/CesiumTextureUtility.spec.cpp @@ -2,7 +2,7 @@ #include "CesiumTextureUtility.h" #include "CesiumAsync/AsyncSystem.h" -#include "ExtensionImageCesiumUnreal.h" +#include "ExtensionImageAssetUnreal.h" #include "Misc/AutomationTest.h" #include "RenderingThread.h" #include @@ -21,7 +21,7 @@ BEGIN_DEFINE_SPEC( std::vector originalPixels; std::vector originalMipPixels; std::vector expectedMipPixelsIfGenerated; -CesiumUtility::IntrusivePointer pImageCesium; +CesiumUtility::IntrusivePointer pImageAsset; void RunTests(); @@ -51,23 +51,23 @@ void CesiumTextureUtilitySpec::Define() { 0x24, 0x44, 0x84, 0xF4, 0x25, 0x45, 0x85, 0xF5}; originalMipPixels.clear(); - pImageCesium.emplace(); - pImageCesium->width = 3; - pImageCesium->height = 2; + pImageAsset.emplace(); + pImageAsset->width = 3; + pImageAsset->height = 2; TestEqual( "image buffer size is correct", originalPixels.size(), - pImageCesium->width * pImageCesium->height * - pImageCesium->bytesPerChannel * pImageCesium->channels); - pImageCesium->pixelData.resize(originalPixels.size()); + pImageAsset->width * pImageAsset->height * + pImageAsset->bytesPerChannel * pImageAsset->channels); + pImageAsset->pixelData.resize(originalPixels.size()); std::memcpy( - pImageCesium->pixelData.data(), + pImageAsset->pixelData.data(), originalPixels.data(), originalPixels.size()); - CesiumUtility::IntrusivePointer pCopy = - new ImageCesium(*pImageCesium); + CesiumUtility::IntrusivePointer pCopy = + new ImageAsset(*pImageAsset); CesiumGltfReader::GltfReader::generateMipMaps(*pCopy); expectedMipPixelsIfGenerated.clear(); @@ -87,31 +87,31 @@ void CesiumTextureUtilitySpec::Define() { Describe("With Mips", [this]() { BeforeEach([this]() { - pImageCesium.emplace(); - pImageCesium->width = 3; - pImageCesium->height = 2; + pImageAsset.emplace(); + pImageAsset->width = 3; + pImageAsset->height = 2; // Original image (3x2) originalPixels = {0x20, 0x40, 0x80, 0xF0, 0x21, 0x41, 0x81, 0xF1, 0x22, 0x42, 0x82, 0xF2, 0x23, 0x43, 0x83, 0xF3, 0x24, 0x44, 0x84, 0xF4, 0x25, 0x45, 0x85, 0xF5}; - pImageCesium->mipPositions.emplace_back( - ImageCesiumMipPosition{0, originalPixels.size()}); + pImageAsset->mipPositions.emplace_back( + ImageAssetMipPosition{0, originalPixels.size()}); // Mip 1 (1x1) originalMipPixels = {0x26, 0x46, 0x86, 0xF6}; - pImageCesium->mipPositions.emplace_back(ImageCesiumMipPosition{ - pImageCesium->mipPositions[0].byteSize, + pImageAsset->mipPositions.emplace_back(ImageAssetMipPosition{ + pImageAsset->mipPositions[0].byteSize, originalMipPixels.size()}); - pImageCesium->pixelData.resize( + pImageAsset->pixelData.resize( originalPixels.size() + originalMipPixels.size()); std::memcpy( - pImageCesium->pixelData.data(), + pImageAsset->pixelData.data(), originalPixels.data(), originalPixels.size()); std::memcpy( - pImageCesium->pixelData.data() + originalPixels.size(), + pImageAsset->pixelData.data() + originalPixels.size(), originalMipPixels.data(), originalMipPixels.size()); }); @@ -121,9 +121,9 @@ void CesiumTextureUtilitySpec::Define() { } void CesiumTextureUtilitySpec::RunTests() { - It("ImageCesium non-sRGB", [this]() { + It("ImageAsset non-sRGB", [this]() { TUniquePtr pHalfLoaded = loadTextureAnyThreadPart( - *pImageCesium, + *pImageAsset, TextureAddress::TA_Mirror, TextureAddress::TA_Wrap, TextureFilter::TF_Bilinear, @@ -145,9 +145,9 @@ void CesiumTextureUtilitySpec::RunTests() { CheckGroup(pRefCountedTexture, TextureGroup::TEXTUREGROUP_Cinematic); }); - It("ImageCesium sRGB", [this]() { + It("ImageAsset sRGB", [this]() { TUniquePtr pHalfLoaded = loadTextureAnyThreadPart( - *pImageCesium, + *pImageAsset, TextureAddress::TA_Clamp, TextureAddress::TA_Mirror, TextureFilter::TF_Trilinear, @@ -178,7 +178,7 @@ void CesiumTextureUtilitySpec::RunTests() { TUniquePtr pHalfLoaded = loadTextureFromImageAndSamplerAnyThreadPart( - *pImageCesium, + *pImageAsset, sampler, false); TestNotNull("pHalfLoaded", pHalfLoaded.Get()); @@ -199,7 +199,7 @@ void CesiumTextureUtilitySpec::RunTests() { Model model; Image& image = model.images.emplace_back(); - image.pCesium = pImageCesium; + image.pCesium = pImageAsset; Sampler& sampler = model.samplers.emplace_back(); sampler.minFilter = Sampler::MinFilter::LINEAR_MIPMAP_LINEAR; @@ -232,7 +232,7 @@ void CesiumTextureUtilitySpec::RunTests() { Model model; Image& image = model.images.emplace_back(); - image.pCesium = pImageCesium; + image.pCesium = pImageAsset; Sampler& sampler1 = model.samplers.emplace_back(); sampler1.minFilter = Sampler::MinFilter::LINEAR_MIPMAP_LINEAR; @@ -299,7 +299,7 @@ void CesiumTextureUtilitySpec::RunTests() { Model model; Image& image = model.images.emplace_back(); - image.pCesium = pImageCesium; + image.pCesium = pImageAsset; Sampler& sampler = model.samplers.emplace_back(); sampler.minFilter = Sampler::MinFilter::LINEAR_MIPMAP_LINEAR; @@ -348,7 +348,7 @@ void CesiumTextureUtilitySpec::RunTests() { Model model; Image& image = model.images.emplace_back(); - image.pCesium = pImageCesium; + image.pCesium = pImageAsset; Sampler& sampler = model.samplers.emplace_back(); sampler.minFilter = Sampler::MinFilter::LINEAR_MIPMAP_LINEAR; diff --git a/Source/CesiumRuntime/Public/CesiumPropertyTextureProperty.h b/Source/CesiumRuntime/Public/CesiumPropertyTextureProperty.h index c9c855b5a..7d4b9a056 100644 --- a/Source/CesiumRuntime/Public/CesiumPropertyTextureProperty.h +++ b/Source/CesiumRuntime/Public/CesiumPropertyTextureProperty.h @@ -98,7 +98,7 @@ struct CESIUMRUNTIME_API FCesiumPropertyTextureProperty { const int64 getTexCoordSetIndex() const; const CesiumGltf::Sampler* getSampler() const; - const CesiumGltf::ImageCesium* getImage() const; + const CesiumGltf::ImageAsset* getImage() const; const std::optional getTextureTransform() const; diff --git a/extern/cesium-native b/extern/cesium-native index 526e66068..883e36f10 160000 --- a/extern/cesium-native +++ b/extern/cesium-native @@ -1 +1 @@ -Subproject commit 526e660687d64d98b3f1aea3b8338dafbac0b1db +Subproject commit 883e36f100c6a1487bf1103bafb937a66578705b