Tango.Tango3DReconstruction._UpdateDepth C# (CSharp) Method

_UpdateDepth() private method

Update the 3D Reconstruction with a new point cloud and pose. It is expected this will get called in from the Tango binder thread.
private _UpdateDepth ( TangoXYZij depth, Matrix4x4 depthPose ) : void
depth TangoXYZij Point cloud from Tango.
depthPose UnityEngine.Matrix4x4 Pose matrix the point cloud corresponds too.
return void
        private void _UpdateDepth(TangoXYZij depth, Matrix4x4 depthPose)
        {
            if (m_context == IntPtr.Zero)
            {
                Debug.Log("Update called before creating a reconstruction context." + Environment.StackTrace);
                return;
            }

            APIPointCloud apiCloud;
            apiCloud.numPoints = depth.xyz_count;
            apiCloud.points = depth.xyz;
            apiCloud.timestamp = depth.timestamp;

            APIPose apiDepthPose = APIPose.FromMatrix4x4(ref depthPose);

            if (!m_sendColorToUpdate)
            {
                // No need to wait for a color image, update reconstruction immediately.
                IntPtr rawUpdatedIndices;
                Status result = (Status)API.Tango3DR_update(
                    m_context, ref apiCloud, ref apiDepthPose, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero,
                    out rawUpdatedIndices);
                if (result != Status.SUCCESS)
                {
                    Debug.Log("Tango3DR_update returned non-success." + Environment.StackTrace);
                    return;
                }

                _AddUpdatedIndices(rawUpdatedIndices);
                API.Tango3DR_GridIndexArray_destroy(rawUpdatedIndices);
            }
            else
            {
                lock (m_lockObject)
                {
                    // We need both a color image and a depth cloud to update reconstruction.  Cache the depth cloud
                    // because there are much less depth points than pixels.
                    m_mostRecentDepth = apiCloud;
                    m_mostRecentDepth.points = IntPtr.Zero;
                    m_mostRecentDepthPose = apiDepthPose;

                    Marshal.Copy(apiCloud.points, m_mostRecentDepthPoints, 0, apiCloud.numPoints * 3);
                    m_mostRecentDepthIsValid = true;
                }
            }
        }