Skip to content

Commit

Permalink
Merge branch 'feature/openxr-support' into integration/openxr-and-icosa
Browse files Browse the repository at this point in the history
  • Loading branch information
andybak committed Dec 17, 2024
2 parents b3dd3fe + c7a10a5 commit a56f8e3
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ jobs:
echo "Initial free space"
df -h /
echo "Removing all pre-loaded docker images"
docker rmi $(docker image ls -aq) # Removes ~3GB
docker image ls -aq | xargs -r docker rmi # Removes ~3GB
df -h /
echo "Listing 100 largest packages"
dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -rn | head -n 100
Expand Down
8 changes: 8 additions & 0 deletions Assets/Scripts/model/core/MeshWithMaterialRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ public void UsePreviewShader(bool usePreview)
// Which Layer this mesh will be drawn to.
public int Layer = DEFAULT_LAYER;

public void OnDestroy()
{
foreach (MeshWithMaterial meshWithMaterial in meshes)
{
Destroy(meshWithMaterial.mesh);
}
}

public void Init(WorldSpace worldSpace)
{
this.worldSpace = worldSpace;
Expand Down
2 changes: 2 additions & 0 deletions Assets/Scripts/model/main/PeltzerMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1550,6 +1550,8 @@ public void CreateNewModel(bool clearReferenceImages = true, bool resetAttention
zoomer.ClearState();
model.Clear(worldSpace);
volumeInserter.ClearState();
MeshCycler.DestroyMeshes();

spatialIndex.Reset(DEFAULT_BOUNDS);
if (resetAttentionCaller)
{
Expand Down
6 changes: 6 additions & 0 deletions Assets/Scripts/model/render/MeshHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
using com.google.apps.peltzer.client.model.import;
using com.google.apps.peltzer.client.model.main;
using com.google.apps.peltzer.client.model.util;
using Object = System.Object;

namespace com.google.apps.peltzer.client.model.render
{
Expand Down Expand Up @@ -165,6 +166,11 @@ public static void UpdateMeshes(MMesh updatedMesh, List<MeshWithMaterial> existi
newPos.Count != uMesh.mesh.vertices.Count())
{
// If materials changed, easiest action is to remesh everything.
foreach (var mm in existing)
{
UnityEngine.Object.Destroy(mm.mesh);
UnityEngine.Object.Destroy(mm.materialAndColor.material);
}
existing.Clear();
// This method is used to update a GameObject, and as such we do not want the vert positions in model space,
// it is the gameObject that will be placed and rotated in the world.
Expand Down
10 changes: 9 additions & 1 deletion Assets/Scripts/model/render/ReMesher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
using com.google.apps.peltzer.client.model.core;
using com.google.apps.peltzer.client.model.util;
using com.google.apps.peltzer.client.model.main;
using UnityEditor;
using Object = UnityEngine.Object;

namespace com.google.apps.peltzer.client.model.render
{
Expand Down Expand Up @@ -342,8 +344,14 @@ public static void InitBufferCaches()

public void Clear()
{
meshInfosByMaterial.Clear();
foreach (var meshInfo in allMeshInfos)
{
Object.Destroy(meshInfo.mesh);
Object.Destroy(meshInfo.materialAndColor.material);
}
allMeshInfos.Clear();
meshInfosByMaterial.Clear();
meshInfosByMesh.Clear();
meshesPendingAdd.Clear();
meshesPendingRemove.Clear();
meshInfosPendingRegeneration.Clear();
Expand Down
10 changes: 10 additions & 0 deletions Assets/Scripts/tools/utils/HighlightStyles/MeshCycler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,15 @@ public static void ResetCycler()
}
meshDict.Clear();
}

public static void DestroyMeshes()
{
ResetCycler();
foreach (Mesh mesh in meshPool)
{
Object.Destroy(mesh);
}
meshPool.Clear();
}
}
}

0 comments on commit a56f8e3

Please sign in to comment.