Skip to content
Snippets Groups Projects
Commit 95b221d1 authored by Vojtech Moravec's avatar Vojtech Moravec
Browse files

Utility functions.

parent 80e4f54e
No related branches found
No related tags found
No related merge requests found
......@@ -208,4 +208,18 @@ public class Chunk3D {
return super.equals(obj);
}
}
public int[] getData() {
return data;
}
public short[] getDataAsShort() {
return Utils.convertIntArrayToShortArray(data);
}
public void zeroData() {
for (int i = 0; i < data.length; i++) {
data[i] = 0;
}
}
}
......@@ -51,7 +51,6 @@ public class Utils {
}
public static double arrayListSum(final ArrayList<Double> array) {
double sum = 0.0;
for (final double val : array) {
......@@ -96,4 +95,17 @@ public class Utils {
}
return result;
}
public static short[] convertIntArrayToShortArray(final int[] src) {
short[] result = new short[src.length];
short shortValue;
for (int i = 0; i < src.length; i++) {
if (src[i] < 0 || src[i] > U16.Max) {
throw new RuntimeException("Source value is outside of bounds for 16-bit unsigned integer.");
}
result[i] = (short) src[i];
}
return result;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment