Skip to content

Commit

Permalink
Tracking pause fixes (#721)
Browse files Browse the repository at this point in the history
  • Loading branch information
ButterscotchV authored Jun 15, 2023
1 parent 66214ba commit f7b4a60
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,29 @@ public void loadFromConfig(ConfigManager configManager) {
@VRServerThread
public void updateSkeletonModelFromServer() {
disconnectComputedHumanPoseTrackers();

// Make a new skeleton and store the old state
HumanSkeleton oldSkeleton = skeleton;
skeleton = new HumanSkeleton(this, server);

// Transfer the state of the old skeleton to the new one
if (oldSkeleton != null) {
skeleton.setPauseTracking(oldSkeleton.getPauseTracking());

// If paused, copy the pose to the new skeleton so it doesn't reset
// to t-pose each time
if (oldSkeleton.getPauseTracking()) {
TransformNode[] oldNodes = oldSkeleton.getAllNodes();
TransformNode[] newNodes = skeleton.getAllNodes();

for (int i = 0; i < newNodes.length; i++) {
newNodes[i]
.getLocalTransform()
.setRotation(oldNodes[i].getLocalTransform().getRotation());
}
}
}

// This recomputes all node offsets, so the defaults don't need to be
// explicitly loaded into the skeleton (no need for
// `updateNodeOffsetsInSkeleton()`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1270,7 +1270,7 @@ public TransformNode getRootNode() {
return hmdNode;
}

protected TransformNode[] getAllNodes() {
public TransformNode[] getAllNodes() {
return new TransformNode[] {
hmdNode,
headNode,
Expand Down Expand Up @@ -1568,6 +1568,11 @@ public boolean getPauseTracking() {
}

public void setPauseTracking(boolean pauseTracking) {
if (!pauseTracking && this.pauseTracking) {
// If unpausing tracking, clear the legtweaks buffer
legTweaks.resetBuffer();
}

this.pauseTracking = pauseTracking;
}
}

0 comments on commit f7b4a60

Please sign in to comment.