[PlutoLib] Code cleanup

This commit is contained in:
Tefek 2020-10-18 00:57:08 +02:00
parent a66114cfea
commit 0e166ade11
4 changed files with 18 additions and 17 deletions

View File

@ -23,12 +23,13 @@ public class InputBus
public static void init(Display display) public static void init(Display display)
{ {
var instance = new InputBus(); var instance = new InputBus();
var windowPointer = display.getWindowPointer();
GLFW.glfwSetKeyCallback(display.getWindowPointer(), instance.keyboard); GLFW.glfwSetKeyCallback(windowPointer, instance.keyboard);
GLFW.glfwSetMouseButtonCallback(display.getWindowPointer(), instance.mouseButton); GLFW.glfwSetMouseButtonCallback(windowPointer, instance.mouseButton);
GLFW.glfwSetCursorPosCallback(display.getWindowPointer(), instance.cursorPosition); GLFW.glfwSetCursorPosCallback(windowPointer, instance.cursorPosition);
GLFW.glfwSetScrollCallback(display.getWindowPointer(), instance.scroll); GLFW.glfwSetScrollCallback(windowPointer, instance.scroll);
GLFW.glfwSetCharCallback(display.getWindowPointer(), instance.charInput); GLFW.glfwSetCharCallback(windowPointer, instance.charInput);
INSTANCE.set(instance); INSTANCE.set(instance);
} }

View File

@ -1,5 +1,6 @@
package cz.tefek.pluto.io.logger; package cz.tefek.pluto.io.logger;
import javax.annotation.Nonnull;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
@ -10,7 +11,7 @@ import java.io.OutputStream;
* @author 493msi * @author 493msi
* *
*/ */
class OutputSplitStream extends OutputStream public class OutputSplitStream extends OutputStream
{ {
private final OutputStream outputStreamA; private final OutputStream outputStreamA;
private final boolean shouldAClose; private final boolean shouldAClose;
@ -36,14 +37,14 @@ class OutputSplitStream extends OutputStream
} }
@Override @Override
public void write(byte[] b) throws IOException public void write(@Nonnull byte[] b) throws IOException
{ {
this.outputStreamA.write(b); this.outputStreamA.write(b);
this.outputStreamB.write(b); this.outputStreamB.write(b);
} }
@Override @Override
public void write(byte[] b, int off, int len) throws IOException public void write(@Nonnull byte[] b, int off, int len) throws IOException
{ {
this.outputStreamA.write(b, off, len); this.outputStreamA.write(b, off, len);
this.outputStreamB.write(b, off, len); this.outputStreamB.write(b, off, len);

View File

@ -10,7 +10,7 @@ package cz.tefek.pluto.math;
public class CubicBezier public class CubicBezier
{ {
private static final int iterations = 16; private static final int iterations = 16;
private double a, b, c, d; private final double a, b, c, d;
/** /**
* Creates a new {@code CubicBezier} from the given parameters. * Creates a new {@code CubicBezier} from the given parameters.
@ -62,23 +62,22 @@ public class CubicBezier
double t = 0.5; double t = 0.5;
double x; double x;
double y = 3 * (1 - t) * (1 - t) * t * this.b + 3 * (1 - t) * t * t * this.d + t * t * t;
// Resulting Y value
double result = 3 * (1 - t) * (1 - t) * t * this.b + 3 * (1 - t) * t * t * this.d + t * t * t;
double delta = 0.25; double delta = 0.25;
boolean uh;
for (int i = 0; i < iterations; i++) for (int i = 0; i < iterations; i++)
{ {
x = 3 * (1 - t) * (1 - t) * t * this.a + 3 * (1 - t) * t * t * this.c + t * t * t; x = 3 * (1 - t) * (1 - t) * t * this.a + 3 * (1 - t) * t * t * this.c + t * t * t;
y = 3 * (1 - t) * (1 - t) * t * this.b + 3 * (1 - t) * t * t * this.d + t * t * t; result = 3 * (1 - t) * (1 - t) * t * this.b + 3 * (1 - t) * t * t * this.d + t * t * t;
uh = x > xIn; t += x > xIn ? -delta : delta;
t += uh ? -delta : delta;
delta /= 2; delta /= 2;
} }
return y; return result;
} }
} }

View File

@ -42,7 +42,7 @@ public class CubicBezierLT
} }
/** /**
* Retrives the approximate value for the given x and the supplied * Retrieves the approximate value for the given x and the supplied
* parameters in the constructor. * parameters in the constructor.
* *
* @param xIn the input X position * @param xIn the input X position