diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index b65a9eb8..d16f6ae0 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -41,6 +41,16 @@ jobs:
uses: actions/checkout@v4
with:
submodules: recursive
+ - name: Cache vcpkg artifacts
+ uses: actions/cache@v4
+ with:
+ path: "d:/.ezvcpkg"
+ key: vcpkg-windows-${{ hashFiles('native~/vcpkg/ports/**/vcpkg.json', 'native~/vcpkg/triplets/**/*', 'native~/extern/*toolchain.cmake') }}-${{ hashFiles('native~/extern/cesium-native/CMakeLists.txt', 'native~/CMakeLists.txt') }}
+ restore-keys: |
+ vcpkg-windows-${{ hashFiles('native~/vcpkg/ports/**/vcpkg.json', 'native~/vcpkg/triplets/**/*', 'native~/extern/*toolchain.cmake') }}-
+ - name: Install Ninja
+ run: |
+ choco install -y ninja
- name: Install nasm
uses: ilammy/setup-nasm@v1.5.1
- name: Install wget
@@ -53,8 +63,8 @@ jobs:
del ./UnityHubSetup.exe
- name: Install Unity
run: |
- Start-Process -FilePath "C:/Program Files/Unity Hub/Unity Hub.exe" -Args "-- --headless install --version 2021.3.13f1 --changeset 9e7d58001ecf" -Wait
- Start-Process -FilePath "C:/Program Files/Unity Hub/Unity Hub.exe" -Args "-- --headless install-modules --version 2021.3.13f1 --changeset 9e7d58001ecf --module android android-sdk-ndk-tools android-open-jdk-8u172-b11 universal-windows-platform uwp-il2cpp" -Wait
+ Start-Process -FilePath "C:/Program Files/Unity Hub/Unity Hub.exe" -Args "-- --headless install --version 2022.3.41f1 --changeset 0f988161febf" -Wait
+ Start-Process -FilePath "C:/Program Files/Unity Hub/Unity Hub.exe" -Args "-- --headless install-modules --version 2022.3.41f1 --changeset 0f988161febf --module android android-sdk-ndk-tools android-open-jdk-11.0.14.1+1 universal-windows-platform" -Wait
- name: Create SSH tunnel to Unity License Server
env:
UNITY_LICENSE_SERVER_SSH_KEY: ${{ secrets.UNITY_LICENSE_SERVER_SSH_KEY }}
@@ -93,6 +103,10 @@ jobs:
run: |
mkdir -p d:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity
mv $ENV:GITHUB_WORKSPACE/* d:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity
+ # Disable Unity audio
+ mkdir -p d:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity\ProjectSettings
+ $text="%YAML 1.1`n%TAG !u! tag:unity3d.com,2011:`n--- !u!11 &1`nAudioManager:`n m_DisableAudio: 1`n"
+ [IO.File]::WriteAllLines("d:/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity/ProjectSettings/AudioManager.asset",$text)
- name: Build Reinterop
run: |
cd d:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity
@@ -103,9 +117,20 @@ jobs:
mkdir -p d:\cesium\temp
# Store temp files on the D drive, which is much faster than the EBS-backed C drive.
$ENV:TEMP="d:\cesium\temp"
+ # We only need a release build of vcpkg dependencies
+ $ENV:CESIUM_VCPKG_RELEASE_ONLY="TRUE"
+ # Clear ANDROID_NDK_ROOT so that we use Unity's version
+ Remove-Item Env:ANDROID_NDK_ROOT
+ # Explicitly set the ezvcpkg path. Otherwise it will be `/.ezvcpkg` and the drive letter is ambiguous.
+ $ENV:EZVCPKG_BASEDIR="D:/.ezvcpkg"
+ # Run the build
dotnet run --project Build~
- cat D:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity\native~\build-WSA-x86_64\build.log
- dir d:\cesium\CesiumForUnityBuildProject
+ - name: Publish Logs
+ if: success() || failure() # run this step even if previous step failed
+ uses: actions/upload-artifact@v4
+ with:
+ name: Native Build Logs - Windows
+ path: d:/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity/native~/build-*/build.log
- name: Publish package artifact
if: ${{ success() }}
uses: actions/upload-artifact@v4
@@ -114,7 +139,7 @@ jobs:
path: d:\cesium\CesiumForUnityBuildProject\*.tgz
- name: Run Tests
run: |
- start -FilePath "C:\Program Files\Unity\Hub\Editor\2021.3.13f1\Editor\Unity.exe" -ArgumentList "-runTests -batchmode -projectPath d:\cesium\CesiumForUnityBuildProject -testResults d:\cesium\temp\TestResults.xml -testPlatform PlayMode -logFile d:\cesium\temp\test-log.txt" -Wait
+ start -FilePath "C:\Program Files\Unity\Hub\Editor\2022.3.41f1\Editor\Unity.exe" -ArgumentList "-runTests -batchmode -projectPath d:\cesium\CesiumForUnityBuildProject -testResults d:\cesium\temp\TestResults.xml -testPlatform PlayMode -logFile d:\cesium\temp\test-log.txt" -Wait
cat d:\cesium\temp\test-log.txt
- name: Test Report
uses: kring/test-reporter@v1.6.2-kring
@@ -125,22 +150,23 @@ jobs:
reporter: dotnet-nunit
MacOS:
needs: [QuickChecks]
- runs-on: macos-12
+ runs-on: macos-latest
# Only allow a single macOS build at a time, for Unity licensing reasons
concurrency: mac
steps:
- - name: Set XCode version
- uses: maxim-lobanov/setup-xcode@v1
- with:
- xcode-version: "14.1"
- name: Check out repository code
uses: actions/checkout@v4
with:
submodules: recursive
+ - name: Cache vcpkg artifacts
+ uses: actions/cache@v4
+ with:
+ path: "~/.ezvcpkg"
+ key: vcpkg-mac-${{ hashFiles('native~/vcpkg/ports/**/vcpkg.json', 'native~/vcpkg/triplets/**/*', 'native~/extern/*toolchain.cmake') }}-${{ hashFiles('native~/extern/cesium-native/CMakeLists.txt', 'native~/CMakeLists.txt') }}
+ restore-keys: |
+ vcpkg-mac-${{ hashFiles('native~/vcpkg/ports/**/vcpkg.json', 'native~/vcpkg/triplets/**/*', 'native~/extern/*toolchain.cmake') }}-
- name: Install nasm
uses: ilammy/setup-nasm@v1.5.1
- - name: Install jq
- run: brew install jq
- name: Install Unity Hub
run: |
wget --quiet https://public-cdn.cloud.unity3d.com/hub/prod/UnityHubSetup.dmg
@@ -149,14 +175,14 @@ jobs:
sudo cp -R "./UnityHubSetup/Unity Hub.app" /Applications
hdiutil detach ./UnityHubSetup
rm ./UnityHubSetup.dmg
- - name: Install Unity 2021.3.13f1
+ - name: Install Unity 2022.3.41f1
# This command sometimes returns exit code 130, despite actually succeeding.
continue-on-error: true
run: |
- /Applications/Unity\ Hub.app/Contents/MacOS/Unity\ Hub -- --headless install --version 2021.3.13f1 --changeset 9e7d58001ecf --architecture x86_64
+ /Applications/Unity\ Hub.app/Contents/MacOS/Unity\ Hub -- --headless install --version 2022.3.41f1 --changeset 0f988161febf --architecture arm64
- name: Install Unity iOS Support
run: |
- /Applications/Unity\ Hub.app/Contents/MacOS/Unity\ Hub -- --headless install-modules --version 2021.3.13f1 --changeset 9e7d58001ecf --module ios --architecture x86_64
+ /Applications/Unity\ Hub.app/Contents/MacOS/Unity\ Hub -- --headless install-modules --version 2022.3.41f1 --changeset 0f988161febf --module ios --architecture arm64
- name: Configure Unity to Use the License Server
run: |
sudo mkdir -p "/Library/Application Support/Unity/config"
@@ -196,19 +222,26 @@ jobs:
run: |
mkdir -p ~/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity
mv $GITHUB_WORKSPACE/* ~/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity
+ # Disable Unity audio
+ mkdir -p ~/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity/ProjectSettings
+ echo '%YAML 1.1\n%TAG !u! tag:unity3d.com,2011:\n--- !u!11 &1\nAudioManager:\n m_DisableAudio: 1\n' > ~/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity/ProjectSettings/AudioManager.asset
- name: Build Reinterop
run: |
cd ~/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity
dotnet publish Reinterop~ -o .
- name: Build Package
run: |
+ # We only need a release build of vcpkg dependencies
+ export CESIUM_VCPKG_RELEASE_ONLY="TRUE"
cd ~/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity
dotnet run --project Build~
ls -l ~/cesium/CesiumForUnityBuildProject
- - name: Print log
- if: ${{ failure() }}
- run: |
- cat /Users/runner/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity/native~/build-iOS/build.log
+ - name: Publish Logs
+ if: success() || failure() # run this step even if previous step failed
+ uses: actions/upload-artifact@v4
+ with:
+ name: Native Build Logs - macOS
+ path: ~/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity/native~/build-*/build.log
- name: Publish package artifact
if: ${{ success() }}
uses: actions/upload-artifact@v4
@@ -217,7 +250,7 @@ jobs:
path: ~/cesium/CesiumForUnityBuildProject/*.tgz
- name: Run Tests
run: |
- /Applications/Unity/Hub/Editor/2021.3.13f1/Unity.app/Contents/MacOS/Unity -runTests -batchmode -projectPath ~/cesium/CesiumForUnityBuildProject -testResults ~/cesium/CesiumForUnityBuildProject/TestResults.xml -testPlatform PlayMode -logFile ~/cesium/CesiumForUnityBuildProject/test-log.txt
+ /Applications/Unity/Hub/Editor/2022.3.41f1/Unity.app/Contents/MacOS/Unity -runTests -batchmode -projectPath ~/cesium/CesiumForUnityBuildProject -testResults ~/cesium/CesiumForUnityBuildProject/TestResults.xml -testPlatform PlayMode -logFile ~/cesium/CesiumForUnityBuildProject/test-log.txt
cat ~/cesium/CesiumForUnityBuildProject/test-log.txt
ls /Users/runner/cesium/CesiumForUnityBuildProject/TestResults.xml
- name: Test Report
diff --git a/.gitmodules b/.gitmodules
index 2fab52ba..0a9976d6 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -6,4 +6,8 @@
url = https://github.com/htacg/tidy-html5.git
[submodule "native~/extern/enum-flags"]
path = native~/extern/enum-flags
- url = https://github.com/grisumbras/enum-flags.git
+ url = https://github.com/kring/enum-flags.git
+[submodule "native~/extern/swl-variant"]
+ path = native~/extern/swl-variant
+ url = https://github.com/kring/swl-variant.git
+ branch = exception-public-inheritance
diff --git a/Build~/Package.cs b/Build~/Package.cs
index f009ae36..2225001b 100644
--- a/Build~/Package.cs
+++ b/Build~/Package.cs
@@ -36,13 +36,16 @@ public void Run()
Directory.CreateDirectory(outputPackagePath);
Console.WriteLine("**** Modifying the csc.rsp files to write generated files to disk");
- string generatedRuntimePath = Path.Combine(tempPath, "generated", "Runtime");
- Directory.CreateDirectory(generatedRuntimePath);
- string generatedEditorPath = Path.Combine(tempPath, "generated", "Editor");
- Directory.CreateDirectory(generatedEditorPath);
+ string generatedRuntimeBasePath = Path.Combine(tempPath, "generated", "Runtime");
+ Directory.CreateDirectory(generatedRuntimeBasePath);
+ string generatedEditorBasePath = Path.Combine(tempPath, "generated", "Editor");
+ Directory.CreateDirectory(generatedEditorBasePath);
- File.AppendAllText(runtimeCscRspPath, "-generatedfilesout:\"" + generatedRuntimePath + "\"" + Environment.NewLine, Encoding.UTF8);
- File.AppendAllText(editorCscRspPath, "-generatedfilesout:\"" + generatedEditorPath + "\"" + Environment.NewLine, Encoding.UTF8);
+ File.AppendAllText(runtimeCscRspPath, "-generatedfilesout:\"" + generatedRuntimeBasePath + "\"" + Environment.NewLine, Encoding.UTF8);
+ File.AppendAllText(editorCscRspPath, "-generatedfilesout:\"" + generatedEditorBasePath + "\"" + Environment.NewLine, Encoding.UTF8);
+
+ string generatedRuntimePath = Path.Combine(generatedRuntimeBasePath, "Reinterop");
+ string generatedEditorPath = Path.Combine(generatedEditorBasePath, "Reinterop");
string sceneDirectory = Path.Combine(Utility.ProjectRoot, "Assets", "Scenes");
Directory.CreateDirectory(sceneDirectory);
@@ -57,6 +60,24 @@ public void Run()
}
}
+ // Disable Unity audio, because we don't need it and because it seems to take 10-20 minutes
+ // to time out on macOS on GitHub Actions every time we start up Unity.
+ string projectSettingsDirectory = Path.Combine(Utility.ProjectRoot, "ProjectSettings");
+ Directory.CreateDirectory(projectSettingsDirectory);
+ string audioManagerPath = Path.Combine(projectSettingsDirectory, "AudioManager.asset");
+ if (!File.Exists(audioManagerPath))
+ {
+ Console.WriteLine("**** Creating AudioManager.asset to disable Unity audio");
+ using (StreamWriter audioManager = new StreamWriter(audioManagerPath))
+ {
+ audioManager.WriteLine("%YAML 1.1");
+ audioManager.WriteLine("%TAG !u! tag:unity3d.com,2011:");
+ audioManager.WriteLine("--- !u!11 &1");
+ audioManager.WriteLine("AudioManager:");
+ audioManager.WriteLine(" m_DisableAudio: 1");
+ }
+ }
+
Console.WriteLine("**** Compiling C# code for the Editor");
unity.Run(new[]
{
@@ -110,6 +131,11 @@ public void Run()
if (OperatingSystem.IsMacOS())
{
+ configureArgs = configureArgs.Concat(new[]
+ {
+ "-DCMAKE_OSX_DEPLOYMENT_TARGET=10.15"
+ }).ToList();
+
// On macOS, we must build the native code twice, once for x86_64 and once for arm64.
// In theory we can build universal binaries, but some of our third party libraries don't
// handle this well.
@@ -161,6 +187,10 @@ public void Run()
Console.WriteLine("**** Adding generated files (for the UWP Player) to the package");
AddGeneratedFiles("!UNITY_EDITOR && UNITY_WSA", generatedRuntimePath, Path.Combine(outputPackagePath, "Runtime", "generated"));
+ // Clean the generated code directory.
+ Directory.Delete(generatedRuntimePath, true);
+ Directory.CreateDirectory(generatedRuntimePath);
+
Console.WriteLine("**** Compiling for Windows Player");
unity.Run(new[]
{
diff --git a/CHANGES.md b/CHANGES.md
index a5f7bc13..18b1dead 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,5 +1,20 @@
# Change Log
+## ? - ?
+
+##### Breaking Changes :mega:
+
+- Player builds for macOS now require macOS 10.15+. Previously, 10.13+ was supported.
+
+##### Additions :tada:
+
+- Editor builds for macOS now target macOS 10.15+. Previously, macOS 12.7+ was required.
+
+##### Fixes :wrench:
+
+- Fixed a bug that could cause a crash in `CesiumIonSession` when the object was garbage collected or the AppDomain was unloaded while network requests were in progress.
+- Fixed a bug that could cause `CesiumFlyToController` to unexpectedly interrupt a flight.
+
## v1.11.1 - 2024-08-01
##### Fixes :wrench:
diff --git a/Editor/BuildCesiumForUnity.cs b/Editor/BuildCesiumForUnity.cs
index 8d8ed5f5..5b75633a 100644
--- a/Editor/BuildCesiumForUnity.cs
+++ b/Editor/BuildCesiumForUnity.cs
@@ -29,6 +29,8 @@ private static void OnEditorCompilationFinished(object o)
public static void CompileForAndroidAndExit()
{
+ CompileCesiumForUnityNative.ExitAfterCompile = true;
+
string buildPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
Directory.CreateDirectory(buildPath);
try
@@ -46,6 +48,8 @@ public static void CompileForAndroidAndExit()
public static void CompileForUWPAndExit()
{
+ CompileCesiumForUnityNative.ExitAfterCompile = true;
+
string buildPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
Directory.CreateDirectory(buildPath);
try
@@ -62,6 +66,8 @@ public static void CompileForUWPAndExit()
public static void CompileForIOSAndExit()
{
+ CompileCesiumForUnityNative.ExitAfterCompile = true;
+
string buildPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
Directory.CreateDirectory(buildPath);
try
@@ -85,6 +91,8 @@ public static void CompileForIOSAndExit()
public static void CompileForWindowsAndExit()
{
+ CompileCesiumForUnityNative.ExitAfterCompile = true;
+
string buildPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
Directory.CreateDirectory(buildPath);
try
@@ -100,6 +108,8 @@ public static void CompileForWindowsAndExit()
public static void CompileForMacAndExit()
{
+ CompileCesiumForUnityNative.ExitAfterCompile = true;
+
string buildPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
Directory.CreateDirectory(buildPath);
try
diff --git a/Editor/CompileCesiumForUnityNative.cs b/Editor/CompileCesiumForUnityNative.cs
index 52de6f9f..1b8657ab 100644
--- a/Editor/CompileCesiumForUnityNative.cs
+++ b/Editor/CompileCesiumForUnityNative.cs
@@ -195,6 +195,16 @@ private static void OnPostprocessAllAssets(
public int callbackOrder => 0;
+ ///
+ /// True if Unity should exit immediately after `OnPostBuildPlayerScriptDLLs` completes.
+ ///
+ public static bool ExitAfterCompile = false;
+
+ ///
+ /// The exit code of the last step of the build process, such as cmake or lipo.
+ ///
+ private static int LastRunExitCode = 0;
+
///
/// Invoked after the managed script assemblies are compiled, including the CesiumForUnity
/// managed code. Building the CesiumForUnity assembly will generate C++ code via Reinterop,
@@ -225,13 +235,21 @@ public void OnPostBuildPlayerScriptDLLs(BuildReport report)
Process p = Process.Start("lipo", string.Join(' ', args));
p.WaitForExit();
if (p.ExitCode != 0)
- throw new Exception("lipo failed");
+ {
+ UnityEngine.Debug.LogError($"Invocation of 'lipo' tool failed. The command-line was:{Environment.NewLine}lipo {string.Join(' ', args)}");
+ LastRunExitCode = p.ExitCode;
+ }
foreach (LibraryToBuild library in libraries)
{
Directory.Delete(library.InstallDirectory, true);
}
}
+
+ if (ExitAfterCompile)
+ {
+ EditorApplication.Exit(LastRunExitCode);
+ }
}
///
@@ -338,6 +356,7 @@ public static LibraryToBuild GetLibraryToBuild(PlatformToBuild platform, Library
library.ExtraConfigureArgs.Add("-DCMAKE_SYSTEM_NAME=iOS");
library.ExtraConfigureArgs.Add("-DCMAKE_SYSTEM_PROCESSOR=aarch64");
library.ExtraConfigureArgs.Add("-DCMAKE_OSX_ARCHITECTURES=arm64");
+ library.ExtraConfigureArgs.Add("-DOSX_DEPLOYMENT_TARGET=12");
}
if (platform.platform == BuildTarget.StandaloneOSX)
@@ -345,7 +364,7 @@ public static LibraryToBuild GetLibraryToBuild(PlatformToBuild platform, Library
if (cpu != null)
library.ExtraConfigureArgs.Add("-DCMAKE_OSX_ARCHITECTURES=" + cpu.ToString().ToLowerInvariant());
- library.ExtraConfigureArgs.Add("-DCMAKE_OSX_DEPLOYMENT_TARGET=10.13");
+ library.ExtraConfigureArgs.Add("-DCMAKE_OSX_DEPLOYMENT_TARGET=10.15");
}
if (platform.platform == BuildTarget.WSAPlayer)
@@ -400,6 +419,9 @@ private static string GetDirectoryNameForPlatform(BuildTargetGroup platformGroup
return "Editor";
else if (IsIOS(platformGroup, platform))
return "iOS";
+ // Make sure we use "WSA" and not "Metro"
+ else if (platformGroup == BuildTargetGroup.WSA)
+ return "WSA";
return platformGroup.ToString();
}
@@ -422,7 +444,7 @@ internal static void BuildNativeLibrary(LibraryToBuild library)
string projectPath = Path.Combine(Application.dataPath, "..");
string logDisplayName = Path.GetRelativePath(projectPath, logFilename);
- EditorUtility.DisplayProgressBar($"Building CesiumForUnityNative", $"See {logDisplayName}.", 0.0f);
+ EditorUtility.DisplayProgressBar($"Building CesiumForUnityNative: {Path.GetFileName(library.BuildDirectory)}", $"See {logDisplayName}.", 0.0f);
using (StreamWriter log = new StreamWriter(logFilename, false, Encoding.UTF8))
{
@@ -510,6 +532,7 @@ private static void RunAndLog(ProcessStartInfo startInfo, StreamWriter log, stri
if (configure.ExitCode != 0)
{
UnityEngine.Debug.LogError($"An error occurred while building CesiumForUnityNative. See {logFilename} for details. The command-line was:{Environment.NewLine}{startInfo.FileName} {startInfo.Arguments}");
+ LastRunExitCode = configure.ExitCode;
}
}
}
@@ -531,12 +554,18 @@ private static void ConfigureEnvironmentVariables(IDictionary en
// the default) won't work to build for Android.
if (library.Platform == BuildTarget.Android && Environment.OSVersion.Platform == PlatformID.Win32NT)
{
- library.ExtraConfigureArgs.Add("-G \"Unix Makefiles\"");
+ library.ExtraConfigureArgs.Add("-G Ninja");
- if (!string.IsNullOrEmpty(ndkRoot))
+ // If the NDK root has a space in it, this will confuse broken software like OpenSSL's build process.
+ // So map a drive letter and rewrite the path.
+ if (ndkRoot != null && ndkRoot.Contains(' '))
{
- string make = Path.Combine(ndkRoot, "prebuilt", "windows-x86_64", "bin", "make.exe").Replace('\\', '/');
- library.ExtraConfigureArgs.Add($"-DCMAKE_MAKE_PROGRAM=\"{make}\"");
+ if (!Directory.Exists("N:\\"))
+ {
+ Process.Start("subst", "N: \"" + ndkRoot + "\"").WaitForExit();
+ }
+
+ ndkRoot = "N:\\";
}
}
diff --git a/Runtime/CesiumFlyToController.cs b/Runtime/CesiumFlyToController.cs
index 51eb7c4d..740f7b25 100644
--- a/Runtime/CesiumFlyToController.cs
+++ b/Runtime/CesiumFlyToController.cs
@@ -219,8 +219,9 @@ private void Reset()
private bool DetectMovementInput()
{
double3 currentPositionECEF = this._globeAnchor.positionGlobeFixed;
- bool3 positionEquality = currentPositionECEF == this._previousPositionECEF;
- return !positionEquality.x || !positionEquality.y || !positionEquality.z;
+ double distanceSquared = math.lengthsq(currentPositionECEF - this._previousPositionECEF);
+ const double distanceConsideredMovement = 1e-6; // 1/1000 of a millimeter
+ return distanceSquared >= (distanceConsideredMovement * distanceConsideredMovement);
}
///
diff --git a/Tests/TestCesiumFlyToController.cs b/Tests/TestCesiumFlyToController.cs
index d2c6bd50..e7196ebe 100644
--- a/Tests/TestCesiumFlyToController.cs
+++ b/Tests/TestCesiumFlyToController.cs
@@ -74,4 +74,63 @@ public IEnumerator FlyToLocationLongitudeLatitudeHeight()
Assert.That(goFlyer.transform.position.y, Is.EqualTo(0.0f).Using(FloatEqualityComparer.Instance));
Assert.That(goFlyer.transform.position.z, Is.EqualTo(0.0f).Using(FloatEqualityComparer.Instance));
}
+
+ [UnityTest]
+ public IEnumerator FlyToLocationLongitudeLatitudeHeightInterrupted()
+ {
+ GameObject goGeoreference = new GameObject("Georeference");
+ CesiumGeoreference georeference = goGeoreference.AddComponent();
+ georeference.longitude = -55.0;
+ georeference.latitude = 55.0;
+ georeference.height = 1000.0;
+
+ GameObject goFlyer = new GameObject("Flyer");
+ goFlyer.transform.parent = goGeoreference.transform;
+
+ CesiumGlobeAnchor anchor = goFlyer.AddComponent();
+ goFlyer.AddComponent();
+ CesiumFlyToController flyToController = goFlyer.AddComponent();
+
+ // Make the flight fast so the test doesn't take too long.
+ flyToController.flyToDuration = 0.25;
+
+ anchor.adjustOrientationForGlobeWhenMoving = false;
+ anchor.longitudeLatitudeHeight = new double3(20.0, -25.0, 1000.0);
+ anchor.adjustOrientationForGlobeWhenMoving = true;
+
+ yield return null;
+
+ // The origin should have been shifted so the flyer is at the origin.
+ Assert.That(goFlyer.transform.position.x, Is.EqualTo(0.0f).Using(FloatEqualityComparer.Instance));
+ Assert.That(goFlyer.transform.position.y, Is.EqualTo(0.0f).Using(FloatEqualityComparer.Instance));
+ Assert.That(goFlyer.transform.position.z, Is.EqualTo(0.0f).Using(FloatEqualityComparer.Instance));
+
+ // Start a flight to elsewhere
+ bool flightComplete = false;
+ flyToController.OnFlightComplete += () =>
+ {
+ flightComplete = true;
+ };
+
+ bool flightInterrupted = false;
+ flyToController.OnFlightInterrupted += () =>
+ {
+ flightInterrupted = true;
+ };
+
+ flyToController.FlyToLocationLongitudeLatitudeHeight(new double3(100.0, 25.0, 800.0), 0.0f, 0.0f, true);
+
+ yield return null;
+
+ Assert.IsFalse(flightComplete);
+ Assert.IsFalse(flightInterrupted);
+
+ // Give the object a new position, which should abort the flight.
+ goFlyer.transform.position = new Vector3(100.0f, 200.0f, 300.0f);
+
+ yield return null;
+
+ Assert.IsFalse(flightComplete);
+ Assert.IsTrue(flightInterrupted);
+ }
}
diff --git a/Tests/TestCesiumGeoreference.cs b/Tests/TestCesiumGeoreference.cs
index efeca57f..4f67049d 100644
--- a/Tests/TestCesiumGeoreference.cs
+++ b/Tests/TestCesiumGeoreference.cs
@@ -24,21 +24,22 @@ public IEnumerator ChangingOriginAtRuntimeUpdatesGlobeAnchors()
yield return null;
- Assert.That(goAnchored.transform.localPosition.x, Is.EqualTo(0.0f));
- Assert.That(goAnchored.transform.localPosition.y, Is.EqualTo(0.0f));
- Assert.That(goAnchored.transform.localPosition.z, Is.EqualTo(0.0f));
+ IEqualityComparer epsilon8f = new FloatEqualityComparer(1e-8f);
+ Assert.That(goAnchored.transform.localPosition.x, Is.EqualTo(0.0f).Using(epsilon8f));
+ Assert.That(goAnchored.transform.localPosition.y, Is.EqualTo(0.0f).Using(epsilon8f));
+ Assert.That(goAnchored.transform.localPosition.z, Is.EqualTo(0.0f).Using(epsilon8f));
georeference.SetOriginLongitudeLatitudeHeight(-55.1, 54.9, 1001.0);
- Assert.That(goAnchored.transform.localPosition.x, Is.Not.EqualTo(0.0f));
- Assert.That(goAnchored.transform.localPosition.y, Is.Not.EqualTo(0.0f));
- Assert.That(goAnchored.transform.localPosition.z, Is.Not.EqualTo(0.0f));
+ Assert.That(goAnchored.transform.localPosition.x, Is.Not.EqualTo(0.0f).Using(epsilon8f));
+ Assert.That(goAnchored.transform.localPosition.y, Is.Not.EqualTo(0.0f).Using(epsilon8f));
+ Assert.That(goAnchored.transform.localPosition.z, Is.Not.EqualTo(0.0f).Using(epsilon8f));
yield return null;
- Assert.That(goAnchored.transform.localPosition.x, Is.Not.EqualTo(0.0f));
- Assert.That(goAnchored.transform.localPosition.y, Is.Not.EqualTo(0.0f));
- Assert.That(goAnchored.transform.localPosition.z, Is.Not.EqualTo(0.0f));
+ Assert.That(goAnchored.transform.localPosition.x, Is.Not.EqualTo(0.0f).Using(epsilon8f));
+ Assert.That(goAnchored.transform.localPosition.y, Is.Not.EqualTo(0.0f).Using(epsilon8f));
+ Assert.That(goAnchored.transform.localPosition.z, Is.Not.EqualTo(0.0f).Using(epsilon8f));
}
[UnityTest]
@@ -56,9 +57,10 @@ public IEnumerator ChangingParentTransformAndGeoreferenceMaintainsCorrectGlobePo
yield return null;
- Assert.That(goAnchored.transform.localPosition.x, Is.EqualTo(0.0f));
- Assert.That(goAnchored.transform.localPosition.y, Is.EqualTo(0.0f));
- Assert.That(goAnchored.transform.localPosition.z, Is.EqualTo(0.0f));
+ IEqualityComparer epsilon8f = new FloatEqualityComparer(1e-8f);
+ Assert.That(goAnchored.transform.localPosition.x, Is.EqualTo(0.0f).Using(epsilon8f));
+ Assert.That(goAnchored.transform.localPosition.y, Is.EqualTo(0.0f).Using(epsilon8f));
+ Assert.That(goAnchored.transform.localPosition.z, Is.EqualTo(0.0f).Using(epsilon8f));
// Change both the origin and the transform.
georeference.transform.localPosition = new Vector3(100.0f, 200.0f, 300.0f);
@@ -74,10 +76,10 @@ public IEnumerator ChangingParentTransformAndGeoreferenceMaintainsCorrectGlobePo
// Its local local position should be affected by the georeference origin change
// but not by the parent transform change.
- IEqualityComparer epsilon4 = new FloatEqualityComparer(1e-3f);
- Assert.That(goAnchored.transform.localPosition.x, Is.EqualTo(0.0f).Using(epsilon4));
- Assert.That(goAnchored.transform.localPosition.y, Is.EqualTo(-1000.0f).Using(epsilon4));
- Assert.That(goAnchored.transform.localPosition.z, Is.EqualTo(0.0f).Using(epsilon4));
+ IEqualityComparer epsilon3 = new FloatEqualityComparer(1e-3f);
+ Assert.That(goAnchored.transform.localPosition.x, Is.EqualTo(0.0f).Using(epsilon3));
+ Assert.That(goAnchored.transform.localPosition.y, Is.EqualTo(-1000.0f).Using(epsilon3));
+ Assert.That(goAnchored.transform.localPosition.z, Is.EqualTo(0.0f).Using(epsilon3));
}
[UnityTest]
@@ -97,13 +99,14 @@ public IEnumerator GeoreferenceScaleAffectsGlobeAnchors()
yield return null;
- Assert.That(goAnchored.transform.localPosition.x, Is.EqualTo(1.0f));
- Assert.That(goAnchored.transform.localPosition.y, Is.EqualTo(2.0f));
- Assert.That(goAnchored.transform.localPosition.z, Is.EqualTo(3.0f));
+ IEqualityComparer epsilon8f = new FloatEqualityComparer(1e-8f);
+ Assert.That(goAnchored.transform.localPosition.x, Is.EqualTo(1.0f).Using(epsilon8f));
+ Assert.That(goAnchored.transform.localPosition.y, Is.EqualTo(2.0f).Using(epsilon8f));
+ Assert.That(goAnchored.transform.localPosition.z, Is.EqualTo(3.0f).Using(epsilon8f));
- Assert.That(goAnchored.transform.localScale.x, Is.EqualTo(4.0f));
- Assert.That(goAnchored.transform.localScale.y, Is.EqualTo(5.0f));
- Assert.That(goAnchored.transform.localScale.z, Is.EqualTo(6.0f));
+ Assert.That(goAnchored.transform.localScale.x, Is.EqualTo(4.0f).Using(epsilon8f));
+ Assert.That(goAnchored.transform.localScale.y, Is.EqualTo(5.0f).Using(epsilon8f));
+ Assert.That(goAnchored.transform.localScale.z, Is.EqualTo(6.0f).Using(epsilon8f));
// The globe anchor's scale initially matches the local scale.
IEqualityComparer epsilon8 = Comparers.Double(1e-8);
diff --git a/native~/CMakeLists.txt b/native~/CMakeLists.txt
index f1e2b10c..77599343 100644
--- a/native~/CMakeLists.txt
+++ b/native~/CMakeLists.txt
@@ -6,6 +6,12 @@ project(CesiumForUnityNative
LANGUAGES CXX C
)
+# By default, vcpkg (or is it cmake?) will try to link against the Debug version
+# of the vcpkg libraries when we build the RelWithDebInfo configuration. Tell it
+# to prefer Release instead. vcpkg Release builds DO have debug symbols, just like
+# RelWithDebInfo.
+SET(CMAKE_MAP_IMPORTED_CONFIG_RELWITHDEBINFO "RelWithDebInfo;Release;")
+
# When building for the Editor, both Runtime and Editor assemblies are
# written to the Editor directory so that Unity won't load them in
# a standalone build.
@@ -57,7 +63,35 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Android")
set(ANDROID_NDK ${CMAKE_ANDROID_NDK})
endif()
-add_subdirectory(extern/cesium-native EXCLUDE_FROM_ALL)
+# vcpkg setup
+set(ENV{VCPKG_OVERLAY_PORTS} "${CMAKE_CURRENT_LIST_DIR}/vcpkg/ports")
+set(ENV{VCPKG_OVERLAY_TRIPLETS} "${CMAKE_CURRENT_LIST_DIR}/vcpkg/triplets")
+
+include(${CMAKE_CURRENT_SOURCE_DIR}/extern/cesium-native/cmake/detect-vcpkg-triplet.cmake)
+
+if (NOT VCPKG_TRIPLET)
+ if (DEFINED ENV{VCPKG_TRIPLET})
+ set(VCPKG_TRIPLET "$ENV{VCPKG_TRIPLET}")
+ elseif(DETECTED_VCPKG_TRIPLET_ERROR)
+ message(FATAL_ERROR "${DETECTED_VCPKG_TRIPLET_ERROR}")
+ else()
+ set(VCPKG_TRIPLET "${DETECTED_VCPKG_TRIPLET}-unity")
+ endif()
+endif()
+
+# We never need any of cesium-native's header files to be installed.
+set(CESIUM_INSTALL_HEADERS OFF)
+
+# We only need cesium-native's static lib files to be installed on iOS.
+if (NOT IOS)
+ set(CESIUM_INSTALL_STATIC_LIBS OFF)
+endif()
+
+add_subdirectory(extern/swl-variant)
+add_subdirectory(extern/cesium-native)
+
+# Don't build the cesium-native tests by default.
+set_target_properties(cesium-native-tests PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1)
# Enum flags is a header-only library without a CMakeLists.txt
file(GLOB ENUM_FLAGS_HEADERS ${CMAKE_CURRENT_LIST_DIR}/extern/enum-flags/include/*.hpp)
@@ -73,70 +107,6 @@ set(LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR})
# Specify all targets that need to compile bitcode
if (${CMAKE_SYSTEM_NAME} STREQUAL "iOS")
- set (ALL_TARGETS
- CesiumForUnityNative-Runtime
- Async++
- Cesium3DTilesContent
- Cesium3DTilesReader
- Cesium3DTilesSelection
- CesiumAsync
- CesiumGeometry
- CesiumGeospatial
- CesiumGltf
- CesiumGltfContent
- CesiumGltfReader
- CesiumJsonReader
- CesiumRasterOverlays
- CesiumQuantizedMeshTerrain
- CesiumUtility
- draco_attributes
- draco_compression_attributes_dec
- draco_compression_bit_coders
- draco_compression_entropy
- draco_compression_decode
- draco_compression_mesh_dec
- draco_compression_point_cloud_dec
- draco_core
- draco_mesh
- draco_metadata
- draco_metadata_dec
- draco_point_cloud
- draco_points_dec
- draco_static
- expected-lite
- GSL
- httplib
- ktx
- meshoptimizer
- modp_b64
- spdlog
- sqlite3
- s2geometry
- tinyxml2
- tidy-static
- uriparser
- webpdecode
- webpdecoder
- webpdspdecode
- webputils
- webputilsdecode
- zlibstatic
- )
- set(MESHOPT_BUILD_SHARED_LIBS OFF BOOL FORCE)
install(TARGETS tidy-static)
- install(
- TARGETS ${ALL_TARGETS}
- PUBLIC_HEADER
- EXCLUDE_FROM_ALL
- FRAMEWORK
- DESTINATION ${CMAKE_INSTALL_LIBDIR}
- )
- set_target_properties(cesium-native-tests PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1)
set_target_properties(tidy-static PROPERTIES EXCLUDE_FROM_ALL 0 EXCLUDE_FROM_DEFAULT_BUILD 0)
- set_target_properties(${ALL_TARGETS} PROPERTIES XCODE_ATTRIBUTE_ENABLE_BITCODE "YES")
-
- # ktx tags itself as a FRAMEWORK on iOS, which causes linker errors. Undo that.
- set_target_properties(ktx PROPERTIES FRAMEWORK FALSE)
endif()
-
-
diff --git a/native~/Editor/CMakeLists.txt b/native~/Editor/CMakeLists.txt
index ba8183ba..5bd262f0 100644
--- a/native~/Editor/CMakeLists.txt
+++ b/native~/Editor/CMakeLists.txt
@@ -41,7 +41,7 @@ target_link_libraries(
set_target_properties(
CesiumForUnityNative-Editor
PROPERTIES
- CXX_STANDARD 17
+ CXX_STANDARD 20
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
)
diff --git a/native~/Editor/src/CesiumEditorWindowImpl.cpp b/native~/Editor/src/CesiumEditorWindowImpl.cpp
index b4c31dcf..0b59e296 100644
--- a/native~/Editor/src/CesiumEditorWindowImpl.cpp
+++ b/native~/Editor/src/CesiumEditorWindowImpl.cpp
@@ -134,7 +134,7 @@ void CesiumEditorWindowImpl::AddAssetFromIon(
}
tileset.ionAssetID(tilesetID);
- getNativeSession().getAssets();
+ getNativeSession().getAssets(getSession());
if (overlayID > 0) {
// TODO: Need to fix this when we support multiple overlays
diff --git a/native~/Editor/src/CesiumIonSessionImpl.cpp b/native~/Editor/src/CesiumIonSessionImpl.cpp
index 797e2a84..669c1c16 100644
--- a/native~/Editor/src/CesiumIonSessionImpl.cpp
+++ b/native~/Editor/src/CesiumIonSessionImpl.cpp
@@ -165,10 +165,13 @@ void CesiumIonSessionImpl::Connect(
ionServerUrl);
std::move(futureApiUrl)
- .thenInMainThread([ionServerUrl, server, session, this](
+ .thenInMainThread([ionServerUrl,
+ server,
+ session,
+ this,
+ asyncSystem = this->_asyncSystem](
std::optional&& ionApiUrl) {
- CesiumAsync::Promise promise =
- this->_asyncSystem.createPromise();
+ CesiumAsync::Promise promise = asyncSystem.createPromise();
if (session == nullptr) {
promise.reject(
@@ -278,11 +281,15 @@ void CesiumIonSessionImpl::Resume(
// Verify that the connection actually works.
this->ensureAppDataLoaded(session)
- .thenInMainThread([this, userAccessToken, server](bool loadedAppData) {
- CesiumAsync::Promise promise =
- this->_asyncSystem.createPromise();
-
- if (!loadedAppData || !this->_appData.has_value()) {
+ .thenInMainThread([this,
+ session,
+ userAccessToken,
+ server,
+ asyncSystem = this->_asyncSystem](bool loadedAppData) {
+ CesiumAsync::Promise promise = asyncSystem.createPromise();
+
+ if (session == nullptr || !loadedAppData ||
+ !this->_appData.has_value()) {
promise.reject(std::runtime_error(
"Failed to obtain _appData, can't resume connection"));
return promise.getFuture();
@@ -290,8 +297,8 @@ void CesiumIonSessionImpl::Resume(
if (this->_appData->needsOauthAuthentication() &&
System::String::IsNullOrEmpty(userAccessToken)) {
- // No user access token was stored, so there's no existing session to
- // resume.
+ // No user access token was stored, so there's no existing session
+ // to resume.
promise.resolve();
this->_isResuming = false;
return promise.getFuture();
@@ -306,9 +313,12 @@ void CesiumIonSessionImpl::Resume(
server.apiUrl().ToStlString());
return pConnection->me().thenInMainThread(
- [this,
- pConnection](CesiumIonClient::Response&&
- response) {
+ [this, session, pConnection](
+ CesiumIonClient::Response&&
+ response) {
+ if (session == nullptr)
+ return;
+
logResponseErrors(response);
if (response.value.has_value()) {
this->_connection = std::move(*pConnection);
@@ -317,10 +327,13 @@ void CesiumIonSessionImpl::Resume(
this->_quickAddItems = nullptr;
this->broadcastConnectionUpdate();
- this->startQueuedLoads();
+ this->startQueuedLoads(session);
});
})
- .catchInMainThread([this](std::exception&& e) {
+ .catchInMainThread([this, session](std::exception&& e) {
+ if (session == nullptr)
+ return;
+
logResponseErrors(e);
this->_isResuming = false;
});
@@ -356,7 +369,7 @@ void CesiumIonSessionImpl::Tick(
System::String CesiumIonSessionImpl::GetProfileUsername(
const DotNet::CesiumForUnity::CesiumIonSession& session) {
- return System::String(this->getProfile().username);
+ return System::String(this->getProfile(session).username);
}
System::String CesiumIonSessionImpl::GetAuthorizeUrl(
@@ -381,7 +394,7 @@ CesiumIonSessionImpl::GetQuickAddItems(
DotNet::CesiumForUnity::QuickAddItem>
result{};
- const CesiumIonClient::Defaults& defaults = this->getDefaults();
+ const CesiumIonClient::Defaults& defaults = this->getDefaults(session);
for (const CesiumIonClient::QuickAddAsset& asset : defaults.quickAddAssets) {
if (asset.type == "3DTILES" ||
(asset.type == "TERRAIN" && !asset.rasterOverlays.empty())) {
@@ -406,10 +419,11 @@ CesiumIonSessionImpl::GetQuickAddItems(
void CesiumIonSessionImpl::RefreshProfile(
const DotNet::CesiumForUnity::CesiumIonSession& session) {
- this->refreshProfile();
+ this->refreshProfile(session);
}
-void CesiumIonSessionImpl::refreshProfile() {
+void CesiumIonSessionImpl::refreshProfile(
+ const DotNet::CesiumForUnity::CesiumIonSession& session) {
if (!this->_connection || this->_isLoadingProfile) {
this->_loadProfileQueued = true;
return;
@@ -420,29 +434,30 @@ void CesiumIonSessionImpl::refreshProfile() {
this->_connection->me()
.thenInMainThread(
- [this](
+ [this, session](
CesiumIonClient::Response&& profile) {
this->_isLoadingProfile = false;
this->_profile = std::move(profile.value);
this->broadcastProfileUpdate();
if (this->_loadProfileQueued)
- this->refreshProfile();
+ this->refreshProfile(session);
})
- .catchInMainThread([this](std::exception&& e) {
+ .catchInMainThread([this, session](std::exception&& e) {
this->_isLoadingProfile = false;
this->_profile = std::nullopt;
this->broadcastProfileUpdate();
if (this->_loadProfileQueued)
- this->refreshProfile();
+ this->refreshProfile(session);
});
}
void CesiumIonSessionImpl::RefreshAssets(
const DotNet::CesiumForUnity::CesiumIonSession& session) {
- this->refreshAssets();
+ this->refreshAssets(session);
}
-void CesiumIonSessionImpl::refreshAssets() {
+void CesiumIonSessionImpl::refreshAssets(
+ const DotNet::CesiumForUnity::CesiumIonSession& session) {
if (!this->_connection || this->_isLoadingAssets) {
this->_loadAssetsQueued = true;
return;
@@ -453,33 +468,35 @@ void CesiumIonSessionImpl::refreshAssets() {
this->_connection->assets()
.thenInMainThread(
- [this](CesiumIonClient::Response&& assets) {
+ [this, session](
+ CesiumIonClient::Response&& assets) {
this->_isLoadingAssets = false;
this->_assets = std::move(assets.value);
this->broadcastAssetsUpdate();
if (this->_loadAssetsQueued)
- this->refreshAssets();
+ this->refreshAssets(session);
})
- .catchInMainThread([this](std::exception&& e) {
+ .catchInMainThread([this, session](std::exception&& e) {
this->_isLoadingAssets = false;
this->_assets = std::nullopt;
this->broadcastAssetsUpdate();
if (this->_loadAssetsQueued)
- this->refreshAssets();
+ this->refreshAssets(session);
});
}
void CesiumIonSessionImpl::RefreshTokens(
const DotNet::CesiumForUnity::CesiumIonSession& session) {
- this->refreshTokens();
+ this->refreshTokens(session);
}
void CesiumIonSessionImpl::RefreshDefaults(
const DotNet::CesiumForUnity::CesiumIonSession& session) {
- this->refreshDefaults();
+ this->refreshDefaults(session);
}
-void CesiumIonSessionImpl::refreshTokens() {
+void CesiumIonSessionImpl::refreshTokens(
+ const DotNet::CesiumForUnity::CesiumIonSession& session) {
if (!this->_connection || this->_isLoadingTokens) {
this->_loadTokensQueued = true;
return;
@@ -490,7 +507,7 @@ void CesiumIonSessionImpl::refreshTokens() {
this->_connection->tokens()
.thenInMainThread(
- [this](
+ [this, session](
CesiumIonClient::Response&& tokens) {
this->_isLoadingTokens = false;
this->_tokens =
@@ -499,18 +516,19 @@ void CesiumIonSessionImpl::refreshTokens() {
: std::nullopt;
this->broadcastTokensUpdate();
if (this->_loadTokensQueued)
- this->refreshTokens();
+ this->refreshTokens(session);
})
- .catchInMainThread([this](std::exception&& e) {
+ .catchInMainThread([this, session](std::exception&& e) {
this->_isLoadingTokens = false;
this->_tokens = std::nullopt;
this->broadcastTokensUpdate();
if (this->_loadTokensQueued)
- this->refreshTokens();
+ this->refreshTokens(session);
});
}
-void CesiumIonSessionImpl::refreshDefaults() {
+void CesiumIonSessionImpl::refreshDefaults(
+ const DotNet::CesiumForUnity::CesiumIonSession& session) {
if (!this->_connection || this->_isLoadingDefaults) {
this->_loadDefaultsQueued = true;
return;
@@ -521,7 +539,7 @@ void CesiumIonSessionImpl::refreshDefaults() {
this->_connection->defaults()
.thenInMainThread(
- [this](
+ [this, session](
CesiumIonClient::Response&& defaults) {
logResponseErrors(defaults);
this->_isLoadingDefaults = false;
@@ -529,43 +547,47 @@ void CesiumIonSessionImpl::refreshDefaults() {
this->_quickAddItems = nullptr;
this->broadcastDefaultsUpdate();
if (this->_loadDefaultsQueued)
- this->refreshDefaults();
+ this->refreshDefaults(session);
})
- .catchInMainThread([this](std::exception&& e) {
+ .catchInMainThread([this, session](std::exception&& e) {
logResponseErrors(e);
this->_isLoadingDefaults = false;
this->_defaults = std::nullopt;
this->_quickAddItems = nullptr;
this->broadcastDefaultsUpdate();
if (this->_loadDefaultsQueued)
- this->refreshDefaults();
+ this->refreshDefaults(session);
});
}
-bool CesiumIonSessionImpl::refreshProfileIfNeeded() {
+bool CesiumIonSessionImpl::refreshProfileIfNeeded(
+ const DotNet::CesiumForUnity::CesiumIonSession& session) {
if (this->_loadProfileQueued || !this->_profile.has_value()) {
- this->refreshProfile();
+ this->refreshProfile(session);
}
return this->_profile.has_value();
}
-bool CesiumIonSessionImpl::refreshAssetsIfNeeded() {
+bool CesiumIonSessionImpl::refreshAssetsIfNeeded(
+ const DotNet::CesiumForUnity::CesiumIonSession& session) {
if (this->_loadAssetsQueued || !this->_assets.has_value()) {
- this->refreshAssets();
+ this->refreshAssets(session);
}
return this->_assets.has_value();
}
-bool CesiumIonSessionImpl::refreshTokensIfNeeded() {
+bool CesiumIonSessionImpl::refreshTokensIfNeeded(
+ const DotNet::CesiumForUnity::CesiumIonSession& session) {
if (this->_loadTokensQueued || !this->_tokens.has_value()) {
- this->refreshTokens();
+ this->refreshTokens(session);
}
return this->_tokens.has_value();
}
-bool CesiumIonSessionImpl::refreshDefaultsIfNeeded() {
+bool CesiumIonSessionImpl::refreshDefaultsIfNeeded(
+ const DotNet::CesiumForUnity::CesiumIonSession& session) {
if (this->_loadDefaultsQueued || !this->_defaults.has_value()) {
- this->refreshDefaults();
+ this->refreshDefaults(session);
}
return this->_defaults.has_value();
}
@@ -677,32 +699,35 @@ CesiumIonSessionImpl::getConnection() const {
return this->_connection;
}
-const CesiumIonClient::Profile& CesiumIonSessionImpl::getProfile() {
+const CesiumIonClient::Profile& CesiumIonSessionImpl::getProfile(
+ const DotNet::CesiumForUnity::CesiumIonSession& session) {
static const CesiumIonClient::Profile empty{};
if (this->_profile) {
return *this->_profile;
} else {
- this->refreshProfile();
+ this->refreshProfile(session);
return empty;
}
}
-const CesiumIonClient::Assets& CesiumIonSessionImpl::getAssets() {
+const CesiumIonClient::Assets& CesiumIonSessionImpl::getAssets(
+ const DotNet::CesiumForUnity::CesiumIonSession& session) {
static const CesiumIonClient::Assets empty;
if (this->_assets) {
return *this->_assets;
} else {
- this->refreshAssets();
+ this->refreshAssets(session);
return empty;
}
}
-const std::vector& CesiumIonSessionImpl::getTokens() {
+const std::vector& CesiumIonSessionImpl::getTokens(
+ const DotNet::CesiumForUnity::CesiumIonSession& session) {
static const std::vector empty;
if (this->_tokens) {
return *this->_tokens;
} else {
- this->refreshTokens();
+ this->refreshTokens(session);
return empty;
}
}
@@ -715,12 +740,13 @@ const CesiumIonClient::ApplicationData& CesiumIonSessionImpl::getAppData() {
return empty;
}
-const CesiumIonClient::Defaults& CesiumIonSessionImpl::getDefaults() {
+const CesiumIonClient::Defaults& CesiumIonSessionImpl::getDefaults(
+ const DotNet::CesiumForUnity::CesiumIonSession& session) {
static const CesiumIonClient::Defaults empty;
if (this->_defaults) {
return *this->_defaults;
} else {
- this->refreshDefaults();
+ this->refreshDefaults(session);
return empty;
}
}
@@ -738,15 +764,16 @@ CesiumAsync::AsyncSystem& CesiumIonSessionImpl::getAsyncSystem() {
return this->_asyncSystem;
}
-void CesiumIonSessionImpl::startQueuedLoads() {
+void CesiumIonSessionImpl::startQueuedLoads(
+ const DotNet::CesiumForUnity::CesiumIonSession& session) {
if (this->_loadProfileQueued)
- this->refreshProfile();
+ this->refreshProfile(session);
if (this->_loadAssetsQueued)
- this->refreshAssets();
+ this->refreshAssets(session);
if (this->_loadTokensQueued)
- this->refreshTokens();
+ this->refreshTokens(session);
if (this->_loadDefaultsQueued)
- this->refreshDefaults();
+ this->refreshDefaults(session);
}
CesiumAsync::Future CesiumIonSessionImpl::ensureAppDataLoaded(
@@ -758,11 +785,18 @@ CesiumAsync::Future CesiumIonSessionImpl::ensureAppDataLoaded(
this->_pAssetAccessor,
server.apiUrl().ToStlString())
.thenInMainThread(
- [this, session](
+ [this, session, asyncSystem = this->_asyncSystem](
CesiumIonClient::Response&&
appData) {
CesiumAsync::Promise promise =
- this->_asyncSystem.createPromise();
+ asyncSystem.createPromise();
+
+ if (session == nullptr) {
+ UnityEngine::Debug::LogError(
+ System::String("CesiumIonSession unexpectedly nullptr"));
+ promise.resolve(false);
+ return promise.getFuture();
+ }
this->_appData = appData.value;
if (!appData.value.has_value()) {
@@ -776,9 +810,10 @@ CesiumAsync::Future CesiumIonSessionImpl::ensureAppDataLoaded(
return promise.getFuture();
})
- .catchInMainThread([this](std::exception&& e) {
+ .catchInMainThread([this, session, asyncSystem = this->_asyncSystem](
+ std::exception&& e) {
logResponseErrors(e);
- return this->_asyncSystem.createResolvedFuture(false);
+ return asyncSystem.createResolvedFuture(false);
});
}
diff --git a/native~/Editor/src/CesiumIonSessionImpl.h b/native~/Editor/src/CesiumIonSessionImpl.h
index 55559e2d..a17f9515 100644
--- a/native~/Editor/src/CesiumIonSessionImpl.h
+++ b/native~/Editor/src/CesiumIonSessionImpl.h
@@ -84,16 +84,6 @@ class CesiumIonSessionImpl {
void RefreshTokens(const DotNet::CesiumForUnity::CesiumIonSession& session);
void RefreshDefaults(const DotNet::CesiumForUnity::CesiumIonSession& session);
- void refreshProfile();
- void refreshAssets();
- void refreshTokens();
- void refreshDefaults();
-
- bool refreshProfileIfNeeded();
- bool refreshAssetsIfNeeded();
- bool refreshTokensIfNeeded();
- bool refreshDefaultsIfNeeded();
-
CesiumAsync::Future>
findToken(const std::string& token) const;
@@ -104,18 +94,37 @@ class CesiumIonSessionImpl {
void invalidateProjectDefaultTokenDetails();
const std::optional& getConnection() const;
- const CesiumIonClient::Profile& getProfile();
- const CesiumIonClient::Assets& getAssets();
- const std::vector& getTokens();
+ const CesiumIonClient::Profile&
+ getProfile(const DotNet::CesiumForUnity::CesiumIonSession& session);
+ const CesiumIonClient::Assets&
+ getAssets(const DotNet::CesiumForUnity::CesiumIonSession& session);
+ const std::vector&
+ getTokens(const DotNet::CesiumForUnity::CesiumIonSession& session);
const CesiumIonClient::ApplicationData& getAppData();
- const CesiumIonClient::Defaults& getDefaults();
+ const CesiumIonClient::Defaults&
+ getDefaults(const DotNet::CesiumForUnity::CesiumIonSession& session);
const std::shared_ptr& getAssetAccessor() const;
const CesiumAsync::AsyncSystem& getAsyncSystem() const;
CesiumAsync::AsyncSystem& getAsyncSystem();
private:
- void startQueuedLoads();
+ void refreshProfile(const DotNet::CesiumForUnity::CesiumIonSession& session);
+ void refreshAssets(const DotNet::CesiumForUnity::CesiumIonSession& session);
+ void refreshTokens(const DotNet::CesiumForUnity::CesiumIonSession& session);
+ void refreshDefaults(const DotNet::CesiumForUnity::CesiumIonSession& session);
+
+ bool refreshProfileIfNeeded(
+ const DotNet::CesiumForUnity::CesiumIonSession& session);
+ bool refreshAssetsIfNeeded(
+ const DotNet::CesiumForUnity::CesiumIonSession& session);
+ bool refreshTokensIfNeeded(
+ const DotNet::CesiumForUnity::CesiumIonSession& session);
+ bool refreshDefaultsIfNeeded(
+ const DotNet::CesiumForUnity::CesiumIonSession& session);
+
+ void
+ startQueuedLoads(const DotNet::CesiumForUnity::CesiumIonSession& session);
/**
* If the {@link _appData} field has no value, this method will request the
diff --git a/native~/Editor/src/IonAssetsTreeViewImpl.cpp b/native~/Editor/src/IonAssetsTreeViewImpl.cpp
index c282e903..2545da79 100644
--- a/native~/Editor/src/IonAssetsTreeViewImpl.cpp
+++ b/native~/Editor/src/IonAssetsTreeViewImpl.cpp
@@ -117,7 +117,7 @@ void IonAssetsTreeViewImpl::CellGUI(
void IonAssetsTreeViewImpl::Refresh(
const DotNet::CesiumForUnity::IonAssetsTreeView& treeView) {
CesiumIonSessionImpl& session = getNativeSession();
- const CesiumIonClient::Assets& assets = session.getAssets();
+ const CesiumIonClient::Assets& assets = session.getAssets(getSession());
this->_assets.resize(assets.items.size());
diff --git a/native~/Editor/src/SelectIonTokenWindowImpl.cpp b/native~/Editor/src/SelectIonTokenWindowImpl.cpp
index 39c7404a..7099beaf 100644
--- a/native~/Editor/src/SelectIonTokenWindowImpl.cpp
+++ b/native~/Editor/src/SelectIonTokenWindowImpl.cpp
@@ -214,8 +214,9 @@ SelectIonTokenWindowImpl::~SelectIonTokenWindowImpl() {
void SelectIonTokenWindowImpl::RefreshTokens(
const DotNet::CesiumForUnity::SelectIonTokenWindow& window) {
+ CesiumForUnity::CesiumIonSession session = getSession(window);
const std::vector& tokens =
- getSession(window).NativeImplementation().getTokens();
+ session.NativeImplementation().getTokens(session);
this->_tokens.resize(tokens.size());
System::Collections::Generic::List1 tokenNames =
diff --git a/native~/Runtime/CMakeLists.txt b/native~/Runtime/CMakeLists.txt
index 02038c76..92515530 100644
--- a/native~/Runtime/CMakeLists.txt
+++ b/native~/Runtime/CMakeLists.txt
@@ -44,12 +44,13 @@ target_link_libraries(
PRIVATE
tidy-static
enum-flags
+ swl-variant
)
set_target_properties(
CesiumForUnityNative-Runtime
PROPERTIES
- CXX_STANDARD 17
+ CXX_STANDARD 20
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
)
@@ -66,6 +67,7 @@ target_compile_definitions(
CesiumForUnityNative-Runtime
PUBLIC
TIDY_STATIC
+ SWL_VARIANT_NO_CONSTEXPR_EMPLACE
)
# If we're building for the Unity Editor, set a #define accordingly.
diff --git a/native~/Runtime/src/CesiumFeatureImpl.h b/native~/Runtime/src/CesiumFeatureImpl.h
index 7c7c3b7c..7898788e 100644
--- a/native~/Runtime/src/CesiumFeatureImpl.h
+++ b/native~/Runtime/src/CesiumFeatureImpl.h
@@ -4,9 +4,9 @@
#include
#include
+#include
#include
-#include
namespace DotNet::CesiumForUnity {
class CesiumFeature;
@@ -18,7 +18,7 @@ class String;
namespace CesiumForUnityNative {
-using ValueType = std::variant<
+using ValueType = swl::variant<
int8_t,
uint8_t,
int16_t,
diff --git a/native~/Runtime/src/CesiumFeaturesMetadataUtility.h b/native~/Runtime/src/CesiumFeaturesMetadataUtility.h
index 8dd836dc..a13738cf 100644
--- a/native~/Runtime/src/CesiumFeaturesMetadataUtility.h
+++ b/native~/Runtime/src/CesiumFeaturesMetadataUtility.h
@@ -59,6 +59,10 @@ class CesiumFeaturesMetadataUtility {
static DotNet::CesiumForUnity::CesiumPropertyArray
makePropertyArray(const CesiumGltf::PropertyArrayView& arrayView);
+ template
+ static DotNet::CesiumForUnity::CesiumPropertyArray
+ makePropertyArray(const CesiumGltf::PropertyArrayCopy& arrayCopy);
+
template
static DotNet::CesiumForUnity::CesiumPropertyTableProperty
makePropertyTableProperty(
@@ -320,6 +324,13 @@ CesiumFeaturesMetadataUtility::makePropertyArray(
return array;
}
+template
+DotNet::CesiumForUnity::CesiumPropertyArray
+CesiumFeaturesMetadataUtility::makePropertyArray(
+ const CesiumGltf::PropertyArrayCopy& arrayCopy) {
+ return makePropertyArray(arrayCopy.view());
+}
+
template
DotNet::CesiumForUnity::CesiumPropertyTableProperty
CesiumFeaturesMetadataUtility::makePropertyTableProperty(
diff --git a/native~/Runtime/src/CesiumGlobeAnchorImpl.cpp b/native~/Runtime/src/CesiumGlobeAnchorImpl.cpp
index 016d5ade..44c18ab4 100644
--- a/native~/Runtime/src/CesiumGlobeAnchorImpl.cpp
+++ b/native~/Runtime/src/CesiumGlobeAnchorImpl.cpp
@@ -16,7 +16,7 @@
#include
#include
#include
-#include
+#include
using namespace CesiumGeometry;
using namespace CesiumGeospatial;
diff --git a/native~/Runtime/src/CesiumMetadataValueImpl.cpp b/native~/Runtime/src/CesiumMetadataValueImpl.cpp
index f0ba7adc..0a6a7362 100644
--- a/native~/Runtime/src/CesiumMetadataValueImpl.cpp
+++ b/native~/Runtime/src/CesiumMetadataValueImpl.cpp
@@ -43,6 +43,7 @@
#include
#include
#include
+#include
#include
@@ -55,21 +56,22 @@ namespace CesiumForUnityNative {
namespace {
-CesiumMetadataValueImpl::ValueType getNativeBooleanValue(
- const DotNet::CesiumForUnity::CesiumMetadataValue& value) {
+template
+auto getNativeBooleanValue(
+ const DotNet::CesiumForUnity::CesiumMetadataValue& value,
+ F&& callback) {
std::optional maybeBoolean =
CesiumForUnity::CesiumMetadataValue::GetObjectAsBoolean(
value.objectValue());
if (maybeBoolean) {
- return *maybeBoolean;
+ return callback(*maybeBoolean);
}
- return std::monostate();
+ return callback(swl::monostate());
}
-template
-CesiumMetadataValueImpl::ValueType
-getNativeScalarValue(const DotNet::System::Object& object) {
+template
+auto getNativeScalarValue(const DotNet::System::Object& object, F&& callback) {
std::optional maybeValue;
if constexpr (std::is_same_v) {
maybeValue = CesiumMetadataValue::GetObjectAsSByte(object);
@@ -94,45 +96,66 @@ getNativeScalarValue(const DotNet::System::Object& object) {
}
if (maybeValue) {
- return *maybeValue;
+ return callback(*maybeValue);
}
- return std::monostate();
+ return callback(swl::monostate());
}
-CesiumMetadataValueImpl::ValueType
-getNativeScalarValue(const DotNet::CesiumForUnity::CesiumMetadataValue& value) {
+template
+auto getNativeScalarValue(
+ const DotNet::CesiumForUnity::CesiumMetadataValue& value,
+ F&& callback) {
CesiumMetadataValueType valueType = value.valueType();
assert(valueType.type == CesiumMetadataType::Scalar);
switch (valueType.componentType) {
case CesiumMetadataComponentType::Int8:
- return getNativeScalarValue(value.objectValue());
+ return getNativeScalarValue(
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Uint8:
- return getNativeScalarValue(value.objectValue());
+ return getNativeScalarValue(
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Int16:
- return getNativeScalarValue(value.objectValue());
+ return getNativeScalarValue(
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Uint16:
- return getNativeScalarValue(value.objectValue());
+ return getNativeScalarValue(
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Int32:
- return getNativeScalarValue(value.objectValue());
+ return getNativeScalarValue(
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Uint32:
- return getNativeScalarValue(value.objectValue());
+ return getNativeScalarValue(
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Int64:
- return getNativeScalarValue(value.objectValue());
+ return getNativeScalarValue(
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Uint64:
- return getNativeScalarValue(value.objectValue());
+ return getNativeScalarValue(
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Float32:
- return getNativeScalarValue(value.objectValue());
+ return getNativeScalarValue(
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Float64:
- return getNativeScalarValue(value.objectValue());
+ return getNativeScalarValue(
+ value.objectValue(),
+ std::forward(callback));
default:
- return std::monostate();
+ return callback(swl::monostate());
}
}
-template
-CesiumMetadataValueImpl::ValueType
-getNativeVecValue(const DotNet::System::Object& object) {
+template
+auto getNativeVecValue(const DotNet::System::Object& object, F&& callback) {
std::optional maybeValue;
if constexpr (std::is_same_v) {
maybeValue = CesiumMetadataValue::GetObjectAsCesiumIntVec2(object);
@@ -161,7 +184,7 @@ getNativeVecValue(const DotNet::System::Object& object) {
}
if (!maybeValue) {
- return std::monostate();
+ return callback(swl::monostate());
}
TTo result = TTo();
@@ -170,102 +193,167 @@ getNativeVecValue(const DotNet::System::Object& object) {
result[i] = value[i];
}
- return result;
+ return callback(std::move(result));
}
-CesiumMetadataValueImpl::ValueType
-getNativeVec2Value(const DotNet::CesiumForUnity::CesiumMetadataValue& value) {
+template
+auto getNativeVec2Value(
+ const DotNet::CesiumForUnity::CesiumMetadataValue& value,
+ F&& callback) {
CesiumMetadataValueType valueType = value.valueType();
assert(valueType.type == CesiumMetadataType::Vec2);
switch (valueType.componentType) {
case CesiumMetadataComponentType::Int8:
- return getNativeVecValue(value.objectValue());
+ return getNativeVecValue(
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Uint8:
- return getNativeVecValue(value.objectValue());
+ return getNativeVecValue(
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Int16:
- return getNativeVecValue(value.objectValue());
+ return getNativeVecValue(
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Uint16:
- return getNativeVecValue(value.objectValue());
+ return getNativeVecValue(
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Int32:
- return getNativeVecValue(value.objectValue());
+ return getNativeVecValue(
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Uint32:
- return getNativeVecValue(value.objectValue());
+ return getNativeVecValue(
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Int64:
- return getNativeVecValue(value.objectValue());
+ return getNativeVecValue(
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Uint64:
- return getNativeVecValue(value.objectValue());
+ return getNativeVecValue(
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Float32:
- return getNativeVecValue(value.objectValue());
+ return getNativeVecValue(
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Float64:
- return getNativeVecValue(value.objectValue());
+ return getNativeVecValue(
+ value.objectValue(),
+ std::forward(callback));
default:
- return std::monostate();
+ return callback(swl::monostate());
}
}
-CesiumMetadataValueImpl::ValueType
-getNativeVec3Value(const DotNet::CesiumForUnity::CesiumMetadataValue& value) {
+template
+auto getNativeVec3Value(
+ const DotNet::CesiumForUnity::CesiumMetadataValue& value,
+ F&& callback) {
CesiumMetadataValueType valueType = value.valueType();
assert(valueType.type == CesiumMetadataType::Vec3);
switch (valueType.componentType) {
case CesiumMetadataComponentType::Int8:
- return getNativeVecValue(value.objectValue());
+ return getNativeVecValue(
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Uint8:
- return getNativeVecValue(value.objectValue());
+ return getNativeVecValue(
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Int16:
- return getNativeVecValue(value.objectValue());
+ return getNativeVecValue(
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Uint16:
- return getNativeVecValue(value.objectValue());
+ return getNativeVecValue(
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Int32:
- return getNativeVecValue(value.objectValue());
+ return getNativeVecValue(
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Uint32:
- return getNativeVecValue(value.objectValue());
+ return getNativeVecValue(
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Int64:
- return getNativeVecValue(value.objectValue());
+ return getNativeVecValue(
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Uint64:
- return getNativeVecValue(value.objectValue());
+ return getNativeVecValue(
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Float32:
- return getNativeVecValue(value.objectValue());
+ return getNativeVecValue(
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Float64:
- return getNativeVecValue(value.objectValue());
+ return getNativeVecValue(
+ value.objectValue(),
+ std::forward(callback));
default:
- return std::monostate();
+ return callback(swl::monostate());
}
}
-CesiumMetadataValueImpl::ValueType
-getNativeVec4Value(const DotNet::CesiumForUnity::CesiumMetadataValue& value) {
+template
+auto getNativeVec4Value(
+ const DotNet::CesiumForUnity::CesiumMetadataValue& value,
+ F&& callback) {
CesiumMetadataValueType valueType = value.valueType();
assert(valueType.type == CesiumMetadataType::Vec4);
switch (valueType.componentType) {
case CesiumMetadataComponentType::Int8:
- return getNativeVecValue(value.objectValue());
+ return getNativeVecValue(
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Uint8:
- return getNativeVecValue(value.objectValue());
+ return getNativeVecValue(
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Int16:
- return getNativeVecValue(value.objectValue());
+ return getNativeVecValue(
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Uint16:
- return getNativeVecValue(value.objectValue());
+ return getNativeVecValue(
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Int32:
- return getNativeVecValue(value.objectValue());
+ return getNativeVecValue(
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Uint32:
- return getNativeVecValue(value.objectValue());
+ return getNativeVecValue(
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Int64:
- return getNativeVecValue(value.objectValue());
+ return getNativeVecValue(
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Uint64:
- return getNativeVecValue(value.objectValue());
+ return getNativeVecValue(
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Float32:
- return getNativeVecValue(value.objectValue());
+ return getNativeVecValue(
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Float64:
- return getNativeVecValue(value.objectValue());
+ return getNativeVecValue(
+ value.objectValue(),
+ std::forward(callback));
default:
- return std::monostate();
+ return callback(swl::monostate());
}
}
-template
-CesiumMetadataValueImpl::ValueType
-getNativeMatValue(const DotNet::System::Object& object) {
+template
+auto getNativeMatValue(const DotNet::System::Object& object, F&& callback) {
std::optional maybeValue;
if constexpr (std::is_same_v) {
maybeValue = CesiumMetadataValue::GetObjectAsCesiumIntMat2x2(object);
@@ -294,7 +382,7 @@ getNativeMatValue(const DotNet::System::Object& object) {
}
if (!maybeValue) {
- return std::monostate();
+ return callback(swl::monostate());
}
TTo result = TTo();
@@ -305,824 +393,771 @@ getNativeMatValue(const DotNet::System::Object& object) {
}
}
- return result;
+ return callback(std::move(result));
}
-CesiumMetadataValueImpl::ValueType
-getNativeMat2Value(const DotNet::CesiumForUnity::CesiumMetadataValue& value) {
+template
+auto getNativeMat2Value(
+ const DotNet::CesiumForUnity::CesiumMetadataValue& value,
+ F&& callback) {
CesiumMetadataValueType valueType = value.valueType();
assert(valueType.type == CesiumMetadataType::Mat2);
switch (valueType.componentType) {
case CesiumMetadataComponentType::Int8:
return getNativeMatValue(
- value.objectValue());
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Uint8:
return getNativeMatValue(
- value.objectValue());
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Int16:
return getNativeMatValue(
- value.objectValue());
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Uint16:
return getNativeMatValue(
- value.objectValue());
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Int32:
return getNativeMatValue(
- value.objectValue());
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Uint32:
return getNativeMatValue(
- value.objectValue());
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Int64:
return getNativeMatValue(
- value.objectValue());
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Uint64:
return getNativeMatValue(
- value.objectValue());
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Float32:
- return getNativeMatValue(value.objectValue());
+ return getNativeMatValue(
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Float64:
- return getNativeMatValue(value.objectValue());
+ return getNativeMatValue(
+ value.objectValue(),
+ std::forward(callback));
default:
- return std::monostate();
+ return callback(swl::monostate());
}
}
-CesiumMetadataValueImpl::ValueType
-getNativeMat3Value(const DotNet::CesiumForUnity::CesiumMetadataValue& value) {
+template
+auto getNativeMat3Value(
+ const DotNet::CesiumForUnity::CesiumMetadataValue& value,
+ F&& callback) {
CesiumMetadataValueType valueType = value.valueType();
assert(valueType.type == CesiumMetadataType::Mat3);
switch (valueType.componentType) {
case CesiumMetadataComponentType::Int8:
return getNativeMatValue(
- value.objectValue());
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Uint8:
return getNativeMatValue(
- value.objectValue());
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Int16:
return getNativeMatValue(
- value.objectValue());
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Uint16:
return getNativeMatValue(
- value.objectValue());
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Int32:
return getNativeMatValue(
- value.objectValue());
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Uint32:
return getNativeMatValue(
- value.objectValue());
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Int64:
return getNativeMatValue(
- value.objectValue());
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Uint64:
return getNativeMatValue(
- value.objectValue());
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Float32:
- return getNativeMatValue(value.objectValue());
+ return getNativeMatValue(
+ value.objectValue(),
+ std::forward(callback));
case CesiumMetadataComponentType::Float64:
- return getNativeMatValue(value.objectValue());
+ return getNativeMatValue(
+ value.objectValue(),
+ std::forward(callback));
default:
- return std::monostate();
+ return callback(swl::monostate());
}
}
-CesiumMetadataValueImpl::ValueType
-getNativeMat4Value(const DotNet::CesiumForUnity::CesiumMetadataValue& value) {
+template
+auto getNativeMat4Value(
+ const DotNet::CesiumForUnity::CesiumMetadataValue& value,
+ F&& callback) {
CesiumMetadataValueType valueType = value.valueType();
assert(valueType.type == CesiumMetadataType::Mat4);
switch (valueType.componentType) {
case CesiumMetadataComponentType::Int8:
return getNativeMatValue