Ejemplo n.º 1
0
        //  Recursively build a tree by separating points at plane boundaries.
        static KDTree MakeFromPointsInner(
            int depth,
            int stIndex, int enIndex,
            Vector3[] points,
            int[] inds
        )
        {

            KDTree root = new KDTree();
            root.axis = depth % numDims;
            int splitPoint = FindPivotIndex(points, inds, stIndex, enIndex, root.axis);

            root.pivotIndex = inds[splitPoint];
            root.pivot = points[root.pivotIndex];

            int leftEndIndex = splitPoint - 1;

            if (leftEndIndex >= stIndex)
            {
                root.lr[0] = MakeFromPointsInner(depth + 1, stIndex, leftEndIndex, points, inds);
            }

            int rightStartIndex = splitPoint + 1;

            if (rightStartIndex <= enIndex)
            {
                root.lr[1] = MakeFromPointsInner(depth + 1, rightStartIndex, enIndex, points, inds);
            }

            return root;
        }
        override protected void Awake()
        {
            base.Awake();

            _kdTree = KDTree.MakeFromPoints(RailNodes.ToArray());

            for (int i = 0; i < CameraTargets.Count; i++)
            {
                var railTransform = new GameObject(CameraTargets[i].TargetTransform.name + "_OnRails").transform;
                _cameraTargetsOnRails.Add(
                    CameraTargets[i],
                    railTransform
                    );

                var cameraTarget = ProCamera2D.AddCameraTarget(railTransform);
                cameraTarget.TargetOffset = CameraTargets[i].TargetOffset;
            }

            if (CameraTargets.Count == 0)
                enabled = false;

            ProCamera2D.Instance.AddPreMover(this);

            Step();
        }