@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)); }
public Bits getVisibleLayers(Bits out) { out.clear(); out.or(visibleLayers); return out; }
/** * Sets the given Bits mask to the given render groups * * @param rgmask * The bit mask * @param rgs * The render groups * @return The bits instance */ public static Bits set(Bits rgmask, RenderGroup... rgs) { rgmask.clear(); return add(rgmask, rgs); }
@Override public void notifyLayerChanged(Bits layer) { visibleLayers.clear(); visibleLayers.or(layer); updateModelCache(visibleLayers); }
@Override public void notifyEntitySelected(GameCharacter entity) { selectedCharacter = entity; markerBillboard.setFollowTransform(entity.motionState.transform, entity.selectionMarkerOffset); markerBillboard.visibleOnLayers.clear(); markerBillboard.visibleOnLayers.or(entity.visibleOnLayers); }
/** * Finds the current triangle and sets the model to be visible on the same layer as mesh part index of current triangle * @param scene the game scene */ public void updateSteerableData(GameScene scene) { visibleOnLayers.clear(); visibleOnLayers.set(getCurrentTriangle(scene).meshPartIndex); }
/** * Make a ray test at this point, using a ray spanning from far up in the sky, to far down in the ground. * * @param testPoint The test point * @param out The point of intersection between ray and triangle * @param meshPartIndex Which mesh parts to test. * @return The triangle, or null if ray did not hit any triangles. */ public Triangle verticalRayTest(Vector3 testPoint, Vector3 out, int meshPartIndex) { tmpBitsVerticalRayTest.clear(); tmpBitsVerticalRayTest.set(meshPartIndex); return verticalRayTest(testPoint, out, tmpBitsVerticalRayTest); }
/** * Remove entity from the system. * * @param e Entity to remove. */ protected void removeFromSystem(Entity e) { actives.removeValue(e, true); e.getSystemBits().clear(systemIndex); removed(e); }
/** * Get a random triangle anywhere on the navigation mesh. * The probability distribution is even in world space, as opposed to triangle index, * meaning large triangles will be chosen more often than small ones. */ public Triangle getRandomTriangle() { tmpBitsGetRandomTriangle.clear(); for (int i = 0; i < graph.getMeshPartCount(); i++) { tmpBitsGetRandomTriangle.set(i); } return getRandomTriangle(tmpBitsGetRandomTriangle); }
public void setLayer(int layer) { layer = MathUtils.clamp(layer, minLayer, maxLayer); slider.setValue(layer); visibleLayers.clear(); for (int i = 0; i < layer; i++) { visibleLayers.set(i); } notifyObserversLayerChanged(visibleLayers); } }
/** * 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(); }
public void setVisibleLayers(Bits visibleLayers) { this.visibleLayers.clear(); this.visibleLayers.or(visibleLayers); layerController.setLayer(visibleLayers.nextClearBit(0) - 1); notifyObserversLayerChanged(this.visibleLayers); } }
public Stick spawnStick(String sharedBlueprintId, Vector3 initialPosition) { GameObjectBlueprint bp = sharedBlueprints.get(sharedBlueprintId); Stick obj = new Stick( bp.model, bp.name, initialPosition, bp.rotation, bp.scale, bp.shape, bp.mass, bp.belongsToFlag, bp.collidesWithFlag, bp.callback, bp.noDeactivate); obj.visibleOnLayers.clear(); obj.visibleOnLayers.or(bp.visibleOnLayers); addGameObject(obj); return obj; }
public GameModelBody spawnGameModelBody(GameObjectBlueprint bp, Vector3 initialPosition) { GameModelBody obj = new GameModelBody( bp.model, bp.name, initialPosition, bp.rotation, bp.scale, bp.shape, bp.mass, bp.belongsToFlag, bp.collidesWithFlag, bp.callback, bp.noDeactivate); obj.visibleOnLayers.clear(); obj.visibleOnLayers.or(bp.visibleOnLayers); if (bp.name.startsWith("door")) { btHingeConstraint hinge = new btHingeConstraint( obj.body, new Vector3(0, 0, -obj.halfExtents.z), Vector3.Y); hinge.enableAngularMotor(true, 0, 0.1f); obj.constraints.add(hinge); } addGameObject(obj); return obj; }
/** * 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); } }
obj.visibleOnLayers.clear(); obj.visibleOnLayers.or(bp.visibleOnLayers); addGameObject(obj);