- An attempt at chase cam smoothing. needs work.

tags : #story[1273]
This commit is contained in:
Alistair McIntyre
2017-09-25 14:39:09 +13:00
parent a19e191684
commit e66abb4340
2 changed files with 46 additions and 3 deletions
@@ -65,6 +65,7 @@ public class ClientYacht extends Observable {
private ReadOnlyLongWrapper timeTillNextProperty = new ReadOnlyLongWrapper();
private ReadOnlyLongWrapper timeSinceLastMarkProperty = new ReadOnlyLongWrapper();
private ReadOnlyIntegerWrapper placingProperty = new ReadOnlyIntegerWrapper();
private ReadOnlyDoubleWrapper headingProperty = new ReadOnlyDoubleWrapper();
private Color colour;
public ClientYacht(String boatType, Integer sourceId, String hullID, String shortName,
@@ -224,6 +225,7 @@ public class ClientYacht extends Observable {
public void setHeading(Double heading) {
this.heading = heading;
setHeadingProperty();
}
@Override
@@ -256,6 +258,7 @@ public class ClientYacht extends Observable {
public void updateLocation(double lat, double lng, double heading, double velocity) {
setLocation(lat, lng);
this.heading = heading;
setHeadingProperty();
this.currentVelocity = velocity;
updateVelocityProperty(velocity);
for (YachtLocationListener yll : locationListeners) {
@@ -263,6 +266,15 @@ public class ClientYacht extends Observable {
}
}
private void setHeadingProperty() {
Double oldHeading = getHeadingProperty().get();
Double currHeading = heading;
while (oldHeading.equals(currHeading)) {
oldHeading++;
headingProperty.set(oldHeading);
}
}
public void addLocationListener(YachtLocationListener listener) {
locationListeners.add(listener);
}
@@ -299,4 +311,10 @@ public class ClientYacht extends Observable {
public BoatObject getBoatObject() {
return this.boatObject;
}
public ReadOnlyDoubleWrapper getHeadingProperty() {
return headingProperty;
}
}