Java 类com.badlogic.gdx.utils.IntArray 实例源码

项目:Cubes_2    文件:CaveGenerator.java   
public Cave generate() {
    int spawnDist = (int) distanceFromSpawn(caveStartX, caveStartZ);
    Log.debug("Generating new cave at " + caveStartX + "," + caveStartZ + " (" + spawnDist + " blocks from spawn)");
    generateNodes();
    calculateBlocks();

    Cave cave = new Cave(caveStartX, caveStartY, caveStartZ, new HashMap<AreaReference, int[]>() {
        {
            for (Map.Entry<AreaReference, IntArray> entry : blocks.entrySet()) {
                this.put(entry.getKey(), entry.getValue().toArray());
            }
        }
    });

    return cave;
}
项目:arcadelegends-gg    文件:Character.java   
/**
 * Sandbox method for returning the entities in an area
 *
 * @param mid   center of the area to search
 * @param start left upper corner relative to the center
 * @param end   right lower corner relative to the center
 * @return entities in area
 */
protected IntArray getEntitiesInArea(Vector2 mid, Vector2 start, Vector2 end) {
    IntArray array = new IntArray();
    for (float x = mid.x + Math.min(start.x, end.x); x <= mid.x + Math.max(start.x, end.x); x++) {
        for (float y = mid.y + Math.min(start.y, end.y); y <= mid.y + Math.max(start.y, end.y); y++) {
            try {
                Tile t = arcadeWorld.getTile((int) x, (int) y);
                if (t.getEntities().size != 0)
                    array.add(t.getEntities().first());
            } catch (IndexOutOfBoundsException ex) {
                continue;
            }
        }
    }
    return array;
}
项目:KyperBox    文件:QuadTree.java   
/**
 * create a quadtree collision manager with a default max_depth of 4 and a
 * max_object count of 10.
 * 
 * @param x
 * @param y
 * @param width
 * @param height
 */
public QuadTree(float x, float y, float width, float height) {
    check_object = new BasicGameObject();
    check_object.init(null);
    remove_objects = new IntArray();
    culling = true;
    follow_x  =0;
    follow_y  =0;
    bounds = new Rectangle(x - PAD, y - PAD, width + PAD * 2, height + PAD * 2);
    objects =  new Array<GameObject>();
    follow_view = false;
    final QuadTree m = this;
    quad_pool = new Pool<QuadTree.Quad>() {
        @Override
        protected Quad newObject() {
            return new Quad(m);
        }
    };
    max_depth = 4;
    max_objects = 10;
    root = quad_pool.obtain();
    root.init(null, 0, bounds.x, bounds.y, bounds.width, bounds.height);
    ret_list = new Array<GameObject>();
}
项目:fluffybalance    文件:HighScoreController.java   
public static IntArray fetchHighScores() {
    Preferences prefs = Gdx.app.getPreferences(PREFERENCES_NAME);

    IntArray scores = new IntArray();

    for (int i = 0; i < MAX_NR_SCORES; i++) {
        int score = prefs.getInteger(PREFERENCES_SCORE_NAME + i, -1);

        if (score == -1) {
            break;
        }

        scores.add(score);
    }

    return scores;
}
项目:jenjin    文件:SkeletonBinary.java   
private Vertices readVertices (DataInput input, int vertexCount) throws IOException {
    int verticesLength = vertexCount << 1;
    Vertices vertices = new Vertices();
    if (!input.readBoolean()) {
        vertices.vertices = readFloatArray(input, verticesLength, scale);
        return vertices;
    }
    FloatArray weights = new FloatArray(verticesLength * 3 * 3);
    IntArray bonesArray = new IntArray(verticesLength * 3);
    for (int i = 0; i < vertexCount; i++) {
        int boneCount = input.readInt(true);
        bonesArray.add(boneCount);
        for (int ii = 0; ii < boneCount; ii++) {
            bonesArray.add(input.readInt(true));
            weights.add(input.readFloat() * scale);
            weights.add(input.readFloat() * scale);
            weights.add(input.readFloat());
        }
    }
    vertices.vertices = weights.toArray();
    vertices.bones = bonesArray.toArray();
    return vertices;
}
项目:jenjin    文件:SkeletonJson.java   
private void readVertices (JsonValue map, VertexAttachment attachment, int verticesLength) {
    attachment.setWorldVerticesLength(verticesLength);
    float[] vertices = map.require("vertices").asFloatArray();
    if (verticesLength == vertices.length) {
        if (scale != 1) {
            for (int i = 0, n = vertices.length; i < n; i++)
                vertices[i] *= scale;
        }
        attachment.setVertices(vertices);
        return;
    }
    FloatArray weights = new FloatArray(verticesLength * 3 * 3);
    IntArray bones = new IntArray(verticesLength * 3);
    for (int i = 0, n = vertices.length; i < n;) {
        int boneCount = (int)vertices[i++];
        bones.add(boneCount);
        for (int nn = i + boneCount * 4; i < nn; i += 4) {
            bones.add((int)vertices[i]);
            weights.add(vertices[i + 1] * scale);
            weights.add(vertices[i + 2] * scale);
            weights.add(vertices[i + 3]);
        }
    }
    attachment.setBones(bones.toArray());
    attachment.setVertices(weights.toArray());
}
项目:libgdx-jbullet    文件:HullLibrary.java   
private int calchull (ObjectArrayList<Vector3> verts, int verts_count, IntArray tris_out, int[] tris_count, int vlimit) {
    int rc = calchullgen(verts, verts_count, vlimit);
    if (rc == 0) return 0;

    IntArray ts = new IntArray();

    for (int i = 0; i < tris.size(); i++) {
        if (tris.getQuick(i) != null) {
            for (int j = 0; j < 3; j++) {
                ts.add((tris.getQuick(i)).getCoord(j));
            }
            deAllocateTriangle(tris.getQuick(i));
        }
    }
    tris_count[0] = ts.size / 3;
    MiscUtil.resize(tris_out, ts.size, 0);

    for (int i = 0; i < ts.size; i++) {
        tris_out.set(i, ts.get(i));
    }
    MiscUtil.resize(tris, 0, NEW_TRI_SUPPLIER);

    return 1;
}
项目:exterminate    文件:BitmapFontCache.java   
/** @param integer If true, rendering positions will be at integer values to avoid filtering artifacts. */
public BitmapFontCache (BitmapFont font, boolean integer) {

    this.font = font;
    this.integer = integer;

    int pageCount = font.regions.size;
    if (pageCount == 0) throw new IllegalArgumentException("The specified font must contain at least one texture page.");

    pageVertices = new float[pageCount][];
    idx = new int[pageCount];
    if (pageCount > 1) {
        // Contains the indices of the glyph in the cache as they are added.
        pageGlyphIndices = new IntArray[pageCount];
        for (int i = 0, n = pageGlyphIndices.length; i < n; i++)
            pageGlyphIndices[i] = new IntArray();
    }
    tempGlyphCount = new int[pageCount];
}
项目:beatoraja    文件:PatternModifier.java   
protected int[] getKeys(Mode mode, boolean containsScratch) {
    int key = (getModifyTarget() == SIDE_2P)
            ? mode.key / mode.player
            : 0;
    if (key == mode.key) {
        return new int[0];
    } else {
        IntArray keys = new IntArray();
        for (int i = 0; i < mode.key / mode.player; i++) {
            if (containsScratch || !mode.isScratchKey(key + i)) {
                keys.add(key + i);
            }
        }
        return keys.toArray();
    }
}
项目:fabulae    文件:GameMapLoader.java   
private IntArray getTilesFromPolygon(Polygon polygon) {
    IntArray tiles = new IntArray();
    Polygon transformedPolygon = transformTiledPolygon(gameMap, polygon);
    Rectangle rectangle = transformedPolygon.getBoundingRectangle();
    int startX = (int) rectangle.getX();
    int startY = (int) rectangle.getY();
    int endX = startX + (int) rectangle.getWidth();
    int endY = startY + (int) rectangle.getHeight();
    for (int x = startX; x <= endX; ++x) {
        for (int y = startY; y <= endY; ++y) {
            if (transformedPolygon.contains(x, y)) {
                tiles.add(x);
                tiles.add(y);
            }
        }
    }
    return tiles;
}
项目:libgdxcn    文件:ConvexHull.java   
/** Sorts x,y pairs of values by the x value, then the y value.
 * @param count Number of indices, must be even. */
private void sort (float[] values, int count) {
    int lower = 0;
    int upper = count - 1;
    IntArray stack = quicksortStack;
    stack.add(lower);
    stack.add(upper - 1);
    while (stack.size > 0) {
        upper = stack.pop();
        lower = stack.pop();
        if (upper <= lower) continue;
        int i = quicksortPartition(values, lower, upper);
        if (i - lower > upper - i) {
            stack.add(lower);
            stack.add(i - 2);
        }
        stack.add(i + 2);
        stack.add(upper);
        if (upper - i >= i - lower) {
            stack.add(lower);
            stack.add(i - 2);
        }
    }
}
项目:libgdxcn    文件:ParticleControllerInfluencer.java   
@Override
public void load (AssetManager manager, ResourceData resources) {
    SaveData data = resources.getSaveData();
    Array<IntArray>effectsIndices = data.load("indices");
    AssetDescriptor descriptor;
    Iterator<IntArray> iterator = effectsIndices.iterator();
    while((descriptor = data.loadAsset()) != null){
        ParticleEffect effect = (ParticleEffect)manager.get(descriptor);
        if(effect == null)
            throw new RuntimeException("Template is null");
        Array<ParticleController> effectControllers = effect.getControllers();
        IntArray effectIndices = iterator.next();

        for (int i = 0, n = effectIndices.size; i < n; i++) {
            templates.add(effectControllers.get(effectIndices.get(i)));
        }
    }
}
项目:libgdxcn    文件:BitmapFontCache.java   
/** @param integer If true, rendering positions will be at integer values to avoid filtering artifacts. */
public BitmapFontCache (BitmapFont font, boolean integer) {
    this.font = font;
    this.integer = integer;

    int regionsLength = font.regions.length;
    if (regionsLength == 0) throw new IllegalArgumentException("The specified font must contain at least one texture page.");

    this.vertexData = new float[regionsLength][];
    this.colorChunks = new Array<ColorChunk>();

    this.idx = new int[regionsLength];
    int vertexDataLength = vertexData.length;
    if (vertexDataLength > 1) { // If we have multiple pages...
        // Contains the indices of the glyph in the Cache as they are added.
        glyphIndices = new IntArray[vertexDataLength];
        for (int i = 0, n = glyphIndices.length; i < n; i++) {
            glyphIndices[i] = new IntArray();
        }

        tmpGlyphCount = new int[vertexDataLength];
    }
}
项目:vis-editor    文件:CenteredTableBuilder.java   
@Override
protected void fillTable (final Table table) {
    final IntArray rowSizes = getRowSizes();
    final int widgetsInRow = getLowestCommonMultiple(rowSizes);

    for (int rowIndex = 0, widgetIndex = 0; rowIndex < rowSizes.size; rowIndex++) {
        final int rowSize = rowSizes.get(rowIndex);
        final int currentWidgetColspan = widgetsInRow / rowSize;
        boolean isFirst = shouldExpand(rowSize);

        for (final int totalWidgetsBeforeRowEnd = widgetIndex + rowSize; widgetIndex < totalWidgetsBeforeRowEnd; widgetIndex++) {
            final Cell<?> cell =
                    getWidget(widgetIndex).buildCell(table, getDefaultWidgetPadding()).colspan(
                            currentWidgetColspan);
            // Keeping widgets together - expanding X for first and last widget, setting alignments:
            if (isFirst) {
                isFirst = false;
                cell.expandX().right();
            } else if (isLast(widgetIndex, rowSize, totalWidgetsBeforeRowEnd)) {
                cell.expandX().left();
            }
        }
        table.row();
    }
}
项目:vis-editor    文件:SkeletonBinary.java   
private Vertices readVertices (DataInput input, int vertexCount) throws IOException {
    int verticesLength = vertexCount << 1;
    Vertices vertices = new Vertices();
    if (!input.readBoolean()) {
        vertices.vertices = readFloatArray(input, verticesLength, scale);
        return vertices;
    }
    FloatArray weights = new FloatArray(verticesLength * 3 * 3);
    IntArray bonesArray = new IntArray(verticesLength * 3);
    for (int i = 0; i < vertexCount; i++) {
        int boneCount = input.readInt(true);
        bonesArray.add(boneCount);
        for (int ii = 0; ii < boneCount; ii++) {
            bonesArray.add(input.readInt(true));
            weights.add(input.readFloat() * scale);
            weights.add(input.readFloat() * scale);
            weights.add(input.readFloat());
        }
    }
    vertices.vertices = weights.toArray();
    vertices.bones = bonesArray.toArray();
    return vertices;
}
项目:vis-editor    文件:SkeletonJson.java   
private void readVertices (JsonValue map, VertexAttachment attachment, int verticesLength) {
    attachment.setWorldVerticesLength(verticesLength);
    float[] vertices = map.require("vertices").asFloatArray();
    if (verticesLength == vertices.length) {
        if (scale != 1) {
            for (int i = 0, n = vertices.length; i < n; i++)
                vertices[i] *= scale;
        }
        attachment.setVertices(vertices);
        return;
    }
    FloatArray weights = new FloatArray(verticesLength * 3 * 3);
    IntArray bones = new IntArray(verticesLength * 3);
    for (int i = 0, n = vertices.length; i < n;) {
        int boneCount = (int)vertices[i++];
        bones.add(boneCount);
        for (int nn = i + boneCount * 4; i < nn; i += 4) {
            bones.add((int)vertices[i]);
            weights.add(vertices[i + 1] * scale);
            weights.add(vertices[i + 2] * scale);
            weights.add(vertices[i + 3]);
        }
    }
    attachment.setBones(bones.toArray());
    attachment.setVertices(weights.toArray());
}
项目:ModularArmour    文件:TabRecipeList.java   
public TabRecipeList(GuiBase gui, IntArray indicies) {
    super(gui, LEFT);

    this.indicies = indicies;

    this.maxHeight = 115;

    ListBoxElementText text;
    int max = 0;
    for (Recipe recipe : UpgradeRegistry.getRecipeList()) {
        text = new ListBoxElementText(StringHelper.localize(recipe.getRecipeOutput().getName()));
        max = Math.max(text.getWidth(), max);
    }

    this.list = new ElementUpgradeListBox(this.gui, 7, 7, max, 100) {

        public void onUpgradeSelected(IUpgrade upgrade, int index) {
            TabRecipeList.this.onUpgradeSelected(upgrade, index);
        }

    };

    this.maxWidth = Math.min(max + 12, 132);

    this.addElement(list);
}
项目:ingress-indonesia-dev    文件:TileMapRenderer.java   
public TileMapRenderer(TiledMap paramTiledMap, TileAtlas paramTileAtlas, int paramInt1, int paramInt2, float paramFloat1, float paramFloat2, ShaderProgram paramShaderProgram)
{
  int[][][] arrayOfInt = new int[paramTiledMap.layers.size()][][];
  for (int i = 0; i < paramTiledMap.layers.size(); i++)
    arrayOfInt[i] = ((TiledLayer)paramTiledMap.layers.get(i)).tiles;
  for (int j = 0; j < paramTiledMap.tileSets.size(); j++)
  {
    if (((TileSet)paramTiledMap.tileSets.get(j)).tileHeight - paramTiledMap.tileHeight > paramFloat2 * this.overdrawY)
      this.overdrawY = ((((TileSet)paramTiledMap.tileSets.get(j)).tileHeight - paramTiledMap.tileHeight) / paramFloat2);
    if (((TileSet)paramTiledMap.tileSets.get(j)).tileWidth - paramTiledMap.tileWidth > paramFloat1 * this.overdrawX)
      this.overdrawX = ((((TileSet)paramTiledMap.tileSets.get(j)).tileWidth - paramTiledMap.tileWidth) / paramFloat1);
  }
  String str = (String)paramTiledMap.properties.get("blended tiles");
  if (str != null);
  for (IntArray localIntArray = createFromCSV(str); ; localIntArray = new IntArray(0))
  {
    init(arrayOfInt, paramTileAtlas, paramTiledMap.tileWidth, paramTiledMap.tileHeight, paramFloat1, paramFloat2, localIntArray, paramInt1, paramInt2, paramShaderProgram);
    this.map = paramTiledMap;
    return;
  }
}
项目:GDX-Engine    文件:TileRenderer.java   
public TileRenderer(int[][][] map, TileAtlas atlas, int tileWidth,
        int tileHeight, float unitsPerTileX, float unitsPerTileY,
        IntArray blendedTiles, int tilesPerBlockX, int tilesPerBlockY,
        ShaderProgram shader) {
    super(map, atlas, tileWidth, tileHeight, unitsPerTileX, unitsPerTileY,
            blendedTiles, tilesPerBlockX, tilesPerBlockY, shader);
    // TODO Auto-generated constructor stub
}
项目:GDX-Engine    文件:TileRenderer.java   
public TileRenderer(int[][][] map, TileAtlas atlas, int tileWidth,
        int tileHeight, float unitsPerTileX, float unitsPerTileY,
        IntArray blendedTiles, int tilesPerBlockX, int tilesPerBlockY) {
    super(map, atlas, tileWidth, tileHeight, unitsPerTileX, unitsPerTileY,
            blendedTiles, tilesPerBlockX, tilesPerBlockY);
    // TODO Auto-generated constructor stub
}
项目:gdx-cclibs    文件:IntArraySerializer.java   
@Override
public void write(Kryo kryo, Output output, IntArray array) {
    output.writeVarInt(array.size, true);
    output.writeBoolean(array.ordered);
    for (int i = 0; i < array.size; i++) {
        output.writeInt(array.get(i));
    }
}
项目:gdx-cclibs    文件:IntArraySerializer.java   
@Override
public IntArray read(Kryo kryo, Input input, Class<IntArray> type) {
    int length = input.readVarInt(true);
    boolean ordered = input.readBoolean();
    IntArray array = new IntArray(ordered, length);
    for (int i = 0; i < length; i++) {
        array.add(input.readInt());
    }
    return array;
}
项目:arcadelegends-gg    文件:ArcadeWorld.java   
/**
 * Extracts the enemy information form the {@link TiledMap}, and spawns them in.
 * Also adds a {@link AIComponent} to the enemies, targeting the player.
 *
 * @param playerId the player to target
 * @return an {@link IntArray} containing all the enemies
 */
public IntArray spawnEnemies(int playerId) {
    String enemies = (String) tiledMap.getProperties().get("enemies");
    IntArray array = new IntArray();
    for (String enemy : enemies.split("-")) {
        String[] parts = enemy.split(";");

        Vector2 pos = new Vector2(Integer.parseInt(parts[0]),
                Integer.parseInt(parts[1]));
        EntityArguments arguments = getArguments(parts[2]);
        PositionComponent.PositionTemplate positionDef = arguments.get("PositionComponent", PositionComponent.PositionTemplate.class);
        positionDef.x = pos.x;
        positionDef.y = pos.y;
        int id = spawn(Entities.Player, arguments);
        StatComponent statComponent = entityWorld.getMapper(StatComponent.class).get(id);
        final float xp = Integer.parseInt(parts[3]);
        statComponent.statEventHandler = (statComponent1, entityId) ->
        {
            StatComponent player = entityWorld.getMapper(StatComponent.class).get(playerId);
            player.addRuntimeStat(StatComponent.RuntimeStat.experience, xp);
            array.removeValue(id);
        };
        statComponent.setFlag(StatComponent.FlagStat.deleteOnDeath, true);
        AIComponent aiComponent = entityWorld.getMapper(AIComponent.class).create(id);
        aiComponent.target = playerId;
        aiComponent.aggroRange = Integer.parseInt(parts[4]);
        array.add(id);
    }
    return array;
}
项目:KyperBox    文件:TileCollisionController.java   
@Override
public void init(GameObject object) {
    solid_filter = new IntArray();
    solid_filter.add(WALL);
    current_collisions = new IntArray();
    collision_map_tiles = new Array<TilemapLayerObject.MapTile>();
    tile_pool = new Pool<TilemapLayerObject.MapTile>() {
        @Override
        protected MapTile newObject() {
            return new MapTile();
        }
    };
}
项目:Cubes    文件:CaveGenerator.java   
public Cave generate() {
  int spawnDist = (int) distanceFromSpawn(caveStartX, caveStartZ);
  Log.debug("Generating new cave at " + caveStartX + "," + caveStartZ + " (" + spawnDist + " blocks from spawn)");
  generateNodes();
  calculateBlocks();

  Cave cave = new Cave(caveStartX, caveStartY, caveStartZ, new HashMap<AreaReference, int[]>() {{
    for (Map.Entry<AreaReference, IntArray> entry : blocks.entrySet()) {
      this.put(entry.getKey(), entry.getValue().toArray());
    }
  }});

  return cave;
}
项目:fluffybalance    文件:HighScoreGuiEntity.java   
private void updateHighScore() {
    IntArray highScores = HighScoreController.fetchHighScores();

    for (int i = 0; i < Math.min(mHighScoreLabel.size, highScores.size); i++) {
        mHighScoreLabel.get(i).setText("" + highScores.get(i));
    }
}
项目:Undertailor    文件:OpenALAudio.java   
public OpenALAudio (int simultaneousSources, int deviceBufferCount, int deviceBufferSize) {
    this.deviceBufferSize = deviceBufferSize;
    this.deviceBufferCount = deviceBufferCount;

    registerSound("ogg", Ogg.Sound.class);
    registerMusic("ogg", Ogg.Music.class);
    registerSound("wav", Wav.Sound.class);
    registerMusic("wav", Wav.Music.class);
    registerSound("mp3", Mp3.Sound.class);
    registerMusic("mp3", Mp3.Music.class);

    try {
        AL.create();
    } catch (LWJGLException ex) {
        noDevice = true;
        ex.printStackTrace();
        return;
    }

    allSources = new IntArray(false, simultaneousSources);
    for (int i = 0; i < simultaneousSources; i++) {
        int sourceID = alGenSources();
        if (alGetError() != AL_NO_ERROR) break;
        allSources.add(sourceID);
    }
    idleSources = new IntArray(allSources);
    soundIdToSource = new LongMap<Integer>();
    sourceToSoundId = new IntMap<Long>();

    FloatBuffer orientation = (FloatBuffer)BufferUtils.createFloatBuffer(6)
        .put(new float[] {0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f}).flip();
    alListener(AL_ORIENTATION, orientation);
    FloatBuffer velocity = (FloatBuffer)BufferUtils.createFloatBuffer(3).put(new float[] {0.0f, 0.0f, 0.0f}).flip();
    alListener(AL_VELOCITY, velocity);
    FloatBuffer position = (FloatBuffer)BufferUtils.createFloatBuffer(3).put(new float[] {0.0f, 0.0f, 0.0f}).flip();
    alListener(AL_POSITION, position);

    recentSounds = new OpenALSound[simultaneousSources];
}
项目:nhglib    文件:PBRShader.java   
@Override
public void init() {
    super.init(shaderProgram, renderable);

    idtMatrix = new Matrix4();
    bones = new float[0];
    bonesLoc = loc(bonesIID);

    lightsFrustum = new Array<>();

    for (int i = 0; i < 100; i++) {
        lightsFrustum.add(new IntArray());
    }

    color = new Color();

    lightTexture = new Texture(64, 128, Pixmap.Format.RGBA8888);
    lightTexture.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest);

    lightInfoTexture = new Texture(1, 128, Pixmap.Format.RGBA8888);
    lightInfoTexture.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest);

    lightPixmap = new Pixmap(64, 128, Pixmap.Format.RGBA8888);
    lightPixmap.setBlending(Pixmap.Blending.None);

    lightInfoPixmap = new Pixmap(1, 128, Pixmap.Format.RGBA8888);
    lightInfoPixmap.setBlending(Pixmap.Blending.None);

    lightGrid = new LightGrid(10, 10);
}
项目:libgdx-jbullet    文件:Dbvt.java   
public static int nearest (IntArray i, ObjectArrayList<sStkNPS> a, float v, int l, int h) {
    int m = 0;
    while (l < h) {
        m = (l + h) >> 1;
        if (a.getQuick(i.get(m)).value >= v) {
            l = m + 1;
        } else {
            h = m;
        }
    }
    return h;
}
项目:libgdx-jbullet    文件:Dbvt.java   
public static int allocate (IntArray ifree, ObjectArrayList<sStkNPS> stock, sStkNPS value) {
    int i;
    if (ifree.size > 0) {
        i = ifree.get(ifree.size - 1);
        ifree.removeIndex(ifree.size - 1);
        stock.getQuick(i).set(value);
    } else {
        i = stock.size();
        stock.add(value);
    }
    return (i);
}
项目:libgdx-jbullet    文件:MiscUtil.java   
/**
 * Resizes list to exact size, filling with given value when expanding.
 */
public static void resize(IntArray list, int size, int value) {
    while (list.size < size) {
        list.add(value);
    }

    while (list.size > size) {
        list.removeIndex(list.size - 1);
    }
}
项目:libgdx-jbullet    文件:HullLibrary.java   
private static int maxdirfiltered (ObjectArrayList<Vector3> p, int count, Vector3 dir, IntArray allow) {
    assert (count != 0);
    int m = -1;
    for (int i = 0; i < count; i++) {
        if (allow.get(i) != 0) {
            if (m == -1 || p.getQuick(i).dot(dir) > p.getQuick(m).dot(dir)) {
                m = i;
            }
        }
    }
    assert (m != -1);
    return m;
}
项目:libgdx-jbullet    文件:GImpactBvh.java   
/**
 * Returns the indices of the primitives in the primitive_manager field.
 */
public boolean boxQuery(AABB box, IntArray collided_results) {
    int curIndex = 0;
    int numNodes = getNodeCount();

    Stack stack = Stack.enter();
    AABB bound = stack.allocAABB();

    while (curIndex < numNodes) {
        getNodeBound(curIndex, bound);

        // catch bugs in tree data

        boolean aabbOverlap = bound.has_collision(box);
        boolean isleafnode = isLeafNode(curIndex);

        if (isleafnode && aabbOverlap) {
            collided_results.add(getNodeData(curIndex));
        }

        if (aabbOverlap || isleafnode) {
            // next subnode
            curIndex++;
        }
        else {
            // skip node
            curIndex += getEscapeNodeIndex(curIndex);
        }
    }
    if (collided_results.size > 0) {
        stack.leave();
        return true;
    }
    stack.leave();
    return false;
}
项目:libgdx-jbullet    文件:GImpactBvh.java   
/**
 * Returns the indices of the primitives in the primitive_manager field.
 */
public boolean boxQueryTrans(AABB box, Transform transform, IntArray collided_results) {
    Stack stack = Stack.enter();
    AABB transbox = stack.alloc(box);
    transbox.appy_transform(transform);
    boolean result = boxQuery(transbox, collided_results);
    stack.leave();
    return result;
}
项目:libgdx-jbullet    文件:GImpactBvh.java   
/**
 * Returns the indices of the primitives in the primitive_manager field.
 */
public boolean rayQuery(Vector3 ray_dir, Vector3 ray_origin, IntArray collided_results) {
    int curIndex = 0;
    int numNodes = getNodeCount();

    Stack stack = Stack.enter();
    AABB bound = stack.allocAABB();

    while (curIndex < numNodes) {
        getNodeBound(curIndex, bound);

        // catch bugs in tree data

        boolean aabbOverlap = bound.collide_ray(ray_origin, ray_dir);
        boolean isleafnode = isLeafNode(curIndex);

        if (isleafnode && aabbOverlap) {
            collided_results.add(getNodeData(curIndex));
        }

        if (aabbOverlap || isleafnode) {
            // next subnode
            curIndex++;
        }
        else {
            // skip node
            curIndex += getEscapeNodeIndex(curIndex);
        }
    }
    if (collided_results.size > 0) {
        stack.leave();
        return true;
    }
    stack.leave();
    return false;
}
项目:libgdx-jbullet    文件:GImpactCollisionAlgorithm.java   
protected void gimpact_vs_shape_find_pairs(Transform trans0, Transform trans1, GImpactShapeInterface shape0, CollisionShape shape1, IntArray collided_primitives) {
    Stack stack = Stack.enter();
    AABB boxshape = stack.allocAABB();

    if (shape0.hasBoxSet()) {
        Transform trans1to0 = stack.allocTransform();
        trans1to0.inverse(trans0);
        trans1to0.mul(trans1);

        shape1.getAabb(trans1to0, boxshape.min, boxshape.max);

        shape0.getBoxSet().boxQuery(boxshape, collided_primitives);
    }
    else {
        shape1.getAabb(trans1, boxshape.min, boxshape.max);

        AABB boxshape0 = stack.allocAABB();
        int i = shape0.getNumChildShapes();

        while ((i--) != 0) {
            shape0.getChildAabb(i, trans0, boxshape0.min, boxshape0.max);

            if (boxshape.has_collision(boxshape0)) {
                collided_primitives.add(i);
            }
        }
    }
    stack.leave();
}
项目:exterminate    文件:BitmapFontCache.java   
public void draw (Batch spriteBatch, int start, int end) {
    if (pageVertices.length == 1) { // 1 page.
        spriteBatch.draw(font.getRegion().getTexture(), pageVertices[0], start * 20, (end - start) * 20);
        return;
    }

    // Determine vertex offset and count to render for each page. Some pages might not need to be rendered at all.
    Array<TextureRegion> regions = font.getRegions();
    for (int i = 0, pageCount = pageVertices.length; i < pageCount; i++) {
        int offset = -1, count = 0;

        // For each set of glyph indices, determine where to begin within the start/end bounds.
        IntArray glyphIndices = pageGlyphIndices[i];
        for (int ii = 0, n = glyphIndices.size; ii < n; ii++) {
            int glyphIndex = glyphIndices.get(ii);

            // Break early if the glyph is out of bounds.
            if (glyphIndex >= end) break;

            // Determine if this glyph is within bounds. Use the first match of that for the offset.
            if (offset == -1 && glyphIndex >= start) offset = ii;

            // Determine the vertex count by counting glyphs within bounds.
            if (glyphIndex >= start) // && gInd < end
                count++;
        }

        // Page doesn't need to be rendered.
        if (offset == -1 || count == 0) continue;

        // Render the page vertex data with the offset and count.
        spriteBatch.draw(regions.get(i).getTexture(), pageVertices[i], offset * 20, count * 20);
    }
}
项目:beatoraja    文件:KeyBoardInputProcesseor.java   
public KeyBoardInputProcesseor(BMSPlayerInputProcessor bmsPlayerInputProcessor, KeyboardConfig config, Resolution resolution) {
    super(Type.KEYBOARD);
    this.bmsPlayerInputProcessor = bmsPlayerInputProcessor;
    this.setConfig(config);
    this.resolution = resolution;

    reserved = new IntArray();
    reserved.addAll(cover);
    reserved.addAll(function);
    reserved.addAll(numbers);
    reserved.addAll(exit);
}
项目:dice-heroes    文件:Die.java   
public IntArray getAvailableIndices(Ability ability) {
    int availableSkill = getTotalSkill() - getUsedSkill();
    IntArray res = new IntArray();
    for (int i = 0; i < abilities.size; i++) {
        Ability check = abilities.get(i);
        if (check == ability)
            continue;
        boolean canBePlaced = check == null ? availableSkill >= ability.skill : availableSkill >= ability.skill - check.skill;
        if (canBePlaced) {
            res.add(i);
        }
    }
    return res;
}
项目:dice-heroes    文件:DieNet.java   
private void highlight(IntArray indices) {
    for (int i = 0; i < indices.size; i++) {
        Vector2 pos = iconPositions[indices.get(i)];
        Image image = new Image(Config.skin, "ui/dice-window/net-selection-selected");
        image.setPosition(pos.x - 2, pos.y - 2);
        addActor(image);
        image.toBack();
        image.getColor().a = 0f;
        blink(image);
        highlights.add(image);
    }
}