Beispiel #1
0
        protected override int AbsoluteDataIndex(params int[] list)
        {
            Assert.IsTrue(list.Length == 2);
            Assert.IsTrue(0 <= list[0] && list[0] < this.DataSize.x);
            Assert.IsTrue(0 <= list[1] && list[1] < this.DataSize.y);
            Vector2Int index = FluidHelper.ClampIndex(new Vector2Int(list[0], list[1]), Vector2Int.zero, this.DataSize);

            return(index.x + (this.DataSize.x * index.y));
        }
Beispiel #2
0
        public override Vector2 GetDataFromIndex(params int[] list)
        {
            Assert.IsTrue(list.Length == 4);

            var ret = new Vector2();

            Assert.IsTrue(0 <= list[0] && list[0] < this.uDataSize.x);
            Assert.IsTrue(0 <= list[1] && list[1] < this.uDataSize.y);
            Vector2Int index = FluidHelper.ClampIndex(new Vector2Int(list[0], list[1]), Vector2Int.zero, this.uDataSize);

            ret.x = this.data[DataType.U][this.AbsoluteIndex(DataType.U, index)];

            Assert.IsTrue(0 <= list[2] && list[2] < this.vDataSize.x);
            Assert.IsTrue(0 <= list[3] && list[3] < this.vDataSize.y);
            index = FluidHelper.ClampIndex(new Vector2Int(list[2], list[3]), Vector2Int.zero, this.vDataSize);
            ret.y = this.data[DataType.V][this.AbsoluteIndex(DataType.V, index)];

            return(ret);
        }