Made Camera Paths take the shortest way between two head rotation values (instead of spinning unnecessarily often)

This commit is contained in:
CrushedPixel
2015-05-09 16:57:16 +02:00
parent c95e66efbc
commit 5fda527cb0
3 changed files with 59 additions and 31 deletions

View File

@@ -170,7 +170,8 @@ public class GuiReplayOverlay extends Gui {
this.drawModalRectWithCustomSizedTexture(ppButtonX, ppButtonY, x, y, 20, 20, 64, 64); this.drawModalRectWithCustomSizedTexture(ppButtonX, ppButtonY, x, y, 20, 20, 64, 64);
//When hurrying, no Timeline jumping etc. is possible //When hurrying, no Timeline jumping etc. is possible
if(Mouse.isButtonDown(0) && FMLClientHandler.instance().isGUIOpen(GuiMouseInput.class) && !ReplayMod.replaySender.isHurrying()) { //clicking the Button if(Mouse.isButtonDown(0) && FMLClientHandler.instance().isGUIOpen(GuiMouseInput.class)) { //clicking the Button
if(!ReplayMod.replaySender.isHurrying()) {
speedSlider.mousePressed(mc, mouseX, mouseY); speedSlider.mousePressed(mc, mouseX, mouseY);
if(!mouseDown) { if(!mouseDown) {
mouseDown = true; mouseDown = true;
@@ -206,6 +207,7 @@ public class GuiReplayOverlay extends Gui {
ReplayMod.replaySender.jumpToTime((int) time); ReplayMod.replaySender.jumpToTime((int) time);
} }
} }
}
} else { } else {
try { try {
@@ -658,7 +660,7 @@ public class GuiReplayOverlay extends Gui {
private void addPlaceKeyframe() { private void addPlaceKeyframe() {
Entity cam = mc.getRenderViewEntity(); Entity cam = mc.getRenderViewEntity();
if(cam == null) return; if(cam == null) return;
ReplayHandler.addKeyframe(new PositionKeyframe(ReplayHandler.getRealTimelineCursor(), new Position(cam.posX, cam.posY, cam.posZ, cam.rotationPitch, cam.rotationYaw, ReplayHandler.getCameraTilt()))); ReplayHandler.addKeyframe(new PositionKeyframe(ReplayHandler.getRealTimelineCursor(), new Position(cam.posX, cam.posY, cam.posZ, cam.rotationPitch, cam.rotationYaw % 360, ReplayHandler.getCameraTilt())));
} }
private void addTimeKeyframe() { private void addTimeKeyframe() {

View File

@@ -4,7 +4,7 @@ import org.apache.commons.lang3.builder.HashCodeBuilder;
public class PositionKeyframe extends Keyframe { public class PositionKeyframe extends Keyframe {
private final Position position; private Position position;
public PositionKeyframe(int realTime, Position position) { public PositionKeyframe(int realTime, Position position) {
super(realTime); super(realTime);
@@ -15,6 +15,8 @@ public class PositionKeyframe extends Keyframe {
return position; return position;
} }
public void setPosition(Position position) { this.position = position; }
@Override @Override
public boolean equals(Object o2) { public boolean equals(Object o2) {
if(o2 == null) return false; if(o2 == null) return false;

View File

@@ -123,6 +123,30 @@ public class ReplayHandler {
public static void addKeyframe(Keyframe keyframe) { public static void addKeyframe(Keyframe keyframe) {
keyframes.add(keyframe); keyframes.add(keyframe);
selectKeyframe(keyframe); selectKeyframe(keyframe);
if(keyframe instanceof PositionKeyframe) {
Float a = null;
Float b;
for(Keyframe kf : keyframes) {
if(!(kf instanceof PositionKeyframe)) continue;
PositionKeyframe pkf = (PositionKeyframe)kf;
Position pos = pkf.getPosition();
b = pos.getYaw() % 360;
System.out.println(a+" "+b);
if(a != null) {
float diff = b-a;
if(Math.abs(diff) > 180) {
b = a - (360 - diff) % 360;
System.out.println(b);
pos.setYaw(b);
pkf.setPosition(pos);
}
}
a = b;
}
}
} }
public static void removeKeyframe(Keyframe keyframe) { public static void removeKeyframe(Keyframe keyframe) {