Clean up Oculus View Manager update() method

empirephoenix-patch-1
Campbell Suter 8 years ago
parent 563c3eabff
commit 5df7f80c04
No known key found for this signature in database
GPG Key ID: 754A66CCF3F73C0F
  1. 24
      jme3-vr/src/main/java/com/jme3/util/VRViewManagerOculus.java

@ -45,6 +45,7 @@ import com.jme3.texture.*;
import java.nio.IntBuffer;
import java.util.Iterator;
import java.util.Objects;
import java.util.logging.Logger;
import org.lwjgl.ovr.*;
@ -75,6 +76,7 @@ public class VRViewManagerOculus extends AbstractVRViewManager {
this.environment = environment;
VRAPI hardware = environment.getVRHardware();
Objects.requireNonNull(hardware, "Attached VR Hardware cannot be null");
if (!(hardware instanceof OculusVR)) {
throw new IllegalStateException("Cannot use Oculus VR view manager on non-Oculus hardware state!");
}
@ -102,7 +104,10 @@ public class VRViewManagerOculus extends AbstractVRViewManager {
hardware.updatePose();
// TODO deduplicate
if (environment != null) {
if (environment == null) {
throw new IllegalStateException("This VR view manager is not attached to any VR environment.");
}
// grab the observer
Object obs = environment.getObserver();
Quaternion objRot;
@ -114,11 +119,9 @@ public class VRViewManagerOculus extends AbstractVRViewManager {
objRot = ((Spatial) obs).getWorldRotation();
objPos = ((Spatial) obs).getWorldTranslation();
}
// grab the hardware handle
VRAPI dev = environment.getVRHardware();
if (dev != null) {
// update the HMD's position & orientation
dev.getPositionAndOrientation(hmdPos, hmdRot);
hardware.getPositionAndOrientation(hmdPos, hmdRot);
if (obs != null) {
// update hmdPos based on obs rotation
finalRotation.set(objRot);
@ -126,12 +129,8 @@ public class VRViewManagerOculus extends AbstractVRViewManager {
finalRotation.multLocal(hmdRot);
}
finalizeCamera(dev.getHMDVectorPoseLeftEye(), objPos, leftCamera);
finalizeCamera(dev.getHMDVectorPoseRightEye(), objPos, rightCamera);
} else {
leftCamera.setFrame(objPos, objRot);
rightCamera.setFrame(objPos, objRot);
}
finalizeCamera(hardware.getHMDVectorPoseLeftEye(), objPos, leftCamera);
finalizeCamera(hardware.getHMDVectorPoseRightEye(), objPos, rightCamera);
if (environment.hasTraditionalGUIOverlay()) {
// update the mouse?
@ -143,9 +142,6 @@ public class VRViewManagerOculus extends AbstractVRViewManager {
environment.getVRGUIManager().updateGuiQuadGeometricState();
}
}
} else {
throw new IllegalStateException("This VR view manager is not attached to any VR environment.");
}
}
/**

Loading…
Cancel
Save