Skip to content

Commit

Permalink
com.unity.xr.magicleap@6.3.0-preview.1
Browse files Browse the repository at this point in the history
## [6.3.0-preview.1] - 2021-06-28
- Update the Image Tracking subsystem to create the Image Tracker disabled and synchronously.
- Explicitly add a way to increment the reference count of the Native Image Tracker to allow for external code to clean up the tracker.
- Emit XRInputSubsystem.trackingOriginUpdated event when Lumin reports a new tracking session.
- Fix a compiler warning about unused format arguments.
- Fixed a new issue with unity 2021.2.0a14 where building a lumin project gives an error (Fixes FB# 1328078)
- Fixed an issue where `isTracked` and `TrackingState` were not getting updated correctly (Fixes FB# 1175008)
- Addressed a case where getting the best controller may not return a valid controller.
  • Loading branch information
Unity Technologies committed Jun 28, 2021
1 parent c815dd4 commit debd3de
Show file tree
Hide file tree
Showing 11 changed files with 202 additions and 56 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## [6.3.0-preview.1] - 2021-06-28
- Update the Image Tracking subsystem to create the Image Tracker disabled and synchronously.
- Explicitly add a way to increment the reference count of the Native Image Tracker to allow for external code to clean up the tracker.
- Emit XRInputSubsystem.trackingOriginUpdated event when Lumin reports a new tracking session.
- Fix a compiler warning about unused format arguments.
- Fixed a new issue with unity 2021.2.0a14 where building a lumin project gives an error (Fixes FB# 1328078)
- Fixed an issue where `isTracked` and `TrackingState` were not getting updated correctly (Fixes FB# 1175008)
- Addressed a case where getting the best controller may not return a valid controller.

## [6.2.2] - 2021-02-15
- Update C# assemblies to compile with "warnings as errors"
- Fix usage of obsolete APIs from XR Managment
Expand All @@ -14,7 +23,6 @@
- Fixed a bug where setting 'Force Multipass' to true was being ignored.
- Fixed a case where hands weren't properly shutdown when stopping the XR Input subsystem

## [6.1.0-preview.2] - 2021-01-05
- Fixed a bug discovered with a later version of Visual Studio 2019.
- Fixed an issue where an unsupported MLSDK would prevent the Manifest Settings from rendering properly (Fixes FB# 1289174)
- Fixed a issue where image tracking would automatically activate the image tracking camera on the device.
Expand Down
51 changes: 35 additions & 16 deletions Editor/ImageDatabase/MagicLeapImageDatabaseBuildProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void Dispose()

static MagicLeapImageDatabaseLibraryCache s_LibraryCache;

static readonly string k_ImageLibraryModificationCachePath = Path.Combine("Assets" + MagicLeapImageTrackingSubsystem.k_StreamingAssetsPath.Substring(Application.dataPath.Length), "ImageLibraryCache.asset");
static readonly string k_ImageLibraryModificationCachePath = Path.Combine(MagicLeapImageTrackingSubsystem.k_ImageTrackingDependencyPath, "ImageLibraryDB.json");

public static IEnumerable<T> AssetsOfType<T>() where T : UnityEngine.Object
{
Expand All @@ -58,51 +58,70 @@ static MagicLeapImageDatabaseLibraryCache CreateOrCleanupImageCacheFileIfNeeded(
{
string libraryCachePath = k_ImageLibraryModificationCachePath;

var libraryCache = AssetDatabase.LoadAssetAtPath<MagicLeapImageDatabaseLibraryCache>(libraryCachePath);
MagicLeapImageDatabaseLibraryCache libraryCache = null;
if (File.Exists(libraryCachePath))
{
libraryCache =
JsonUtility.FromJson<MagicLeapImageDatabaseLibraryCache>(File.ReadAllText(libraryCachePath));
}

if (libraryCache == null)
{
libraryCache = ScriptableObject.CreateInstance<MagicLeapImageDatabaseLibraryCache>();
libraryCache.m_LibraryCache = new Dictionary<string, DateTime>();
libraryCache = new MagicLeapImageDatabaseLibraryCache();
}
else
{
foreach (var libraryGuid in libraryCache.m_LibraryCache)
foreach (var libraryGuid in libraryCache.m_ImageLibraryCache)
{
if (!assetGuids.Contains(libraryGuid.Key))
libraryCache.m_LibraryCache.Remove(libraryGuid.Key);
if (!assetGuids.Contains(libraryGuid.assetGuid))
libraryCache.m_ImageLibraryCache.Remove(libraryGuid);
}
}

return libraryCache;
}

static bool DoesLibraryNeedToBeUpdated(string libraryGuid, ref Dictionary<string, DateTime> libraryCache)
static bool DoesLibraryNeedToBeUpdated(string libraryGuid, ref List<ImageDatabaseEntry> libraryCache)
{
var libraryPath = AssetDatabase.GUIDToAssetPath(libraryGuid);
var pakFilePath = Path.Combine(MagicLeapImageTrackingSubsystem.k_StreamingAssetsPath, libraryGuid + ".imgpak");
var currentTimestamp = File.GetLastWriteTime(libraryPath);

if (libraryCache.ContainsKey(libraryGuid) || File.Exists(pakFilePath))
var libraryEntryIndex = libraryCache.FindIndex(x => x.assetGuid == libraryGuid);
if (libraryEntryIndex < 0)
{
libraryCache.Add(new ImageDatabaseEntry()
{
assetGuid = libraryGuid
});
libraryEntryIndex = libraryCache.Count - 1;
}

else if (File.Exists(pakFilePath) ||
libraryCache[libraryEntryIndex].assetGuid == libraryGuid)
{
var previousTimestamp = libraryCache[libraryGuid];
var previousTimestamp = libraryCache[libraryEntryIndex].timeStamp;

if (!(previousTimestamp < currentTimestamp))
{
return false;
}
}

libraryCache[libraryGuid] = currentTimestamp;
libraryCache[libraryEntryIndex].timeStamp = currentTimestamp;
return true;
}

static void SaveStaticLibraryCachePostBuild()
{
if (AssetDatabase.Contains(s_LibraryCache))
AssetDatabase.SaveAssets();
else
AssetDatabase.CreateAsset(s_LibraryCache, k_ImageLibraryModificationCachePath);
// Overwrite the current library cache file
if (!Directory.Exists(MagicLeapImageTrackingSubsystem.k_ImageTrackingDependencyPath))
{
Directory.CreateDirectory(MagicLeapImageTrackingSubsystem.k_ImageTrackingDependencyPath);
}

var jsonData = JsonUtility.ToJson(s_LibraryCache);
File.WriteAllText(k_ImageLibraryModificationCachePath, jsonData);
}

static void SetTemporaryTextureImportSettingsIfNeeded(
Expand Down Expand Up @@ -181,7 +200,7 @@ public static void BuildImageTrackingAssets()

foreach (var library in AssetsOfType<XRReferenceImageLibrary>())
{
if (!DoesLibraryNeedToBeUpdated(assetGuidList[count++], ref s_LibraryCache.m_LibraryCache))
if (!DoesLibraryNeedToBeUpdated(assetGuidList[count++], ref s_LibraryCache.m_ImageLibraryCache))
continue;

EditorUtility.DisplayProgressBar(
Expand Down
44 changes: 35 additions & 9 deletions Editor/ImageDatabase/MagicLeapImageDatabaseLibraryCache.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,49 @@
using UnityEngine.XR.MagicLeap;

using UnityEngine;

using System;
using System.Collections.Generic;
using UnityEngine;

namespace UnityEditor.XR.MagicLeap
{
[Serializable]
public class ImageDatabaseEntry
{
public string assetGuid;
[SerializeField]
private long _timestamp;

/// <summary>
/// Getter/Setter to map the 'DateTime' we store for the entry vs what we can serialize
/// - note that the JSONUtility class cannot serialize a DateTime
/// </summary>
public DateTime timeStamp
{
get
{
return DateTime.FromFileTimeUtc(_timestamp);
}
set
{
_timestamp = value.ToFileTimeUtc();
}
}
}

/// <summary>
/// A scriptable object that is used to cache image library binary blob
/// generation data to prevent rebuilds everytime the user presses play in
/// the editor.
/// </summary>
public class MagicLeapImageDatabaseLibraryCache : ScriptableObject
[Serializable]
public class MagicLeapImageDatabaseLibraryCache
{
public MagicLeapImageDatabaseLibraryCache()
{
m_ImageLibraryCache = new List<ImageDatabaseEntry>(25);
}

/// <summary>
/// The dictionary that maps all image database assets to the cache.
/// </summary>
[Obsolete("To be removed when we bump the major version", true)]
public Dictionary<string, DateTime> m_LibraryCache;

public List<ImageDatabaseEntry> m_ImageLibraryCache;
}
}
}
Loading

0 comments on commit debd3de

Please sign in to comment.