コード例 #1
0
        // Methods to handle parking spots
        protected void InitParkingSpots()
        {
            int index = 0;

            for (int i = 0; i < parkingSpots.GetLength(0); i++)
            {
                for (int j = 0; j < parkingSpots.GetLength(1); j++)
                {
                    for (int k = 0; k < parkingSpots.GetLength(2); k++)
                    {
                        index++;
                        var tmp = context.Vehicles.FirstOrDefault(v => v.VehicleParkingSpot == index);
                        if (tmp != null)
                        {
                            for (int l = 0; l < tmp.VehicleSize; l++)
                            {
                                parkingSpots[i, j, k + l] = true;
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
ファイル: Tron3D.cs プロジェクト: Nachev/Telerik
        private static bool IsOnWall(bool[, ,] cuboid, int[] cube, out int newDimension)
        {
            for (int dimension = 0; dimension < 3; dimension++)
            {
                if (isMinOrMax(cube[dimension], cuboid.GetLength(dimension) - 1))
                {
                    newDimension = dimension;
                    return(true);
                }
            }

            newDimension = -1;
            return(false);
        }
コード例 #3
0
ファイル: MazGen.cs プロジェクト: JonRurka/BattleScapesEngine
 public double GetValue(double x, double y, double z)
 {
     if (Voxels != null)
     {
         try
         {
             if (IsInBounds((int)x, (int)y, (int)z))
             {
                 return(Voxels[(int)x, (int)z, (int)z] ? 1 : 0);
             }
             else
             {
                 return(0);
             }
         }
         catch (Exception e)
         {
             SafeDebug.LogError(string.Format("Message: {0}, \nfunction: GetValue, \nStacktrace: {1}, \nValues: x={2}/{3}, z={4}/{5}.",
                                              e.Message, e.StackTrace, x, Voxels.GetLength(0), z, Voxels.GetLength(1)), e);
         }
     }
     return(0);
 }
コード例 #4
0
            public void SetImagePath(string filepath)
            {
                if (ImagePath != filepath)
                {
                    try
                    {
                        Bitmap image = new Bitmap("Assets/Textures/Tilesets/" + filepath);
                        ImagePath = filepath;

                        bool[,,] oldPasabilites    = Pasabilities;
                        int[,] oldPriorities       = Priorities;
                        int[,] oldTerrainTags      = TerrainTags;
                        bool[,] oldBushFlags       = BushFlags;
                        bool[,] oldCounterFlags    = CounterFlags;
                        bool[,] oldReflectionFlags = ReflectionFlags;
                        bool[,] oldBridgeFlags     = BridgeFlags;

                        Pasabilities    = new bool[8, (image.Height / 32) + 1, 8];
                        Priorities      = new int[8, (image.Height / 32) + 1];
                        TerrainTags     = new int[8, (image.Height / 32) + 1];
                        BushFlags       = new bool[8, (image.Height / 32) + 1];
                        CounterFlags    = new bool[8, (image.Height / 32) + 1];
                        ReflectionFlags = new bool[8, (image.Height / 32) + 1];
                        BridgeFlags     = new bool[8, (image.Height / 32) + 1];

                        for (int x = 0; x < Pasabilities.GetLength(0); x++)
                        {
                            for (int y = 0; y < Pasabilities.GetLength(1); y++)
                            {
                                if (y < oldPasabilites.GetLength(1))
                                {
                                    for (int dir = 0; dir < 8; dir++)
                                    {
                                        Pasabilities[x, y, dir] = oldPasabilites[x, y, dir];
                                    }
                                    Priorities[x, y]      = oldPriorities[x, y];
                                    TerrainTags[x, y]     = oldTerrainTags[x, y];
                                    BushFlags[x, y]       = oldBushFlags[x, y];
                                    CounterFlags[x, y]    = oldCounterFlags[x, y];
                                    ReflectionFlags[x, y] = oldReflectionFlags[x, y];
                                    BridgeFlags[x, y]     = oldBridgeFlags[x, y];
                                }
                            }
                        }

                        image.Dispose();
                    }
                    catch { }
                }
            }
コード例 #5
0
    public static int Misplaced(bool[, ,] initial, bool[, ,] target)
    {
        int misplaced = 0;

        for (int i = 0; i < initial.GetLength(0); ++i)
        {
            for (int j = 0; j < initial.GetLength(1); ++j)
            {
                for (int k = 0; k < initial.GetLength(2); ++k)
                {
                    // If it's a block, check if there is no block in target
                    if (!initial [i, j, k])
                    {
                        if (target [i, j, k])
                        {
                            ++misplaced;
                        }
                    }
                }
            }
        }
        return(misplaced);
    }
コード例 #6
0
ファイル: Tron3D.cs プロジェクト: Nachev/Telerik
        private static bool IsOnEdge(bool[,,] cuboid, int[] cube)
        {
            int count = 0;

            for (int dimension = 0; dimension < 3; dimension++)
            {
                if (isMinOrMax(cube[dimension], cuboid.GetLength(dimension) - 1))
                {
                    count++;
                }
            }

            return(count > 1 ? true : false);
        }
コード例 #7
0
        public Simulation(int resx, int resy, int resz, float hbar, float[,,] px, float[,,] py, float[,,] pz)
        {
            _px = px;
            _py = py;
            _pz = pz;

            isJet = new bool[resx, resy, resz];

            kvec  = new float[] { JetVelocity[0] / hbar, JetVelocity[1] / hbar, JetVelocity[2] / hbar };
            omega = (JetVelocity[0] * JetVelocity[0] + JetVelocity[1] * JetVelocity[1] + JetVelocity[2] * JetVelocity[2]) / (2 * hbar);

            for (int i = 0; i < isJet.GetLength(0); i++)
            {
                for (int j = 0; j < isJet.GetLength(1); j++)
                {
                    for (int k = 0; k < isJet.GetLength(2); k++)
                    {
                        isJet[i, j, k] = (Math.Abs(px[i, j, k] - nozzle_cen[0]) <= nozzle_len / 2) &&
                                         ((Math.Pow(py[i, j, k] - nozzle_cen[1], 2) + (pz[i, j, k] - nozzle_cen[2]) * (pz[i, j, k] - nozzle_cen[2])) <= nozzle_rad * nozzle_rad);
                    }
                }
            }
        }
コード例 #8
0
    List <Matrix4x4> GeneratePositionMatricies(bool[,,] field)
    {
        List <Matrix4x4> outputList = new List <Matrix4x4>();

        for (int iX = 0; iX < field.GetLength(0); iX++)
        {
            for (int iY = 0; iY < field.GetLength(1); iY++)
            {
                for (int iZ = 0; iZ < field.GetLength(2); iZ++)
                {
                    if (fieldWeight[iX, iY, iZ])
                    {
                        float posX = objectSize.x * iX + objectSize.x / 2;
                        float posY = objectSize.y * iY + objectSize.y / 2;
                        float posZ = objectSize.z * iZ + objectSize.z / 2;

                        Vector3 localPosition = new Vector3(posX, posY, posZ);

                        Vector3 rotatedLocalPosition = gameObject.transform.rotation * localPosition;

                        Vector3 position = gameObject.transform.position + rotatedLocalPosition;

                        Quaternion rotation = gameObject.transform.rotation;

                        Vector3 scale = gameObject.transform.localScale;


                        Matrix4x4 objectTRS = Matrix4x4.TRS(position, rotation, scale);

                        outputList.Add(objectTRS);
                    }
                }
            }
        }

        return(outputList);
    }
コード例 #9
0
ファイル: sc2D3D.cs プロジェクト: gbtapps/NT
    private GameObject[] makeObject(bool[,,] f, GameObject parentObj, GameObject blockPrefab, int targetArea)
    {
        Vector3 sc = parentObj.transform.localScale;
        int     sx = f.GetLength(0), sy = f.GetLength(1), sz = f.GetLength(2);
        Vector3 scDiv = sc;

        scDiv.x /= (float)sx * 2f;
        scDiv.y /= (float)sy * 2f;
        scDiv.z /= (float)sz * 2f;

        Vector3 p0  = parentObj.transform.position;
        Vector3 pSc = parentObj.transform.localScale;

        GameObject[] Obj     = new GameObject[sx * sy * sz];
        int          counter = 0;

        for (int i = 0; i < sx; i++)
        {
            for (int j = 0; j < sy; j++)
            {
                for (int k = 0; k < sz; k++)
                {
                    if (f[i, j, k])
                    {
                        objBlocks[targetArea, counter].SetActive(true);
                    }
                    else
                    {
                        objBlocks[targetArea, counter].SetActive(false);
                    }
                    counter++;
                }
            }
        }

        return(Obj);
    }
コード例 #10
0
            public LocalDataset(double[] freq, double[,,] uvw, bool[,,] flags, Complex[,,] vis)
            {
                Frequencies  = freq;
                UVW          = uvw;
                Flags        = flags;
                Visibilities = vis;

                var visCountLocal = 0;

                for (int i = 0; i < flags.GetLength(0); i++)
                {
                    for (int j = 0; j < flags.GetLength(1); j++)
                    {
                        for (int k = 0; k < flags.GetLength(2); k++)
                        {
                            if (!flags[i, j, k])
                            {
                                visCountLocal++;
                            }
                        }
                    }
                }
                VisibilitiesCount = visCountLocal;
            }
コード例 #11
0
    public bool IsValidVoxel(bool[,,] bools, int x, int y, int z, bool keepInside = true)
    {
        if (keepInside && bools[x, y, z])
        {
            return(true);
        }

        // If the current voxel is false, return false
        if (!bools[x, y, z])
        {
            return(false);
        }

        // If it's on the "border", return true
        if (x == 0 || y == 0 || z == 0 || x == (bools.GetLength(0) - 1) || y == (bools.GetLength(1) - 1) || z == (bools.GetLength(2) - 1))
        {
            return(true);
        }

        // If any of the surroundings is false, it is a border voxel, return true
        for (int dx = x - 1; dx < (x + 2); ++dx)
        {
            for (int dy = y - 1; dy < (y + 2); ++dy)
            {
                for (int dz = z - 1; dz < (z + 2); ++dz)
                {
                    if (!bools[dx, dy, dz])
                    {
                        return(true);
                    }
                }
            }
        }

        return(false);
    }
コード例 #12
0
        /// <summary>
        /// Creates an instance of this class from 3D boolean table.
        /// </summary>
        /// <param name="accessible">Boolean table: true - clear; false - obstacle.</param>
        public GraphMap(bool[,,] accessible)
        {
            for (int x = 0; x < accessible.GetLength(0); x++)
            {
                for (int y = 0; y < accessible.GetLength(1); y++)
                {
                    for (int z = 0; z < accessible.GetLength(2); z++)
                    {
                        if (!accessible[x, y, z])
                        {
                            continue;
                        }
                        var node = new Node(new Vector3(x, y, z));

                        for (int sx = -1; sx <= 1; sx++)
                        {
                            for (int sy = -1; sy <= 1; sy++)
                            {
                                for (int sz = -1; sz <= 1; sz++)
                                {
                                    Node neighbour;
                                    var  offset = new Vector3(x + sx, y + sy, z + sz);
                                    if (!_nodes.TryGetValue(offset, out neighbour))
                                    {
                                        continue;
                                    }
                                    neighbour.LinkAdjacent(node.Position - neighbour.Position, node);
                                    node.LinkAdjacent(neighbour.Position - node.Position, neighbour);
                                }
                            }
                        }
                        _nodes.Add(node.Position, node);
                    }
                }
            }
        }
コード例 #13
0
        private static ShapeType?Lookup(bool[,] match)
        {
            for (int i = 0; i < shapes.GetLength(0); i++)
            {
                var isMatch = true;
                for (int y = 0; isMatch && y < shapes.GetLength(1); y++)
                {
                    for (int x = 0; isMatch && x < shapes.GetLength(2); x++)
                    {
                        if (shapes[i, y, x] != match[x, y])
                        {
                            isMatch = false;
                        }
                    }
                }

                if (isMatch)
                {
                    return(GetMatchType(i));
                }
            }

            return(null);
        }
コード例 #14
0
ファイル: Day17.cs プロジェクト: rvugt85/Advent-of-code
        private bool[,,] StateChanges3D(bool[,,] configuration)
        {
            var xLength = configuration.GetLength(0);
            var yLength = configuration.GetLength(1);
            var zLength = configuration.GetLength(2);

            var changes = new bool[xLength, yLength, zLength];

            for (int x = 0; x < xLength; x++)
            {
                for (int y = 0; y < yLength; y++)
                {
                    for (int z = 0; z < zLength; z++)
                    {
                        var activeNeighbors = GetActiveNeighbors3D(x, y, z, configuration);

                        if (configuration[x, y, z] == true)
                        {
                            if (activeNeighbors != 3 && activeNeighbors != 4)
                            {
                                changes[x, y, z] = true;
                            }
                        }
                        if (configuration[x, y, z] == false)
                        {
                            if (activeNeighbors == 3)
                            {
                                changes[x, y, z] = true;
                            }
                        }
                    }
                }
            }

            return(changes);
        }
コード例 #15
0
ファイル: TextureResource.cs プロジェクト: wachel/block
    static Color[] ToColorsA(bool[, ,] values, int bits)
    {
        int dx = values.GetLength(0);
        int dy = values.GetLength(1);
        int dz = values.GetLength(2) / bits;

        Color[] colors = new Color[dx * dy * dz];
        for (int x = 0; x < dx; x++)
        {
            for (int y = 0; y < dy; y++)
            {
                for (int z = 0; z < dz; z++)
                {
                    int iv = 0;
                    for (int n = 0; n < bits; n++)
                    {
                        iv |= values[x, y, z *bits + n] ? (1 << n) : 0;
                    }
                    colors[z * dx * dy + y * dx + x] = new Color(0, 0, 0, iv / (float)((1 << bits) - 1));
                }
            }
        }
        return(colors);
    }
コード例 #16
0
ファイル: Day17.cs プロジェクト: rvugt85/Advent-of-code
        private int CountActiveCubes3D(bool [,,] configuration)
        {
            var xLength = configuration.GetLength(0);
            var yLength = configuration.GetLength(1);
            var zLength = configuration.GetLength(2);

            var activeCubes = 0;

            for (int x = 0; x < xLength; x++)
            {
                for (int y = 0; y < yLength; y++)
                {
                    for (int z = 0; z < zLength; z++)
                    {
                        if (configuration[x, y, z] == true)
                        {
                            activeCubes++;
                        }
                    }
                }
            }

            return(activeCubes);
        }
コード例 #17
0
ファイル: Day17.cs プロジェクト: rvugt85/Advent-of-code
        private bool[,,] IncreaseConfiguration3D(bool[,,] configuration)
        {
            var xLength = configuration.GetLength(0);
            var yLength = configuration.GetLength(1);
            var zLength = configuration.GetLength(2);

            var increasedConfiguration = new bool[xLength + 2, yLength + 2, zLength + 2];

            for (int x = 0; x < xLength; x++)
            {
                for (int y = 0; y < yLength; y++)
                {
                    for (int z = 0; z < zLength; z++)
                    {
                        if (configuration[x, y, z] == true)
                        {
                            increasedConfiguration[x + 1, y + 1, z + 1] = true;
                        }
                    }
                }
            }

            return(increasedConfiguration);
        }
コード例 #18
0
    protected override void ThreadFunction()
    {
        int chunkSize   = ChunkManager.CHUNK_SIZE;
        int chunkHeight = ChunkManager.CHUNK_HEIGHT;

        Vector3 offset = chunkLocationToGenerate * chunkSize;

        chunkVoxelArray = new bool[chunkSize + 1, chunkHeight, chunkSize + 1];
        for (int i = 0; i < chunkVoxelArray.GetLength(0); i++)
        {
            for (int j = 0; j < chunkVoxelArray.GetLength(2); j++)
            {
                int height = PerlinCalculator.GetHeightAtCoords(i + (int)offset.x, j + (int)offset.z, 2);

                for (int k = 0; k < chunkVoxelArray.GetLength(1); k++)
                {
                    if (k <= height)
                    {
                        chunkVoxelArray[i, k, j] = true;
                    }
                }
            }
        }
    }
コード例 #19
0
ファイル: table.cs プロジェクト: servelll/skyscrapers_v4
 public void clear()
 {
     //очистка ВСЕХ ячеек и кандидатов на всякий от мусора
     for (int i = 0; i < matrix.GetLength(0); i++)
     {
         for (int j = 0; j < matrix.GetLength(1); j++)
         {
             matrix[i, j] = 0;
             for (int k = 0; k < candidates.GetLength(2); k++)
             {
                 candidates[i, j, k] = true;
             }
         }
     }
 }
コード例 #20
0
ファイル: TetrisField.cs プロジェクト: ly774508966/VRTetris
 public void setBit(int x, int y, int z, bool val)
 {
     if (x >= field.GetLength(2) ||
         y >= field.GetLength(0) ||
         z >= field.GetLength(1) ||
         false
         )
     {
         return;
     }
     field[y, z, x] = val;
     tetrisGrid.setBit(x, y, z, val);
 }
コード例 #21
0
    private void FillEvironmentMap()
    {
        Vector3 halfExtents = Vector3.one * (CellSize / 2);

        for (int x = 0; x < environmentMap.GetLength(0); x++)
        {
            for (int y = 0; y < environmentMap.GetLength(1); y++)
            {
                for (int z = 0; z < environmentMap.GetLength(2); z++)
                {
                    if (Physics.OverlapBox(ConvertCellToPosition(new Point3D(x, y, z)), halfExtents).Length == 0)
                    {
                        environmentMap[x, y, z] = true;
                    }
                }
            }
        }
    }
コード例 #22
0
 public static bool[, ,] CopyMap(bool[, ,] given)
 {
     bool[, ,] ret = new bool[given.GetLength(0), given.GetLength(1), given.GetLength(2)];
     for (int i = 0; i < given.GetLength(0); ++i)
     {
         for (int j = 0; j < given.GetLength(1); ++j)
         {
             for (int k = 0; k < given.GetLength(2); ++k)
             {
                 ret [i, j, k] = given [i, j, k];
             }
         }
     }
     return(ret);
 }
コード例 #23
0
    /// <summary>
    /// Takes a Point3 in data coordinates.
    /// </summary>
    public Pathfinding(MazeStructure maze, bool[, ,] walls, Point3 center)
    {
        // initialize member variables
        this.center = center;
        this.maze   = maze;
        //Debug.Log(center);
        data = new int[walls.GetLength(0), walls.GetLength(1), walls.GetLength(2)];
        data.Initialize();

        // create visited matrix
        bool[, ,] visited = new bool[walls.GetLength(0), walls.GetLength(1), walls.GetLength(2)];
        visited.Initialize();

        // initialize vars
        Queue <VisitPoint> toVisit = new Queue <VisitPoint>(walls.GetLength(0) * walls.GetLength(1));

        toVisit.Enqueue(new VisitPoint(center, 0));

        // visit every possible cell
        while (toVisit.Count > 0)
        {
            // visit the given cell
            int    value = toVisit.Peek().value;
            Point3 pos   = toVisit.Dequeue().pos;
            data[pos.x, pos.y, pos.z]    = value;
            visited[pos.x, pos.y, pos.z] = true;

            // add appropriate neighbors to toVisit
            Point3[] neighbors = Point3.Scramble(pos.neighbors(2));
            foreach (Point3 newPos in neighbors)
            {
                if (maze.ValidMove(pos, newPos) && (!visited[newPos.x, newPos.y, newPos.z]))
                {
                    toVisit.Enqueue(new VisitPoint(newPos, value + 1));
                }
            }
        }
    }
コード例 #24
0
        /// <summary>
        /// Change bool[,,] to string[,,]
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public static string[,,] NumberToString(bool[,,] input)
        {
            string[,,] result = new string[input.GetLength(0), input.GetLength(1), input.GetLength(2)];

            for (int i = 0; i < input.GetLength(0); i++)
            {
                for (int j = 0; j < input.GetLength(1); j++)
                {
                    for (int k = 0; k < input.GetLength(2); k++)
                    {
                        result[i, j, k] = input[i, j, k].ToString();
                    }
                }
            }
            return(result);
        }
コード例 #25
0
ファイル: Class1.cs プロジェクト: curtca/AoC2020
    private int ActiveNeighbors(bool[,,] space, int x, int y, int z)
    {
        int size            = space.GetLength(0);
        int activeneighbors = 0;

        for (int dx = -1; dx <= 1; dx++)
        {
            for (int dy = -1; dy <= 1; dy++)
            {
                for (int dz = -1; dz <= 1; dz++)
                {
                    int x2 = x + dx, y2 = y + dy, z2 = z + dz;
                    if (x2 >= 0 && x2 < size && y2 >= 0 && y2 < size && z2 >= 0 && z2 < size &&
                        !(x2 == x && y2 == y && z2 == z) && space[x2, y2, z2])
                    {
                        activeneighbors++;
                    }
                }
            }
        }

        return(activeneighbors);
    }
コード例 #26
0
        public void RebuildGrid(float cellSize, int gridSize, float duration,
                                float timeStep, Vector2 globalPosition, float visualHeightScale)
        {
            var allMatch = (
                cellSize == CellSize &&
                gridSize == GridSize &&
                duration == Duration &&
                timeStep == TimeStep &&
                globalPosition == GlobalPosition &&
                visualHeightScale == VisualHeightScale
                );

            if (allMatch)
            {
                RecreateGrid();
                return;
            }

            CellSize          = cellSize;
            GridSize          = gridSize;
            Duration          = duration;
            TimeStep          = timeStep;
            GlobalPosition    = globalPosition;
            TimeStepCount     = Mathf.RoundToInt(Duration / TimeStep);
            Height            = TimeStep * TimeStepCount;
            Width             = GridSideLength * CellSize;
            GlobalY           = Height / 2 - TimeStep / 2;
            CellSize3D        = new Vector3(CellSize, TimeStep, CellSize);
            VisualHeightScale = visualHeightScale;
            RecreateGrid();

            _globalCoords = new Vector3[GridSideLength, TimeStepCount, GridSideLength];
            for (var x = 0; x < _grid.GetLength(0); x++)
            {
                for (var t = 0; t < _grid.GetLength(1); t++)
                {
                    for (var y = 0; y < _grid.GetLength(2); y++)
                    {
                        _globalCoords[x, t, y] = GridCoordsToGlobal(
                            x, t, y
                            );
                    }
                }
            }
        }
コード例 #27
0
    void Start()
    {
        wallEntityLayerMask = 1 << LayersManager.layersManager.wallEntityLayer;
        wallLayerMask       = 1 << LayersManager.layersManager.wallLayer;
        raycastLayerMask    = wallEntityLayerMask | wallLayerMask;

        minPositionX = Mathf.RoundToInt(boundaryWW.transform.position.x);          // ASSUMPTION: will never round out of bounds
        maxPositionX = Mathf.RoundToInt(boundaryEE.transform.position.x);
        minPositionY = Mathf.RoundToInt(boundarySS.transform.position.y);
        maxPositionY = Mathf.RoundToInt(boundaryNN.transform.position.y);
        maxIndexX    = maxPositionX - minPositionX;
        maxIndexY    = maxPositionY - minPositionY;

        InitializeEnvironmentGraph();
        XN = environmentGraph.GetLength(0);
        YM = environmentGraph.GetLength(1);
        circleSmallArray = new GameObject[maxIndexX + 1, maxIndexY + 1];
    }
コード例 #28
0
    public static bool MazeMapEquals(bool[, ,] a, bool[, ,] b)
    {
        if (a.GetLength(0) != b.GetLength(0) || a.GetLength(1) != b.GetLength(1) || a.GetLength(2) != b.GetLength(2))
        {
            return(false);
        }

        for (int i = 0; i < a.GetLength(0); ++i)
        {
            for (int j = 0; j < a.GetLength(1); ++j)
            {
                for (int k = 0; k < a.GetLength(2); ++k)
                {
                    if (a [i, j, k] != b [i, j, k])
                    {
                        return(false);
                    }
                }
            }
        }
        return(true);
    }
コード例 #29
0
ファイル: BooleanTests.cs プロジェクト: xornand/RemoteBridge
        public static bool RunTests(int pid, NktRemoteBridge remoteBridge)
        {
            //bool<->bool test
            Console.Write("  Boolean single value test... ");
            try
            {
                bool   bBaseBool = true;
                object res;

                res = remoteBridge.InvokeJavaStaticMethod(pid, "JavaBooleanTest", "Test", bBaseBool);
                if (res.GetType() != typeof(bool))
                {
                    Console.WriteLine("Error: Invalid returned type");
                    return(false);
                }
                if ((bool)res != (!bBaseBool))
                {
                    Console.WriteLine("Error: Returned data mismatch");
                    return(false);
                }
            }
            catch (System.Exception ex)
            {
                Console.WriteLine("failed.");
                Console.WriteLine(ex.ToString());
                return(false);
            }
            Console.WriteLine("  OK");

            //bool<->bool array test
            Console.Write("  Boolean array test... ");
            try
            {
                bool[, ,] arrayBool = new bool[4, 6, 5];
                object res;
                int    i, j, k;

                for (i = 0; i < 4; i++)
                {
                    for (j = 0; j < 6; j++)
                    {
                        for (k = 0; k < 5; k++)
                        {
                            arrayBool[i, j, k] = (((i + j + k) & 1) != 0) ? true : false;
                        }
                    }
                }
                res = remoteBridge.InvokeJavaStaticMethod(pid, "JavaBooleanTest", "Test3D", new object[] { arrayBool });
                if (res.GetType() != typeof(bool[, , ]))
                {
                    Console.WriteLine("Error: Invalid returned type");
                    return(false);
                }
                bool[, ,] arrayBoolRes = (bool[, , ])res;
                if (arrayBoolRes.GetLength(0) != 4 || arrayBoolRes.GetLength(1) != 6 || arrayBoolRes.GetLength(2) != 5)
                {
                    Console.WriteLine("Error: Returned array size mismatch");
                    return(false);
                }
                for (i = 0; i < 4; i++)
                {
                    for (j = 0; j < 6; j++)
                    {
                        for (k = 0; k < 5; k++)
                        {
                            if (arrayBoolRes[i, j, k] != (!arrayBool[i, j, k]))
                            {
                                Console.WriteLine("Error: Returned data mismatch (" + i.ToString() + "," + j.ToString() + "," + k.ToString() + ")");
                                return(false);
                            }
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                Console.WriteLine("failed.");
                Console.WriteLine(ex.ToString());
                return(false);
            }
            Console.WriteLine("  OK");
            return(true);
        }
コード例 #30
0
ファイル: SplatManager.cs プロジェクト: silky/armok-vision
    void UpdateSplatTextures()
    {
        if (ContentLoader.Instance == null)
        {
            return;
        }
        UnityEngine.Profiling.Profiler.BeginSample("UpdateTerrainTextures", this);
        var timer = System.Diagnostics.Stopwatch.StartNew();

        for (int z = terrainDirtyBits.GetLength(2) - 1; z >= 0; z--)
        {
            bool setTerrain = false;
            bool setGrass   = false;
            bool setSplat   = false;
            for (int y = 0; y < terrainDirtyBits.GetLength(1); y++)
            {
                for (int x = 0; x < terrainDirtyBits.GetLength(0); x++)
                {
                    if (terrainDirtyBits[x, y, z])
                    {
                        GenerateTerrainTexture(x, y, z);
                        setTerrain = true;
                        terrainDirtyBits[x, y, z] = false;
                        if (timer.ElapsedMilliseconds > timeout)
                        {
                            break;
                        }
                    }
                    if (grassDirtyBits[x, y, z])
                    {
                        setGrass |= GenerateGrassTexture(x, y, z);
                        grassDirtyBits[x, y, z] = false;
                        if (timer.ElapsedMilliseconds > timeout)
                        {
                            break;
                        }
                    }
                    if (spatterDirtyBits[x, y, z])
                    {
                        GenerateSpatterTexture(x, y, z);
                        setSplat = true;
                        spatterDirtyBits[x, y, z] = false;
                        if (timer.ElapsedMilliseconds > timeout)
                        {
                            break;
                        }
                    }
                    if (timer.ElapsedMilliseconds > timeout)
                    {
                        break;
                    }
                }
            }
            if (setTerrain || setGrass || setSplat)
            {
                UnityEngine.Profiling.Profiler.BeginSample("Apply terrain textures.", this);
                if (setTerrain)
                {
                    UpdateTerrainSplatTexture(z);
                    UpdateTerrainTintTexture(z);
                }
                if (setGrass)
                {
                    UpdateGrassTexture(z);
                }
                if (setSplat)
                {
                    UpdateSplatterTexture(z);
                }
                UnityEngine.Profiling.Profiler.EndSample();
            }
        }
        UnityEngine.Profiling.Profiler.EndSample();
    }