Search in sources :

Example 1 with IntBag

use of com.artemis.utils.IntBag in project nhglib by VoidZombie.

the class ThreadedIteratingSystem method processSystem.

@Override
protected final void processSystem() {
    IntBag actives = subscription.getEntities();
    int activesSize = actives.size();
    if (activesSize > 0) {
        int previousSplit = split;
        split = MathUtils.ceil((float) actives.size() / (float) Threading.cores);
        int previousRows = rows;
        if (activesSize > Threading.cores) {
            rows = Threading.cores;
        } else {
            rows = activesSize;
        }
        if (previousRows != rows) {
            threading.setLatchCount(latchId, rows);
        }
        if (previousRows != rows || previousSplit != split) {
            splitEntities = new int[rows][split];
            int from;
            int to;
            int[] data = actives.getData();
            for (int i = 0; i < rows; i++) {
                if (split == 1) {
                    splitEntities[i][0] = data[i];
                } else {
                    from = i * split;
                    to = from + split;
                    splitEntities[i] = Arrays.copyOfRange(data, from, to);
                }
                if (i > 0) {
                    postProcessList(splitEntities[i]);
                }
            }
        }
        for (int i = 0; i < rows; i++) {
            threading.execute(new ProcessWork(splitEntities[i]));
        }
        threading.awaitLatch(latchId);
    }
}
Also used : IntBag(com.artemis.utils.IntBag)

Example 2 with IntBag

use of com.artemis.utils.IntBag in project nhglib by VoidZombie.

the class PhysicsSystem method dispose.

@Override
public void dispose() {
    IntBag entityIds = getEntityIds();
    for (int entity : entityIds.getData()) {
        RigidBodyComponent bodyComponent = rigidBodyMapper.get(entity);
        if (bodyComponent != null) {
            bodyComponent.dispose();
        }
    }
    dynamicsWorld.dispose();
    constraintSolver.dispose();
    collisionConfiguration.dispose();
    collisionDispatcher.dispose();
    dbvtBroadphase.dispose();
}
Also used : RigidBodyComponent(io.github.voidzombie.nhglib.runtime.ecs.components.physics.RigidBodyComponent) IntBag(com.artemis.utils.IntBag)

Aggregations

IntBag (com.artemis.utils.IntBag)2 RigidBodyComponent (io.github.voidzombie.nhglib.runtime.ecs.components.physics.RigidBodyComponent)1