Skip to content

Commit

Permalink
AutoBone: Optimize PoseRecorder tick
Browse files Browse the repository at this point in the history
  • Loading branch information
ButterscotchV committed Aug 20, 2021
1 parent 3b61f88 commit 337912f
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions src/main/java/io/eiren/gui/autobone/PoseRecorder.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,23 @@ public PoseRecorder(VRServer server) {

@VRServerThread
public void onTick() {
HumanSkeletonWithLegs skeleton = this.skeleton;
if (skeleton != null) {
if (frames.size() < numFrames) {
if (System.currentTimeMillis() >= nextFrameTimeMs) {
nextFrameTimeMs = System.currentTimeMillis() + frameRecordingInterval;
frames.add(new PoseFrame(skeleton));

// If done, send finished recording
if (frames.size() >= numFrames) {
internalStopRecording();
if (numFrames > 0) {
HumanSkeletonWithLegs skeleton = this.skeleton;
if (skeleton != null) {
if (frames.size() < numFrames) {
if (System.currentTimeMillis() >= nextFrameTimeMs) {
nextFrameTimeMs = System.currentTimeMillis() + frameRecordingInterval;
frames.add(new PoseFrame(skeleton));

// If done, send finished recording
if (frames.size() >= numFrames) {
internalStopRecording();
}
}
} else {
// If done and hasn't yet, send finished recording
internalStopRecording();
}
} else {
// If done and hasn't yet, send finished recording
internalStopRecording();
}
}
}
Expand All @@ -60,6 +62,12 @@ public void skeletonUpdated(HumanSkeleton newSkeleton) {
}

public synchronized Future<PoseFrame[]> startFrameRecording(int numFrames, long interval) {
if (numFrames < 1) {
throw new IllegalArgumentException("numFrames must at least have a value of 1");
}
if (interval < 1) {
throw new IllegalArgumentException("interval must at least have a value of 1");
}
if (!isReadyToRecord()) {
throw new IllegalStateException("PoseRecorder isn't ready to record!");
}
Expand Down

0 comments on commit 337912f

Please sign in to comment.