コード例 #1
0
            private void GetEdgeVerticesSafe(MyNavigationTriangle triangle, int edgeIndex, out Vector3 left, out Vector3 right)
            {
                triangle.GetEdgeVertices(edgeIndex, out left, out right);

                float d = (left - right).LengthSquared();

                bool leftDangerous  = triangle.IsEdgeVertexDangerous(edgeIndex, predVertex: true);
                bool rightDangerous = triangle.IsEdgeVertexDangerous(edgeIndex, predVertex: false);

                m_segmentDangerous |= leftDangerous | rightDangerous;

                if (leftDangerous)
                {
                    if (rightDangerous)
                    {
                        if (SAFE_DISTANCE2_SQ > d)
                        {
                            left  = (left + right) * 0.5f;
                            right = left;
                        }
                        else
                        {
                            float   t       = SAFE_DISTANCE / (float)Math.Sqrt(d);
                            Vector3 newLeft = right * t + left * (1.0f - t);
                            right = left * t + right * (1.0f - t);
                            left  = newLeft;
                        }
                    }
                    else
                    {
                        if (SAFE_DISTANCE_SQ > d)
                        {
                            left = right;
                        }
                        else
                        {
                            float t = SAFE_DISTANCE / (float)Math.Sqrt(d);
                            left = right * t + left * (1.0f - t);
                        }
                    }
                }
                else
                {
                    if (rightDangerous)
                    {
                        if (SAFE_DISTANCE_SQ > d)
                        {
                            right = left;
                        }
                        else
                        {
                            float t = SAFE_DISTANCE / (float)Math.Sqrt(d);
                            right = left * t + right * (1.0f - t);
                        }
                    }
                }

                m_debugPointsLeft.Add(left);
                m_debugPointsRight.Add(right);
            }
コード例 #2
0
            private void GetEdgeVerticesSafe(MyNavigationTriangle triangle, int edgeIndex, out Vector3 left, out Vector3 right)
            {
                triangle.GetEdgeVertices(edgeIndex, out left, out right);
                float num   = (left - right).LengthSquared();
                bool  flag  = triangle.IsEdgeVertexDangerous(edgeIndex, true);
                bool  flag2 = triangle.IsEdgeVertexDangerous(edgeIndex, false);

                this.m_segmentDangerous |= flag | flag2;
                if (!flag)
                {
                    if (flag2)
                    {
                        if (SAFE_DISTANCE_SQ > num)
                        {
                            right = left;
                        }
                        else
                        {
                            float num4 = SAFE_DISTANCE / ((float)Math.Sqrt((double)num));
                            right = (left * num4) + (right * (1f - num4));
                        }
                    }
                }
                else if (!flag2)
                {
                    if (SAFE_DISTANCE_SQ > num)
                    {
                        left = right;
                    }
                    else
                    {
                        float num3 = SAFE_DISTANCE / ((float)Math.Sqrt((double)num));
                        left = (right * num3) + (left * (1f - num3));
                    }
                }
                else if (SAFE_DISTANCE2_SQ > num)
                {
                    left  = (left + right) * 0.5f;
                    right = left;
                }
                else
                {
                    float   num2    = SAFE_DISTANCE / ((float)Math.Sqrt((double)num));
                    Vector3 vector2 = (right * num2) + (left * (1f - num2));
                    right = (left * num2) + (right * (1f - num2));
                    left  = vector2;
                }
                MyNavigationMesh.m_debugPointsLeft.Add(left);
                MyNavigationMesh.m_debugPointsRight.Add(right);
            }