private bool CreateAndAddMesh( GameObject obj, out ulong meshHandle, out ulong instanceHandle) { Debug.Assert(passthroughOverlay != null); Debug.Assert(passthroughOverlay.layerId > 0); meshHandle = 0; instanceHandle = 0; MeshFilter meshFilter = obj.GetComponent <MeshFilter>(); if (meshFilter == null) { Debug.LogError("Passthrough surface GameObject does not have a mesh component."); return(false); } Mesh mesh = meshFilter.sharedMesh; // TODO: evaluate using GetNativeVertexBufferPtr() instead to avoid copy Vector3[] vertices = mesh.vertices; int[] triangles = mesh.triangles; Matrix4x4 T_worldInsight_model = GetTransformMatrixForPassthroughSurfaceObject(obj); if (!OVRPlugin.CreateInsightTriangleMesh(passthroughOverlay.layerId, vertices, triangles, out meshHandle)) { Debug.LogWarning("Failed to create triangle mesh handle."); return(false); } if (!OVRPlugin.AddInsightPassthroughSurfaceGeometry(passthroughOverlay.layerId, meshHandle, T_worldInsight_model, out instanceHandle)) { Debug.LogWarning("Failed to add mesh to passthrough surface."); return(false); } return(true); }