Skip to content

Commit

Permalink
Code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Eirenliel committed Dec 24, 2021
1 parent 7b15d24 commit e2d6189
Show file tree
Hide file tree
Showing 25 changed files with 534 additions and 543 deletions.
64 changes: 32 additions & 32 deletions src/main/java/dev/slimevr/autobone/AutoBone.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public String toString() {
// TODO Needs much more work, probably going to rethink how the errors work to avoid this barely functional workaround @ButterscotchVanilla
// For scaling distances, since smaller sizes will cause smaller distances
//private float totalLengthBase = 2f;

// Human average is probably 1.1235 (SD 0.07)
public float legBodyRatio = 1.1235f;
// SD of 0.07, capture 68% within range
Expand All @@ -83,10 +83,10 @@ public String toString() {
public final EnumMap<SkeletonConfigValue, Float> configs = new EnumMap<SkeletonConfigValue, Float>(SkeletonConfigValue.class);
public final EnumMap<SkeletonConfigValue, Float> staticConfigs = new EnumMap<SkeletonConfigValue, Float>(SkeletonConfigValue.class);

public final FastList<SkeletonConfigValue> heightConfigs = new FastList<SkeletonConfigValue>(new SkeletonConfigValue[] {
SkeletonConfigValue.NECK, SkeletonConfigValue.TORSO, SkeletonConfigValue.LEGS_LENGTH});
public final FastList<SkeletonConfigValue> lengthConfigs = new FastList<SkeletonConfigValue>(new SkeletonConfigValue[] {
SkeletonConfigValue.HEAD, SkeletonConfigValue.NECK, SkeletonConfigValue.TORSO, SkeletonConfigValue.HIPS_WIDTH, SkeletonConfigValue.LEGS_LENGTH});
public final FastList<SkeletonConfigValue> heightConfigs = new FastList<SkeletonConfigValue>(new SkeletonConfigValue[]{
SkeletonConfigValue.NECK, SkeletonConfigValue.TORSO, SkeletonConfigValue.LEGS_LENGTH});
public final FastList<SkeletonConfigValue> lengthConfigs = new FastList<SkeletonConfigValue>(new SkeletonConfigValue[]{
SkeletonConfigValue.HEAD, SkeletonConfigValue.NECK, SkeletonConfigValue.TORSO, SkeletonConfigValue.HIPS_WIDTH, SkeletonConfigValue.LEGS_LENGTH});

public AutoBone(VRServer server) {
this.server = server;
Expand Down Expand Up @@ -132,7 +132,7 @@ public void reloadConfigValues(List<PoseFrameTracker> trackers) {
staticConfigs.put(SkeletonConfigValue.HIPS_WIDTH, readFromConfig(SkeletonConfigValue.HIPS_WIDTH));
configs.put(SkeletonConfigValue.LEGS_LENGTH, readFromConfig(SkeletonConfigValue.LEGS_LENGTH));
configs.put(SkeletonConfigValue.KNEE_HEIGHT, readFromConfig(SkeletonConfigValue.KNEE_HEIGHT));

// Keep "feet" at ankles
staticConfigs.put(SkeletonConfigValue.FOOT_LENGTH, 0f);
staticConfigs.put(SkeletonConfigValue.FOOT_OFFSET, 0f);
Expand Down Expand Up @@ -177,7 +177,7 @@ private void setConfig(SkeletonConfigValue config) {

// This doesn't require a skeleton, therefore can be used if skeleton is null
public void saveConfigs() {
for (SkeletonConfigValue config : SkeletonConfigValue.values) {
for(SkeletonConfigValue config : SkeletonConfigValue.values) {
setConfig(config);
}

Expand All @@ -197,11 +197,11 @@ public Float getConfig(SkeletonConfigValue config, Map<SkeletonConfigValue, Floa
Float configVal = configs.get(config);
return configVal != null || configsAlt == null ? configVal : configsAlt.get(config);
}

public float sumSelectConfigs(List<SkeletonConfigValue> selection, Map<SkeletonConfigValue, Float> configs, Map<SkeletonConfigValue, Float> configsAlt) {
float sum = 0f;

for (SkeletonConfigValue config : selection) {
for(SkeletonConfigValue config : selection) {
Float length = getConfig(config, configs, configsAlt);
if(length != null) {
sum += length;
Expand All @@ -214,29 +214,29 @@ public float sumSelectConfigs(List<SkeletonConfigValue> selection, Map<SkeletonC
public float sumSelectConfigs(List<SkeletonConfigValue> selection, SkeletonConfig skeletonConfig) {
float sum = 0f;

for (SkeletonConfigValue config : selection) {
for(SkeletonConfigValue config : selection) {
sum += skeletonConfig.getConfig(config);
}

return sum;
}

public float getLengthSum(Map<SkeletonConfigValue, Float> configs) {
return getLengthSum(configs, null);
}

public float getLengthSum(Map<SkeletonConfigValue, Float> configs, Map<SkeletonConfigValue, Float> configsAlt) {
float length = 0f;

if (configsAlt != null) {
if(configsAlt != null) {
for(Entry<SkeletonConfigValue, Float> config : configsAlt.entrySet()) {
// If there isn't a duplicate config
if (!configs.containsKey(config.getKey())) {
if(!configs.containsKey(config.getKey())) {
length += config.getValue();
}
}
}

for(Float boneLength : configs.values()) {
length += boneLength;
}
Expand Down Expand Up @@ -277,7 +277,7 @@ public float processFrames(PoseFrames frames, boolean calcInitError, float targe

public float processFrames(PoseFrames frames, boolean calcInitError, float targetHeight, Consumer<Epoch> epochCallback) {
final int frameCount = frames.getMaxFrameCount();

List<PoseFrameTracker> trackers = frames.getTrackers();
reloadConfigValues(trackers); // Reload configs and detect chest tracker from the first frame

Expand Down Expand Up @@ -311,13 +311,13 @@ public float processFrames(PoseFrames frames, boolean calcInitError, float targe
for(int cursorOffset = minDataDistance; cursorOffset <= maxDataDistance && cursorOffset < frameCount; cursorOffset++) {
for(int frameCursor = 0; frameCursor < frameCount - cursorOffset; frameCursor += cursorIncrement) {
int frameCursor2 = frameCursor + cursorOffset;

skeleton1.skeletonConfig.setConfigs(configs, null);
skeleton2.skeletonConfig.setConfigs(configs, null);

skeleton1.setCursor(frameCursor);
skeleton1.updatePose();

skeleton2.setCursor(frameCursor2);
skeleton2.updatePose();

Expand Down Expand Up @@ -348,7 +348,7 @@ public float processFrames(PoseFrames frames, boolean calcInitError, float targe
float adjustVal = error * adjustRate;

// If there is no adjustment whatsoever, skip this
if (adjustVal == 0f) {
if(adjustVal == 0f) {
continue;
}

Expand Down Expand Up @@ -420,21 +420,21 @@ protected float getSlideErrorDeriv(PoseFrameSkeleton skeleton1, PoseFrameSkeleto
// Divide by 4 to halve and average, it's halved because you want to approach a midpoint, not the other point
return (slideLeft + slideRight) / 4f;
}

// The change in distance between both of the ankles over time
protected float getOffsetSlideErrorDeriv(PoseFrameSkeleton skeleton1, PoseFrameSkeleton skeleton2) {
Vector3f leftFoot1 = skeleton1.getComputedTracker(TrackerRole.LEFT_FOOT).position;
Vector3f rightFoot1 = skeleton1.getComputedTracker(TrackerRole.RIGHT_FOOT).position;

Vector3f leftFoot2 = skeleton2.getComputedTracker(TrackerRole.LEFT_FOOT).position;
Vector3f rightFoot2 = skeleton2.getComputedTracker(TrackerRole.RIGHT_FOOT).position;

float slideDist1 = leftFoot1.distance(rightFoot1);
float slideDist2 = leftFoot2.distance(rightFoot2);

float slideDist3 = leftFoot1.distance(rightFoot2);
float slideDist4 = leftFoot2.distance(rightFoot1);

float dist1 = FastMath.abs(slideDist1 - slideDist2);
float dist2 = FastMath.abs(slideDist3 - slideDist4);

Expand All @@ -452,7 +452,7 @@ protected float getOffsetSlideErrorDeriv(PoseFrameSkeleton skeleton1, PoseFrameS
protected float getOffsetErrorDeriv(PoseFrameSkeleton skeleton1, PoseFrameSkeleton skeleton2) {
float leftFoot1 = skeleton1.getComputedTracker(TrackerRole.LEFT_FOOT).position.getY();
float rightFoot1 = skeleton1.getComputedTracker(TrackerRole.RIGHT_FOOT).position.getY();

float leftFoot2 = skeleton2.getComputedTracker(TrackerRole.LEFT_FOOT).position.getY();
float rightFoot2 = skeleton2.getComputedTracker(TrackerRole.RIGHT_FOOT).position.getY();

Expand All @@ -476,7 +476,7 @@ protected float getProportionErrorDeriv(SkeletonConfig skeleton) {
float torsoLength = skeleton.getConfig(SkeletonConfigValue.TORSO);
float legsLength = skeleton.getConfig(SkeletonConfigValue.LEGS_LENGTH);
float kneeHeight = skeleton.getConfig(SkeletonConfigValue.KNEE_HEIGHT);

float chestTorso = FastMath.abs((chestLength / torsoLength) - chestTorsoRatio);
float legBody = FastMath.abs((legsLength / (torsoLength + neckLength)) - legBodyRatio);
float kneeLeg = FastMath.abs((kneeHeight / legsLength) - kneeLegRatio);
Expand All @@ -496,9 +496,9 @@ protected float getPositionErrorDeriv(PoseFrames frames, int cursor, PoseFrameSk
int offsetCount = 0;

List<PoseFrameTracker> trackers = frames.getTrackers();
for (int i = 0; i < trackers.size(); i++) {
for(int i = 0; i < trackers.size(); i++) {
PoseFrameTracker tracker = trackers.get(i);

TrackerFrame trackerFrame = tracker.safeGetFrame(cursor);
if(trackerFrame == null || !trackerFrame.hasData(TrackerFrameData.POSITION)) {
continue;
Expand All @@ -520,9 +520,9 @@ protected float getPositionOffsetErrorDeriv(PoseFrames frames, int cursor1, int
int offsetCount = 0;

List<PoseFrameTracker> trackers = frames.getTrackers();
for (int i = 0; i < trackers.size(); i++) {
for(int i = 0; i < trackers.size(); i++) {
PoseFrameTracker tracker = trackers.get(i);

TrackerFrame trackerFrame1 = tracker.safeGetFrame(cursor1);
if(trackerFrame1 == null || !trackerFrame1.hasData(TrackerFrameData.POSITION)) {
continue;
Expand Down Expand Up @@ -561,7 +561,7 @@ protected float getErrorDeriv(PoseFrames frames, int cursor1, int cursor2, PoseF
totalError += getSlideErrorDeriv(skeleton1, skeleton2) * distScale * slideErrorFactor;
sumWeight += slideErrorFactor;
}

if(offsetSlideErrorFactor > 0f) {
totalError += getOffsetSlideErrorDeriv(skeleton1, skeleton2) * distScale * offsetSlideErrorFactor;
sumWeight += offsetSlideErrorFactor;
Expand Down Expand Up @@ -605,7 +605,7 @@ protected static float errorFunc(float errorDeriv) {
protected void updateSkeletonBoneLength(PoseFrameSkeleton skeleton1, PoseFrameSkeleton skeleton2, SkeletonConfigValue config, float newLength) {
skeleton1.skeletonConfig.setConfig(config, newLength);
skeleton1.updatePoseAffectedByConfig(config);

skeleton2.skeletonConfig.setConfig(config, newLength);
skeleton2.updatePoseAffectedByConfig(config);
}
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/dev/slimevr/gui/AbstractComponentListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,4 @@ public void componentShown(ComponentEvent e) {
@Override
public void componentHidden(ComponentEvent e) {
}

}
}
2 changes: 1 addition & 1 deletion src/main/java/dev/slimevr/gui/AbstractWindowListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ public void windowActivated(WindowEvent e) {
@Override
public void windowDeactivated(WindowEvent e) {
}
}
}
18 changes: 7 additions & 11 deletions src/main/java/dev/slimevr/gui/Keybinding.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ public class Keybinding implements HotkeyListener {
public final VRServer server;
private static final int RESET = 1;
private static final int QUICK_RESET = 2;

@AWTThread
public Keybinding(VRServer server) {
this.server = server;

try {
if(JIntellitype.getInstance() instanceof JIntellitype) {
JIntellitype.getInstance().addHotKeyListener(this);

String resetBinding = this.server.config.getString("keybindings.reset");
if(resetBinding == null) {
resetBinding = "CTRL+ALT+SHIFT+Y";
this.server.config.setProperty("keybindings.reset", resetBinding);
}
JIntellitype.getInstance().registerHotKey(RESET, resetBinding);
LogManager.log.info("[Keybinding] Bound reset to " + resetBinding);

String quickResetBinding = this.server.config.getString("keybindings.quickReset");
if(quickResetBinding == null) {
quickResetBinding = "CTRL+ALT+SHIFT+U";
Expand All @@ -38,17 +38,13 @@ public Keybinding(VRServer server) {
JIntellitype.getInstance().registerHotKey(QUICK_RESET, quickResetBinding);
LogManager.log.info("[Keybinding] Bound quick reset to " + quickResetBinding);
}
}
catch (JIntellitypeException je)
{
} catch(JIntellitypeException je) {
LogManager.log.info("[Keybinding] JIntellitype initialization failed. Keybindings will be disabled. Try restarting your computer.");
}
catch (ExceptionInInitializerError e)
{
} catch(ExceptionInInitializerError e) {
LogManager.log.info("[Keybinding] JIntellitype initialization failed. Keybindings will be disabled. Try restarting your computer.");
}
}

@AWTThread
@Override
public void onHotKey(int identifier) {
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/dev/slimevr/gui/ScalableFont.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public ScalableFont(Font font) {
super(font);

if(font instanceof ScalableFont) {
ScalableFont sourceFont = (ScalableFont)font;
ScalableFont sourceFont = (ScalableFont) font;

this.initSize = sourceFont.getInitSize();
this.initPointSize = sourceFont.getInitSize2D();
Expand All @@ -39,7 +39,7 @@ public ScalableFont(Font font, float scale) {
super(font);

if(font instanceof ScalableFont) {
ScalableFont sourceFont = (ScalableFont)font;
ScalableFont sourceFont = (ScalableFont) font;

this.initSize = sourceFont.getInitSize();
this.initPointSize = sourceFont.getInitSize2D();
Expand Down Expand Up @@ -84,8 +84,7 @@ private void setScale(float scale) {

float newPointSize = initPointSize * scale;

this.size = (int)(newPointSize + 0.5);
this.size = (int) (newPointSize + 0.5);
this.pointSize = newPointSize;
}

}
1 change: 0 additions & 1 deletion src/main/java/dev/slimevr/poserecorder/PoseFrameIO.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public static boolean writeFrames(DataOutputStream outputStream, PoseFrames fram
if(frames != null) {
outputStream.writeInt(frames.getTrackerCount());
for(PoseFrameTracker tracker : frames.getTrackers()) {

outputStream.writeUTF(tracker.name);
outputStream.writeInt(tracker.getFrameCount());
for(int i = 0; i < tracker.getFrameCount(); i++) {
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/dev/slimevr/poserecorder/PoseFrameSkeleton.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,29 @@
import dev.slimevr.vr.trackers.Tracker;

public class PoseFrameSkeleton extends SimpleSkeleton {

private int frameCursor = 0;

protected PoseFrameSkeleton(List<? extends ComputedHumanPoseTracker> computedTrackers) {
super(computedTrackers);
}

public PoseFrameSkeleton(VRServer server, List<? extends ComputedHumanPoseTracker> computedTrackers) {
super(server, computedTrackers);
}

public PoseFrameSkeleton(List<? extends Tracker> trackers, List<? extends ComputedHumanPoseTracker> computedTrackers) {
super(trackers, computedTrackers);
}

public PoseFrameSkeleton(List<? extends Tracker> trackers, List<? extends ComputedHumanPoseTracker> computedTrackers, Map<SkeletonConfigValue, Float> configs, Map<SkeletonConfigValue, Float> altConfigs) {
super(trackers, computedTrackers, configs, altConfigs);
}

public PoseFrameSkeleton(List<? extends Tracker> trackers, List<? extends ComputedHumanPoseTracker> computedTrackers, Map<SkeletonConfigValue, Float> configs) {
super(trackers, computedTrackers, configs);
}

private int limitCursor() {
if(frameCursor < 0) {
frameCursor = 0;
Expand All @@ -58,13 +58,13 @@ public int incrementCursor() {
public int getCursor() {
return frameCursor;
}

// Get tracker for specific frame
@Override
protected Tracker trackerPreUpdate(Tracker tracker) {
if (tracker instanceof PoseFrameTracker) {
if(tracker instanceof PoseFrameTracker) {
// Return frame if available, otherwise return the original tracker
TrackerFrame frame = ((PoseFrameTracker)tracker).safeGetFrame(frameCursor);
TrackerFrame frame = ((PoseFrameTracker) tracker).safeGetFrame(frameCursor);
return frame == null ? tracker : frame;
}
return tracker;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public boolean isComputed() {
public Iterator<TrackerFrame> iterator() {
return frames.iterator();
}

@Override
public int getTrackerId() {
return this.trackerId;
Expand Down
Loading

0 comments on commit e2d6189

Please sign in to comment.