From 3f376eaf7bd32fb356e6f5961b44b94ff8445400 Mon Sep 17 00:00:00 2001 From: McHorse Date: Thu, 6 Feb 2020 17:26:09 +0000 Subject: [PATCH] Fix performance of path preview with velocity control (reported by Negative_Entropy and terbin) --- .../mchorse/aperture/camera/CameraRenderer.java | 10 ++++++++++ .../aperture/camera/fixtures/PathFixture.java | 13 ++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/main/java/mchorse/aperture/camera/CameraRenderer.java b/src/main/java/mchorse/aperture/camera/CameraRenderer.java index 9e7fd5ea..397e98d9 100644 --- a/src/main/java/mchorse/aperture/camera/CameraRenderer.java +++ b/src/main/java/mchorse/aperture/camera/CameraRenderer.java @@ -227,6 +227,11 @@ public void onLastRender(RenderWorldLastEvent event) for (AbstractFixture fixture : profile.getAll()) { + if (fixture instanceof PathFixture) + { + ((PathFixture) fixture).disableSpeed(); + } + fixture.applyFixture(0, 0.0F, profile, this.prev); fixture.applyFixture(fixture.getDuration(), 0.0F, profile, this.next); @@ -242,6 +247,11 @@ public void onLastRender(RenderWorldLastEvent event) this.drawCard(color, i++, duration, this.prev); this.drawFixture(0.0F, color, fixture, this.prev, this.next); + + if (fixture instanceof PathFixture) + { + ((PathFixture) fixture).reenableSpeed(); + } } GlStateManager.disableBlend(); diff --git a/src/main/java/mchorse/aperture/camera/fixtures/PathFixture.java b/src/main/java/mchorse/aperture/camera/fixtures/PathFixture.java index daf98241..d9a09801 100644 --- a/src/main/java/mchorse/aperture/camera/fixtures/PathFixture.java +++ b/src/main/java/mchorse/aperture/camera/fixtures/PathFixture.java @@ -60,6 +60,7 @@ public class PathFixture extends AbstractFixture private Point tmpPoint = new Point(0, 0, 0); private CachedPosition result = new CachedPosition(); private List cache = new ArrayList(); + private boolean disableSpeed = false; public PathFixture() { @@ -102,6 +103,16 @@ public void updateSpeedCache() } } + public void disableSpeed() + { + this.disableSpeed = true; + } + + public void reenableSpeed() + { + this.disableSpeed = false; + } + public DurablePosition getPoint(int index) { if (this.points.size() == 0) @@ -255,7 +266,7 @@ public void applyFixture(long ticks, float partialTicks, float previewPartialTic } /* If use speed is enabled */ - if (this.useSpeed) + if (this.useSpeed && !this.disableSpeed) { float tick = ticks + previewPartialTick;