private void transform(Entity entity) { Bag<Entity> children = tm.get(entity).getChildren(); SkeletonComponent skl = sm.get(entity); for (int i = 0, s = children.size(); s > i; i++) { TransformComponent childTC = tm.get(children.get(i)); childTC.getWorldTransform().set(childTC.getLocalTransform()); if (childTC.getJoint() != -1 && skl != null) { TempVars tempVars = TempVars.get(); skl.getCurrentPosesMatrices()[childTC.getJoint()].mult( skl.getBaseSkeleton().getJoints().get(childTC.getJoint()).base, tempVars.tempMat4); tempVars.tempMat4.toTranslationVector(tempVars.vect1); tempVars.tempMat4.toRotationQuat(tempVars.quat1); tempVars.tempMat4.toScaleVector(tempVars.vect2); tempVars.tempTF.set(tempVars.vect1, tempVars.quat1, tempVars.vect2); childTC.getWorldTransform().combineFromParent(tempVars.tempTF); tempVars.release(); } else { } childTC.getWorldTransform().combineFromParent(tm.get(entity).getWorldTransform()); transform(children.get(i)); } }
@Override protected void processEntities() { for (int i = 0, s = roots.size(); s > i; i++) { TransformComponent rootTC = tm.get(roots.get(i)); rootTC.getWorldTransform().set(rootTC.getLocalTransform()); transform(roots.get(i)); } }
@Override public void updatedComponentState(int entityId, int componentIndex, Object[] values) { for (int i = 0, n = _listeners.size(); i < n; ++i) { EntityTrackerCommunicator communicator = _listeners.get(i); communicator.updatedComponentState(entityId, componentIndex, values); } }
@Override public void addedComponentType(int index, ComponentTypeInfo info) { for (int i = 0, n = _listeners.size(); i < n; ++i) { EntityTrackerCommunicator communicator = _listeners.get(i); communicator.addedComponentType(index, info); } _componentTypes.set(index, info); }
@Override public void addedManager(String name) { for (int i = 0, n = _listeners.size(); i < n; ++i) { EntityTrackerCommunicator communicator = _listeners.get(i); communicator.addedManager(name); } _managers.add(name); }
@Override public void addedEntity(int entityId, BitSet components) { for (int i = 0, n = _listeners.size(); i < n; ++i) { EntityTrackerCommunicator communicator = _listeners.get(i); communicator.addedEntity(entityId, components); } _entities.put(entityId, components); }
@Override public void deletedEntity(int entityId) { for (int i = 0, n = _listeners.size(); i < n; ++i) { EntityTrackerCommunicator communicator = _listeners.get(i); communicator.deletedEntity(entityId); } _entities.remove(entityId); }
private static Bag<Class<? extends Component>> toClasses( Bag<Component> source, Bag<Class<? extends Component>> target) { for (int i = 0; i < source.size(); i++) { target.add(source.get(i).getClass()); } return target; }
/** Let framework take care of internal business. */ public void loopStart() { if (!refreshed.isEmpty()) { for (int i = 0; refreshed.size() > i; i++) { entityManager.refresh(refreshed.get(i)); } refreshed.clear(); } if (!deleted.isEmpty()) { for (int i = 0; deleted.size() > i; i++) { Entity e = deleted.get(i); groupManager.remove(e); entityManager.remove(e); } deleted.clear(); } }
@Override public void updatedEntitySystem(int systemIndex, int entitiesCount, int maxEntitiesCount) { for (int i = 0, n = _listeners.size(); i < n; ++i) { EntityTrackerCommunicator communicator = _listeners.get(i); communicator.updatedEntitySystem(systemIndex, entitiesCount, maxEntitiesCount); } _entitySystemsEntitiesCount.set(systemIndex, entitiesCount); _entitySystemsMaxEntitiesCount.set(systemIndex, maxEntitiesCount); }
@Override public void addedSystem( int index, String name, BitSet allTypes, BitSet oneTypes, BitSet notTypes) { for (int i = 0, n = _listeners.size(); i < n; ++i) { EntityTrackerCommunicator communicator = _listeners.get(i); communicator.addedSystem(index, name, allTypes, oneTypes, notTypes); } _systems.add(Tuple3.create(index, name, new AspectInfo(allTypes, oneTypes, notTypes))); _entitySystemsEntitiesCount.set(index, 0); _entitySystemsMaxEntitiesCount.set(index, 0); }
void synchronize(EntitySubscription es) { for (int i = 1; highestSeenIdentity >= i; i++) { BitSet componentBits = identityResolver.composition.get(i); es.processComponentIdentity(i, componentBits); } for (int i = 0; i < entities.size(); i++) { Entity e = entities.get(i); if (e != null && !disabled.get(e.id)) es.check(e.id); } es.informEntityChanges(); es.rebuildCompressedActives(); }
/** * Removes the entity from the manager, freeing it's id for new entities. * * @param entityId the entity to remove */ @Override public void deleted(int entityId) { Entity entity = entities.get(entityId); if (entity == null) return; entities.set(entityId, null); // usually never happens but: // this happens when an entity is deleted before // it is added to the world, ie; created and deleted // before World#process has been called newlyCreatedEntityIds.set(entityId, false); recyclingEntityFactory.free(entity); disabled.clear(entityId); }
private int forceResolveIdentity(int entityId) { updateCompositionIdentity(entities.get(entityId).edit()); return entityToIdentity.get(entityId); }
protected boolean isPackedComponent(int index) { return types.get(index).isPackedComponent(); }
protected Taxonomy getTaxonomy(int index) { return types.get(index).getTaxonomy(); }
/** * Gets the component type for the given component class. * * <p> * * @param c the component's class to get the type for * @return the component's {@link ComponentType} */ public ComponentType getTypeFor(int index) { return types.get(index); }
/** * Get a entity with this id. * * @param entityId the entities id * @return the entity */ protected Entity getEntity(int entityId) { return entities.get(entityId); }