Skip to content

Commit

Permalink
Fix performance of path preview with velocity control (reported by Ne…
Browse files Browse the repository at this point in the history
…gative_Entropy and terbin)
  • Loading branch information
mchorse committed Feb 6, 2020
1 parent 8d19ffb commit 3f376ea
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/main/java/mchorse/aperture/camera/CameraRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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();
Expand Down
13 changes: 12 additions & 1 deletion src/main/java/mchorse/aperture/camera/fixtures/PathFixture.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public class PathFixture extends AbstractFixture
private Point tmpPoint = new Point(0, 0, 0);
private CachedPosition result = new CachedPosition();
private List<CachedPosition> cache = new ArrayList<CachedPosition>();
private boolean disableSpeed = false;

public PathFixture()
{
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 3f376ea

Please sign in to comment.