Ejemplo n.º 1
0
        /// <summary>
        /// 頂点の追加
        /// </summary>
        public void Add(Vector2 point)
        {
            mainLine.Add(point);
            //エフェクトの生成
            int count = mainLine.GetVertexCount();

            if (count > 1)
            {
                EmitEffect(effectParticle, mainLine.GetVertex(count - 2), point, density);
            }
            draw = true;
        }
Ejemplo n.º 2
0
    /// <summary>
    /// 頂点追加前の例外検出。例外を検出した場合はtrueを返す
    /// </summary>
    private bool ExceptionDetector(Vector2 point)
    {
        int count = polyLine.GetVertexCount();

        //同一点の検出
        if (doublePointRemoval)
        {
            if (count > 1)
            {
                Vector2 prevPoint = polyLine.GetVertex(count - 1);
                float   dis       = (point - prevPoint).magnitude;
                if (dis < doublePointThreshold)
                {
                    if (doublePointCallback != null)
                    {
                        doublePointCallback();
                    }
                    return(true);
                }
            }
        }

        //線分の交差判定
        if (crossLineRemoval)
        {
            if (count > 2)
            {
                //検出線分の作成
                LineSegment line = new LineSegment(polyLine.GetVertex(count - 1), point);
                for (int i = 0; i < count - 2; ++i)
                {
                    //比較線分の作成
                    LineSegment sample = new LineSegment(polyLine.GetVertex(i), polyLine.GetVertex(i + 1));
                    if (line.Intersects(sample))
                    {
                        if (crossLineCallback != null)
                        {
                            crossLineCallback();
                        }
                        return(true);
                    }
                }
            }
        }

        return(false);
    }