Search in sources :

Example 1 with AppTask

use of com.jme3.app.AppTask in project jmonkeyengine by jMonkeyEngine.

the class PhysicsSpace method preTick_native.

private void preTick_native(float f) {
    AppTask task = pQueue.poll();
    task = pQueue.poll();
    while (task != null) {
        while (task.isCancelled()) {
            task = pQueue.poll();
        }
        try {
            task.invoke();
        } catch (Exception ex) {
            logger.log(Level.SEVERE, null, ex);
        }
        task = pQueue.poll();
    }
    for (Iterator<PhysicsTickListener> it = tickListeners.iterator(); it.hasNext(); ) {
        PhysicsTickListener physicsTickCallback = it.next();
        physicsTickCallback.prePhysicsTick(this, f);
    }
}
Also used : AppTask(com.jme3.app.AppTask)

Example 2 with AppTask

use of com.jme3.app.AppTask in project jmonkeyengine by jMonkeyEngine.

the class PhysicsSpace method setTickCallback.

private void setTickCallback() {
    final PhysicsSpace space = this;
    InternalTickCallback callback2 = new InternalTickCallback() {

        @Override
        public void internalTick(DynamicsWorld dw, float f) {
            //execute task list
            AppTask task = pQueue.poll();
            task = pQueue.poll();
            while (task != null) {
                while (task.isCancelled()) {
                    task = pQueue.poll();
                }
                try {
                    task.invoke();
                } catch (Exception ex) {
                    logger.log(Level.SEVERE, null, ex);
                }
                task = pQueue.poll();
            }
            for (Iterator<PhysicsTickListener> it = tickListeners.iterator(); it.hasNext(); ) {
                PhysicsTickListener physicsTickCallback = it.next();
                physicsTickCallback.prePhysicsTick(space, f);
            }
        }
    };
    dynamicsWorld.setPreTickCallback(callback2);
    InternalTickCallback callback = new InternalTickCallback() {

        @Override
        public void internalTick(DynamicsWorld dw, float f) {
            for (Iterator<PhysicsTickListener> it = tickListeners.iterator(); it.hasNext(); ) {
                PhysicsTickListener physicsTickCallback = it.next();
                physicsTickCallback.physicsTick(space, f);
            }
        }
    };
    dynamicsWorld.setInternalTickCallback(callback, this);
}
Also used : AppTask(com.jme3.app.AppTask) InternalTickCallback(com.bulletphysics.dynamics.InternalTickCallback) DiscreteDynamicsWorld(com.bulletphysics.dynamics.DiscreteDynamicsWorld) DynamicsWorld(com.bulletphysics.dynamics.DynamicsWorld)

Aggregations

AppTask (com.jme3.app.AppTask)2 DiscreteDynamicsWorld (com.bulletphysics.dynamics.DiscreteDynamicsWorld)1 DynamicsWorld (com.bulletphysics.dynamics.DynamicsWorld)1 InternalTickCallback (com.bulletphysics.dynamics.InternalTickCallback)1