From 97818e1504b13fdd675be944960583baa095b06d Mon Sep 17 00:00:00 2001 From: Erimel Date: Tue, 3 Jan 2023 11:13:53 -0500 Subject: [PATCH] Switch rotation to orientation (#435) --- .../pages/mounting/ManualMounting.tsx | 2 +- .../trackers-assign/TrackerAssignment.tsx | 2 +- .../components/tracker/TrackerSettings.tsx | 2 +- .../config/CurrentVRConfigConverter.java | 33 +++++++++++++++---- .../dev/slimevr/config/TrackerConfig.java | 10 +++--- .../java/dev/slimevr/config/VRConfig.java | 2 +- .../protocol/datafeed/DataFeedBuilder.java | 4 +-- .../dev/slimevr/protocol/rpc/RPCHandler.java | 12 +++---- .../dev/slimevr/vr/trackers/IMUTracker.java | 12 +++---- solarxr-protocol | 2 +- 10 files changed, 50 insertions(+), 31 deletions(-) diff --git a/gui/src/components/onboarding/pages/mounting/ManualMounting.tsx b/gui/src/components/onboarding/pages/mounting/ManualMounting.tsx index d3e9618c8..6aebd5178 100644 --- a/gui/src/components/onboarding/pages/mounting/ManualMounting.tsx +++ b/gui/src/components/onboarding/pages/mounting/ManualMounting.tsx @@ -45,7 +45,7 @@ export function ManualMountingPage() { const assignreq = new AssignTrackerRequestT(); assignreq.bodyPosition = td.tracker.info?.bodyPart || BodyPart.NONE; - assignreq.mountingRotation = QuaternionToQuatT( + assignreq.mountingOrientation = QuaternionToQuatT( Quaternion.fromEuler(0, +mountingOrientation, 0) ); assignreq.trackerId = td.tracker.trackerId; diff --git a/gui/src/components/onboarding/pages/trackers-assign/TrackerAssignment.tsx b/gui/src/components/onboarding/pages/trackers-assign/TrackerAssignment.tsx index a9f187c3a..185d446b4 100644 --- a/gui/src/components/onboarding/pages/trackers-assign/TrackerAssignment.tsx +++ b/gui/src/components/onboarding/pages/trackers-assign/TrackerAssignment.tsx @@ -57,7 +57,7 @@ export function TrackersAssignPage() { const assignreq = new AssignTrackerRequestT(); assignreq.bodyPosition = role; - assignreq.mountingRotation = rotation; + assignreq.mountingOrientation = rotation; assignreq.trackerId = trackerId; sendRPCPacket(RpcMessage.AssignTrackerRequest, assignreq); }; diff --git a/gui/src/components/tracker/TrackerSettings.tsx b/gui/src/components/tracker/TrackerSettings.tsx index 3a21aa71a..f12b8c21e 100644 --- a/gui/src/components/tracker/TrackerSettings.tsx +++ b/gui/src/components/tracker/TrackerSettings.tsx @@ -59,7 +59,7 @@ export function TrackerSettingsPage() { const assignreq = new AssignTrackerRequestT(); - assignreq.mountingRotation = QuaternionToQuatT( + assignreq.mountingOrientation = QuaternionToQuatT( Quaternion.fromEuler( 0, 0, diff --git a/server/src/main/java/dev/slimevr/config/CurrentVRConfigConverter.java b/server/src/main/java/dev/slimevr/config/CurrentVRConfigConverter.java index c74484d67..f099d6533 100644 --- a/server/src/main/java/dev/slimevr/config/CurrentVRConfigConverter.java +++ b/server/src/main/java/dev/slimevr/config/CurrentVRConfigConverter.java @@ -19,13 +19,7 @@ public class CurrentVRConfigConverter implements VersionedModelConverter { int version = Integer.parseInt(modelVersion); // Configs with old versions need a migration to the latest config - if (version == 2) { - // Check for out-of-bound filtering amount - ObjectNode filtersNode = (ObjectNode) modelData.get("filters"); - if (filtersNode != null && filtersNode.get("amount").floatValue() > 2f) { - filtersNode.set("amount", new FloatNode(0.2f)); - } - } else if (version < 2) { + if (version < 2) { // Move zoom to the window config ObjectNode windowNode = (ObjectNode) modelData.get("window"); DoubleNode zoomNode = (DoubleNode) modelData.get("zoom"); @@ -83,6 +77,31 @@ public class CurrentVRConfigConverter implements VersionedModelConverter { modelData.remove("body"); } } + if (version < 3) { + // Check for out-of-bound filtering amount + ObjectNode filtersNode = (ObjectNode) modelData.get("filters"); + if (filtersNode != null && filtersNode.get("amount").floatValue() > 2f) { + filtersNode.set("amount", new FloatNode(0.2f)); + } + } + if (version < 4) { + // Change mountingRotation to mountingOrientation + ObjectNode oldTrackersNode = (ObjectNode) modelData.get("trackers"); + if (oldTrackersNode != null) { + var trackersIter = oldTrackersNode.iterator(); + var fieldNamesIter = oldTrackersNode.fieldNames(); + ObjectNode trackersNode = nodeFactory.objectNode(); + String fieldName; + while (trackersIter.hasNext()) { + ObjectNode node = (ObjectNode) trackersIter.next(); + fieldName = fieldNamesIter.next(); + node.set("mountingOrientation", node.get("mountingRotation")); + node.remove("mountingRotation"); + trackersNode.set(fieldName, node); + } + modelData.set("trackers", trackersNode); + } + } return modelData; } diff --git a/server/src/main/java/dev/slimevr/config/TrackerConfig.java b/server/src/main/java/dev/slimevr/config/TrackerConfig.java index 2992aeb94..38a964688 100644 --- a/server/src/main/java/dev/slimevr/config/TrackerConfig.java +++ b/server/src/main/java/dev/slimevr/config/TrackerConfig.java @@ -15,7 +15,7 @@ public class TrackerConfig { private Quaternion adjustment; - private Quaternion mountingRotation; + private Quaternion mountingOrientation; public TrackerConfig() { } @@ -73,11 +73,11 @@ public class TrackerConfig { this.adjustment = adjustment; } - public Quaternion getMountingRotation() { - return mountingRotation; + public Quaternion getMountingOrientation() { + return mountingOrientation; } - public void setMountingRotation(Quaternion mountingRotation) { - this.mountingRotation = mountingRotation; + public void setMountingOrientation(Quaternion mountingOrientation) { + this.mountingOrientation = mountingOrientation; } } diff --git a/server/src/main/java/dev/slimevr/config/VRConfig.java b/server/src/main/java/dev/slimevr/config/VRConfig.java index a782416f7..ace2b03fc 100644 --- a/server/src/main/java/dev/slimevr/config/VRConfig.java +++ b/server/src/main/java/dev/slimevr/config/VRConfig.java @@ -14,7 +14,7 @@ import java.util.Map; @JsonVersionedModel( - currentVersion = "3", defaultDeserializeToVersion = "3", toCurrentConverterClass = CurrentVRConfigConverter.class + currentVersion = "4", defaultDeserializeToVersion = "4", toCurrentConverterClass = CurrentVRConfigConverter.class ) public class VRConfig { diff --git a/server/src/main/java/dev/slimevr/protocol/datafeed/DataFeedBuilder.java b/server/src/main/java/dev/slimevr/protocol/datafeed/DataFeedBuilder.java index 3d33385e1..b37ed1cde 100644 --- a/server/src/main/java/dev/slimevr/protocol/datafeed/DataFeedBuilder.java +++ b/server/src/main/java/dev/slimevr/protocol/datafeed/DataFeedBuilder.java @@ -98,8 +98,8 @@ public class DataFeedBuilder { // TODO need support: TrackerInfo.addPollRate(fbb, tracker.); if (tracker instanceof IMUTracker imuTracker) { - if (imuTracker.getMountingRotation() != null) { - Quaternion quaternion = imuTracker.getMountingRotation(); + if (imuTracker.getMountingOrientation() != null) { + Quaternion quaternion = imuTracker.getMountingOrientation(); TrackerInfo .addMountingOrientation( fbb, diff --git a/server/src/main/java/dev/slimevr/protocol/rpc/RPCHandler.java b/server/src/main/java/dev/slimevr/protocol/rpc/RPCHandler.java index c0dc38f54..7ada2b664 100644 --- a/server/src/main/java/dev/slimevr/protocol/rpc/RPCHandler.java +++ b/server/src/main/java/dev/slimevr/protocol/rpc/RPCHandler.java @@ -191,15 +191,15 @@ public class RPCHandler extends ProtocolHandler TrackerPosition pos = TrackerPosition.getByBodyPart(req.bodyPosition()).orElse(null); tracker.setBodyPosition(pos); - if (req.mountingRotation() != null) { + if (req.mountingOrientation() != null) { if (tracker instanceof IMUTracker imu) { imu - .setMountingRotation( + .setMountingOrientation( new Quaternion( - req.mountingRotation().x(), - req.mountingRotation().y(), - req.mountingRotation().z(), - req.mountingRotation().w() + req.mountingOrientation().x(), + req.mountingOrientation().y(), + req.mountingOrientation().z(), + req.mountingOrientation().w() ) ); } diff --git a/server/src/main/java/dev/slimevr/vr/trackers/IMUTracker.java b/server/src/main/java/dev/slimevr/vr/trackers/IMUTracker.java index 25ff43a13..223f381e6 100644 --- a/server/src/main/java/dev/slimevr/vr/trackers/IMUTracker.java +++ b/server/src/main/java/dev/slimevr/vr/trackers/IMUTracker.java @@ -87,7 +87,7 @@ public class IMUTracker public void writeConfig(TrackerConfig config) { config.setDesignation(bodyPosition == null ? null : bodyPosition.designation); config - .setMountingRotation( + .setMountingOrientation( mounting != null ? mounting : new Quaternion().fromAngles(0, FastMath.PI, 0) ); config.setCustomName(customName); @@ -100,9 +100,9 @@ public class IMUTracker if (userEditable()) { setCustomName(config.getCustomName()); - if (config.getMountingRotation() != null) { - mounting = config.getMountingRotation(); - mountAdjust.set(config.getMountingRotation()); + if (config.getMountingOrientation() != null) { + mounting = config.getMountingOrientation(); + mountAdjust.set(config.getMountingOrientation()); } else { mountAdjust.loadIdentity(); } @@ -116,11 +116,11 @@ public class IMUTracker } } - public Quaternion getMountingRotation() { + public Quaternion getMountingOrientation() { return mounting; } - public void setMountingRotation(Quaternion mr) { + public void setMountingOrientation(Quaternion mr) { mounting = mr; if (mounting != null) { mountAdjust.set(mounting); diff --git a/solarxr-protocol b/solarxr-protocol index 24dc5b2fc..d96bf2136 160000 --- a/solarxr-protocol +++ b/solarxr-protocol @@ -1 +1 @@ -Subproject commit 24dc5b2fcbda3f70b74e4beba1eda7ae22baa0f5 +Subproject commit d96bf2136fd50b653799c9f3a925309798924272