Example #1
0
        public void Update()
        {
            try {
                DMeshOutputStatus result = Compute.CheckForNewMesh();
                if (result.State == DMeshOutputStatus.States.Ready)
                {
                    ReplaceOutputMesh(result.Mesh, false);
                    if (result.Mesh.VertexCount == rectified_leg.Mesh.VertexCount)
                    {
                        rectified_leg.UpdateVertices(result.Mesh, true, true);
                    }
                    else
                    {
                        rectified_leg.ReplaceMesh(result.Mesh);
                    }
                }
            } catch (Exception e) {
                DebugUtil.Log(2, "LegModel.Update: caught exception! " + e.Message);
            }

            if (Compute.HaveBackgroundException)
            {
                Exception e = Compute.ExtractBackgroundException();
                DebugUtil.Log(2, "LegModel.Update: exception in background compute: " + e.Message);
                DebugUtil.Log(2, e.StackTrace);
            }
        }
        public void Update()
        {
            if (EnableUpdate == false)
            {
                return;
            }

            try {
                DMeshOutputStatus result = Compute.CheckForNewMesh();
                if (result.State == DMeshOutputStatus.States.Ready)
                {
                    socket.ReplaceMesh(result.Mesh);
                    OnSocketUpdated?.Invoke();
                    OnSocketUpdateStatus?.Invoke(
                        (DeviceGenOp.LastResultStatus == DeviceGeneratorOp.ResultStatus.PreviewResult) ?
                        SocketStatus.PreviewSocket : SocketStatus.FullSocket, "Ok");
                }
            } catch (Exception e) {
                DebugUtil.Log(2, "SocketModel.Update: caught exception! " + e.Message);
                DebugUtil.Log(2, e.StackTrace);
                OnSocketUpdateStatus?.Invoke(SocketStatus.ErrorSocket, "[REPLACE_EXCEPTION] " + e.Message);
            }

            if (Compute.HaveBackgroundException)
            {
                Exception e = Compute.ExtractBackgroundException();
                DebugUtil.Log(2, "SocketMode.Update: exception in background compute: " + e.Message);
                DebugUtil.Log(2, e.StackTrace);
                OnSocketUpdateStatus?.Invoke(SocketStatus.ErrorSocket, "[COMPUTE_EXCEPTION] " + e.Message);
            }
        }