Ill be using client server so it should not be a problem, at least server side, unless they hold it to long and get booted because it looks like a dropped connection.[quote=“pspeed, post:13, topic:39003”]
I think things like Bullet still update correctly even if no frames are rendered. At least I’d hope so (else it’s broken).
[/quote]
This does happen for everything else like minimize, just not when pressing the title bar. I know the update loops and listeners don’t fire so I think the entire program is frozen until key release. It starts up right where it stopped processing input.
This is the test case I wrote. If you click-hold the title bar, program will freeze and when released the ball will restart from right where it stopped. At least for me it does.
package mygame;
import com.jme3.app.LostFocusBehavior;
import com.jme3.app.SimpleApplication;
import com.jme3.bullet.BulletAppState;
import com.jme3.bullet.control.BetterCharacterControl;
import com.jme3.bullet.control.RigidBodyControl;
import com.jme3.input.controls.ActionListener;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort;
import com.jme3.scene.Geometry;
import com.jme3.scene.control.AbstractControl;
import com.jme3.scene.shape.Box;
import com.jme3.scene.shape.Sphere;
/**
* This is the Main Class of your Game. You should only do initialization here.
* Move your Logic into AppStates or Controls
*
* @author normenhansen
*/
public class Main extends SimpleApplication {
private final float moveSpeed = 3f;
public static void main(String[] args) {
Main app = new Main();
app.setLostFocusBehavior(LostFocusBehavior.Disabled);
app.start();
}
@Override
public void simpleInitApp() {
BulletAppState bas = new BulletAppState();
getStateManager().attach(bas);
flyCam.setEnabled(false);
Sphere sphere = new Sphere(32, 32, 1f);
Geometry geom = new Geometry("Sphere", sphere);
geom.setLocalTranslation(new Vector3f(-4f, .0f, 0f));
Material mat2 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat2.setColor("Color", ColorRGBA.Yellow);
geom.setMaterial(mat2);
geom.addControl(new SphereCharControl(1f, 2f, 1f));
bas.getPhysicsSpace().add(geom);
geom.addControl(new MoveSphereControl());
geom.getControl(MoveSphereControl.class).moveTo(new Vector3f(4f, 0f, 0f));
rootNode.attachChild(geom);
Box boxMesh = new Box(10f, 0f, 10f);
Geometry boxGeo = new Geometry("Box", boxMesh);
boxGeo.setLocalTranslation(new Vector3f(0f, 0f, 0f));
Material boxMat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
boxMat.setColor("Color", ColorRGBA.Green);
boxGeo.setMaterial(boxMat);
boxGeo.addControl(new RigidBodyControl(0f));
bas.getPhysicsSpace().add(boxGeo);
rootNode.attachChild(boxGeo);
}
@Override
public void simpleUpdate(float tpf) {
//TODO: add update code
}
@Override
public void simpleRender(RenderManager rm) {
//TODO: add render code
}
private class SphereCharControl extends BetterCharacterControl implements ActionListener {
private boolean forward;
public SphereCharControl(float radius, float height, float mass) {
super(radius, height, mass);
}
@Override
public void update(float tpf) {
super.update(tpf);
Vector3f modelForwardDir = spatial.getWorldRotation().mult(Vector3f.UNIT_Z);
walkDirection.set(0, 0, 0);
if (forward) {
walkDirection.addLocal(modelForwardDir.mult(moveSpeed));
}
setWalkDirection(walkDirection);
}
@Override
public void onAction(String name, boolean isPressed, float tpf) {
if (name.equals("MoveForward")) {
forward = isPressed;
}
}
}
private class MoveSphereControl extends AbstractControl {
private Vector3f target;
@Override
protected void controlUpdate(float tpf) {
Vector3f spatialPosition = spatial.getWorldTranslation();
Vector3f distance = spatialPosition.subtract(target);
if (distance.length() > 1) {
Vector3f direction = target.subtract(spatialPosition);
direction.mult(tpf);
spatial.getControl(SphereCharControl.class).setViewDirection(new Vector3f(direction).normalize());
spatial.getControl(SphereCharControl.class).onAction("MoveForward", true, 1);
} else {
target.negateLocal();
this.moveTo(target);
}
}
@Override
protected void controlRender(RenderManager rm, ViewPort vp) {
}
public void moveTo(Vector3f target) {
this.target = target;
}
}
}