本文整理匯總了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++;
}
}
示例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;
}
示例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());
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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());
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}