|
|
|
|
|
|
|
|
|
|
[SerializeField] |
|
|
|
ARRaycastManager m_RaycastManager; |
|
|
|
|
|
|
|
|
|
|
|
ARMeshManager m_MeshManager; |
|
|
|
public ARMeshManager m_MeshManager; |
|
|
|
Camera m_MainCamera; |
|
|
|
public Camera m_MainCamera; |
|
|
|
|
|
|
|
Vector2 m_ScreenCenter; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<MeshFilter> m_AddedSubmeshes = new List<MeshFilter>(); |
|
|
|
List<MeshFilter> m_UpdatedSubmeshes = new List<MeshFilter>(); |
|
|
|
List<MeshFilter> m_RemovedSubmeshes = new List<MeshFilter>(); |
|
|
|
Dictionary<TrackableId, NativeArray<ARMeshClassification>> m_MeshDictionary; |
|
|
|
|
|
|
|
readonly Dictionary<TrackableId, NativeArray<ARMeshClassification>> m_MeshDictionary = new Dictionary<TrackableId, NativeArray<ARMeshClassification>>(); |
|
|
|
|
|
|
|
|
|
|
|
void OnEnable() |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
m_MeshDictionary = new Dictionary<TrackableId, NativeArray<ARMeshClassification>>(); |
|
|
|
|
|
|
|
|
|
|
|
m_MeshManager.meshesChanged += MeshManagerOnmeshesChanged; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
//m_DebugTextTwo.text = GetClassificationName(m_CurrentClassification);
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
m_AddedSubmeshes = obj.added; |
|
|
|
m_UpdatedSubmeshes = obj.updated; |
|
|
|
m_RemovedSubmeshes = obj.removed; |
|
|
|
|
|
|
|
foreach (MeshFilter mesh in m_AddedSubmeshes) |
|
|
|
foreach (MeshFilter mesh in obj.added) |
|
|
|
m_CurrentTrackableID = ExtractTrackableId(mesh.name); |
|
|
|
m_MeshDictionary.Add(m_CurrentTrackableID, m_MeshSubsystem.GetFaceClassifications(m_CurrentTrackableID, Allocator.Persistent)); |
|
|
|
TrackableId trackableId = ExtractTrackableId(mesh.name); |
|
|
|
m_MeshDictionary.Add(trackableId, m_MeshSubsystem.GetFaceClassifications(trackableId, Allocator.Persistent)); |
|
|
|
foreach (MeshFilter mesh in m_UpdatedSubmeshes) |
|
|
|
foreach (MeshFilter mesh in obj.updated) |
|
|
|
m_CurrentTrackableID = ExtractTrackableId(mesh.name); |
|
|
|
m_MeshDictionary[m_CurrentTrackableID] = m_MeshSubsystem.GetFaceClassifications(m_CurrentTrackableID, Allocator.Persistent); |
|
|
|
TrackableId trackableId = ExtractTrackableId(mesh.name); |
|
|
|
|
|
|
|
// Must dispose of the memory allocated for the previous native array in the entry, before setting a new one.
|
|
|
|
if (m_MeshDictionary[trackableId].IsCreated) |
|
|
|
{ |
|
|
|
m_MeshDictionary[trackableId].Dispose(); |
|
|
|
} |
|
|
|
|
|
|
|
m_MeshDictionary[trackableId] = m_MeshSubsystem.GetFaceClassifications(trackableId, Allocator.Persistent); |
|
|
|
foreach (MeshFilter mesh in m_RemovedSubmeshes) |
|
|
|
foreach (MeshFilter mesh in obj.removed) |
|
|
|
m_CurrentTrackableID = ExtractTrackableId(mesh.name); |
|
|
|
m_MeshDictionary.Remove(m_CurrentTrackableID); |
|
|
|
TrackableId trackableId = ExtractTrackableId(mesh.name); |
|
|
|
|
|
|
|
// Must dispose of the memory allocated for the native array, before deleting the entry in the dictionary.
|
|
|
|
if (m_MeshDictionary[trackableId].IsCreated) |
|
|
|
{ |
|
|
|
m_MeshDictionary[trackableId].Dispose(); |
|
|
|
} |
|
|
|
|
|
|
|
m_MeshDictionary.Remove(trackableId); |
|
|
|
Debug.Assert(m_MeshDictionary.ContainsKey(meshID), $"Mesh ID [{meshID}] does not exist in the dictionary"); |
|
|
|
Debug.Assert(triangleIndex < m_MeshDictionary[meshID].Length, $"Mesh ID [{meshID}] does have a triangle classification with index {triangleIndex}"); |
|
|
|
m_CurrentClassification = m_MeshDictionary[meshID][triangleIndex]; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
return retVal; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
TrackableId ExtractTrackableId(string meshFilterName) |
|
|
|
{ |
|
|
|
string[] nameSplit = meshFilterName.Split(' '); |
|
|
|