Add linear interpolation to simplepathing

This commit is contained in:
johni0702
2016-09-03 13:32:17 +02:00
parent dca1131d49
commit ef00c45068
4 changed files with 15 additions and 1 deletions

View File

@@ -3,6 +3,7 @@ package com.replaymod.simplepathing;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import com.replaymod.core.ReplayMod;
import com.replaymod.core.events.SettingsChangedEvent;
import com.replaymod.pathing.properties.CameraProperties;
import com.replaymod.pathing.properties.SpectatorProperty;
import com.replaymod.pathing.properties.TimestampProperty;
@@ -62,6 +63,15 @@ public class ReplayModSimplePathing implements PathingRegistry {
selectedKeyframe = null;
}
@SubscribeEvent
public void onSettingsChanged(SettingsChangedEvent event) {
if (event.getKey() == Setting.LINEAR_INTERPOLATION) {
if (currentTimeline != null && guiPathing != null) {
currentTimeline.applyChange(guiPathing.updateInterpolators());
}
}
}
private Timeline currentTimeline = createTimeline(); { currentTimeline.createPath(); currentTimeline.createPath(); }
private Keyframe selectedKeyframe;

View File

@@ -4,6 +4,7 @@ import com.replaymod.core.SettingsRegistry;
public final class Setting<T> extends SettingsRegistry.SettingKeys<T> {
public static final Setting<Boolean> PATH_PREVIEW = make("pathpreview", "pathpreview", true);
public static final Setting<Boolean> LINEAR_INTERPOLATION = make("linear_interpolation", "linearinterpolation", false);
private static <T> Setting<T> make(String key, String displayName, T defaultValue) {
return new Setting<>(key, displayName, defaultValue);

View File

@@ -26,6 +26,7 @@ import com.replaymod.replaystudio.pathing.property.Property;
import com.replaymod.replaystudio.util.EntityPositionTracker;
import com.replaymod.replaystudio.util.Location;
import com.replaymod.simplepathing.ReplayModSimplePathing;
import com.replaymod.simplepathing.Setting;
import de.johni0702.minecraft.gui.GuiRenderer;
import de.johni0702.minecraft.gui.RenderInfo;
import de.johni0702.minecraft.gui.container.GuiContainer;
@@ -531,6 +532,7 @@ public class GuiPathing {
}
public Change updateInterpolators() {
boolean linearInterpolation = mod.getCore().getSettingsRegistry().get(Setting.LINEAR_INTERPOLATION);
List<Change> changes = new ArrayList<>();
Interpolator interpolator = null;
boolean isSpectatorInterpolator = false;
@@ -548,7 +550,7 @@ public class GuiPathing {
// Normal segment
if (isSpectatorInterpolator || interpolator == null) {
isSpectatorInterpolator = false;
interpolator = new CubicSplineInterpolator();
interpolator = linearInterpolation ? new LinearInterpolator() : new CubicSplineInterpolator();
interpolator.registerProperty(CameraProperties.POSITION);
interpolator.registerProperty(CameraProperties.ROTATION);
}

View File

@@ -278,6 +278,7 @@ replaymod.gui.settings.lighting=Ambient Lighting
replaymod.gui.settings.forcechunks=Force Render Chunks
replaymod.gui.settings.resources=Server Resource Packs
replaymod.gui.settings.interpolation=Path Interpolation
replaymod.gui.settings.linearinterpolation=Linear Path Interpolation
replaymod.gui.settings.pathpreview=Show Path Preview
replaymod.gui.settings.keyframecleancallback=Clear Confirmation
replaymod.gui.settings.renderinvisible=Render invisible Entities