Significantly improved the performance of video rendering by using the magic of multithreading
This commit is contained in:
@@ -121,7 +121,6 @@ public class GuiReplayOverlay extends Gui {
|
|||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void tick(TickEvent event) {
|
public void tick(TickEvent event) {
|
||||||
if(!ReplayHandler.isInReplay()) return;
|
if(!ReplayHandler.isInReplay()) return;
|
||||||
if(ReplayHandler.isInPath()) ReplayProcess.unblockAndTick();
|
|
||||||
if(ReplayHandler.getCameraEntity() != null)
|
if(ReplayHandler.getCameraEntity() != null)
|
||||||
ReplayHandler.getCameraEntity().updateMovement();
|
ReplayHandler.getCameraEntity().updateMovement();
|
||||||
if(!ReplayHandler.isInPath()) onMouseMove(new MouseEvent());
|
if(!ReplayHandler.isInPath()) onMouseMove(new MouseEvent());
|
||||||
@@ -145,15 +144,15 @@ public class GuiReplayOverlay extends Gui {
|
|||||||
throws IllegalAccessException, IllegalArgumentException,
|
throws IllegalAccessException, IllegalArgumentException,
|
||||||
InvocationTargetException, IOException {
|
InvocationTargetException, IOException {
|
||||||
if(!ReplayHandler.isInReplay()) return;
|
if(!ReplayHandler.isInReplay()) return;
|
||||||
|
if(ReplayHandler.isInPath()) ReplayProcess.unblockAndTick();
|
||||||
if(ReplayHandler.isCamera()) ReplayHandler.setCameraEntity(ReplayHandler.getCameraEntity());
|
if(ReplayHandler.isCamera()) ReplayHandler.setCameraEntity(ReplayHandler.getCameraEntity());
|
||||||
if(ReplayHandler.isInReplay() && ReplayHandler.isPaused()) {
|
if(ReplayHandler.isInReplay() && ReplayHandler.isPaused()) {
|
||||||
if(mc != null && mc.thePlayer != null)
|
if(mc != null && mc.thePlayer != null)
|
||||||
MinecraftTicker.runMouseKeyboardTick(mc);
|
MinecraftTicker.runMouseKeyboardTick(mc);
|
||||||
}
|
}
|
||||||
if((mc.getRenderViewEntity() == mc.thePlayer || !mc.getRenderViewEntity().isEntityAlive())
|
if((mc.getRenderViewEntity() == mc.thePlayer || !mc.getRenderViewEntity().isEntityAlive())
|
||||||
&& ReplayHandler.getCameraEntity() != null) {
|
&& ReplayHandler.getCameraEntity() != null && !ReplayHandler.isInPath()) {
|
||||||
ReplayHandler.spectateCamera();
|
ReplayHandler.spectateCamera();
|
||||||
ReplayHandler.getCameraEntity().movePath(new Position(lastX, lastY, lastZ, lastPitch, lastYaw));
|
|
||||||
} else if(!ReplayHandler.isCamera()) {
|
} else if(!ReplayHandler.isCamera()) {
|
||||||
lastX = mc.getRenderViewEntity().posX;
|
lastX = mc.getRenderViewEntity().posX;
|
||||||
lastY = mc.getRenderViewEntity().posY;
|
lastY = mc.getRenderViewEntity().posY;
|
||||||
|
|||||||
@@ -30,5 +30,12 @@ public class SafeEntityRenderer extends EntityRenderer {
|
|||||||
} catch(Exception e) {} //This is plain easier than doing proper error prevention.
|
} catch(Exception e) {} //This is plain easier than doing proper error prevention.
|
||||||
//If Johni reads this, don't think I'm a bad programmer... Just a lazy one :P
|
//If Johni reads this, don't think I'm a bad programmer... Just a lazy one :P
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateRenderer() {
|
||||||
|
try {
|
||||||
|
super.updateRenderer();
|
||||||
|
} catch(Exception e) {}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,6 +63,8 @@ public class ReplayProcess {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
blocked = deepBlock = false;
|
||||||
|
|
||||||
startRealTime = System.currentTimeMillis();
|
startRealTime = System.currentTimeMillis();
|
||||||
lastRealTime = startRealTime;
|
lastRealTime = startRealTime;
|
||||||
lastRealReplayTime = 0;
|
lastRealReplayTime = 0;
|
||||||
@@ -110,7 +112,6 @@ public class ReplayProcess {
|
|||||||
if(!deepBlock) blocked = false;
|
if(!deepBlock) blocked = false;
|
||||||
if(!blocked || !isVideoRecording())
|
if(!blocked || !isVideoRecording())
|
||||||
ReplayProcess.tickReplay();
|
ReplayProcess.tickReplay();
|
||||||
else System.out.println("nope");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void tickReplay() {
|
public static void tickReplay() {
|
||||||
@@ -272,7 +273,9 @@ public class ReplayProcess {
|
|||||||
curPos = timeLinear.getPoint(Math.max(0, Math.min(1, timePos)));
|
curPos = timeLinear.getPoint(Math.max(0, Math.min(1, timePos)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pos != null) ReplayHandler.getCameraEntity().movePath(pos);
|
if(pos != null) {
|
||||||
|
ReplayHandler.getCameraEntity().movePath(pos);
|
||||||
|
}
|
||||||
|
|
||||||
ReplayHandler.setSpeed(curSpeed);
|
ReplayHandler.setSpeed(curSpeed);
|
||||||
|
|
||||||
@@ -288,7 +291,6 @@ public class ReplayProcess {
|
|||||||
lastRealReplayTime = curRealReplayTime;
|
lastRealReplayTime = curRealReplayTime;
|
||||||
lastRealTime = curTime;
|
lastRealTime = curTime;
|
||||||
|
|
||||||
//Video capturing, for testing purposes
|
|
||||||
if(isVideoRecording()) {
|
if(isVideoRecording()) {
|
||||||
try {
|
try {
|
||||||
if(!VideoWriter.isRecording() && ReplayHandler.isInPath()) {
|
if(!VideoWriter.isRecording() && ReplayHandler.isInPath()) {
|
||||||
|
|||||||
@@ -615,11 +615,13 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
|||||||
|
|
||||||
CameraEntity cent = ReplayHandler.getCameraEntity();
|
CameraEntity cent = ReplayHandler.getCameraEntity();
|
||||||
|
|
||||||
if(!allowMovement && !((Math.abs(cent.posX - ppl.func_148932_c()) > ReplayMod.TP_DISTANCE_LIMIT) ||
|
if(cent != null) {
|
||||||
(Math.abs(cent.posZ - ppl.func_148933_e()) > ReplayMod.TP_DISTANCE_LIMIT))) {
|
if(!allowMovement && !((Math.abs(cent.posX - ppl.func_148932_c()) > ReplayMod.TP_DISTANCE_LIMIT) ||
|
||||||
return;
|
(Math.abs(cent.posZ - ppl.func_148933_e()) > ReplayMod.TP_DISTANCE_LIMIT))) {
|
||||||
} else {
|
return;
|
||||||
allowMovement = false;
|
} else {
|
||||||
|
allowMovement = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread t = new Thread(new Runnable() {
|
Thread t = new Thread(new Runnable() {
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ public class VideoWriter {
|
|||||||
VideoFormatKeys.WidthKey, width,
|
VideoFormatKeys.WidthKey, width,
|
||||||
VideoFormatKeys.HeightKey, height,
|
VideoFormatKeys.HeightKey, height,
|
||||||
VideoFormatKeys.DepthKey, 24,
|
VideoFormatKeys.DepthKey, 24,
|
||||||
VideoFormatKeys.QualityKey, ReplayMod.replaySettings.getVideoQuality());
|
VideoFormatKeys.QualityKey, (float)ReplayMod.replaySettings.getVideoQuality());
|
||||||
|
|
||||||
|
|
||||||
track = out.addTrack(format);
|
track = out.addTrack(format);
|
||||||
|
|||||||
Reference in New Issue
Block a user