Skip to content

Commit a9a1a74

Browse files
authored
Merge branch 'main' into more-texture-formats
2 parents 05849fc + 34ffd15 commit a9a1a74

File tree

6 files changed

+71
-38
lines changed

6 files changed

+71
-38
lines changed

.github/workflows/build.yml

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,36 @@ jobs:
66
runs-on: ubuntu-latest
77
steps:
88
- name: Check out repository code
9-
uses: actions/checkout@v3
9+
uses: actions/checkout@v4
1010
- name: Install clang-format
1111
run: pip install clang-format
1212
- name: Check source formatting
1313
run: |
1414
find native~/Runtime native~/Editor native~/Shared \( -iname '*.cpp' -o -iname '*.h' \) -print0 | xargs -0 clang-format --dry-run -Werror
1515
Windows:
1616
needs: [QuickChecks]
17-
runs-on: ["self-hosted","windows","x64","unity-2021-3"]
17+
runs-on: windows-latest
1818
# Only allow a single Windows build at a time, for Unity licensing reasons
1919
concurrency: windows
2020
steps:
2121
- name: Check out repository code
22-
uses: actions/checkout@v3
22+
uses: actions/checkout@v4
2323
with:
2424
submodules: recursive
2525
- name: Install nasm
26-
uses: ilammy/setup-nasm@v1.4.0
26+
uses: ilammy/setup-nasm@v1.5.1
27+
- name: Install wget
28+
run: |
29+
choco install -y wget
30+
- name: Install Unity Hub
31+
run: |
32+
wget https://public-cdn.cloud.unity3d.com/hub/prod/UnityHubSetup.exe
33+
Start-Process "./UnityHubSetup.exe" -Args "/S" -Wait
34+
del ./UnityHubSetup.exe
35+
- name: Install Unity
36+
run: |
37+
Start-Process -FilePath "C:/Program Files/Unity Hub/Unity Hub.exe" -Args "-- --headless install --version 2021.3.13f1 --changeset 9e7d58001ecf" -Wait
38+
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
2739
- name: Create SSH tunnel to Unity License Server
2840
env:
2941
UNITY_LICENSE_SERVER_SSH_KEY: ${{ secrets.UNITY_LICENSE_SERVER_SSH_KEY }}
@@ -77,7 +89,7 @@ jobs:
7789
dir d:\cesium\CesiumForUnityBuildProject
7890
- name: Publish package artifact
7991
if: ${{ success() }}
80-
uses: actions/upload-artifact@v3
92+
uses: actions/upload-artifact@v4
8193
with:
8294
name: Windows Package
8395
path: d:\cesium\CesiumForUnityBuildProject\*.tgz
@@ -86,24 +98,28 @@ jobs:
8698
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
8799
cat d:\cesium\temp\test-log.txt
88100
- name: Test Report
89-
uses: kring/test-reporter@v1.6.1-kring
101+
uses: kring/test-reporter@v1.6.2-kring
90102
if: success() || failure() # run this step even if previous step failed
91103
with:
92104
name: Tests - Windows
93105
path: d:/cesium/temp/TestResults.xml
94106
reporter: dotnet-nunit
95107
MacOS:
96108
needs: [QuickChecks]
97-
runs-on: macos-11
109+
runs-on: macos-12
98110
# Only allow a single macOS build at a time, for Unity licensing reasons
99111
concurrency: mac
100112
steps:
113+
- name: Set XCode version
114+
uses: maxim-lobanov/setup-xcode@v1
115+
with:
116+
xcode-version: "14.1"
101117
- name: Check out repository code
102-
uses: actions/checkout@v3
118+
uses: actions/checkout@v4
103119
with:
104120
submodules: recursive
105121
- name: Install nasm
106-
uses: ilammy/setup-nasm@v1.4.0
122+
uses: ilammy/setup-nasm@v1.5.1
107123
- name: Install jq
108124
run: brew install jq
109125
- name: Install Unity Hub
@@ -118,10 +134,10 @@ jobs:
118134
# This command sometimes returns exit code 130, despite actually succeeding.
119135
continue-on-error: true
120136
run: |
121-
/Applications/Unity\ Hub.app/Contents/MacOS/Unity\ Hub -- --headless install --version 2021.3.13f1 --changeset 9e7d58001ecf
137+
/Applications/Unity\ Hub.app/Contents/MacOS/Unity\ Hub -- --headless install --version 2021.3.13f1 --changeset 9e7d58001ecf --architecture x86_64
122138
- name: Install Unity iOS Support
123139
run: |
124-
/Applications/Unity\ Hub.app/Contents/MacOS/Unity\ Hub -- --headless install-modules --version 2021.3.13f1 --changeset 9e7d58001ecf --module ios
140+
/Applications/Unity\ Hub.app/Contents/MacOS/Unity\ Hub -- --headless install-modules --version 2021.3.13f1 --changeset 9e7d58001ecf --module ios --architecture x86_64
125141
- name: Configure Unity to Use the License Server
126142
run: |
127143
sudo mkdir -p "/Library/Application Support/Unity/config"
@@ -172,7 +188,7 @@ jobs:
172188
ls -l ~/cesium/CesiumForUnityBuildProject
173189
- name: Publish package artifact
174190
if: ${{ success() }}
175-
uses: actions/upload-artifact@v3
191+
uses: actions/upload-artifact@v4
176192
with:
177193
name: macOS Package
178194
path: ~/cesium/CesiumForUnityBuildProject/*.tgz
@@ -182,7 +198,7 @@ jobs:
182198
cat ~/cesium/CesiumForUnityBuildProject/test-log.txt
183199
ls /Users/runner/cesium/CesiumForUnityBuildProject/TestResults.xml
184200
- name: Test Report
185-
uses: kring/test-reporter@v1.6.1-kring
201+
uses: kring/test-reporter@v1.6.2-kring
186202
if: success() || failure() # run this step even if previous step failed
187203
with:
188204
name: Tests - macOS
@@ -193,11 +209,11 @@ jobs:
193209
needs: [Windows, MacOS]
194210
steps:
195211
- name: Check out repository code
196-
uses: actions/checkout@v3
212+
uses: actions/checkout@v4
197213
- name: Install jq
198214
run: sudo apt install jq
199215
- name: Download macOS build
200-
uses: actions/download-artifact@v3
216+
uses: actions/download-artifact@v4
201217
with:
202218
name: macOS Package
203219
path: combine/macos
@@ -207,7 +223,7 @@ jobs:
207223
tar xzf *.tgz
208224
rm *.tgz
209225
- name: Download Windows build
210-
uses: actions/download-artifact@v3
226+
uses: actions/download-artifact@v4
211227
with:
212228
name: Windows Package
213229
path: combine/windows
@@ -268,7 +284,7 @@ jobs:
268284
tar czf $NAME-$VERSION.tgz package
269285
- name: Publish combined package
270286
if: ${{ success() }}
271-
uses: actions/upload-artifact@v3
287+
uses: actions/upload-artifact@v4
272288
with:
273289
name: Combined Package
274290
path: combine/merged/*.tgz

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
- Fixed a bug where adding a `CesiumSubScene` as the child of an existing `CesiumGeoreference` in editor would cause the parent `CesiumGeoreference` to have its coordinates reset to the default.
2727
- Fixed the "DynamicCamera is not nested inside a game object with a CesiumGeoreference" warning when adding a new DynamicCamera in the editor.
2828
- Fixed support for loading textures with less than four channels.
29+
- Fixed "Destroying assets is not permitted to avoid data loss" error when using a custom opaque material with texture assets on a `Cesium3DTileset`.
2930

3031
##### Deprecated :hourglass_flowing_sand:
3132

Tests/TestCesiumOriginShift.cs

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -164,31 +164,36 @@ public IEnumerator ShiftsOriginWithCharacterController()
164164

165165
yield return new WaitForEndOfFrame();
166166

167-
IEqualityComparer<double> epsilon6 = Comparers.Double(1e-6, 1e-6);
167+
IEqualityComparer<double> epsilon6 = Comparers.Double(1e-6, 1e-4);
168168

169169
Assert.That(baseEcef.x, Is.EqualTo(globeAnchor.positionGlobeFixed.x).Using(epsilon6));
170170

171-
// speed per second
172-
double speed = 1000.0;
173-
double duration = 10.0;
174-
float startTime = Time.time;
175-
Vector3 startPos = globeAnchor.transform.position;
171+
yield return null;
172+
173+
// Move, but not far enough to trigger an origin shift
174+
double3 previousPositionEcef = globeAnchor.positionGlobeFixed.x;
175+
double3 movement = georeference.TransformEarthCenteredEarthFixedDirectionToUnity(new double3(2500.0, 0, 0));
176+
controller.Move((float3)movement);
176177

177-
while ((Time.time - startTime) < duration)
178-
{
179-
double3 previousPositionEcef = globeAnchor.positionGlobeFixed.x;
178+
// Explicitly sync the globe anchor, so that the origin shift's LateUpdate sees the new position this frame.
179+
// Otherwise, it will base the shift on the position in the previous frame because CesiumGlobeAnchor
180+
// coroutine that updates from the Transform already ran for this frame before the Move above was called.
181+
globeAnchor.Sync();
180182

181-
yield return new WaitForFixedUpdate();
183+
yield return null;
182184

183-
double unitsEcef = speed * Time.deltaTime;
184-
double3 movement = georeference.TransformEarthCenteredEarthFixedDirectionToUnity(new double3(unitsEcef, 0, 0));
185-
controller.Move((float3)movement);
185+
Assert.That(previousPositionEcef.x + 2500.0, Is.EqualTo(globeAnchor.positionGlobeFixed.x).Using(epsilon6));
186+
Assert.Less(georeference.ecefX - globeAnchor.positionGlobeFixed.x, 5000.0);
186187

187-
yield return new WaitForEndOfFrame();
188+
// Move again, this time triggering an origin shift
189+
previousPositionEcef = globeAnchor.positionGlobeFixed.x;
190+
movement = georeference.TransformEarthCenteredEarthFixedDirectionToUnity(new double3(3000.0, 0, 0));
191+
controller.Move((float3)movement);
192+
globeAnchor.Sync();
193+
194+
yield return null;
188195

189-
globeAnchor.Sync();
190-
Assert.That(previousPositionEcef.x + unitsEcef, Is.EqualTo(globeAnchor.positionGlobeFixed.x).Using(epsilon6));
191-
Assert.Less(georeference.ecefX - globeAnchor.positionGlobeFixed.x, 5000.0);
192-
}
196+
Assert.That(previousPositionEcef.x + 3000.0, Is.EqualTo(globeAnchor.positionGlobeFixed.x).Using(epsilon6));
197+
Assert.Less(System.Math.Abs(georeference.ecefX - globeAnchor.positionGlobeFixed.x), 5000.0);
193198
}
194199
}

native~/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,17 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "iOS")
6565
set (ALL_TARGETS
6666
CesiumForUnityNative-Runtime
6767
Async++
68+
Cesium3DTilesContent
6869
Cesium3DTilesReader
6970
Cesium3DTilesSelection
7071
CesiumAsync
71-
CesiumGeospatial
7272
CesiumGeometry
73+
CesiumGeospatial
7374
CesiumGltf
75+
CesiumGltfContent
7476
CesiumGltfReader
7577
CesiumJsonReader
78+
CesiumRasterOverlays
7679
CesiumUtility
7780
draco_attributes
7881
draco_compression_attributes_dec

native~/Runtime/src/UnityPrepareRendererResources.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1046,6 +1046,7 @@ void setGltfMaterialParameterValues(
10461046
UnityEngine::Texture texture =
10471047
TextureLoader::loadTexture(model, baseColorTexture->index);
10481048
if (texture != nullptr) {
1049+
texture.hideFlags(DotNet::UnityEngine::HideFlags::HideAndDontSave);
10491050
unityMaterial.SetTexture(
10501051
materialProperties.getBaseColorTextureID(),
10511052
texture);
@@ -1065,6 +1066,7 @@ void setGltfMaterialParameterValues(
10651066
UnityEngine::Texture texture =
10661067
TextureLoader::loadTexture(model, metallicRoughness->index);
10671068
if (texture != nullptr) {
1069+
texture.hideFlags(DotNet::UnityEngine::HideFlags::HideAndDontSave);
10681070
unityMaterial.SetTexture(
10691071
materialProperties.getMetallicRoughnessTextureID(),
10701072
texture);
@@ -1087,6 +1089,7 @@ void setGltfMaterialParameterValues(
10871089
model,
10881090
gltfMaterial.emissiveTexture->index);
10891091
if (texture != nullptr) {
1092+
texture.hideFlags(DotNet::UnityEngine::HideFlags::HideAndDontSave);
10901093
unityMaterial.SetTexture(
10911094
materialProperties.getEmissiveTextureID(),
10921095
texture);
@@ -1104,6 +1107,7 @@ void setGltfMaterialParameterValues(
11041107
UnityEngine::Texture texture =
11051108
TextureLoader::loadTexture(model, gltfMaterial.normalTexture->index);
11061109
if (texture != nullptr) {
1110+
texture.hideFlags(DotNet::UnityEngine::HideFlags::HideAndDontSave);
11071111
unityMaterial.SetTexture(
11081112
materialProperties.getNormalMapTextureID(),
11091113
texture);
@@ -1125,6 +1129,7 @@ void setGltfMaterialParameterValues(
11251129
model,
11261130
gltfMaterial.occlusionTexture->index);
11271131
if (texture != nullptr) {
1132+
texture.hideFlags(DotNet::UnityEngine::HideFlags::HideAndDontSave);
11281133
unityMaterial.SetTexture(
11291134
materialProperties.getOcclusionTextureID(),
11301135
texture);
@@ -1587,8 +1592,11 @@ void freePrimitiveGameObject(
15871592
for (int32_t i = 0, len = textureIDs.Count(); i < len; ++i) {
15881593
int32_t textureID = textureIDs[i];
15891594
UnityEngine::Texture texture = material.GetTexture(textureID);
1590-
if (texture != nullptr)
1595+
if (texture != nullptr &&
1596+
(texture.hideFlags() & UnityEngine::HideFlags::HideAndDontSave) ==
1597+
UnityEngine::HideFlags::HideAndDontSave) {
15911598
UnityLifetime::Destroy(texture);
1599+
}
15921600
}
15931601

15941602
UnityLifetime::Destroy(material);

native~/extern/cesium-native

0 commit comments

Comments
 (0)