Пример #1
0
        private void RemoveTerrainTriangle(MyNavigationTriangle tri)
        {
            MyWingedEdgeMesh.FaceVertexEnumerator vertexEnumerator = tri.GetVertexEnumerator();
            vertexEnumerator.MoveNext();
            Vector3 current = vertexEnumerator.Current;

            vertexEnumerator.MoveNext();
            Vector3 vector2 = vertexEnumerator.Current;

            vertexEnumerator.MoveNext();
            Vector3 vector3   = vertexEnumerator.Current;
            int     edgeIndex = tri.GetEdgeIndex(0);
            int     num2      = tri.GetEdgeIndex(1);
            int     num3      = tri.GetEdgeIndex(2);
            int     num4      = edgeIndex;

            if (!this.m_connectionHelper.TryRemoveOuterEdge(ref current, ref vector2, ref num4) && (base.Mesh.GetEdge(edgeIndex).OtherFace(tri.Index) != -1))
            {
                this.m_connectionHelper.AddOuterEdgeIndex(ref vector2, ref current, edgeIndex);
            }
            num4 = num2;
            if (!this.m_connectionHelper.TryRemoveOuterEdge(ref vector2, ref vector3, ref num4) && (base.Mesh.GetEdge(num2).OtherFace(tri.Index) != -1))
            {
                this.m_connectionHelper.AddOuterEdgeIndex(ref vector3, ref vector2, num2);
            }
            num4 = num3;
            if (!this.m_connectionHelper.TryRemoveOuterEdge(ref vector3, ref current, ref num4) && (base.Mesh.GetEdge(num3).OtherFace(tri.Index) != -1))
            {
                this.m_connectionHelper.AddOuterEdgeIndex(ref current, ref vector3, num3);
            }
            base.RemoveTriangle(tri);
        }
Пример #2
0
 public void GetVertices(out Vector3 a, out Vector3 b, out Vector3 c)
 {
     MyWingedEdgeMesh.FaceVertexEnumerator vertexEnumerator = this.m_navMesh.Mesh.GetFace(this.m_triIndex).GetVertexEnumerator();
     vertexEnumerator.MoveNext();
     a = vertexEnumerator.Current;
     vertexEnumerator.MoveNext();
     b = vertexEnumerator.Current;
     vertexEnumerator.MoveNext();
     c = vertexEnumerator.Current;
 }
Пример #3
0
        public void FindDangerousVertices(List <int> output)
        {
            MyWingedEdgeMesh.FaceVertexEnumerator vertexEnumerator = this.m_navMesh.Mesh.GetFace(this.m_triIndex).GetVertexEnumerator();
            vertexEnumerator.MoveNext();
            int currentIndex = vertexEnumerator.CurrentIndex;

            vertexEnumerator.MoveNext();
            int num2 = vertexEnumerator.CurrentIndex;

            vertexEnumerator.MoveNext();
            int num3 = vertexEnumerator.CurrentIndex;
        }
Пример #4
0
 public void GetTransformed(ref MatrixI tform, out Vector3 newA, out Vector3 newB, out Vector3 newC)
 {
     MyWingedEdgeMesh.FaceVertexEnumerator vertexEnumerator = this.m_navMesh.Mesh.GetFace(this.m_triIndex).GetVertexEnumerator();
     vertexEnumerator.MoveNext();
     newA = vertexEnumerator.Current;
     Vector3.Transform(ref newA, ref tform, out newA);
     vertexEnumerator.MoveNext();
     newB = vertexEnumerator.Current;
     Vector3.Transform(ref newB, ref tform, out newB);
     vertexEnumerator.MoveNext();
     newC = vertexEnumerator.Current;
     Vector3.Transform(ref newC, ref tform, out newC);
 }
Пример #5
0
        private bool IsFaceTriangle(MyNavigationTriangle triangle, Vector3I cubePosition, Vector3I direction)
        {
            MyWingedEdgeMesh.FaceVertexEnumerator vertexEnumerator = triangle.GetVertexEnumerator();
            vertexEnumerator.MoveNext();
            vertexEnumerator.MoveNext();
            vertexEnumerator.MoveNext();
            cubePosition *= 0x100;
            Vector3I vectori4 = (Vector3I)(cubePosition + (direction * 0x80));
            Vector3I vectori  = Vector3I.Round(vertexEnumerator.Current * 256f) - vectori4;
            Vector3I vectori2 = Vector3I.Round(vertexEnumerator.Current * 256f) - vectori4;
            Vector3I vectori3 = Vector3I.Round(vertexEnumerator.Current * 256f) - vectori4;

            return(!((vectori * direction) != Vector3I.Zero) ? (!((vectori2 * direction) != Vector3I.Zero) ? (!((vectori3 * direction) != Vector3I.Zero) ? ((vectori.AbsMax() <= 0x80) && ((vectori2.AbsMax() <= 0x80) && (vectori3.AbsMax() <= 0x80))) : false) : false) : false);
        }
Пример #6
0
        private void RemoveAndAddTriangle(ref Vector3I positionA, ref Vector3I positionB, int registeredEdgeIndex)
        {
            MyNavigationTriangle edgeTriangle = base.GetEdgeTriangle(registeredEdgeIndex);

            MyWingedEdgeMesh.FaceVertexEnumerator vertexEnumerator = edgeTriangle.GetVertexEnumerator();
            vertexEnumerator.MoveNext();
            Vector3 current = vertexEnumerator.Current;

            vertexEnumerator.MoveNext();
            vertexEnumerator.MoveNext();
            Vector3I cube = this.FindTriangleCube(edgeTriangle.Index, ref positionA, ref positionB);

            this.RemoveTriangle(edgeTriangle, cube);
            MyNavigationTriangle tri = this.AddTriangleInternal(current, vertexEnumerator.Current, vertexEnumerator.Current);

            this.RegisterTriangleInternal(tri, ref cube);
        }
Пример #7
0
        private void RemoveTriangle(MyNavigationTriangle triangle, Vector3I cube)
        {
            int num4;
            int num5;
            int num6;

            MyWingedEdgeMesh.FaceVertexEnumerator vertexEnumerator = triangle.GetVertexEnumerator();
            vertexEnumerator.MoveNext();
            Vector3I pointA = Vector3I.Round(vertexEnumerator.Current * 256f);

            vertexEnumerator.MoveNext();
            Vector3I pointB = Vector3I.Round(vertexEnumerator.Current * 256f);

            vertexEnumerator.MoveNext();
            Vector3I vectori3  = Vector3I.Round(vertexEnumerator.Current * 256f);
            int      edgeIndex = triangle.GetEdgeIndex(0);
            int      num2      = triangle.GetEdgeIndex(1);
            int      num3      = triangle.GetEdgeIndex(2);

            if (!this.m_connectionHelper.TryGetValue(new EdgeIndex(ref pointA, ref vectori3), out num4))
            {
                num4 = -1;
            }
            if (!this.m_connectionHelper.TryGetValue(new EdgeIndex(ref vectori3, ref pointB), out num5))
            {
                num5 = -1;
            }
            if (!this.m_connectionHelper.TryGetValue(new EdgeIndex(ref pointB, ref pointA), out num6))
            {
                num6 = -1;
            }
            if ((num4 == -1) || (num3 != num4))
            {
                this.m_connectionHelper.Add(new EdgeIndex(vectori3, pointA), num3);
            }
            else
            {
                this.m_connectionHelper.Remove(new EdgeIndex(ref pointA, ref vectori3));
            }
            if ((num5 == -1) || (num2 != num5))
            {
                this.m_connectionHelper.Add(new EdgeIndex(pointB, vectori3), num2);
            }
            else
            {
                this.m_connectionHelper.Remove(new EdgeIndex(ref vectori3, ref pointB));
            }
            if ((num6 == -1) || (edgeIndex != num6))
            {
                this.m_connectionHelper.Add(new EdgeIndex(pointA, pointB), edgeIndex);
            }
            else
            {
                this.m_connectionHelper.Remove(new EdgeIndex(ref pointB, ref pointA));
            }
            List <int> list = null;

            this.m_smallTriangleRegistry.TryGetValue(cube, out list);
            int index = 0;

            while (true)
            {
                if (index < list.Count)
                {
                    if (list[index] != triangle.Index)
                    {
                        index++;
                        continue;
                    }
                    list.RemoveAtFast <int>(index);
                }
                if (list.Count == 0)
                {
                    this.m_smallTriangleRegistry.Remove(cube);
                }
                base.RemoveTriangle(triangle);
                if ((num4 != -1) && (num3 != num4))
                {
                    this.RemoveAndAddTriangle(ref pointA, ref vectori3, num4);
                }
                if ((num5 != -1) && (num2 != num5))
                {
                    this.RemoveAndAddTriangle(ref vectori3, ref pointB, num5);
                }
                if ((num6 != -1) && (edgeIndex != num6))
                {
                    this.RemoveAndAddTriangle(ref pointB, ref pointA, num6);
                }
                return;
            }
        }
Пример #8
0
        private MyNavigationTriangle GetClosestNavigationTriangle(ref Vector3 point, ref float closestDistSq)
        {
            Vector3I vectori;

            Vector3I.Round(ref point, out vectori);
            MyNavigationTriangle   triangle = null;
            Vector3I               start    = vectori - new Vector3I(4, 4, 4);
            Vector3I               end      = (Vector3I)(vectori + new Vector3I(4, 4, 4));
            Vector3I_RangeIterator iterator = new Vector3I_RangeIterator(ref start, ref end);

            while (iterator.IsValid())
            {
                List <int> list;
                this.m_smallTriangleRegistry.TryGetValue(start, out list);
                if (list != null)
                {
                    foreach (int num in list)
                    {
                        MyNavigationTriangle triangle2 = base.GetTriangle(num);
                        MyWingedEdgeMesh.FaceVertexEnumerator vertexEnumerator = triangle2.GetVertexEnumerator();
                        vertexEnumerator.MoveNext();
                        Vector3 current = vertexEnumerator.Current;
                        vertexEnumerator.MoveNext();
                        Vector3 vector2 = vertexEnumerator.Current;
                        vertexEnumerator.MoveNext();
                        Vector3 vector3 = vertexEnumerator.Current;
                        Vector3 vector4 = ((current + vector2) + vector3) / 3f;
                        Vector3 vector5 = vector2 - current;
                        Vector3 vector6 = vector3 - vector2;
                        float   num2    = Vector3.DistanceSquared(vector4, point);
                        if (num2 < (vector5.LengthSquared() + vector6.LengthSquared()))
                        {
                            Vector3 vector7 = Vector3.Cross(vector5, vector6);
                            vector7.Normalize();
                            vector5 = Vector3.Cross(vector5, vector7);
                            vector6 = Vector3.Cross(vector6, vector7);
                            float   num3    = -Vector3.Dot(vector5, current);
                            float   num4    = -Vector3.Dot(vector6, vector2);
                            Vector3 vector1 = Vector3.Cross(current - vector3, vector7);
                            float   num5    = -Vector3.Dot(vector1, vector3);
                            float   num6    = Vector3.Dot(vector5, point) + num3;
                            float   num7    = Vector3.Dot(vector6, point) + num4;
                            float   num8    = Vector3.Dot(vector1, point) + num5;
                            num2  = Vector3.Dot(vector7, point) - Vector3.Dot(vector7, vector4);
                            num2 *= num2;
                            if (num6 > 0f)
                            {
                                if (num7 <= 0f)
                                {
                                    num2 = (num8 <= 0f) ? (num2 + Vector3.DistanceSquared(vector3, point)) : (num2 + (num7 * num7));
                                }
                                else if (num8 < 0f)
                                {
                                    num2 += num8 * num8;
                                }
                            }
                            else if (num7 > 0f)
                            {
                                num2 = (num8 <= 0f) ? (num2 + Vector3.DistanceSquared(current, point)) : (num2 + (num6 * num6));
                            }
                            else if (num8 > 0f)
                            {
                                num2 += Vector3.DistanceSquared(vector2, point);
                            }
                        }
                        if (num2 < closestDistSq)
                        {
                            triangle      = triangle2;
                            closestDistSq = num2;
                        }
                    }
                }
                iterator.GetNext(out start);
            }
            return(triangle);
        }