コード例 #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]);
                }
            }
        }
コード例 #2
0
 public void AddTransitionsList(TransitionsList trns)
 {
     for (int t = 0; t < trns.count; t++)
     {
         SetPosition(trns.arr[t].pos);
     }
 }
コード例 #3
0
ファイル: PosTab.cs プロジェクト: AJ213/Awitu
 public void Add(TransitionsList transitions)
 {
     for (int t = 0; t < transitions.count; t++)
     {
         Add(transitions.arr[t]);
     }
 }
コード例 #4
0
 public void Add(TransitionsList other)
 /// Combines two lists in current
 {
     for (int t = 0; t < other.count; t++)
     {
         Add(other.arr[t]);
     }
     //TODO: avoid resizing array several times
 }
コード例 #5
0
        public void AddTransitionsList(TransitionsList trns, float customHeight)
        {
            for (int t = 0; t < trns.count; t++)
            {
                if (trns.arr[t].pos.x <worldPos.x || trns.arr[t].pos.x> worldPos.x + worldSize.x ||
                    trns.arr[t].pos.z <worldPos.z || trns.arr[t].pos.z> worldPos.z + worldSize.z)
                {
                    continue;
                }

                SetPosition(new Vector3(trns.arr[t].pos.x, customHeight, trns.arr[t].pos.z));
            }
        }
コード例 #6
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);
        }
コード例 #7
0
 //public TransitionsList (int count) { arr=new Transition[count]; this.count=count; }
 //public TransitionsList (int count, int startId) { arr=new Transition[count]; this.count=count; idCounter=startId; }
 public TransitionsList(TransitionsList src)
 {
     arr = new Transition[src.arr.Length]; Array.Copy(src.arr, arr, src.arr.Length); count = src.count;
 }