Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -425,19 +425,37 @@ private static void populateByteArray(byte[] array, LittleEndien stream, int cou
int stride = Math.max(dataLength, byteStride);
int end = count * stride + byteOffset;
stream.skipBytes(byteOffset);

if (dataLength == stride) {
read(stream, array, end - index);

return;
}

int arrayIndex = 0;
byte[] buffer = new byte[numComponents];
while (index < end) {
for (int i = 0; i < numComponents; i++) {
array[arrayIndex] = stream.readByte();
arrayIndex++;
}
read(stream, buffer, numComponents);
System.arraycopy(buffer, 0, array, arrayIndex, numComponents);
arrayIndex += numComponents;
if (dataLength < stride) {
stream.skipBytes(stride - dataLength);
}
index += stride;
}
}

private static void read(LittleEndien stream, byte[] buffer, int length) throws IOException {
int n = 0;
while (n < length) {
int cnt = stream.read(buffer, n, length - n);
if (cnt < 0) {
throw new AssetLoadException("Data ended prematurely");
}
n += cnt;
}
}

private static void populateShortArray(short[] array, LittleEndien stream, int count, int byteOffset, int byteStride, int numComponents, VertexBuffer.Format format) throws IOException {
int componentSize = format.getComponentSize();
int index = byteOffset;
Expand Down Expand Up @@ -737,30 +755,24 @@ public static void assertNotNull(Object o, String errorMessage) {
}
}

// public static boolean equalBindAndLocalTransforms(Joint b) {
// return equalsEpsilon(b.getBindPosition(), b.getLocalPosition())
// && equalsEpsilon(b.getBindRotation(), b.getLocalRotation())
// && equalsEpsilon(b.getBindScale(), b.getLocalScale());
// }

private static float epsilon = 0.0001f;
private static final float EPSILON = 0.0001f;

public static boolean equalsEpsilon(Vector3f v1, Vector3f v2) {
return FastMath.abs(v1.x - v2.x) < epsilon
&& FastMath.abs(v1.y - v2.y) < epsilon
&& FastMath.abs(v1.z - v2.z) < epsilon;
return FastMath.abs(v1.x - v2.x) < EPSILON
&& FastMath.abs(v1.y - v2.y) < EPSILON
&& FastMath.abs(v1.z - v2.z) < EPSILON;
}

public static boolean equalsEpsilon(Quaternion q1, Quaternion q2) {
return (FastMath.abs(q1.getX() - q2.getX()) < epsilon
&& FastMath.abs(q1.getY() - q2.getY()) < epsilon
&& FastMath.abs(q1.getZ() - q2.getZ()) < epsilon
&& FastMath.abs(q1.getW() - q2.getW()) < epsilon)
return (FastMath.abs(q1.getX() - q2.getX()) < EPSILON
&& FastMath.abs(q1.getY() - q2.getY()) < EPSILON
&& FastMath.abs(q1.getZ() - q2.getZ()) < EPSILON
&& FastMath.abs(q1.getW() - q2.getW()) < EPSILON)
||
(FastMath.abs(q1.getX() + q2.getX()) < epsilon
&& FastMath.abs(q1.getY() + q2.getY()) < epsilon
&& FastMath.abs(q1.getZ() + q2.getZ()) < epsilon
&& FastMath.abs(q1.getW() + q2.getW()) < epsilon);
(FastMath.abs(q1.getX() + q2.getX()) < EPSILON
&& FastMath.abs(q1.getY() + q2.getY()) < EPSILON
&& FastMath.abs(q1.getZ() + q2.getZ()) < EPSILON
&& FastMath.abs(q1.getW() + q2.getW()) < EPSILON);
}


Expand Down