Esempio n. 1
0
        public IEnumerator UpdateGeometryOnMainThread()
        {
            if (BoundaryInfo == null)
            {
                yield break;
            }
            if (is_disconnected)
            {
                yield break;
            }
            MeshBoundaryData boundary_info = BoundaryInfo;

            // if mesh was modified before we got here, push it back onto dirty list
            if (boundary_info.timestamp != SO.Mesh.ShapeTimestamp)
            {
                OnComputeUpdateRequired?.Invoke(this);
                yield break;
            }

            int add_per_frame = 100;
            int counter       = 0;

            foreach (DCurve3 loop in boundary_info.Loops)
            {
                if (is_disconnected || boundary_info.timestamp != SO.Mesh.ShapeTimestamp)
                {
                    yield break;
                }
                List <Vector3f> vertices = new List <Vector3f>(loop.Vertices.Select(x => (Vector3f)x).ToList());
                vertices.Add(vertices[0]);
                fPolylineGameObject go = GameObjectFactory.CreatePolylineGO("boundary_curve", vertices, BoundaryLoopColor, BoundaryCurveWidth, LineWidthType.Pixel);
                SO.RootGameObject.AddChild(go, false);
                BoundaryCurveGOs.Add(go);
                if (counter++ == add_per_frame)
                {
                    counter = 0;
                    yield return(null);
                }
            }
            foreach (DCurve3 span in boundary_info.Spans)
            {
                if (is_disconnected || boundary_info.timestamp != SO.Mesh.ShapeTimestamp)
                {
                    yield break;
                }
                List <Vector3f>     vertices = new List <Vector3f>(span.Vertices.Select(x => (Vector3f)x).ToList());
                fPolylineGameObject go       = GameObjectFactory.CreatePolylineGO("boundary_span", vertices, BoundaryLoopColor, BoundaryCurveWidth, LineWidthType.Pixel);
                SO.RootGameObject.AddChild(go, false);
                BoundaryCurveGOs.Add(go);
                if (counter++ == add_per_frame)
                {
                    counter = 0;
                    yield return(null);
                }
            }
        }
Esempio n. 2
0
        public void ComputeOnBackgroundThread()
        {
            BoundaryInfo = null;

            object result = SO.SafeMeshRead(LockedComputeMeshBoundaryData);

            if (result is MeshBoundaryData)
            {
                BoundaryInfo = result as MeshBoundaryData;
                OnGeometryUpdateRequired?.Invoke(this);
            }
            else if (result is Exception)
            {
                DebugUtil.Log("MeshAnalysisViz.UpdateMesh - Exception: " + (result as Exception).Message);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// this runs inside SO.SafeMeshRead
        /// </summary>
        private object LockedComputeMeshBoundaryData(DMesh3 mesh)
        {
            MeshBoundaryLoops loops = new MeshBoundaryLoops(mesh, true);

            MeshBoundaryData bd = new MeshBoundaryData();

            foreach (EdgeLoop loop in loops.Loops)
            {
                bd.Loops.Add(loop.ToCurve());
            }
            if (loops.SawOpenSpans)
            {
                foreach (EdgeSpan span in loops.Spans)
                {
                    bd.Spans.Add(span.ToCurve());
                }
            }

            bd.timestamp = mesh.ShapeTimestamp;

            return(bd);
        }