Ejemplo n.º 1
0
        public override void Apply(Path p)
        {
            //Good Game
            Vector3[] vectorPath = IntMath.Int3s2Vector3s(p.vectorPath).ToArray();
            //VInt3[] vectorPath = p.vectorPath.ToArray();

            if (vectorPath == null || vectorPath.Length <= 2)
            {
                return;
            }

            //Good Game
            List <Vector3> newPath = new List <Vector3>();

            //List<VInt3> newPath = new List<VInt3>();
            newPath.Add(vectorPath[0]);

            TurnConstructor.turningRadius = turningRadius;

            for (int i = 1; i < vectorPath.Length - 1; i++)
            {
                List <Turn> turnList = new List <Turn>();

                TurnConstructor.Setup(i, vectorPath);
                turnConstruct1.Prepare(i, vectorPath);
                turnConstruct2.Prepare(i, vectorPath);

                TurnConstructor.PostPrepare();

                if (i == 1)
                {
                    turnConstruct1.PointToTangent(turnList);
                    turnConstruct2.PointToTangent(turnList);
                }
                else
                {
                    turnConstruct1.TangentToTangent(turnList);
                    turnConstruct2.TangentToTangent(turnList);
                }

                EvaluatePaths(turnList, newPath);

                //Last point
                if (i == vectorPath.Length - 2)
                {
                    turnConstruct1.TangentToPoint(turnList);
                    turnConstruct2.TangentToPoint(turnList);
                }

                EvaluatePaths(turnList, newPath);
            }

            newPath.Add(vectorPath[vectorPath.Length - 1]);
            //Good Game
            //p.vectorPath = newPath;
            p.vectorPath = IntMath.Vector3s2Int3s(newPath);
        }
Ejemplo n.º 2
0
        public override void Apply(Path p)
        {
            // This should never trigger unless some other modifier has messed stuff up
            if (p.vectorPath == null)
            {
                Debug.LogWarning("Can't process NULL path (has another modifier logged an error?)");
                return;
            }

            //Good Game
            //List<Vector3> path = null;
            List <VInt3> path = null;

            switch (smoothType)
            {
            case SmoothType.Simple:
                path = SmoothSimple(p.vectorPath); break;

            case SmoothType.Bezier:
                path = SmoothBezier(p.vectorPath); break;

            case SmoothType.OffsetSimple:
                path = SmoothOffsetSimple(p.vectorPath); break;

            case SmoothType.CurvedNonuniform:
                //Good Game
                //path = CurvedNonuniform(p.vectorPath); break;
                path = IntMath.Vector3s2Int3s(CurvedNonuniform(IntMath.Int3s2Vector3s(p.vectorPath))); break;
            }

            if (path != p.vectorPath)
            {
                //Good Game
                //ListPool<Vector3>.Release(ref p.vectorPath);
                ListPool <VInt3> .Release(ref p.vectorPath);

                p.vectorPath = path;
            }
        }