/// <summary> /// /// Meshes /// /// Parse mesh data /// Function decides if we are updating an already existing mesh or creating a new one. /// If a new mesh has been created this function will go through stored mesh instances /// and check if it can create new mesh instances. /// </summary> public static void ParseMeshData(System.IntPtr meshDataPtr) { try { var meshData = (MeshData)System.Runtime.InteropServices.Marshal.PtrToStructure(meshDataPtr, typeof(MeshData)); // Convert unmanaged to managed memory ManagedMeshData managedMeshData = MeshHandler.ManageMeshMemory(meshData); // If all dependants are here, create or update the mesh bool dependencySuccess = MeshHandler.DependencyCheck(managedMeshData, meshData.entityToken); if (dependencySuccess) { ParseMeshData(meshData, managedMeshData); // Delete the data ImportMenu.stpUnityDeleteMeshData(meshDataPtr); } else { // If we are not able to create or update store the mesh data and try later meshDataStore.Add(meshDataPtr); } } catch (System.Exception e) { Debug.LogException(e); // Delete the data ImportMenu.stpUnityDeleteMeshData(meshDataPtr); } }
// Iterate through mesh store that were missing dependants and check if we can create new mesh objects // or update existing mesh objects public static void IterateMeshStore() { for (int i = meshDataStore.Count - 1; i >= 0; i--) { MeshData meshData = (MeshData)System.Runtime.InteropServices.Marshal.PtrToStructure(meshDataStore[i], typeof(MeshData)); // Convert unmanaged to managed memory ManagedMeshData managedMeshData = MeshHandler.ManageMeshMemory(meshData); // If all dependants are here, create or update the mesh if (MeshHandler.DependencyCheck(managedMeshData, meshData.entityToken)) { ParseMeshData(meshData, managedMeshData); // Delete the data ImportMenu.stpUnityDeleteMeshData(meshDataStore[i]); // Remove from the store meshDataStore.RemoveAt(i); } } }