示例#1
0
            // "VEdge cont init"


            /// <summary>
            /// [BE WARNED: the degraded triangle case, the triangle might degrade into an edge or a point]
            ///
            ///
            /// </summary>
            private void _InitVEdgeTable()
            {
                int[] rvIdxs = m_RealMesh.triangles;
                int   triCnt = rvIdxs.Length / 3;

                //Dbg.Log("triCnt = {0}", triCnt);
                //ETimeProf prof = new ETimeProf();

                // loop over all real-tris, and generate VEdges
                for (int triIdx = 0; triIdx < triCnt; triIdx++)
                {
                    //prof.SecStart(0);
                    int rv0 = rvIdxs[triIdx * 3];
                    int rv1 = rvIdxs[triIdx * 3 + 1];
                    int rv2 = rvIdxs[triIdx * 3 + 2];

                    VVert vv0 = GetVV(rv0);
                    VVert vv1 = GetVV(rv1);
                    VVert vv2 = GetVV(rv2);

                    bool bDegradedTri = (vv0 == vv1) || (vv1 == vv2) || (vv0 == vv2);
                    if (bDegradedTri)
                    {
                        m_DegRTriCont.Add(triIdx); //record the degraded real-tri
                    }
                    //prof.SecEnd(0);

                    if (vv0 != vv1)
                    {
                        VEdge vedge = null;
                        //prof.SecStart(1);
                        if ((vedge = vv0.GetVEdge(vv1)) == null)
                        {
                            vedge = _CreateNewVEdge(vv0, vv1);
                        }
                        Dbg.Assert(vedge != null, "VMesh._InitVEdgeTable: vedge is null");

                        if (!bDegradedTri)
                        {
                            vedge.AddRTri(triIdx);
                        }
                        //prof.SecEnd(1);
                    }

                    if (vv1 != vv2)
                    {
                        VEdge vedge = null;
                        //prof.SecStart(2);
                        if ((vedge = vv1.GetVEdge(vv2)) == null)
                        {
                            vedge = _CreateNewVEdge(vv1, vv2);
                        }
                        if (!bDegradedTri)
                        {
                            vedge.AddRTri(triIdx);
                        }
                        //prof.SecEnd(2);
                    }

                    if (vv0 != vv2)
                    {
                        VEdge vedge = null;
                        //prof.SecStart(3);
                        if ((vedge = vv2.GetVEdge(vv0)) == null)
                        {
                            vedge = _CreateNewVEdge(vv2, vv0);
                        }
                        if (!bDegradedTri)
                        {
                            vedge.AddRTri(triIdx);
                        }
                        //prof.SecEnd(3);
                    }
                } // end of for

                m_VEdgeArr = m_VEdgeCont.ToArray();
                //prof.SecShowAll();
            }