Example #1
0
        public static void Mask(TransitionsList src, TransitionsList dst, MatrixWorld mask, Noise random, bool invert)
        /// Adds masked (or unmasked if invert) objects to dst
        {
            for (int t = 0; t < src.count; t++)
            {
                Vector3 pos = src.arr[t].pos;

                if (pos.x <= mask.worldPos.x && pos.x >= mask.worldPos.x + mask.worldSize.x &&
                    pos.z <= mask.worldPos.z && pos.z >= mask.worldPos.x + mask.worldSize.z)
                {
                    continue;                                     //do remove out of range objects?
                }
                float val = mask.GetWorldValue(pos.x, pos.z);
                float rnd = random.Random(src.arr[t].hash);

                if (val < rnd && invert)
                {
                    dst.Add(src.arr[t]);
                }
                if (val >= rnd && !invert)
                {
                    dst.Add(src.arr[t]);
                }
            }
        }
Example #2
0
        public TransitionsList ToTransitionsList()
        {
            TransitionsList list = new TransitionsList();             //capacity rect.size.x * rect.size.z

            Coord min = rect.Min; Coord max = rect.Max;

            for (int x = min.x; x < max.x; x++)
            {
                for (int z = min.z; z < max.z; z++)
                {
                    Vector3 pos = this[x, z];
                    //if (pos.y < minHeight) continue;
                    Transition trs = new Transition(pos.x, pos.z);
                    trs.hash = x * 2000 + z;                   //to make hash independent from grid size
                    list.Add(trs);
                }
            }

            return(list);
        }