Add linear interpolation to simplepathing
This commit is contained in:
@@ -3,6 +3,7 @@ package com.replaymod.simplepathing;
|
|||||||
import com.google.gson.stream.JsonReader;
|
import com.google.gson.stream.JsonReader;
|
||||||
import com.google.gson.stream.JsonWriter;
|
import com.google.gson.stream.JsonWriter;
|
||||||
import com.replaymod.core.ReplayMod;
|
import com.replaymod.core.ReplayMod;
|
||||||
|
import com.replaymod.core.events.SettingsChangedEvent;
|
||||||
import com.replaymod.pathing.properties.CameraProperties;
|
import com.replaymod.pathing.properties.CameraProperties;
|
||||||
import com.replaymod.pathing.properties.SpectatorProperty;
|
import com.replaymod.pathing.properties.SpectatorProperty;
|
||||||
import com.replaymod.pathing.properties.TimestampProperty;
|
import com.replaymod.pathing.properties.TimestampProperty;
|
||||||
@@ -62,6 +63,15 @@ public class ReplayModSimplePathing implements PathingRegistry {
|
|||||||
selectedKeyframe = null;
|
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 Timeline currentTimeline = createTimeline(); { currentTimeline.createPath(); currentTimeline.createPath(); }
|
||||||
private Keyframe selectedKeyframe;
|
private Keyframe selectedKeyframe;
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.replaymod.core.SettingsRegistry;
|
|||||||
|
|
||||||
public final class Setting<T> extends SettingsRegistry.SettingKeys<T> {
|
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> 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) {
|
private static <T> Setting<T> make(String key, String displayName, T defaultValue) {
|
||||||
return new Setting<>(key, displayName, defaultValue);
|
return new Setting<>(key, displayName, defaultValue);
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import com.replaymod.replaystudio.pathing.property.Property;
|
|||||||
import com.replaymod.replaystudio.util.EntityPositionTracker;
|
import com.replaymod.replaystudio.util.EntityPositionTracker;
|
||||||
import com.replaymod.replaystudio.util.Location;
|
import com.replaymod.replaystudio.util.Location;
|
||||||
import com.replaymod.simplepathing.ReplayModSimplePathing;
|
import com.replaymod.simplepathing.ReplayModSimplePathing;
|
||||||
|
import com.replaymod.simplepathing.Setting;
|
||||||
import de.johni0702.minecraft.gui.GuiRenderer;
|
import de.johni0702.minecraft.gui.GuiRenderer;
|
||||||
import de.johni0702.minecraft.gui.RenderInfo;
|
import de.johni0702.minecraft.gui.RenderInfo;
|
||||||
import de.johni0702.minecraft.gui.container.GuiContainer;
|
import de.johni0702.minecraft.gui.container.GuiContainer;
|
||||||
@@ -531,6 +532,7 @@ public class GuiPathing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Change updateInterpolators() {
|
public Change updateInterpolators() {
|
||||||
|
boolean linearInterpolation = mod.getCore().getSettingsRegistry().get(Setting.LINEAR_INTERPOLATION);
|
||||||
List<Change> changes = new ArrayList<>();
|
List<Change> changes = new ArrayList<>();
|
||||||
Interpolator interpolator = null;
|
Interpolator interpolator = null;
|
||||||
boolean isSpectatorInterpolator = false;
|
boolean isSpectatorInterpolator = false;
|
||||||
@@ -548,7 +550,7 @@ public class GuiPathing {
|
|||||||
// Normal segment
|
// Normal segment
|
||||||
if (isSpectatorInterpolator || interpolator == null) {
|
if (isSpectatorInterpolator || interpolator == null) {
|
||||||
isSpectatorInterpolator = false;
|
isSpectatorInterpolator = false;
|
||||||
interpolator = new CubicSplineInterpolator();
|
interpolator = linearInterpolation ? new LinearInterpolator() : new CubicSplineInterpolator();
|
||||||
interpolator.registerProperty(CameraProperties.POSITION);
|
interpolator.registerProperty(CameraProperties.POSITION);
|
||||||
interpolator.registerProperty(CameraProperties.ROTATION);
|
interpolator.registerProperty(CameraProperties.ROTATION);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -278,6 +278,7 @@ replaymod.gui.settings.lighting=Ambient Lighting
|
|||||||
replaymod.gui.settings.forcechunks=Force Render Chunks
|
replaymod.gui.settings.forcechunks=Force Render Chunks
|
||||||
replaymod.gui.settings.resources=Server Resource Packs
|
replaymod.gui.settings.resources=Server Resource Packs
|
||||||
replaymod.gui.settings.interpolation=Path Interpolation
|
replaymod.gui.settings.interpolation=Path Interpolation
|
||||||
|
replaymod.gui.settings.linearinterpolation=Linear Path Interpolation
|
||||||
replaymod.gui.settings.pathpreview=Show Path Preview
|
replaymod.gui.settings.pathpreview=Show Path Preview
|
||||||
replaymod.gui.settings.keyframecleancallback=Clear Confirmation
|
replaymod.gui.settings.keyframecleancallback=Clear Confirmation
|
||||||
replaymod.gui.settings.renderinvisible=Render invisible Entities
|
replaymod.gui.settings.renderinvisible=Render invisible Entities
|
||||||
|
|||||||
Reference in New Issue
Block a user