Skip to content

Commit

Permalink
Replace C style array declaration with Java style
Browse files Browse the repository at this point in the history
  • Loading branch information
Renanse committed Mar 1, 2024
1 parent e92da9c commit c7c1baa
Show file tree
Hide file tree
Showing 52 changed files with 889 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public static Image makeArdor3dImage(final BufferedImage image, final boolean fl
}

// Get image as a byte buffer - note this corrects order of Alpha component from ARGB to RGBA
final byte data[] = asByteArray(texToConvert);
final byte[] data = asByteArray(texToConvert);
final ByteBuffer scratch =
createOnHeap ? BufferUtils.createByteBufferOnHeap(data.length) : BufferUtils.createByteBuffer(data.length);
scratch.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ public boolean intersection(final OrientedBoundingBox box1) {
int i;

// convenience variables
final ReadOnlyVector3 akA[] = new ReadOnlyVector3[] {box0.getXAxis(), box0.getYAxis(), box0.getZAxis()};
final ReadOnlyVector3[] akA = new ReadOnlyVector3[] {box0.getXAxis(), box0.getYAxis(), box0.getZAxis()};
final ReadOnlyVector3[] akB = new ReadOnlyVector3[] {box1.getXAxis(), box1.getYAxis(), box1.getZAxis()};
final ReadOnlyVector3 afEA = box0._extent;
final ReadOnlyVector3 afEB = box1._extent;
Expand Down Expand Up @@ -809,7 +809,7 @@ public boolean intersectsBoundingBox(final BoundingBox bb) {
int i;

// convenience variables
final Vector3 akA[] = new Vector3[] {_xAxis, _yAxis, _zAxis};
final Vector3[] akA = new Vector3[] {_xAxis, _yAxis, _zAxis};
final Vector3[] akB =
new Vector3[] {Vector3.fetchTempInstance(), Vector3.fetchTempInstance(), Vector3.fetchTempInstance()};
final Vector3 afEA = _extent;
Expand Down Expand Up @@ -1016,7 +1016,7 @@ public boolean intersectsOrientedBoundingBox(final OrientedBoundingBox obb) {
int i;

// convenience variables
final Vector3 akA[] = new Vector3[] {_xAxis, _yAxis, _zAxis};
final Vector3[] akA = new Vector3[] {_xAxis, _yAxis, _zAxis};
final Vector3[] akB = new Vector3[] {obb._xAxis, obb._yAxis, obb._zAxis};
final Vector3 afEA = _extent;
final Vector3 afEB = obb._extent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ private final static class DdsImageInfo {
int bpp = 0;
DdsHeader header;
DdsHeaderDX10 headerDX10;
int mipmapByteSizes[];
int[] mipmapByteSizes;

void calcMipmapSizes(final boolean compressed) {
int width = header.dwWidth;
Expand Down
8 changes: 4 additions & 4 deletions ardor3d-core/src/main/java/com/ardor3d/renderer/Camera.java
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,10 @@ public enum FrustumIntersect {

// Temporary values computed in onFrustumChange that are needed if a
// call is made to onFrameChange.
protected double _coeffLeft[];
protected double _coeffRight[];
protected double _coeffBottom[];
protected double _coeffTop[];
protected double[] _coeffLeft;
protected double[] _coeffRight;
protected double[] _coeffBottom;
protected double[] _coeffTop;

/** Number of camera planes used by this camera. Default is 6. */
protected int _planeQuantity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ public RenderState extract(final Stack<? extends RenderState> stack, final Spati
// accumulate the textures in the stack into a single TextureState object
final TextureState newTState = new TextureState();
boolean foundEnabled = false;
final Object states[] = stack.toArray();
final Object[] states = stack.toArray();
switch (mode) {
case CombineClosest:
case CombineClosestEnabled:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ public Box clone() {
*/
public Vector3[] computeVertices() {

final Vector3 rVal[] = new Vector3[8];
final Vector3[] rVal = new Vector3[8];
rVal[0] = _center.add(-_xExtent, -_yExtent, -_zExtent, null);
rVal[1] = _center.add(_xExtent, -_yExtent, -_zExtent, null);
rVal[2] = _center.add(_xExtent, _yExtent, -_zExtent, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,8 @@ public void updateGeometry(final Line shape, final List<ReadOnlyVector3> points,
if (closed) {
np = np + 3;
}
final double d[][] = new double[3][np]; // Newton form coefficients
final double x[] = new double[np]; // x-coordinates of nodes
final double[][] d = new double[3][np]; // Newton form coefficients
final double[] x = new double[np]; // x-coordinates of nodes

final List<ReadOnlyVector3> path = new ArrayList<>();

Expand All @@ -290,14 +290,14 @@ public void updateGeometry(final Line shape, final List<ReadOnlyVector3> points,

if (np > 1) {
final double[][] a = new double[3][np];
final double h[] = new double[np];
final double[] h = new double[np];
for (int i = 1; i <= np - 1; i++) {
h[i] = x[i] - x[i - 1];
}
if (np > 2) {
final double sub[] = new double[np - 1];
final double diag[] = new double[np - 1];
final double sup[] = new double[np - 1];
final double[] sub = new double[np - 1];
final double[] diag = new double[np - 1];
final double[] sup = new double[np - 1];

for (int i = 1; i <= np - 2; i++) {
diag[i] = (h[i] + h[i + 1]) / 3;
Expand Down Expand Up @@ -343,8 +343,8 @@ public void updateGeometry(final Line shape, final List<ReadOnlyVector3> points,
* (the values sub[1], sup[n] are ignored) right hand side vector b[1:n] is overwritten with
* solution NOTE: 1...n is used in all arrays, 0 is unused
*/
private static void solveTridiag(final double sub[], final double diag[], final double sup[], final double b[],
final int n) {
private static void solveTridiag(final double[] sub, final double[] diag, final double[] sup, final double[] b,
final int n) {
// factorization and forward substitution
for (int i = 2; i <= n; i++) {
sub[i] = sub[i] / diag[i - 1];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,11 @@ public StripBox clone() {
*/
public Vector3[] computeVertices() {

final Vector3 akEAxis[] = {Vector3.UNIT_X.multiply(_xExtent, Vector3.fetchTempInstance()),
final Vector3[] akEAxis = {Vector3.UNIT_X.multiply(_xExtent, Vector3.fetchTempInstance()),
Vector3.UNIT_Y.multiply(_yExtent, Vector3.fetchTempInstance()),
Vector3.UNIT_Z.multiply(_zExtent, Vector3.fetchTempInstance())};

final Vector3 rVal[] = new Vector3[8];
final Vector3[] rVal = new Vector3[8];
rVal[0] = _center.subtract(akEAxis[0], new Vector3()).subtractLocal(akEAxis[1]).subtractLocal(akEAxis[2]);
rVal[1] = _center.add(akEAxis[0], new Vector3()).subtractLocal(akEAxis[1]).subtractLocal(akEAxis[2]);
rVal[2] = _center.add(akEAxis[0], new Vector3()).addLocal(akEAxis[1]).subtractLocal(akEAxis[2]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ public final double readDouble() throws IOException {
}

@Override
public final void readFully(final byte b[]) throws IOException {
public final void readFully(final byte[] b) throws IOException {
readFully(b, 0, b.length);
}

@Override
public final void readFully(final byte b[], final int off, final int len) throws IOException {
public final void readFully(final byte[] b, final int off, final int len) throws IOException {
// this may look over-complicated, but the problem is that the InputStream.read() methods are
// not guaranteed to fill up the buffer you pass to it. So we need to loop until we have filled
// up the buffer or until we reach the end of the file.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ public final double readDouble() throws IOException {
}

@Override
public final void readFully(final byte b[]) throws IOException {
public final void readFully(final byte[] b) throws IOException {
readFully(b, 0, b.length);
}

@Override
public final void readFully(final byte b[], final int off, final int len) throws IOException {
public final void readFully(final byte[] b, final int off, final int len) throws IOException {
if (len - off + _contents.position() > _contents.capacity()) {
throw new EOFException("EOF reached");
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void updateWorldBound(final boolean recurse) {
if (numParticles == 0) {
return;
}
Vector2 sharedTextureData[];
Vector2[] sharedTextureData;

// setup texture coords and index mode
final MeshData meshData = mesh.getMeshData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public ParticlePoints(final String name, final int numParticles) {

@Override
protected void initializeParticles(final int numParticles) {
Vector2 sharedTextureData[];
Vector2[] sharedTextureData;

// setup texture coords
sharedTextureData = new Vector2[] {new Vector2(0.0, 0.0)};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public enum ParticleType {
protected final Vector3 _facingUpVector = new Vector3(Vector3.UNIT_Y);
protected final Vector3 _facingLeftVector = new Vector3(-1, 0, 0);

protected Particle _particles[];
protected Particle[] _particles;

// protected Vector3 particleSpeed;
protected int _releaseRate; // particles per second
Expand All @@ -108,7 +108,7 @@ public enum ParticleType {
protected ParticleController _controller;

protected Vector3 _oldEmit = new Vector3(Float.NaN, Float.NaN, Float.NaN);
protected double _matData[] = new double[9];
protected double[] _matData = new double[9];

public ParticleSystem() {}

Expand Down Expand Up @@ -200,8 +200,8 @@ public void updateRotationMatrix() {
final double f4 = 2.0 / _abUpMinUp.dot(_abUpMinUp);
final double f6 = 2.0 / _upXemit.dot(_upXemit);
final double f8 = f4 * f6 * _abUpMinUp.dot(_upXemit);
final double af1[] = {_abUpMinUp.getX(), _abUpMinUp.getY(), _abUpMinUp.getZ()};
final double af2[] = {_upXemit.getX(), _upXemit.getY(), _upXemit.getZ()};
final double[] af1 = {_abUpMinUp.getX(), _abUpMinUp.getY(), _abUpMinUp.getZ()};
final double[] af2 = {_upXemit.getX(), _upXemit.getY(), _upXemit.getZ()};
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
_matData[(i * 3) + j] = (-f4 * af1[i] * af1[j] - f6 * af2[i] * af2[j]) + f8 * af2[i] * af1[j];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private static double grad(final int hash, final double x, final double y, final
return ((h & 1) == 0 ? u : -u) + ((h & 2) == 0 ? v : -v);
}

private static final int p[] = new int[512], permutation[] = {151, 160, 137, 91, 90, 15, 131, 13, 201, 95, 96, 53,
private static final int[] p = new int[512], permutation = {151, 160, 137, 91, 90, 15, 131, 13, 201, 95, 96, 53,
194, 233, 7, 225, 140, 36, 103, 30, 69, 142, 8, 99, 37, 240, 21, 10, 23, 190, 6, 148, 247, 120, 234, 75, 0, 26,
197, 62, 94, 252, 219, 203, 117, 35, 11, 32, 57, 177, 33, 88, 237, 149, 56, 87, 174, 20, 125, 136, 171, 168, 68,
175, 74, 165, 71, 134, 139, 48, 27, 166, 77, 146, 158, 231, 83, 111, 229, 122, 60, 211, 133, 230, 220, 105, 92,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public class ProjectedGrid extends Mesh {
private final ExecutorService executorService = Executors.newCachedThreadPool(new DeamonThreadFactory());
private final Stack<Future<?>> futureStack = new Stack<>();

private final int connections[] = {0, 1, 2, 3, 0, 4, 1, 5, 2, 6, 3, 7, 4, 5, 6, 7,};
private final int[] connections = {0, 1, 2, 3, 0, 4, 1, 5, 2, 6, 3, 7, 4, 5, 6, 7,};

// Debug drawing
private boolean drawDebug = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ private double sign(final double a) {
return 0.0;
}

private double projectionMatrix[] = new double[16];
private double[] projectionMatrix = new double[16];
private final Vector4 cornerPoint = new Vector4();
private final Matrix4 tmpMatrix = new Matrix4();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class ProjectedGridExample extends ExampleBase {
private boolean animateExternalCamera = false;

/** Text fields used to present info about the example. */
private final BasicText _exampleInfo[] = new BasicText[4];
private final BasicText[] _exampleInfo = new BasicText[4];

public static void main(final String[] args) {
start(ProjectedGridExample.class);
Expand Down
Loading

0 comments on commit c7c1baa

Please sign in to comment.