Skip to content

Commit

Permalink
Remove barely used utility classes
Browse files Browse the repository at this point in the history
  • Loading branch information
booleanbyte committed Dec 21, 2023
1 parent 8399738 commit 8b50528
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import net.worldsynth.glpreview.Commons;
import net.worldsynth.glpreview.buffered.Shader.ShaderType;
import net.worldsynth.glpreview.model.AbstractModel;
import net.worldsynth.util.math.MathHelperScalar;

import javax.swing.SwingUtilities;
import java.awt.event.MouseEvent;
Expand Down Expand Up @@ -279,7 +278,7 @@ public void mouseDragged(MouseEvent e) {
display();
} else if(SwingUtilities.isMiddleMouseButton(e)) {
yLookatHeight += (y - lastMouseY) * -zoom * 0.2f;
yLookatHeight = MathHelperScalar.clamp(yLookatHeight, minYLookatHeight, maxYLookatHeight);
yLookatHeight = Math.min(Math.max(yLookatHeight, minYLookatHeight), maxYLookatHeight);
display();
} else if(SwingUtilities.isRightMouseButton(e)) {
float lightDist = 5000;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import com.jogamp.opengl.GLCapabilities;
import com.jogamp.opengl.GLProfile;
import net.worldsynth.glpreview.buffered.BufferedGLPanel;
import net.worldsynth.util.Arrays;
import net.worldsynth.util.math.MathHelperScalar;


public class Heightmap3DGLPreviewBufferedGL extends BufferedGLPanel {
Expand Down Expand Up @@ -49,7 +47,17 @@ public void setHeightmap(float[][] heightmap, double size, float normalizedHeigh
}

public void setHeightmap(double[][] heightmap, double size, float normalizedHeight) {
setHeightmap(Arrays.cast2f(heightmap), size, normalizedHeight);
setHeightmap(cast2f(heightmap), size, normalizedHeight);
}

private float[][] cast2f(double[][] array2d) {
float[][] array2f = new float[array2d.length][array2d[0].length];
for(int i = 0, width = array2d.length; i < width; i++) {
for(int j = 0, length = array2d[0].length; j < length; j++) {
array2f[i][j] = (float) array2d[i][j];
}
}
return array2f;
}

public void setColorscale(float[][] colorscale) {
Expand All @@ -71,7 +79,7 @@ private float[][][] colormapFromHeightmap(float[][] heightmap, float normalizedH
}

private float[] heightToColor(float height, float normalizedHeight) {
height = MathHelperScalar.clamp(height, 0.0f, normalizedHeight) / normalizedHeight;
height = Math.min(Math.max(height, 0.0f), normalizedHeight) / normalizedHeight;

float[] lowRange = colorscale[0];
float[] highRange = colorscale[1];
Expand Down
48 changes: 0 additions & 48 deletions src/main/java/net/worldsynth/util/Arrays.java

This file was deleted.

22 changes: 0 additions & 22 deletions src/main/java/net/worldsynth/util/math/MathHelperScalar.java

This file was deleted.

0 comments on commit 8b50528

Please sign in to comment.