當前位置: 首頁>>代碼示例>>Java>>正文


Java Pool.obtain方法代碼示例

本文整理匯總了Java中com.badlogic.gdx.utils.Pool.obtain方法的典型用法代碼示例。如果您正苦於以下問題:Java Pool.obtain方法的具體用法?Java Pool.obtain怎麽用?Java Pool.obtain使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.badlogic.gdx.utils.Pool的用法示例。


在下文中一共展示了Pool.obtain方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getRenderables

import com.badlogic.gdx.utils.Pool; //導入方法依賴的package包/類
@Override
public void getRenderables (Array<Renderable> renderables, Pool<Renderable> pool) {
	renderedChunks = 0;
	for (int i = 0; i < chunks.length; i++) {
		VoxelChunk chunk = chunks[i];
		Mesh mesh = meshes[i];
		if (dirty[i]) {
			int numVerts = chunk.calculateVertices(vertices);
			numVertices[i] = numVerts / 4 * 6;
			mesh.setVertices(vertices, 0, numVerts * VoxelChunk.VERTEX_SIZE);
			dirty[i] = false;
		}
		if (numVertices[i] == 0) continue;
		Renderable renderable = pool.obtain();
		renderable.material = materials[i];
		renderable.mesh = mesh;
		renderable.meshPartOffset = 0;
		renderable.meshPartSize = numVertices[i];
		renderable.primitiveType = GL20.GL_TRIANGLES;
		renderables.add(renderable);
		renderedChunks++;
	}
}
 
開發者ID:basherone,項目名稱:libgdxcn,代碼行數:24,代碼來源:VoxelWorld.java

示例2: getSimpleCopy

import com.badlogic.gdx.utils.Pool; //導入方法依賴的package包/類
/**
 * Gets a copy of this object but does not copy its parent or children
 * 
 * @return The copied object
 */
@Override
public <T extends SceneGraphNode> T getSimpleCopy() {
    Class<? extends AbstractOctreeWrapper> clazz = this.getClass();
    Pool<? extends AbstractOctreeWrapper> pool = MyPools.get(clazz);
    try {
        AbstractOctreeWrapper instance = pool.obtain();
        instance.copy = true;
        instance.name = this.name;
        instance.transform.set(this.transform);
        instance.ct = this.ct;
        if (this.localTransform != null)
            instance.localTransform.set(this.localTransform);

        return (T) instance;
    } catch (Exception e) {
        Logger.error(e);
    }
    return null;
}
 
開發者ID:langurmonkey,項目名稱:gaiasky,代碼行數:25,代碼來源:AbstractOctreeWrapper.java

示例3: registerType

import com.badlogic.gdx.utils.Pool; //導入方法依賴的package包/類
public static <T> void registerType(Class<? extends T> c, Pool<T> aPool) {
	T obj = aPool.obtain();
	Class<?> objClass = obj.getClass();
	aPool.free(obj);
	if (objClass.equals(c)) {
		synchronized (Pools.pools) {
			if (!Pools.pools.containsKey(c)) {
				Pools.pools.put(c, aPool);
			}
		}
	} else {
		throw new CubesException("Calling obtain on " + aPool + " does not return " + c.getName());
	}
}
 
開發者ID:RedTroop,項目名稱:Cubes_2,代碼行數:15,代碼來源:Pools.java

示例4: obtain

import com.badlogic.gdx.utils.Pool; //導入方法依賴的package包/類
public static <T> T obtain(Class<T> c) {
	Pool<T> pool = pool(c);
	if (pool == null)
		return null;
	synchronized (pool) {
		return pool.obtain();
	}
}
 
開發者ID:RedTroop,項目名稱:Cubes_2,代碼行數:9,代碼來源:Pools.java

示例5: obtainAreaReference

import com.badlogic.gdx.utils.Pool; //導入方法依賴的package包/類
public static AreaReference obtainAreaReference() {
	Pool<AreaReference> pool = pool(AreaReference.class);
	if (pool == null)
		return null;
	synchronized (pool) {
		return pool.obtain();
	}
}
 
開發者ID:RedTroop,項目名稱:Cubes_2,代碼行數:9,代碼來源:Pools.java

示例6: obtainBlockReference

import com.badlogic.gdx.utils.Pool; //導入方法依賴的package包/類
public static BlockReference obtainBlockReference() {
	Pool<BlockReference> pool = pool(BlockReference.class);
	if (pool == null)
		return null;
	synchronized (pool) {
		return pool.obtain();
	}
}
 
開發者ID:RedTroop,項目名稱:Cubes_2,代碼行數:9,代碼來源:Pools.java

示例7: registerType

import com.badlogic.gdx.utils.Pool; //導入方法依賴的package包/類
public static <T> void registerType(Class<? extends T> c, Pool<T> pool) {
  T obj = pool.obtain();
  Class<?> objClass = obj.getClass();
  pool.free(obj);
  if (objClass.equals(c)) {
    synchronized (pools) {
      if (!pools.containsKey(c)) {
        pools.put(c, pool);
      }
    }
  } else {
    throw new CubesException("Calling obtain on " + pool + " does not return " + c.getName());
  }
}
 
開發者ID:RedTroop,項目名稱:Cubes,代碼行數:15,代碼來源:Pools.java

示例8: obtain

import com.badlogic.gdx.utils.Pool; //導入方法依賴的package包/類
public static <T> T obtain(Class<T> c) {
  Pool<T> pool = pool(c);
  if (pool == null) return null;
  synchronized (pool) {
    return pool.obtain();
  }
}
 
開發者ID:RedTroop,項目名稱:Cubes,代碼行數:8,代碼來源:Pools.java

示例9: obtainAreaReference

import com.badlogic.gdx.utils.Pool; //導入方法依賴的package包/類
public static AreaReference obtainAreaReference() {
  Pool<AreaReference> pool = pool(AreaReference.class);
  if (pool == null) return null;
  synchronized (pool) {
    return pool.obtain();
  }
}
 
開發者ID:RedTroop,項目名稱:Cubes,代碼行數:8,代碼來源:Pools.java

示例10: obtainBlockReference

import com.badlogic.gdx.utils.Pool; //導入方法依賴的package包/類
public static BlockReference obtainBlockReference() {
  Pool<BlockReference> pool = pool(BlockReference.class);
  if (pool == null) return null;
  synchronized (pool) {
    return pool.obtain();
  }
}
 
開發者ID:RedTroop,項目名稱:Cubes,代碼行數:8,代碼來源:Pools.java

示例11: prepare

import com.badlogic.gdx.utils.Pool; //導入方法依賴的package包/類
/**
 * Returns a new or pooled action of the specified type.
 */
static public <T extends Step> T prepare(Class<T> type, float atAge) {
    Pool<T> pool = Pools.get(type);
    T node = pool.obtain();
    node.setPool(pool);
    node.atAge = atAge;
    return node;
}
 
開發者ID:DaanVanYperen,項目名稱:naturally-selected-2d,代碼行數:11,代碼來源:Script.java

示例12: prepare

import com.badlogic.gdx.utils.Pool; //導入方法依賴的package包/類
/**
 * Returns a new or pooled action of the specified type.
 */
public static <T extends Operation> T prepare(Class<T> type) {
	final Pool<T> pool = Pools.get(type);
	T node = pool.obtain();
	node.setPool(pool);
	return node;
}
 
開發者ID:DaanVanYperen,項目名稱:artemis-odb-contrib,代碼行數:10,代碼來源:Operation.java

示例13: action3d

import com.badlogic.gdx.utils.Pool; //導入方法依賴的package包/類
/** Returns a new or pooled action of the specified type. */
static public <T extends Action3d> T action3d (Class<T> type) {
        Pool<T> pool = Pools.get(type);
        T action = pool.obtain();
        action.setPool(pool);
        return action;
}
 
開發者ID:pyros2097,項目名稱:Scene3d,代碼行數:8,代碼來源:Actions3d.java

示例14: createBehaviorTree

import com.badlogic.gdx.utils.Pool; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public <T> BehaviorTree<T> createBehaviorTree(String treeReference, T blackboard) {
	Pool<BehaviorTree> pool = getPool(treeReference);
	BehaviorTree<T> tree = (BehaviorTree<T>)pool.obtain();
	tree.setObject(blackboard);
	return tree;
}
 
開發者ID:libgdx,項目名稱:gdx-ai,代碼行數:9,代碼來源:PooledBehaviorTreeLibrary.java

示例15: getRenderableFor

import com.badlogic.gdx.utils.Pool; //導入方法依賴的package包/類
private Renderable getRenderableFor(Pool<Renderable> pool, Mesh mesh, Material material, Object userData) {
	Renderable renderable = pool.obtain();
	renderable.mesh = mesh;
	renderable.meshPartOffset = 0;
	renderable.meshPartSize = mesh.getNumVertices();
	renderable.primitiveType = GL20.GL_TRIANGLES;
	renderable.bones = null;
	renderable.environment = null;
	renderable.shader = null;
	renderable.userData = userData;
	renderable.material = material;
	return renderable;
}
 
開發者ID:gered,項目名稱:gdx-tilemap3d,代碼行數:14,代碼來源:TileChunk.java


注:本文中的com.badlogic.gdx.utils.Pool.obtain方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。