コード例 #1
0
ファイル: ClientSegment.cs プロジェクト: daxola123/Qbes
        /// <summary>
        /// Does a check for either FrontZ or BackZ
        /// </summary>
        /// <param name="box">Box</param>
        /// <param name="side">Side</param>
        /// <param name="visMatrix">Visibility matrix</param>
        /// <param name="z">Z coordinate</param>
        /// <param name="x1">X1 coordinate</param>
        /// <param name="x2">X2 coordinate</param>
        /// <param name="y1">Y1 coordinate</param>
        /// <param name="y2">Y2 coordinate</param>
        /// <param name="hiddenFaces">Hidden sides reference</param>
        private static void CheckHiddenZ(ClientBox box, int side, BinaryMatrix3D visMatrix, int z, ref int x1, ref int x2, ref int y1, ref int y2, ref int hiddenFaces)
        {
            box.HiddenSides[side] = true;
            for (int x = x1; x <= x2; x++)
            {
                for (int y = y1; y <= y2; y++)
                {
                    if (!visMatrix.Get(ref x, ref y, ref z))
                    {
                        box.HiddenSides[side] = false;
                        break;
                    }
                }

                if (!box.HiddenSides[side])
                {
                    break;
                }
            }

            if (box.HiddenSides[side])
            {
                hiddenFaces++;
            }
        }
コード例 #2
0
ファイル: BinaryMatrix3DTest.cs プロジェクト: daxola123/Qbes
        public void UpdateMatrixTest()
        {
            BinaryMatrix3D target = new BinaryMatrix3D();

            bool[][][] expected = new bool[8][][];
            for (int x = 0; x < 8; x++)
            {
                expected[x] = new bool[8][];
                for (int y = 0; y < 8; y++)
                {
                    expected[x][y] = new bool[8];
                }
            }

            target.UpdateMatrix(expected);

            // check all zeros
            for (int x = 0; x < 8; x++)
            {
                for (int y = 0; y < 8; y++)
                {
                    for (int z = 0; z < 8; z++)
                    {
                        bool received = target.Get(x, y, z);
                        Assert.IsTrue(!received, "Excepted false but received " + received.ToString());
                    }
                }
            }

            // create with a random matrix
            Random r = new Random();

            for (int x = 0; x < 8; x++)
            {
                for (int y = 0; y < 8; y++)
                {
                    for (int z = 0; z < 8; z++)
                    {
                        expected[x][y][z] = (r.Next(2) == 1);
                    }
                }
            }

            target.UpdateMatrix(expected);
            // check against expected
            for (int x = 0; x < 8; x++)
            {
                for (int y = 0; y < 8; y++)
                {
                    for (int z = 0; z < 8; z++)
                    {
                        bool received = target.Get(x, y, z);
                        Assert.IsTrue(received == expected[x][y][z], "Excepted " + expected[x][y][z] + " but received " + received.ToString());
                    }
                }
            }
        }
コード例 #3
0
ファイル: BinaryMatrix3DTest.cs プロジェクト: daxola123/Qbes
        public void BinaryMatrix3DConstructorTest()
        {
            bool[][][] initialData = new bool[8][][];
            for (int x = 0; x < 8; x++)
            {
                initialData[x] = new bool[8][];
                for (int y = 0; y < 8; y++)
                {
                    initialData[x][y] = new bool[8];
                }
            }

            BinaryMatrix3D target = new BinaryMatrix3D(initialData);

            // check all zeros
            for (int x = 0; x < 8; x++)
            {
                for (int y = 0; y < 8; y++)
                {
                    for (int z = 0; z < 8; z++)
                    {
                        bool received = target.Get(x, y, z);
                        Assert.IsTrue(!received, "Excepted false but received " + received.ToString());
                    }
                }
            }

            // create with a random matrix
            Random r = new Random();

            for (int x = 0; x < 8; x++)
            {
                for (int y = 0; y < 8; y++)
                {
                    for (int z = 0; z < 8; z++)
                    {
                        initialData[x][y][z] = (r.Next(2) == 1);
                    }
                }
            }

            target = new BinaryMatrix3D(initialData);
            // check against expected
            for (int x = 0; x < 8; x++)
            {
                for (int y = 0; y < 8; y++)
                {
                    for (int z = 0; z < 8; z++)
                    {
                        bool received = target.Get(x, y, z);
                        Assert.IsTrue(received == initialData[x][y][z], "Excepted " + initialData[x][y][z] + " but received " + received.ToString());
                    }
                }
            }
        }
コード例 #4
0
ファイル: BinaryMatrix3DTest.cs プロジェクト: daxola123/Qbes
        public void GetSetTest()
        {
            BinaryMatrix3D target = new BinaryMatrix3D();

            bool[][][] expected = new bool[8][][];
            for (int x = 0; x < 8; x++)
            {
                expected[x] = new bool[8][];
                for (int y = 0; y < 8; y++)
                {
                    expected[x][y] = new bool[8];
                }
            }

            Random r = new Random();

            for (int pass = 1; pass < 4; pass++)
            {
                // store values
                for (int x = 0; x < 8; x++)
                {
                    for (int y = 0; y < 8; y++)
                    {
                        for (int z = 0; z < 8; z++)
                        {
                            expected[x][y][z] = (r.Next(2) == 1);
                            target.Set(x, y, z, expected[x][y][z]);
                        }
                    }
                }

                // check values
                for (int x = 0; x < 8; x++)
                {
                    for (int y = 0; y < 8; y++)
                    {
                        for (int z = 0; z < 8; z++)
                        {
                            bool received = target.Get(x, y, z);
                            Assert.IsTrue(received == expected[x][y][z], "Pass " + pass + " Excepted " + expected[x][y][z] + " but received " + received.ToString());
                        }
                    }
                }
            }
        }