mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-12-06 08:42:32 -08:00
Make filter dependent on tracker tps
Why was this in the wrong place wth
This commit is contained in:
1 parent
48c509ef54
commit
784ec877d8
2 files changed
+41
-43
No files matched your search
@@ -32,23 +32,23 @@ public class TrackersFiltersGUI extends EJBagNoStretch {
|
||||
private JLabel amountLabel, ticksLabel;
|
||||
|
||||
public TrackersFiltersGUI(VRServer server, VRServerGUI gui) {
|
||||
|
||||
|
||||
super(false, true);
|
||||
this.server = server;
|
||||
|
||||
|
||||
int row = 0;
|
||||
|
||||
|
||||
setAlignmentY(TOP_ALIGNMENT);
|
||||
add(Box.createVerticalStrut(10));
|
||||
|
||||
|
||||
filterType = server.config.getString("filters.type");
|
||||
if(filterType == null){
|
||||
if(filterType == null) {
|
||||
filterType = "NONE";
|
||||
}
|
||||
|
||||
|
||||
JComboBox<String> filterSelect;
|
||||
add(filterSelect = new JComboBox<>(), s(c(0, row, 2), 4, 1));
|
||||
|
||||
|
||||
for(TrackerFilters f : TrackerFilters.values()) {
|
||||
filterSelect.addItem(f.name());
|
||||
}
|
||||
@@ -57,7 +57,7 @@ public class TrackersFiltersGUI extends EJBagNoStretch {
|
||||
} else {
|
||||
filterSelect.setSelectedItem(TrackerFilters.NONE);
|
||||
}
|
||||
|
||||
|
||||
filterSelect.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
@@ -69,7 +69,7 @@ public class TrackersFiltersGUI extends EJBagNoStretch {
|
||||
});
|
||||
add(Box.createVerticalStrut(40));
|
||||
row++;
|
||||
|
||||
|
||||
filterAmount = (Float) FastMath.clamp(server.config.getFloat("filters.amount", 0.3f), 0, 1);
|
||||
|
||||
add(new JLabel("Intensity"), c(0, row, 2));
|
||||
@@ -77,47 +77,43 @@ public class TrackersFiltersGUI extends EJBagNoStretch {
|
||||
add(amountLabel = new JLabel(StringUtils.prettyNumber(filterAmount * 100f) + "%"), c(2, row, 2));
|
||||
add(new AdjButton("-", 0, true), c(3, row, 2));
|
||||
row++;
|
||||
|
||||
filterTicks = (int) FastMath.clamp(server.config.getInt("filters.tickCount", 2), 0, 80);
|
||||
|
||||
|
||||
filterTicks = (int) FastMath.clamp(server.config.getInt("filters.tickCount", 1), 0, 80);
|
||||
|
||||
add(new JLabel("Ticks"), c(0, row, 2));
|
||||
add(new AdjButton("+", 1, false), c(1, row, 2));
|
||||
add(ticksLabel = new JLabel(StringUtils.prettyNumber(filterTicks)), c(2, row, 2));
|
||||
add(new AdjButton("-", 1, true), c(3, row, 2));
|
||||
|
||||
|
||||
}
|
||||
|
||||
void updateTrackersFilters(){
|
||||
allTrackers = server.getAllTrackers();
|
||||
|
||||
void updateTrackersFilters() {
|
||||
IMUTracker imu;
|
||||
for (Tracker t : allTrackers) {
|
||||
for(Tracker t : server.getAllTrackers()) {
|
||||
Tracker realTracker = t;
|
||||
if(t instanceof ReferenceAdjustedTracker)
|
||||
realTracker = ((ReferenceAdjustedTracker<? extends Tracker>) t).getTracker();
|
||||
if(realTracker instanceof IMUTracker){
|
||||
imu = (IMUTracker)realTracker;
|
||||
realTracker = ((ReferenceAdjustedTracker<? extends Tracker>) t).getTracker();
|
||||
if(realTracker instanceof IMUTracker) {
|
||||
imu = (IMUTracker) realTracker;
|
||||
imu.setFilter(filterType, filterAmount, filterTicks);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void adjustValues(int cat, boolean neg){
|
||||
if(cat == 0){
|
||||
if(neg){
|
||||
|
||||
void adjustValues(int cat, boolean neg) {
|
||||
if(cat == 0) {
|
||||
if(neg) {
|
||||
filterAmount = (Float) FastMath.clamp(filterAmount - 0.1f, 0, 1);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
filterAmount = (Float) FastMath.clamp(filterAmount + 0.1f, 0, 1);
|
||||
}
|
||||
amountLabel.setText((StringUtils.prettyNumber(filterAmount * 100f)) + "%");
|
||||
server.config.setProperty("filters.amount", filterAmount);
|
||||
}
|
||||
else if(cat == 1){
|
||||
if(neg){
|
||||
filterTicks = (int) FastMath.clamp(filterTicks - 1, 0, 80);
|
||||
}
|
||||
else{
|
||||
filterTicks = (int) FastMath.clamp(filterTicks + 1, 0, 80);
|
||||
} else if(cat == 1) {
|
||||
if(neg) {
|
||||
filterTicks = (int) FastMath.clamp(filterTicks - 1, 0, 50);
|
||||
} else {
|
||||
filterTicks = (int) FastMath.clamp(filterTicks + 1, 0, 50);
|
||||
}
|
||||
ticksLabel.setText((StringUtils.prettyNumber(filterTicks)));
|
||||
server.config.setProperty("filters.tickCount", filterTicks);
|
||||
@@ -126,8 +122,9 @@ public class TrackersFiltersGUI extends EJBagNoStretch {
|
||||
server.saveConfig();
|
||||
updateTrackersFilters();
|
||||
}
|
||||
|
||||
private class AdjButton extends JButton {
|
||||
|
||||
|
||||
public AdjButton(String text, int category, boolean neg) {
|
||||
super(text);
|
||||
addMouseListener(new MouseInputAdapter() {
|
||||
|
||||
@@ -82,16 +82,16 @@ public class IMUTracker implements Tracker, TrackerWithTPS, TrackerWithBattery {
|
||||
rotAdjust.loadIdentity();
|
||||
}
|
||||
bodyPosition = TrackerPosition.getByDesignation(config.designation);
|
||||
setFilter(vrserver.config.getString("filters.type"), vrserver.config.getFloat("filters.amount", 0.3f), vrserver.config.getInt("filters.tickCount", 2));
|
||||
setFilter(vrserver.config.getString("filters.type"), vrserver.config.getFloat("filters.amount", 0.3f), vrserver.config.getInt("filters.tickCount", 1));
|
||||
}
|
||||
}
|
||||
public void setFilter(String type, float amount, int ticks){
|
||||
amount = FastMath.clamp(amount, 0, 1f);
|
||||
ticks = (int) FastMath.clamp(ticks, 0, 80);
|
||||
ticks = (int) FastMath.clamp(ticks, 0, 50);
|
||||
if(type != null){
|
||||
switch(type){
|
||||
case "INTERPOLATION":
|
||||
movementFilterAmount = 1f - (amount / 1.75f);
|
||||
movementFilterAmount = 1f - (amount / 1.6f);
|
||||
movementFilterTickCount = ticks;
|
||||
break;
|
||||
case "EXTRAPOLATION":
|
||||
@@ -134,12 +134,6 @@ public class IMUTracker implements Tracker, TrackerWithTPS, TrackerWithBattery {
|
||||
calculateLiveMagnetometerCorrection();
|
||||
}
|
||||
}
|
||||
if(movementFilterTickCount != 0){
|
||||
previousRots.add(rotQuaternion.clone());
|
||||
if(previousRots.size() > movementFilterTickCount){
|
||||
previousRots.remove(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -189,6 +183,13 @@ public class IMUTracker implements Tracker, TrackerWithTPS, TrackerWithBattery {
|
||||
@Override
|
||||
public void dataTick() {
|
||||
timer.update();
|
||||
|
||||
if(movementFilterTickCount != 0) {
|
||||
previousRots.add(rotQuaternion.clone());
|
||||
if(previousRots.size() > movementFilterTickCount) {
|
||||
previousRots.remove(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user