private int AddTriangle(int index) { if (!this.m_funnelConstructed) { this.ConstructFunnel(index); } else { Vector3 vector; Vector3 vector2; MyPath <MyNavigationPrimitive> .PathNode node = this.m_input[index]; MyNavigationTriangle vertex = node.Vertex as MyNavigationTriangle; vertex.GetNavigationEdge(node.nextVertex); this.GetEdgeVerticesSafe(vertex, node.nextVertex, out vector, out vector2); PointTestResult result = this.TestPoint(vector); PointTestResult result2 = this.TestPoint(vector2); if (result == PointTestResult.INSIDE) { this.NarrowFunnel(vector, index, true); } if (result2 == PointTestResult.INSIDE) { this.NarrowFunnel(vector2, index, false); } if (result == PointTestResult.RIGHT) { this.m_apex = this.m_rightPoint; this.m_funnelConstructed = false; this.ConstructFunnel(this.m_rightIndex + 1); return(this.m_rightIndex + 1); } if (result2 == PointTestResult.LEFT) { this.m_apex = this.m_leftPoint; this.m_funnelConstructed = false; this.ConstructFunnel(this.m_leftIndex + 1); return(this.m_leftIndex + 1); } if ((result == PointTestResult.INSIDE) || (result2 == PointTestResult.INSIDE)) { MyNavigationMesh.FunnelState item = new MyNavigationMesh.FunnelState { Apex = this.m_apex, Left = this.m_leftPoint, Right = this.m_rightPoint }; MyNavigationMesh.m_debugFunnel.Add(item); } } return(index + 1); }
private void ConstructFunnel(int index) { if (index >= this.m_endIndex) { this.AddPoint(this.m_apex); } else { MyPath <MyNavigationPrimitive> .PathNode node = this.m_input[index]; MyNavigationTriangle vertex = node.Vertex as MyNavigationTriangle; vertex.GetNavigationEdge(node.nextVertex); this.GetEdgeVerticesSafe(vertex, node.nextVertex, out this.m_leftPoint, out this.m_rightPoint); if (Vector3.IsZero(this.m_leftPoint - this.m_apex)) { this.m_apex = vertex.Center; } else if (Vector3.IsZero(this.m_rightPoint - this.m_apex)) { this.m_apex = vertex.Center; } else { this.m_apexNormal = vertex.Normal; float num = this.m_leftPoint.Dot(this.m_apexNormal); this.m_apex -= this.m_apexNormal * (this.m_apex.Dot(this.m_apexNormal) - num); this.m_leftIndex = this.m_rightIndex = index; this.RecalculateLeftPlane(); this.RecalculateRightPlane(); this.m_funnelConstructed = true; this.AddPoint(this.m_apex); MyNavigationMesh.FunnelState item = new MyNavigationMesh.FunnelState { Apex = this.m_apex, Left = this.m_leftPoint, Right = this.m_rightPoint }; MyNavigationMesh.m_debugFunnel.Add(item); } } }