/** * Sets the seencells bit for all cells of a segment * * @param seg */ private void udpateSeenCellsForSegment(Seg seg) { seg.seen = true; // updates the segment int sdx = seg.dx / map_unit; // constant, only set once here int sdy = seg.dy / map_unit; // constant, only set once here // get initial position right on loop variables sx, sy int sx = seg.x / map_unit; if (sdx < 0) sx--; int sy = seg.y / map_unit; if (sdy < 0) sy--; // define constants to avoid method calls in following loop int sdsx = MazeBuilder.getSign(sdx); int sdsy = MazeBuilder.getSign(sdy); int bit = (sdx != 0) ? Cells.CW_TOP : Cells.CW_LEFT; int len = Math.abs(sdx + sdy); // true loop variables are (sx,sy), for (int i = 0; i != len; i++) { // seencells[sx][sy] |= bit; seencells.setBitToOne(sx, sy, bit); // updates the cell sx += sdsx; sy += sdsy; } }