@Test public void testHashcodeAndEquals() { Bits b1 = new Bits(); Bits b2 = new Bits(); b1.set(1); b2.set(1); assertEquals(b1.hashCode(), b2.hashCode()); assertTrue(b1.equals(b2)); // temporarily setting/clearing a single bit causing // the backing array to grow b2.set(420); b2.clear(420); assertEquals(b1.hashCode(), b2.hashCode()); assertTrue(b1.equals(b2)); b1.set(810); b1.clear(810); assertEquals(b1.hashCode(), b2.hashCode()); assertTrue(b1.equals(b2)); }
/** Creates a bit set whose initial size is large enough to explicitly represent bits with indices in the range 0 through * nbits-1. * @param nbits the initial size of the bit set */ public Bits (int nbits) { checkCapacity(nbits >>> 6); }
boolean contains = e.getSystemBits().get(systemIndex); boolean interested = true; // possibly interested, let's try to prove it wrong. if(!filter.allSet.isEmpty()) { for (int i = filter.allSet.nextSetBit(0); i >= 0; i = filter.allSet.nextSetBit(i+1)) { if(!componentBits.get(i)) { interested = false; break; if(interested && !filter.anySet.isEmpty()) { interested = filter.anySet.intersects(componentBits); if(interested && !filter.exclusionSet.isEmpty()) { interested = !filter.exclusionSet.intersects(componentBits);
private void setFromObject(BlenderObject object) { this.name = object.name; this.position = object.position; this.rotation = object.rotation; this.scale = object.scale; this.visibleOnLayers = new Bits(); for (int i = 0; i < object.layers.length; i++) { if (object.layers[i]) { this.visibleOnLayers.set(i); } } } @Override
/** * Adds the given render groups to the given Bits mask * * @param rgmask * The bit mask * @param rgs * The render groups * @return The bits instance */ public static Bits add(Bits rgmask, RenderGroup... rgs) { for (RenderGroup rg : rgs) { rgmask.set(rg.index); } return rgmask; }
@Override public float reportHit(Vector3 hitNormalLocal, float hitFraction, int partId, int triangleIndex) { if ((meshPartIndices == null || meshPartIndices.get(partId)) && hitFraction < this.hitFraction) { this.hitNormalLocal.set(hitNormalLocal); this.hitFraction = hitFraction; this.partId = partId; this.triangleIndex = triangleIndex; return hitFraction; } return 1; }
public void setVisibleLayers(Bits visibleLayers) { this.visibleLayers.clear(); this.visibleLayers.or(visibleLayers); layerController.setLayer(visibleLayers.nextClearBit(0) - 1); notifyObserversLayerChanged(this.visibleLayers); } }
/** * Remove Component of specified class for a given Entity. * * @param e Entity to remove the component for. * @param type Component class to remove. */ public void removeComponent(Entity e, Class<? extends Component> type) { int classIndex = getComponentClassIndex(type); if(e.getComponentBits().get(classIndex)) { e.getComponentBits().clear(classIndex); if (!componentsToDelete.containsKey(e)) { componentsToDelete.put(e, Pools.obtain(IntArray.class)); } componentsToDelete.get(e).add(classIndex); } }
/** * Clean up Components belonging to the Entity * @param e Entity to clear components for. */ public void removeComponentsOfEntity(Entity e) { Bits componentBits = e.getComponentBits(); for (int i = componentBits.nextSetBit(0); i >= 0; i = componentBits.nextSetBit(i+1)) { removeComponent(e.id, i); } componentBits.clear(); }
@Override public int hashCode() { final int word = length() >>> 6; int hash = 0; for (int i = 0; word >= i; i++) { hash = 127 * hash + (int)(bits[i] ^ (bits[i] >>> 32)); } return hash; }
/** * Checks if a model is visible using camera frustum culling and model layer visibility. * * @param camera * @param gameModel * @return */ private boolean isVisible(final Camera camera, final GameModel gameModel) { if (!gameModel.visibleOnLayers.intersects(engine.getVisibleLayers())) { return false; } gameModel.modelInstance.transform.getTranslation(tmp); tmp.add(gameModel.center); return camera.frustum.sphereInFrustum(tmp, gameModel.boundingBoxRadius); }