Exemplo n.º 1
0
        // If edgeIndex == -1, this method finds the first matching edge. Otherwise, it finds the edge with the given index
        public bool TryRemoveOuterEdge(ref Vector3 posv0, ref Vector3 posv1, ref int edgeIndex)
        {
            // Careful: This is quadratic in the number of entries in a bin in m_outerEdgePoints, so don't make the bins too large!
            if (edgeIndex == -1)
            {
                var en0 = m_outerEdgePoints.QueryPointsSphere(ref posv0, OUTER_EDGE_EPSILON);
                while (en0.MoveNext())
                {
                    var en1 = m_outerEdgePoints.QueryPointsSphere(ref posv1, OUTER_EDGE_EPSILON);
                    while (en1.MoveNext())
                    {
                        OuterEdgePoint p0 = en0.Current;
                        OuterEdgePoint p1 = en1.Current;
                        if (p0.EdgeIndex == p1.EdgeIndex && p0.FirstPoint && !p1.FirstPoint)
                        {
                            edgeIndex = p0.EdgeIndex;
                            m_outerEdgePoints.RemoveTwo(ref en0, ref en1);
                            return(true);
                        }
                    }
                }

                edgeIndex = -1;
            }
            else
            {
                int found = 0;
                var en0   = m_outerEdgePoints.QueryPointsSphere(ref posv0, OUTER_EDGE_EPSILON);
                while (en0.MoveNext())
                {
                    if (en0.Current.EdgeIndex == edgeIndex && en0.Current.FirstPoint)
                    {
                        found++;
                        break;
                    }
                }

                var en1 = m_outerEdgePoints.QueryPointsSphere(ref posv1, OUTER_EDGE_EPSILON);
                while (en1.MoveNext())
                {
                    if (en1.Current.EdgeIndex == edgeIndex && !en1.Current.FirstPoint)
                    {
                        found++;
                        break;
                    }
                }

                if (found == 2)
                {
                    m_outerEdgePoints.RemoveTwo(ref en0, ref en1);
                    return(true);
                }
                else
                {
                    edgeIndex = -1;
                }
            }

            return(false);
        }
Exemplo n.º 2
0
        public void FixOuterEdge(int edgeIndex, bool firstPoint, Vector3 currentPosition)
        {
            OuterEdgePoint data  = new OuterEdgePoint(edgeIndex, firstPoint);
            var            query = m_outerEdgePoints.QueryPointsSphere(ref currentPosition, OUTER_EDGE_EPSILON * 3);
            bool           moved = false;

            while (query.MoveNext())
            {
                if (query.Current.EdgeIndex == edgeIndex && query.Current.FirstPoint == firstPoint)
                {
                    //Debug.Assert(moved == false, "The point was already moved!");
                    m_outerEdgePoints.MovePoint(query.StorageIndex, ref currentPosition);
                    moved = true;
                }
            }
        }
Exemplo n.º 3
0
        public void FixOuterEdge(int edgeIndex, bool firstPoint, Vector3 currentPosition)
        {
            OuterEdgePoint point1 = new OuterEdgePoint(edgeIndex, firstPoint);

            MyVector3Grid <OuterEdgePoint> .SphereQuery query = this.m_outerEdgePoints.QueryPointsSphere(ref currentPosition, OUTER_EDGE_EPSILON * 3f);
            while (query.MoveNext())
            {
                if (query.Current.EdgeIndex != edgeIndex)
                {
                    continue;
                }
                if (query.Current.FirstPoint == firstPoint)
                {
                    this.m_outerEdgePoints.MovePoint(query.StorageIndex, ref currentPosition);
                }
            }
        }
Exemplo n.º 4
0
 public bool TryRemoveOuterEdge(ref Vector3 posv0, ref Vector3 posv1, ref int edgeIndex)
 {
     if (edgeIndex == -1)
     {
         MyVector3Grid <OuterEdgePoint> .SphereQuery query = this.m_outerEdgePoints.QueryPointsSphere(ref posv0, OUTER_EDGE_EPSILON);
         while (true)
         {
             if (!query.MoveNext())
             {
                 edgeIndex = -1;
                 break;
             }
             MyVector3Grid <OuterEdgePoint> .SphereQuery query2 = this.m_outerEdgePoints.QueryPointsSphere(ref posv1, OUTER_EDGE_EPSILON);
             while (query2.MoveNext())
             {
                 OuterEdgePoint current = query.Current;
                 OuterEdgePoint point2  = query2.Current;
                 if ((current.EdgeIndex == point2.EdgeIndex) && (current.FirstPoint && !point2.FirstPoint))
                 {
                     edgeIndex = current.EdgeIndex;
                     this.m_outerEdgePoints.RemoveTwo(ref query, ref query2);
                     return(true);
                 }
             }
         }
     }
     else
     {
         int num = 0;
         MyVector3Grid <OuterEdgePoint> .SphereQuery query3 = this.m_outerEdgePoints.QueryPointsSphere(ref posv0, OUTER_EDGE_EPSILON);
         while (true)
         {
             if (query3.MoveNext())
             {
                 if (query3.Current.EdgeIndex != edgeIndex)
                 {
                     continue;
                 }
                 if (!query3.Current.FirstPoint)
                 {
                     continue;
                 }
                 num++;
             }
             MyVector3Grid <OuterEdgePoint> .SphereQuery query4 = this.m_outerEdgePoints.QueryPointsSphere(ref posv1, OUTER_EDGE_EPSILON);
             while (true)
             {
                 if (query4.MoveNext())
                 {
                     if (query4.Current.EdgeIndex != edgeIndex)
                     {
                         continue;
                     }
                     if (query4.Current.FirstPoint)
                     {
                         continue;
                     }
                     num++;
                 }
                 if (num != 2)
                 {
                     edgeIndex = -1;
                     break;
                 }
                 this.m_outerEdgePoints.RemoveTwo(ref query3, ref query4);
                 return(true);
             }
             break;
         }
     }
     return(false);
 }