From 95ff93ad8c8946a8b8605a2c53aa39ce8d11e267 Mon Sep 17 00:00:00 2001 From: Marco Hutter Date: Thu, 4 Mar 2021 17:23:15 +0100 Subject: [PATCH] Use bytes for raw data --- Source/Cesium/Private/CesiumGltfComponent.cpp | 3 ++- Source/Cesium/Private/UnrealAssetAccessor.cpp | 9 +++++---- Source/Cesium/Public/UnrealAssetAccessor.h | 3 ++- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Source/Cesium/Private/CesiumGltfComponent.cpp b/Source/Cesium/Private/CesiumGltfComponent.cpp index 2f1977a57..c303be706 100644 --- a/Source/Cesium/Private/CesiumGltfComponent.cpp +++ b/Source/Cesium/Private/CesiumGltfComponent.cpp @@ -37,6 +37,7 @@ #define STB_IMAGE_RESIZE_IMPLEMENTATION #include +#include using namespace CesiumGltf; @@ -1229,7 +1230,7 @@ void UCesiumGltfComponent::ModelRequestComplete(FHttpRequestPtr request, FHttpRe // TODO: is it reasonable to use the global thread pool for this? TFuture future = Async(EAsyncExecution::ThreadPool, [this, content] { - gsl::span data(static_cast(content.GetData()), content.Num()); + gsl::span data(reinterpret_cast(content.GetData()), content.Num()); std::unique_ptr pLoadResult = std::make_unique(std::move(CesiumGltf::readModel(data))); if (!pLoadResult->warnings.empty()) { diff --git a/Source/Cesium/Private/UnrealAssetAccessor.cpp b/Source/Cesium/Private/UnrealAssetAccessor.cpp index 7d7823a92..f3517f3a8 100644 --- a/Source/Cesium/Private/UnrealAssetAccessor.cpp +++ b/Source/Cesium/Private/UnrealAssetAccessor.cpp @@ -11,6 +11,7 @@ #include "UnrealConversions.h" #include #include +#include static CesiumAsync::HttpHeaders parseHeaders(const TArray& unrealHeaders) { CesiumAsync::HttpHeaders result; @@ -48,9 +49,9 @@ class UnrealAssetResponse : public CesiumAsync::IAssetResponse { return this->_headers; } - virtual gsl::span data() const override { + virtual gsl::span data() const override { const TArray& content = this->_pResponse->GetContent(); - return gsl::span(static_cast(content.GetData()), content.Num()); + return gsl::span(reinterpret_cast(content.GetData()), content.Num()); } private: @@ -133,7 +134,7 @@ CesiumAsync::Future> UnrealAssetAcce const CesiumAsync::AsyncSystem& asyncSystem, const std::string& url, const std::vector& headers, - const gsl::span& contentPayload + const gsl::span& contentPayload ) { return asyncSystem.createFuture>([ &url, @@ -151,7 +152,7 @@ CesiumAsync::Future> UnrealAssetAcce pRequest->AppendToHeader(TEXT("User-Agent"), TEXT("Cesium for Unreal")); - pRequest->SetContent(TArray(contentPayload.data(), contentPayload.size())); + pRequest->SetContent(TArray(reinterpret_cast(contentPayload.data()), contentPayload.size())); pRequest->OnProcessRequestComplete().BindLambda([promise](FHttpRequestPtr pRequest, FHttpResponsePtr pResponse, bool connectedSuccessfully) { if (connectedSuccessfully) { diff --git a/Source/Cesium/Public/UnrealAssetAccessor.h b/Source/Cesium/Public/UnrealAssetAccessor.h index 8c8cdd27f..ff4fd6c2c 100644 --- a/Source/Cesium/Public/UnrealAssetAccessor.h +++ b/Source/Cesium/Public/UnrealAssetAccessor.h @@ -4,6 +4,7 @@ #include "CesiumAsync/IAssetAccessor.h" #include "CesiumAsync/AsyncSystem.h" +#include class CESIUM_API UnrealAssetAccessor : public CesiumAsync::IAssetAccessor { @@ -18,7 +19,7 @@ class CESIUM_API UnrealAssetAccessor : public CesiumAsync::IAssetAccessor const CesiumAsync::AsyncSystem& asyncSystem, const std::string& url, const std::vector& headers, - const gsl::span& contentPayload + const gsl::span& contentPayload ) override; virtual void tick() noexcept override;