本文整理汇总了Java中com.badlogic.gdx.utils.Bits.get方法的典型用法代码示例。如果您正苦于以下问题:Java Bits.get方法的具体用法?Java Bits.get怎么用?Java Bits.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.utils.Bits
的用法示例。
在下文中一共展示了Bits.get方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeEntityListener
import com.badlogic.gdx.utils.Bits; //导入方法依赖的package包/类
public void removeEntityListener (EntityListener listener) {
for (int i = 0; i < entityListeners.size; i++) {
EntityListenerData entityListenerData = entityListeners.get(i);
if (entityListenerData.listener == listener) {
// Shift down bitmasks by one step
for (Bits mask : entityListenerMasks.values()) {
for (int k = i, n = mask.length(); k < n; k++) {
if (mask.get(k + 1)) {
mask.set(k);
} else {
mask.clear(k);
}
}
}
entityListeners.removeIndex(i--);
}
}
}
示例2: matches
import com.badlogic.gdx.utils.Bits; //导入方法依赖的package包/类
/**
* @return Whether the entity matches the family requirements or not
*/
public boolean matches(Entity entity) {
Bits entityComponentBits = entity.getComponentBits();
if (entityComponentBits.isEmpty())
return false;
for (int i = all.nextSetBit(0); i >= 0; i = all.nextSetBit(i + 1)) {
if (!entityComponentBits.get(i))
return false;
}
if (!one.isEmpty() && !one.intersects(entityComponentBits)) {
return false;
}
if (!exclude.isEmpty() && exclude.intersects(entityComponentBits)) {
return false;
}
return true;
}
示例3: addEntityListener
import com.badlogic.gdx.utils.Bits; //导入方法依赖的package包/类
public void addEntityListener (Family family, int priority, EntityListener listener) {
registerFamily(family);
int insertionIndex = 0;
while (insertionIndex < entityListeners.size) {
if (entityListeners.get(insertionIndex).priority <= priority) {
insertionIndex++;
} else {
break;
}
}
// Shift up bitmasks by one step
for (Bits mask : entityListenerMasks.values()) {
for (int k = mask.length(); k > insertionIndex; k--) {
if (mask.get(k - 1)) {
mask.set(k);
} else {
mask.clear(k);
}
}
mask.clear(insertionIndex);
}
entityListenerMasks.get(family).set(insertionIndex);
EntityListenerData entityListenerData = new EntityListenerData();
entityListenerData.listener = listener;
entityListenerData.priority = priority;
entityListeners.insert(insertionIndex, entityListenerData);
}
示例4: getUniquePositionVertexIndices
import com.badlogic.gdx.utils.Bits; //导入方法依赖的package包/类
/**
* Get an array of the vertex indices from the mesh. Any vertices which share the same position will be counted
* as a single vertex and share the same index. That is, position duplicates will be filtered out.
*
* @param mesh
* @return
*/
private static short[] getUniquePositionVertexIndices(Mesh mesh) {
FloatBuffer verticesBuffer = mesh.getVerticesBuffer();
int positionOffset = mesh.getVertexAttributes().findByUsage(VertexAttributes.Usage.Position).offset / 4;
// Number of array elements which make up a vertex
int vertexSize = mesh.getVertexSize() / 4;
// The indices tell us which vertices are part of a triangle.
short[] indices = new short[mesh.getNumIndices()];
mesh.getIndices(indices);
// Marks true if an index has already been compared to avoid unnecessary comparisons
Bits handledIndices = new Bits(mesh.getNumIndices());
for (int i = 0; i < indices.length; i++) {
short indexI = indices[i];
if (handledIndices.get(indexI)) {
// Index handled in an earlier iteration
continue;
}
int vBufIndexI = indexI * vertexSize + positionOffset;
float xi = verticesBuffer.get(vBufIndexI++);
float yi = verticesBuffer.get(vBufIndexI++);
float zi = verticesBuffer.get(vBufIndexI++);
for (int j = i + 1; j < indices.length; j++) {
short indexJ = indices[j];
int vBufIndexJ = indexJ * vertexSize + positionOffset;
float xj = verticesBuffer.get(vBufIndexJ++);
float yj = verticesBuffer.get(vBufIndexJ++);
float zj = verticesBuffer.get(vBufIndexJ++);
if (xi == xj && yi == yj && zi == zj) {
indices[j] = indexI;
}
}
handledIndices.set(indexI);
}
return indices;
}
示例5: getRandomTriangle
import com.badlogic.gdx.utils.Bits; //导入方法依赖的package包/类
/**
* Get a random triangle on the navigation mesh, on any of the allowed mesh parts.
* The probability distribution is even in world space, as opposed to triangle index,
* meaning large triangles will be chosen more often than small ones.
* <p/>
* Example usage, to get a random point on the second navigation mesh part:
* allowedMeshParts.clear();
* allowedMeshParts.set(1);
* Triangle randomTri = navmesh.getRandomTriangle(allowedMeshParts);
* Vector3 randomPoint = new Vector3();
* randomTri.getRandomPoint(randomPoint);
*
* @param allowedMeshParts Bits representing allowed mesh part indices.
* @return A random triangle.
*/
public Triangle getRandomTriangle(Bits allowedMeshParts) {
tmpFloatArrayGetRandomTriangle.clear();
tmpFloatArrayGetRandomTriangle.ordered = true;
tmpTriArrayGetRandomTriangle.clear();
tmpTriArrayGetRandomTriangle.ordered = true;
// To get a uniform distribution over the triangles in the mesh parts
// we must take areas of the triangles into account.
for (int mpIndex = 0; mpIndex < graph.getMeshPartCount(); mpIndex++) {
if (allowedMeshParts.get(mpIndex)) {
for (int triIndex = 0; triIndex < graph.getTriangleCount(mpIndex); triIndex++) {
Triangle tri = graph.getTriangleFromMeshPart(mpIndex, triIndex);
float integratedArea = 0;
if (tmpFloatArrayGetRandomTriangle.size > 0) {
integratedArea = tmpFloatArrayGetRandomTriangle.get(tmpFloatArrayGetRandomTriangle.size - 1);
}
tmpFloatArrayGetRandomTriangle.add(integratedArea + tri.area());
tmpTriArrayGetRandomTriangle.add(tri);
}
}
}
if (tmpFloatArrayGetRandomTriangle.size == 0) {
return null;
}
float r = MathUtils.random(0f, tmpFloatArrayGetRandomTriangle.get(tmpFloatArrayGetRandomTriangle.size - 1));
int i;
for (i = 0; i < tmpFloatArrayGetRandomTriangle.size; i++) {
if (r <= tmpFloatArrayGetRandomTriangle.get(i)) {
break;
}
}
return tmpTriArrayGetRandomTriangle.get(i);
}
示例6: check
import com.badlogic.gdx.utils.Bits; //导入方法依赖的package包/类
/**
* Will check if the entity is of interest to this system.
* @param e entity to check
*/
protected final void check(Entity e) {
if(dummy) {
return;
}
boolean contains = e.getSystemBits().get(systemIndex);
boolean interested = true; // possibly interested, let's try to prove it wrong.
Bits componentBits = e.getComponentBits();
// Check if the entity possesses ALL of the components defined in the aspect.
if(!allSet.isEmpty()) {
for (int i = allSet.nextSetBit(0); i >= 0; i = allSet.nextSetBit(i+1)) {
if(!componentBits.get(i)) {
interested = false;
break;
}
}
}
// Check if the entity possesses ANY of the exclusion components, if it does then the system is not interested.
if(!exclusionSet.isEmpty() && interested) {
interested = !exclusionSet.intersects(componentBits);
}
// Check if the entity possesses ANY of the components in the oneSet. If so, the system is interested.
if(!oneSet.isEmpty()) {
interested = oneSet.intersects(componentBits);
}
if (interested && !contains) {
insertToSystem(e);
} else if (!interested && contains) {
removeFromSystem(e);
}
}
示例7: get
import com.badlogic.gdx.utils.Bits; //导入方法依赖的package包/类
@Override
protected boolean get(Bits bitSource, int index) {
return bitSource.get(index);
}
示例8: updateFamilyMembership
import com.badlogic.gdx.utils.Bits; //导入方法依赖的package包/类
public void updateFamilyMembership (Entity entity) {
// Find families that the entity was added to/removed from, and fill
// the bitmasks with corresponding listener bits.
Bits addListenerBits = bitsPool.obtain();
Bits removeListenerBits = bitsPool.obtain();
for (Family family : entityListenerMasks.keys()) {
final int familyIndex = family.getIndex();
final Bits entityFamilyBits = entity.getFamilyBits();
boolean belongsToFamily = entityFamilyBits.get(familyIndex);
boolean matches = family.matches(entity) && !entity.removing;
if (belongsToFamily != matches) {
final Bits listenersMask = entityListenerMasks.get(family);
final Array<Entity> familyEntities = families.get(family);
if (matches) {
addListenerBits.or(listenersMask);
familyEntities.add(entity);
entityFamilyBits.set(familyIndex);
} else {
removeListenerBits.or(listenersMask);
familyEntities.removeValue(entity, true);
entityFamilyBits.clear(familyIndex);
}
}
}
// Notify listeners; set bits match indices of listeners
notifying = true;
Object[] items = entityListeners.begin();
for (int i = removeListenerBits.nextSetBit(0); i >= 0; i = removeListenerBits.nextSetBit(i + 1)) {
((EntityListenerData)items[i]).listener.entityRemoved(entity);
}
for (int i = addListenerBits.nextSetBit(0); i >= 0; i = addListenerBits.nextSetBit(i + 1)) {
((EntityListenerData)items[i]).listener.entityAdded(entity);
}
addListenerBits.clear();
removeListenerBits.clear();
bitsPool.free(addListenerBits);
bitsPool.free(removeListenerBits);
entityListeners.end();
notifying = false;
}
示例9: is
import com.badlogic.gdx.utils.Bits; //导入方法依赖的package包/类
public boolean is(Bits rgmask) {
return (index < 0 && rgmask.isEmpty()) || rgmask.get(index);
}
示例10: updateFamilyMembership
import com.badlogic.gdx.utils.Bits; //导入方法依赖的package包/类
public void updateFamilyMembership (Entity entity) {
// Find families that the entity was added to/removed from, and fill
// the bitmasks with corresponding listener bits.
Bits addListenerBits = bitsPool.obtain();
Bits removeListenerBits = bitsPool.obtain();
for (Family family : entityListenerMasks.keys()) {
final int familyIndex = family.getIndex();
final Bits entityFamilyBits = entity.getFamilyBits();
boolean belongsToFamily = entityFamilyBits.get(familyIndex);
boolean matches = family.matches(entity) && !entity.removing;
if (belongsToFamily != matches) {
final Bits listenersMask = entityListenerMasks.get(family);
final Array<Entity> familyEntities = families.get(family);
if (matches) {
addListenerBits.or(listenersMask);
familyEntities.add(entity);
entityFamilyBits.set(familyIndex);
} else {
removeListenerBits.or(listenersMask);
familyEntities.removeValue(entity, true);
entityFamilyBits.clear(familyIndex);
}
}
}
// Notify listeners; set bits match indices of listeners
notifying = true;
Object[] items = entityListeners.begin();
try {
for (int i = removeListenerBits.nextSetBit(0); i >= 0; i = removeListenerBits.nextSetBit(i + 1)) {
((EntityListenerData)items[i]).listener.entityRemoved(entity);
}
for (int i = addListenerBits.nextSetBit(0); i >= 0; i = addListenerBits.nextSetBit(i + 1)) {
((EntityListenerData)items[i]).listener.entityAdded(entity);
}
}
finally {
addListenerBits.clear();
removeListenerBits.clear();
bitsPool.free(addListenerBits);
bitsPool.free(removeListenerBits);
entityListeners.end();
notifying = false;
}
}