From cb33dac3b9bbe49239629bc482743fd561bafd52 Mon Sep 17 00:00:00 2001 From: ButterscotchVanilla Date: Tue, 14 Sep 2021 09:14:16 -0400 Subject: [PATCH] Handle getRotation and getPosition responses properly --- .../slimevr/vr/poserecorder/TrackerFrame.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/java/dev/slimevr/vr/poserecorder/TrackerFrame.java b/src/main/java/dev/slimevr/vr/poserecorder/TrackerFrame.java index f37c4ccc9..fc9a606af 100644 --- a/src/main/java/dev/slimevr/vr/poserecorder/TrackerFrame.java +++ b/src/main/java/dev/slimevr/vr/poserecorder/TrackerFrame.java @@ -43,23 +43,27 @@ public final class TrackerFrame implements Tracker { return null; } - boolean hasPosition = tracker.hasPosition() && tracker.getStatus() != TrackerStatus.OCCLUDED; // If tracker has no data - if (tracker.getBodyPosition() == null && !tracker.hasRotation() && !hasPosition) { + if (tracker.getBodyPosition() == null && !tracker.hasRotation() && !tracker.hasPosition()) { return null; } Quaternion rotation = null; if (tracker.hasRotation()) { rotation = new Quaternion(); - tracker.getRotation(rotation); + if (!tracker.getRotation(rotation)) { + // If getting the rotation failed, set it back to null + rotation = null; + } } - // If the tracker is occluded, don't get the position Vector3f position = null; - if (hasPosition) { + if (tracker.hasPosition()) { position = new Vector3f(); - tracker.getPosition(position); + if (!tracker.getPosition(position)) { + // If getting the position failed, set it back to null + position = null; + } } return new TrackerFrame(tracker.getBodyPosition(), rotation, position);