diff options
author | Julien Gouesse <[email protected]> | 2016-06-30 22:36:24 +0200 |
---|---|---|
committer | Julien Gouesse <[email protected]> | 2016-06-30 22:36:24 +0200 |
commit | ced8e5e5a3439630b51a5aef53ef5dfbde69eb95 (patch) | |
tree | d09e41e49f4ad4a172a2cb4760d373aead49d4eb /ardor3d-math/src/main/java/com/ardor3d | |
parent | 1257dbbf93986d1c2f21c0b1758efd8ffd110cf5 (diff) |
Switches from Java 1.6 to Java 1.7 and fixes numerous warnings
Diffstat (limited to 'ardor3d-math/src/main/java/com/ardor3d')
18 files changed, 576 insertions, 724 deletions
diff --git a/ardor3d-math/src/main/java/com/ardor3d/math/ColorRGBA.java b/ardor3d-math/src/main/java/com/ardor3d/math/ColorRGBA.java index a6879cd..61aebce 100644 --- a/ardor3d-math/src/main/java/com/ardor3d/math/ColorRGBA.java +++ b/ardor3d-math/src/main/java/com/ardor3d/math/ColorRGBA.java @@ -3,7 +3,7 @@ * * This file is part of Ardor3D. * - * Ardor3D is free software: you can redistribute it and/or modify it + * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ @@ -14,6 +14,7 @@ import java.io.Externalizable; import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; +import java.util.Objects; import com.ardor3d.math.type.ReadOnlyColorRGBA; import com.ardor3d.util.export.InputCapsule; @@ -107,7 +108,7 @@ public class ColorRGBA implements Cloneable, Savable, Externalizable, ReadOnlyCo /** * Constructs a new, mutable color set to the (r, g, b, a) values of the provided source color. - * + * * @param src */ public ColorRGBA(final ReadOnlyColorRGBA src) { @@ -116,7 +117,7 @@ public class ColorRGBA implements Cloneable, Savable, Externalizable, ReadOnlyCo /** * Constructs a new color set to (r, g, b, a). - * + * * @param r * @param g * @param b @@ -198,7 +199,7 @@ public class ColorRGBA implements Cloneable, Savable, Externalizable, ReadOnlyCo /** * Stores the float values of this color in the given float array. - * + * * @param store * if null, a new float[4] array is created. * @return the float array @@ -222,7 +223,7 @@ public class ColorRGBA implements Cloneable, Savable, Externalizable, ReadOnlyCo /** * Sets the red component of this color to the given float value. - * + * * @param r * new red value, generally should be in the range [0.0f, 1.0f] */ @@ -232,7 +233,7 @@ public class ColorRGBA implements Cloneable, Savable, Externalizable, ReadOnlyCo /** * Sets the green component of this color to the given float value. - * + * * @param g * new green value, generally should be in the range [0.0f, 1.0f] */ @@ -242,7 +243,7 @@ public class ColorRGBA implements Cloneable, Savable, Externalizable, ReadOnlyCo /** * Sets the blue component of this color to the given float value. - * + * * @param b * new blue value, generally should be in the range [0.0f, 1.0f] */ @@ -253,7 +254,7 @@ public class ColorRGBA implements Cloneable, Savable, Externalizable, ReadOnlyCo /** * Sets the alpha component of this color to the given float value. Consider that an alpha of 1.0f means opaque (can * not see through) and 0.0f means transparent. - * + * * @param a * new alpha value, generally should be in the range [0.0f, 1.0f] */ @@ -263,7 +264,7 @@ public class ColorRGBA implements Cloneable, Savable, Externalizable, ReadOnlyCo /** * Sets the value of this color to (r, g, b, a) - * + * * @param r * new red value, generally should be in the range [0.0f, 1.0f] * @param g @@ -284,7 +285,7 @@ public class ColorRGBA implements Cloneable, Savable, Externalizable, ReadOnlyCo /** * Sets the value of this color to the (r, g, b, a) values of the provided source color. - * + * * @param source * @return this color for chaining * @throws NullPointerException @@ -300,7 +301,7 @@ public class ColorRGBA implements Cloneable, Savable, Externalizable, ReadOnlyCo /** * Sets the value of this color to (0, 0, 0, 0) - * + * * @return this color for chaining */ public ColorRGBA zero() { @@ -310,7 +311,7 @@ public class ColorRGBA implements Cloneable, Savable, Externalizable, ReadOnlyCo /** * Brings all values (r,g,b,a) into the range [0.0f, 1.0f]. If a value is above or below this range it is replaced * with the appropriate end of the range. - * + * * @param store * the color to store the result in for return. If null, a new color object is created and returned. */ @@ -353,7 +354,7 @@ public class ColorRGBA implements Cloneable, Savable, Externalizable, ReadOnlyCo /** * Brings all values (r,g,b,a) into the range [0.0f, 1.0f]. If a value is above or below this range it is replaced * with the appropriate end of the range. - * + * * @return this color for chaining */ public ColorRGBA clampLocal() { @@ -405,7 +406,7 @@ public class ColorRGBA implements Cloneable, Savable, Externalizable, ReadOnlyCo /** * Reads a color, packed into a 4 byte int as 1 byte values in the order ARGB. These byte values are normalized to * the range [0.0f, 1.0f] - * + * * @param color * @return this color for chaining */ @@ -420,7 +421,7 @@ public class ColorRGBA implements Cloneable, Savable, Externalizable, ReadOnlyCo /** * Reads a color, packed into a 4 byte int as 1 byte values in the order RGBA. These byte values are normalized to * the range [0.0f, 1.0f] - * + * * @param color * @return this color for chaining */ @@ -463,7 +464,7 @@ public class ColorRGBA implements Cloneable, Savable, Externalizable, ReadOnlyCo /** * Adds the given values to those of this color and returns them in store. - * + * * @param r * @param g * @param b @@ -484,7 +485,7 @@ public class ColorRGBA implements Cloneable, Savable, Externalizable, ReadOnlyCo /** * Increments the values of this color with the given r, g, b and a values. - * + * * @param r * @param g * @param b @@ -497,7 +498,7 @@ public class ColorRGBA implements Cloneable, Savable, Externalizable, ReadOnlyCo /** * Adds the values of the given source color to those of this color and returns them in store. - * + * * @param source * @param store * the color to store the result in for return. If null, a new color object is created and returned. @@ -512,7 +513,7 @@ public class ColorRGBA implements Cloneable, Savable, Externalizable, ReadOnlyCo /** * Increments the values of this color with the r, g, b and a values of the given color. - * + * * @param source * @return this color for chaining * @throws NullPointerException @@ -524,7 +525,7 @@ public class ColorRGBA implements Cloneable, Savable, Externalizable, ReadOnlyCo /** * Subtracts the given values from those of this color and returns them in store. - * + * * @param r * @param g * @param b @@ -545,7 +546,7 @@ public class ColorRGBA implements Cloneable, Savable, Externalizable, ReadOnlyCo /** * Decrements the values of this color by the given r, g, b and a values. - * + * * @param r * @param g * @param b @@ -558,7 +559,7 @@ public class ColorRGBA implements Cloneable, Savable, Externalizable, ReadOnlyCo /** * Subtracts the values of the given source color from those of this color and returns them in store. - * + * * @param source * @param store * the color to store the result in for return. If null, a new color object is created and returned. @@ -573,7 +574,7 @@ public class ColorRGBA implements Cloneable, Savable, Externalizable, ReadOnlyCo /** * Decrements the values of this color by the r, g, b and a values from the given source color. - * + * * @param source * @return this color for chaining * @throws NullPointerException @@ -585,7 +586,7 @@ public class ColorRGBA implements Cloneable, Savable, Externalizable, ReadOnlyCo /** * Multiplies the values of this color by the given scalar value and returns the result in store. - * + * * @param scalar * @param store * the color to store the result in for return. If null, a new color object is created and returned. @@ -603,10 +604,10 @@ public class ColorRGBA implements Cloneable, Savable, Externalizable, ReadOnlyCo /** * Internally modifies the values of this color by multiplying them each by the given scalar value. - * + * * @param scalar * @return this color for chaining - * + * * . */ public ColorRGBA multiplyLocal(final float scalar) { @@ -615,7 +616,7 @@ public class ColorRGBA implements Cloneable, Savable, Externalizable, ReadOnlyCo /** * Multiplies the values of this color by the given scalar value and returns the result in store. - * + * * @param scale * @param store * the color to store the result in for return. If null, a new color object is created and returned. @@ -634,18 +635,18 @@ public class ColorRGBA implements Cloneable, Savable, Externalizable, ReadOnlyCo /** * Internally modifies the values of this color by multiplying them each by the given scale values. - * + * * @param scale * @return this color for chaining */ public ColorRGBA multiplyLocal(final ReadOnlyColorRGBA scale) { - return set(getRed() * scale.getRed(), getGreen() * scale.getGreen(), getBlue() * scale.getBlue(), getAlpha() - * scale.getAlpha()); + return set(getRed() * scale.getRed(), getGreen() * scale.getGreen(), getBlue() * scale.getBlue(), + getAlpha() * scale.getAlpha()); } /** * Divides the values of this color by the given scalar value and returns the result in store. - * + * * @param scalar * @param store * the color to store the result in for return. If null, a new color object is created and returned. @@ -663,7 +664,7 @@ public class ColorRGBA implements Cloneable, Savable, Externalizable, ReadOnlyCo /** * Internally modifies the values of this color by dividing them each by the given scalar value. - * + * * @param scalar * @return this color for chaining * @throws ArithmeticException @@ -677,7 +678,7 @@ public class ColorRGBA implements Cloneable, Savable, Externalizable, ReadOnlyCo /** * Divides the values of this color by the given scale values and returns the result in store. - * + * * @param scale * @param store * the color to store the result in for return. If null, a new color object is created and returned. @@ -696,20 +697,20 @@ public class ColorRGBA implements Cloneable, Savable, Externalizable, ReadOnlyCo /** * Internally modifies the values of this color by dividing them each by the given scale values. - * + * * @param scale * @return this color for chaining */ public ColorRGBA divideLocal(final ReadOnlyColorRGBA scale) { - return set(getRed() / scale.getRed(), getGreen() / scale.getGreen(), getBlue() / scale.getBlue(), getAlpha() - / scale.getAlpha()); + return set(getRed() / scale.getRed(), getGreen() / scale.getGreen(), getBlue() / scale.getBlue(), + getAlpha() / scale.getAlpha()); } /** * Performs a linear interpolation between this color and the given end color, using the given scalar as a percent. * iow, if changeAmnt is closer to 0, the result will be closer to the current value of this color and if it is * closer to 1, the result will be closer to the end value. - * + * * @param endColor * @param scalar * @param store @@ -736,7 +737,7 @@ public class ColorRGBA implements Cloneable, Savable, Externalizable, ReadOnlyCo * Performs a linear interpolation between this color and the given end color, using the given scalar as a percent. * iow, if changeAmnt is closer to 0, the result will be closer to the current value of this color and if it is * closer to 1, the result will be closer to the end value. The result is stored back in this color. - * + * * @param endColor * @param scalar * @return this color for chaining @@ -755,7 +756,7 @@ public class ColorRGBA implements Cloneable, Savable, Externalizable, ReadOnlyCo * Performs a linear interpolation between the given begin and end colors, using the given scalar as a percent. iow, * if changeAmnt is closer to 0, the result will be closer to the begin value and if it is closer to 1, the result * will be closer to the end value. - * + * * @param beginColor * @param endColor * @param scalar @@ -784,7 +785,7 @@ public class ColorRGBA implements Cloneable, Savable, Externalizable, ReadOnlyCo * Performs a linear interpolation between the given begin and end colors, using the given scalar as a percent. iow, * if changeAmnt is closer to 0, the result will be closer to the begin value and if it is closer to 1, the result * will be closer to the end value. The result is stored back in this color. - * + * * @param beginColor * @param endColor * @param changeAmnt @@ -793,7 +794,8 @@ public class ColorRGBA implements Cloneable, Savable, Externalizable, ReadOnlyCo * @throws NullPointerException * if beginVec or endVec are null. */ - public ColorRGBA lerpLocal(final ReadOnlyColorRGBA beginColor, final ReadOnlyColorRGBA endColor, final float scalar) { + public ColorRGBA lerpLocal(final ReadOnlyColorRGBA beginColor, final ReadOnlyColorRGBA endColor, + final float scalar) { setRed((1.0f - scalar) * beginColor.getRed() + scalar * endColor.getRed()); setGreen((1.0f - scalar) * beginColor.getGreen() + scalar * endColor.getGreen()); setBlue((1.0f - scalar) * beginColor.getBlue() + scalar * endColor.getBlue()); @@ -803,7 +805,7 @@ public class ColorRGBA implements Cloneable, Savable, Externalizable, ReadOnlyCo /** * Check a color... if it is null or its values are NaN or infinite, return false. Else return true. - * + * * @param color * the color to check * @return true or false as stated above. @@ -838,21 +840,8 @@ public class ColorRGBA implements Cloneable, Savable, Externalizable, ReadOnlyCo */ @Override public int hashCode() { - int result = 17; - - final int r = Float.floatToIntBits(getRed()); - result += 31 * result + r; - - final int g = Float.floatToIntBits(getGreen()); - result += 31 * result + g; - - final int b = Float.floatToIntBits(getBlue()); - result += 31 * result + b; - - final int a = Float.floatToIntBits(getAlpha()); - result += 31 * result + a; - - return result; + return Objects.hash(Float.valueOf(getRed()), Float.valueOf(getGreen()), Float.valueOf(getBlue()), + Float.valueOf(getAlpha())); } /** @@ -913,7 +902,7 @@ public class ColorRGBA implements Cloneable, Savable, Externalizable, ReadOnlyCo /** * Used with serialization. Not to be called manually. - * + * * @param in * ObjectInput * @throws IOException @@ -929,7 +918,7 @@ public class ColorRGBA implements Cloneable, Savable, Externalizable, ReadOnlyCo /** * Used with serialization. Not to be called manually. - * + * * @param out * ObjectOutput * @throws IOException @@ -961,7 +950,7 @@ public class ColorRGBA implements Cloneable, Savable, Externalizable, ReadOnlyCo /** * Releases a ColorRGBA back to be used by a future call to fetchTempInstance. TAKE CARE: this ColorRGBA object * should no longer have other classes referencing it or "Bad Things" will happen. - * + * * @param color * the ColorRGBA to release. */ @@ -983,7 +972,7 @@ public class ColorRGBA implements Cloneable, Savable, Externalizable, ReadOnlyCo * <li>6: RRGGBB - RGB is parsed as RR/255, GG/255, BB/255, A=1</li> * <li>8: RRGGBBAA - RGBA is parsed as RR/255, GG/255, BB/255, AA/255</li> * </ul> - * + * * @param colorString * @param store * @return @@ -1030,8 +1019,8 @@ public class ColorRGBA implements Cloneable, Savable, Externalizable, ReadOnlyCo b = Integer.parseInt(colorString.substring(5, 7), 16) / 255f; a = Integer.parseInt(colorString.substring(7, 9), 16) / 255f; } else { - throw new IllegalArgumentException("unsupported value, must be 1, 2, 3, 4, 5, 7 or 9 hexvalues: " - + colorString); + throw new IllegalArgumentException( + "unsupported value, must be 1, 2, 3, 4, 5, 7 or 9 hexvalues: " + colorString); } rVal.set(r, g, b, a); diff --git a/ardor3d-math/src/main/java/com/ardor3d/math/Line3Base.java b/ardor3d-math/src/main/java/com/ardor3d/math/Line3Base.java index 409268a..3e4fbbf 100644 --- a/ardor3d-math/src/main/java/com/ardor3d/math/Line3Base.java +++ b/ardor3d-math/src/main/java/com/ardor3d/math/Line3Base.java @@ -3,7 +3,7 @@ * * This file is part of Ardor3D. * - * Ardor3D is free software: you can redistribute it and/or modify it + * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ @@ -14,6 +14,7 @@ import java.io.Externalizable; import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; +import java.util.Objects; import com.ardor3d.math.type.ReadOnlyVector3; import com.ardor3d.util.export.InputCapsule; @@ -46,7 +47,7 @@ public abstract class Line3Base implements Savable, Externalizable { /** * Sets the line's origin point to the values of the given vector. - * + * * @param origin * @throws NullPointerException * if normal is null. @@ -57,7 +58,7 @@ public abstract class Line3Base implements Savable, Externalizable { /** * Sets the line's direction to the values of the given vector. - * + * * @param direction * @throws NullPointerException * if direction is null. @@ -72,12 +73,7 @@ public abstract class Line3Base implements Savable, Externalizable { */ @Override public int hashCode() { - int result = 17; - - result += 31 * result + _origin.hashCode(); - result += 31 * result + _direction.hashCode(); - - return result; + return Objects.hash(getOrigin(), getDirection()); } // ///////////////// @@ -107,7 +103,7 @@ public abstract class Line3Base implements Savable, Externalizable { /** * Used with serialization. Not to be called manually. - * + * * @param in * ObjectInput * @throws IOException @@ -121,7 +117,7 @@ public abstract class Line3Base implements Savable, Externalizable { /** * Used with serialization. Not to be called manually. - * + * * @param out * ObjectOutput * @throws IOException diff --git a/ardor3d-math/src/main/java/com/ardor3d/math/LineSegment3.java b/ardor3d-math/src/main/java/com/ardor3d/math/LineSegment3.java index aa62875..8005268 100644 --- a/ardor3d-math/src/main/java/com/ardor3d/math/LineSegment3.java +++ b/ardor3d-math/src/main/java/com/ardor3d/math/LineSegment3.java @@ -3,7 +3,7 @@ * * This file is part of Ardor3D. * - * Ardor3D is free software: you can redistribute it and/or modify it + * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ @@ -13,6 +13,7 @@ package com.ardor3d.math; import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; +import java.util.Objects; import com.ardor3d.math.type.ReadOnlyLineSegment3; import com.ardor3d.math.type.ReadOnlyVector3; @@ -42,7 +43,7 @@ public class LineSegment3 extends Line3Base implements ReadOnlyLineSegment3, Poo /** * Copy constructor. - * + * * @param source * the line segment to copy from. */ @@ -52,7 +53,7 @@ public class LineSegment3 extends Line3Base implements ReadOnlyLineSegment3, Poo /** * Constructs a new segment segment using the supplied origin point, unit length direction vector and extent - * + * * @param origin * @param direction * - unit length @@ -65,7 +66,7 @@ public class LineSegment3 extends Line3Base implements ReadOnlyLineSegment3, Poo /** * Constructs a new segment segment using the supplied start and end points - * + * * @param start * @param end */ @@ -79,7 +80,7 @@ public class LineSegment3 extends Line3Base implements ReadOnlyLineSegment3, Poo /** * Copies the values of the given source segment into this segment. - * + * * @param source * @return this segment for chaining * @throws NullPointerException @@ -101,7 +102,7 @@ public class LineSegment3 extends Line3Base implements ReadOnlyLineSegment3, Poo /** * Sets the segment's extent to the provided value. - * + * * @param extent */ public void setExtent(final double extent) { @@ -170,7 +171,7 @@ public class LineSegment3 extends Line3Base implements ReadOnlyLineSegment3, Poo } /** - * + * * @param position * a random position lying somewhere on this line segment. */ @@ -191,7 +192,7 @@ public class LineSegment3 extends Line3Base implements ReadOnlyLineSegment3, Poo /** * Check a segment... if it is null or the values of its origin or direction or extent are NaN or infinite, return * false. Else return true. - * + * * @param segment * the segment to check * @return true or false as stated above. @@ -237,14 +238,7 @@ public class LineSegment3 extends Line3Base implements ReadOnlyLineSegment3, Poo */ @Override public int hashCode() { - int result = 17; - - result += 31 * result + _origin.hashCode(); - result += 31 * result + _direction.hashCode(); - final long ex = Double.doubleToLongBits(_extent); - result += 31 * result + (int) (ex ^ ex >>> 32); - - return result; + return Objects.hash(getOrigin(), getDirection(), Double.valueOf(getExtent())); } // ///////////////// @@ -278,7 +272,7 @@ public class LineSegment3 extends Line3Base implements ReadOnlyLineSegment3, Poo /** * Used with serialization. Not to be called manually. - * + * * @param in * ObjectInput * @throws IOException @@ -292,7 +286,7 @@ public class LineSegment3 extends Line3Base implements ReadOnlyLineSegment3, Poo /** * Used with serialization. Not to be called manually. - * + * * @param out * ObjectOutput * @throws IOException @@ -322,7 +316,7 @@ public class LineSegment3 extends Line3Base implements ReadOnlyLineSegment3, Poo /** * Releases a LineSegment3 back to be used by a future call to fetchTempInstance. TAKE CARE: this LineSegment3 * object should no longer have other classes referencing it or "Bad Things" will happen. - * + * * @param segment * the LineSegment3 to release. */ diff --git a/ardor3d-math/src/main/java/com/ardor3d/math/Matrix3.java b/ardor3d-math/src/main/java/com/ardor3d/math/Matrix3.java index 78a9b16..702a467 100644 --- a/ardor3d-math/src/main/java/com/ardor3d/math/Matrix3.java +++ b/ardor3d-math/src/main/java/com/ardor3d/math/Matrix3.java @@ -3,7 +3,7 @@ * * This file is part of Ardor3D. * - * Ardor3D is free software: you can redistribute it and/or modify it + * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ @@ -17,6 +17,7 @@ import java.io.ObjectOutput; import java.nio.BufferOverflowException; import java.nio.DoubleBuffer; import java.nio.FloatBuffer; +import java.util.Objects; import com.ardor3d.math.type.ReadOnlyMatrix3; import com.ardor3d.math.type.ReadOnlyQuaternion; @@ -27,7 +28,7 @@ import com.ardor3d.util.export.Savable; /** * Matrix3 represents a double precision 3x3 matrix. - * + * * Note: some algorithms in this class were ported from Eberly, Wolfram, Game Gems and others to Java. */ public class Matrix3 implements Cloneable, Savable, Externalizable, ReadOnlyMatrix3, Poolable { @@ -61,7 +62,7 @@ public class Matrix3 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Constructs a new, mutable matrix using the given matrix values (names are mRC = m[ROW][COL]) - * + * * @param m00 * @param m01 * @param m02 @@ -88,7 +89,7 @@ public class Matrix3 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Constructs a new, mutable matrix using the values from the given matrix - * + * * @param source */ public Matrix3(final ReadOnlyMatrix3 source) { @@ -235,7 +236,7 @@ public class Matrix3 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Same as set(IDENTITY) - * + * * @return this matrix for chaining */ public Matrix3 setIdentity() { @@ -252,7 +253,7 @@ public class Matrix3 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Sets the value of this matrix at row, column to the given value. - * + * * @param row * @param column * @param value @@ -319,7 +320,7 @@ public class Matrix3 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Sets the values of this matrix to the values given. - * + * * @param m00 * @param m01 * @param m02 @@ -349,7 +350,7 @@ public class Matrix3 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Sets the values of this matrix to the values of the provided source matrix. - * + * * @param source * @return this matrix for chaining * @throws NullPointerException @@ -373,7 +374,7 @@ public class Matrix3 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Sets the values of this matrix to the rotational value of the given quaternion. - * + * * @param quaternion * @return this matrix for chaining */ @@ -425,7 +426,7 @@ public class Matrix3 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Note: data is cast to floats. - * + * * @param store * the buffer to read our matrix data from. * @return this matrix for chaining. @@ -436,7 +437,7 @@ public class Matrix3 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Note: data is cast to floats. - * + * * @param store * the buffer to read our matrix data from. * @param rowMajor @@ -471,7 +472,7 @@ public class Matrix3 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Sets the values of this matrix to the values of the provided double array. - * + * * @param source * @return this matrix for chaining * @throws NullPointerException @@ -485,7 +486,7 @@ public class Matrix3 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Sets the values of this matrix to the values of the provided double array. - * + * * @param source * @param rowMajor * @return this matrix for chaining @@ -521,7 +522,7 @@ public class Matrix3 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Replaces a column in this matrix with the values of the given vector. - * + * * @param columnIndex * @param columnData * @return this matrix for chaining @@ -555,7 +556,7 @@ public class Matrix3 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Replaces a row in this matrix with the values of the given vector. - * + * * @param rowIndex * @param rowData * @return this matrix for chaining @@ -589,7 +590,7 @@ public class Matrix3 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Set the values of this matrix from the axes (columns) provided. - * + * * @param uAxis * @param vAxis * @param wAxis @@ -607,7 +608,7 @@ public class Matrix3 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Sets this matrix to the rotation indicated by the given angle and axis of rotation. Note: This method creates an * object, so use fromAngleNormalAxis when possible, particularly if your axis is already normalized. - * + * * @param angle * the angle to rotate (in radians). * @param axis @@ -626,7 +627,7 @@ public class Matrix3 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Sets this matrix to the rotation indicated by the given angle and a unit-length axis of rotation. - * + * * @param angle * the angle to rotate (in radians). * @param axis @@ -665,11 +666,11 @@ public class Matrix3 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * XXX: Need to redo this again... or at least correct the terms. YRP are arbitrary terms, based on a specific frame * of axis. - * + * * Updates this matrix from the given Euler rotation angles (y,r,p). Note that we are applying in order: roll, * pitch, yaw but we've ordered them in x, y, and z for convenience. See: * http://www.euclideanspace.com/maths/geometry/rotations/conversions/eulerToMatrix/index.htm - * + * * @param yaw * the Euler yaw of rotation (in radians). (aka Bank, often rot around x) * @param roll @@ -700,8 +701,8 @@ public class Matrix3 implements Cloneable, Savable, Externalizable, ReadOnlyMatr public Matrix3 applyRotation(final double angle, final double x, final double y, final double z) { final double m00 = _m00, m01 = _m01, m02 = _m02, // - m10 = _m10, m11 = _m11, m12 = _m12, // - m20 = _m20, m21 = _m21, m22 = _m22; + m10 = _m10, m11 = _m11, m12 = _m12, // + m20 = _m20, m21 = _m21, m22 = _m22; final double cosAngle = Math.cos(angle); final double sinAngle = Math.sin(angle); @@ -740,14 +741,14 @@ public class Matrix3 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Apply rotation around X (Mrx * this) - * + * * @param angle * @return */ public Matrix3 applyRotationX(final double angle) { final double m01 = _m01, m02 = _m02, // - m11 = _m11, m12 = _m12, // - m21 = _m21, m22 = _m22; + m11 = _m11, m12 = _m12, // + m21 = _m21, m22 = _m22; final double cosAngle = Math.cos(angle); final double sinAngle = Math.sin(angle); @@ -766,14 +767,14 @@ public class Matrix3 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Apply rotation around Y (Mry * this) - * + * * @param angle * @return */ public Matrix3 applyRotationY(final double angle) { final double m00 = _m00, m02 = _m02, // - m10 = _m10, m12 = _m12, // - m20 = _m20, m22 = _m22; + m10 = _m10, m12 = _m12, // + m20 = _m20, m22 = _m22; final double cosAngle = Math.cos(angle); final double sinAngle = Math.sin(angle); @@ -792,14 +793,14 @@ public class Matrix3 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Apply rotation around Z (Mrz * this) - * + * * @param angle * @return */ public Matrix3 applyRotationZ(final double angle) { final double m00 = _m00, m01 = _m01, // - m10 = _m10, m11 = _m11, // - m20 = _m20, m21 = _m21; + m10 = _m10, m11 = _m11, // + m20 = _m20, m21 = _m21; final double cosAngle = Math.cos(angle); final double sinAngle = Math.sin(angle); @@ -946,7 +947,7 @@ public class Matrix3 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Note: data is cast to floats. - * + * * @param store * the buffer to store our matrix data in. Must not be null. Data is entered starting at current buffer * position. @@ -963,7 +964,7 @@ public class Matrix3 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Note: data is cast to floats. - * + * * @param store * the buffer to store our matrix data in. Must not be null. Data is entered starting at current buffer * position. @@ -1060,7 +1061,7 @@ public class Matrix3 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * converts this matrix to Euler rotation angles (yaw, roll, pitch). See * http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToEuler/index.htm - * + * * @param store * the double[] array to store the computed angles in. If null, a new double[] will be created * @return the double[] array. @@ -1141,7 +1142,7 @@ public class Matrix3 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Multiplies this matrix by the diagonal matrix formed by the given vector (v^D * M). If supplied, the result is * stored into the supplied "store" matrix. - * + * * @param vec * @param store * a matrix to store the result in. If store is null, a new matrix is created. Note that it IS safe for @@ -1168,7 +1169,7 @@ public class Matrix3 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Multiplies this matrix by the diagonal matrix formed by the given vector (M * v^D). If supplied, the result is * stored into the supplied "store" matrix. - * + * * @param vec * @param store * a matrix to store the result in. If store is null, a new matrix is created. Note that it IS safe for @@ -1194,7 +1195,7 @@ public class Matrix3 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Internally scales all values of this matrix by the given scalar. - * + * * @param scalar * @return this matrix for chaining. */ @@ -1243,7 +1244,7 @@ public class Matrix3 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Internally adds the values of the given matrix to this matrix. - * + * * @param matrix * the matrix to add to this. * @return this matrix for chaining @@ -1286,7 +1287,7 @@ public class Matrix3 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Internally subtracts the values of the given matrix from this matrix. - * + * * @param matrix * the matrix to subtract from this. * @return this matrix for chaining @@ -1299,7 +1300,7 @@ public class Matrix3 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Applies the given scale to this matrix and returns the result as a new matrix - * + * * @param scale * @param store * a matrix to store the result in. If store is null, a new matrix is created. @@ -1322,7 +1323,7 @@ public class Matrix3 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Applies the given scale to this matrix values internally - * + * * @param scale * @return this matrix for chaining. * @throws NullPointerException @@ -1334,7 +1335,7 @@ public class Matrix3 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * transposes this matrix as a new matrix, basically flipping it across the diagonal - * + * * @param store * a matrix to store the result in. If store is null, a new matrix is created. * @return this matrix for chaining. @@ -1361,7 +1362,7 @@ public class Matrix3 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * transposes this matrix in place - * + * * @return this matrix for chaining. * @see <a href="http://en.wikipedia.org/wiki/Transpose">wikipedia.org-Transpose</a> */ @@ -1383,7 +1384,7 @@ public class Matrix3 implements Cloneable, Savable, Externalizable, ReadOnlyMatr * a matrix to store the result in. If store is null, a new matrix is created. Note that it IS safe for * store == this. * @return a matrix that represents this matrix, inverted. - * + * * if store is not null and is read only * @throws ArithmeticException * if this matrix can not be inverted. @@ -1416,7 +1417,7 @@ public class Matrix3 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Inverts this matrix locally. - * + * * @return this matrix inverted internally. * @throws ArithmeticException * if this matrix can not be inverted. @@ -1471,7 +1472,7 @@ public class Matrix3 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * A function for creating a rotation matrix that rotates a vector called "start" into another vector called "end". - * + * * @param start * normalized non-zero starting vector * @param end @@ -1554,7 +1555,7 @@ public class Matrix3 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Multiplies the given vector by this matrix (v * M). If supplied, the result is stored into the supplied "store" * vector. - * + * * @param vec * the vector to multiply this matrix by. * @param store @@ -1584,7 +1585,7 @@ public class Matrix3 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Multiplies the given vector by this matrix (M * v). If supplied, the result is stored into the supplied "store" * vector. - * + * * @param vec * the vector to multiply this matrix by. * @param store @@ -1613,7 +1614,7 @@ public class Matrix3 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Modifies this matrix to equal the rotation required to point the z-axis at 'direction' and the y-axis to 'up'. - * + * * @param direction * where to 'look' at * @param up @@ -1638,7 +1639,7 @@ public class Matrix3 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Check a matrix... if it is null or its doubles are NaN or infinite, return false. Else return true. - * + * * @param matrix * the vector to check * @return true or false as stated above. @@ -1704,7 +1705,7 @@ public class Matrix3 implements Cloneable, Savable, Externalizable, ReadOnlyMatr */ @Override public String toString() { - final StringBuffer result = new StringBuffer("com.ardor3d.math.Matrix3\n[\n"); + final StringBuilder result = new StringBuilder("com.ardor3d.math.Matrix3\n[\n"); result.append(' '); result.append(_m00); result.append(' '); @@ -1739,30 +1740,9 @@ public class Matrix3 implements Cloneable, Savable, Externalizable, ReadOnlyMatr */ @Override public int hashCode() { - int result = 17; - - long val = Double.doubleToLongBits(_m00); - result += 31 * result + (int) (val ^ val >>> 32); - val = Double.doubleToLongBits(_m01); - result += 31 * result + (int) (val ^ val >>> 32); - val = Double.doubleToLongBits(_m02); - result += 31 * result + (int) (val ^ val >>> 32); - - val = Double.doubleToLongBits(_m10); - result += 31 * result + (int) (val ^ val >>> 32); - val = Double.doubleToLongBits(_m11); - result += 31 * result + (int) (val ^ val >>> 32); - val = Double.doubleToLongBits(_m12); - result += 31 * result + (int) (val ^ val >>> 32); - - val = Double.doubleToLongBits(_m20); - result += 31 * result + (int) (val ^ val >>> 32); - val = Double.doubleToLongBits(_m21); - result += 31 * result + (int) (val ^ val >>> 32); - val = Double.doubleToLongBits(_m22); - result += 31 * result + (int) (val ^ val >>> 32); - - return result; + return Objects.hash(Double.valueOf(getM00()), Double.valueOf(getM01()), Double.valueOf(getM02()), + Double.valueOf(getM10()), Double.valueOf(getM11()), Double.valueOf(getM12()), Double.valueOf(getM20()), + Double.valueOf(getM21()), Double.valueOf(getM22())); } /** @@ -1889,7 +1869,7 @@ public class Matrix3 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Used with serialization. Not to be called manually. - * + * * @param in * ObjectInput * @throws IOException @@ -1910,7 +1890,7 @@ public class Matrix3 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Used with serialization. Not to be called manually. - * + * * @param out * ObjectOutput * @throws IOException @@ -1947,7 +1927,7 @@ public class Matrix3 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Releases a Matrix3 back to be used by a future call to fetchTempInstance. TAKE CARE: this Matrix3 object should * no longer have other classes referencing it or "Bad Things" will happen. - * + * * @param mat * the Matrix3 to release. */ diff --git a/ardor3d-math/src/main/java/com/ardor3d/math/Matrix4.java b/ardor3d-math/src/main/java/com/ardor3d/math/Matrix4.java index 8d21433..5579aac 100644 --- a/ardor3d-math/src/main/java/com/ardor3d/math/Matrix4.java +++ b/ardor3d-math/src/main/java/com/ardor3d/math/Matrix4.java @@ -3,7 +3,7 @@ * * This file is part of Ardor3D. * - * Ardor3D is free software: you can redistribute it and/or modify it + * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ @@ -17,6 +17,7 @@ import java.io.ObjectOutput; import java.nio.BufferOverflowException; import java.nio.DoubleBuffer; import java.nio.FloatBuffer; +import java.util.Objects; import com.ardor3d.math.type.ReadOnlyMatrix3; import com.ardor3d.math.type.ReadOnlyMatrix4; @@ -30,7 +31,7 @@ import com.ardor3d.util.export.Savable; /** * Matrix4 represents a double precision 4x4 matrix and contains a flag, set at object creation, indicating if the given * Matrix4 object is mutable. - * + * * Note: some algorithms in this class were ported from Eberly, Wolfram, Game Gems and others to Java. */ public class Matrix4 implements Cloneable, Savable, Externalizable, ReadOnlyMatrix4, Poolable { @@ -65,7 +66,7 @@ public class Matrix4 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Constructs a new matrix set to the given matrix values. (names are mRC = m[ROW][COL]) - * + * * @param m00 * @param m01 * @param m02 @@ -107,7 +108,7 @@ public class Matrix4 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Constructs a new matrix set to the values of the given matrix. - * + * * @param source */ public Matrix4(final ReadOnlyMatrix4 source) { @@ -336,7 +337,7 @@ public class Matrix4 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Same as set(IDENTITY) - * + * * @return this matrix for chaining */ public Matrix4 setIdentity() { @@ -353,7 +354,7 @@ public class Matrix4 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Sets the value of this matrix at row, column to the given value. - * + * * @param row * @param column * @param value @@ -448,7 +449,7 @@ public class Matrix4 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Sets the values of this matrix to the values given. - * + * * @param m00 * @param m01 * @param m02 @@ -493,7 +494,7 @@ public class Matrix4 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Sets the values of this matrix to the values of the provided source matrix. - * + * * @param source * @return this matrix for chaining * @throws NullPointerException @@ -525,7 +526,7 @@ public class Matrix4 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Sets the 3x3 rotation part of this matrix to the values of the provided source matrix. - * + * * @param source * @return this matrix for chaining * @throws NullPointerException @@ -547,7 +548,7 @@ public class Matrix4 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Sets the values of this matrix to the rotational value of the given quaternion. Only modifies the 3x3 rotation * part of this matrix. - * + * * @param quaternion * @return this matrix for chaining */ @@ -613,7 +614,7 @@ public class Matrix4 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Note: data is cast to floats. - * + * * @param store * the buffer to read our matrix data from. * @return this matrix for chaining. @@ -624,7 +625,7 @@ public class Matrix4 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Note: data is cast to floats. - * + * * @param store * the buffer to read our matrix data from. * @param rowMajor @@ -673,7 +674,7 @@ public class Matrix4 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Sets the values of this matrix to the values of the provided double array. - * + * * @param source * @return this matrix for chaining * @throws NullPointerException @@ -687,7 +688,7 @@ public class Matrix4 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Sets the values of this matrix to the values of the provided double array. - * + * * @param source * @param rowMajor * @return this matrix for chaining @@ -737,7 +738,7 @@ public class Matrix4 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Replaces a column in this matrix with the values of the given array. - * + * * @param columnIndex * @param columnData * @return this matrix for chaining @@ -782,7 +783,7 @@ public class Matrix4 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Replaces a row in this matrix with the values of the given array. - * + * * @param rowIndex * @param rowData * @return this matrix for chaining @@ -829,7 +830,7 @@ public class Matrix4 implements Cloneable, Savable, Externalizable, ReadOnlyMatr * Sets the 3x3 rotation portion of this matrix to the rotation indicated by the given angle and axis of rotation. * Note: This method creates an object, so use fromAngleNormalAxis when possible, particularly if your axis is * already normalized. - * + * * @param angle * the angle to rotate (in radians). * @param axis @@ -849,7 +850,7 @@ public class Matrix4 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Sets the 3x3 rotation portion of this matrix to the rotation indicated by the given angle and a unit-length axis * of rotation. - * + * * @param angle * the angle to rotate (in radians). * @param axis @@ -887,9 +888,9 @@ public class Matrix4 implements Cloneable, Savable, Externalizable, ReadOnlyMatr public Matrix4 applyRotation(final double angle, final double x, final double y, final double z) { final double m00 = _m00, m01 = _m01, m02 = _m02, // - m10 = _m10, m11 = _m11, m12 = _m12, // - m20 = _m20, m21 = _m21, m22 = _m22, // - m30 = _m30, m31 = _m31, m32 = _m32; + m10 = _m10, m11 = _m11, m12 = _m12, // + m20 = _m20, m21 = _m21, m22 = _m22, // + m30 = _m30, m31 = _m31, m32 = _m32; final double cosAngle = Math.cos(angle); final double sinAngle = Math.sin(angle); @@ -936,9 +937,9 @@ public class Matrix4 implements Cloneable, Savable, Externalizable, ReadOnlyMatr public Matrix4 applyRotationX(final double angle) { final double m01 = _m01, m02 = _m02, // - m11 = _m11, m12 = _m12, // - m21 = _m21, m22 = _m22, // - m31 = _m31, m32 = _m32; + m11 = _m11, m12 = _m12, // + m21 = _m21, m22 = _m22, // + m31 = _m31, m32 = _m32; final double cosAngle = Math.cos(angle); final double sinAngle = Math.sin(angle); @@ -960,9 +961,9 @@ public class Matrix4 implements Cloneable, Savable, Externalizable, ReadOnlyMatr public Matrix4 applyRotationY(final double angle) { final double m00 = _m00, m02 = _m02, // - m10 = _m10, m12 = _m12, // - m20 = _m20, m22 = _m22, // - m30 = _m30, m32 = _m32; + m10 = _m10, m12 = _m12, // + m20 = _m20, m22 = _m22, // + m30 = _m30, m32 = _m32; final double cosAngle = Math.cos(angle); final double sinAngle = Math.sin(angle); @@ -984,9 +985,9 @@ public class Matrix4 implements Cloneable, Savable, Externalizable, ReadOnlyMatr public Matrix4 applyRotationZ(final double angle) { final double m00 = _m00, m01 = _m01, // - m10 = _m10, m11 = _m11, // - m20 = _m20, m21 = _m21, // - m30 = _m30, m31 = _m31; + m10 = _m10, m11 = _m11, // + m20 = _m20, m21 = _m21, // + m30 = _m30, m31 = _m31; final double cosAngle = Math.cos(angle); final double sinAngle = Math.sin(angle); @@ -1008,7 +1009,7 @@ public class Matrix4 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * M*T - * + * * @param x * @param y * @param z @@ -1025,7 +1026,7 @@ public class Matrix4 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * T*M - * + * * @param x * @param y * @param z @@ -1200,7 +1201,7 @@ public class Matrix4 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Note: data is cast to floats. - * + * * @param store * the buffer to store our matrix data in. Must not be null. Data is entered starting at current buffer * @return matrix data as a FloatBuffer in row major order. The position is at the end of the inserted data. @@ -1216,7 +1217,7 @@ public class Matrix4 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Note: data is cast to floats. - * + * * @param store * the buffer to store our matrix data in. Must not be null. Data is entered starting at current buffer * @param rowMajor @@ -1340,7 +1341,7 @@ public class Matrix4 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Multiplies this matrix by the diagonal matrix formed by the given vector (v^D * M). If supplied, the result is * stored into the supplied "store" matrix. - * + * * @param vec * @param store * a matrix to store the result in. If store is null, a new matrix is created. Note that it IS safe for @@ -1368,7 +1369,7 @@ public class Matrix4 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Multiplies this matrix by the diagonal matrix formed by the given vector (M * v^D). If supplied, the result is * stored into the supplied "store" matrix. - * + * * @param vec * @param store * a matrix to store the result in. If store is null, a new matrix is created. Note that it IS safe for @@ -1419,41 +1420,41 @@ public class Matrix4 implements Cloneable, Savable, Externalizable, ReadOnlyMatr result = new Matrix4(); } - final double temp00 = _m00 * matrix.getM00() + _m01 * matrix.getM10() + _m02 * matrix.getM20() + _m03 - * matrix.getM30(); - final double temp01 = _m00 * matrix.getM01() + _m01 * matrix.getM11() + _m02 * matrix.getM21() + _m03 - * matrix.getM31(); - final double temp02 = _m00 * matrix.getM02() + _m01 * matrix.getM12() + _m02 * matrix.getM22() + _m03 - * matrix.getM32(); - final double temp03 = _m00 * matrix.getM03() + _m01 * matrix.getM13() + _m02 * matrix.getM23() + _m03 - * matrix.getM33(); - - final double temp10 = _m10 * matrix.getM00() + _m11 * matrix.getM10() + _m12 * matrix.getM20() + _m13 - * matrix.getM30(); - final double temp11 = _m10 * matrix.getM01() + _m11 * matrix.getM11() + _m12 * matrix.getM21() + _m13 - * matrix.getM31(); - final double temp12 = _m10 * matrix.getM02() + _m11 * matrix.getM12() + _m12 * matrix.getM22() + _m13 - * matrix.getM32(); - final double temp13 = _m10 * matrix.getM03() + _m11 * matrix.getM13() + _m12 * matrix.getM23() + _m13 - * matrix.getM33(); - - final double temp20 = _m20 * matrix.getM00() + _m21 * matrix.getM10() + _m22 * matrix.getM20() + _m23 - * matrix.getM30(); - final double temp21 = _m20 * matrix.getM01() + _m21 * matrix.getM11() + _m22 * matrix.getM21() + _m23 - * matrix.getM31(); - final double temp22 = _m20 * matrix.getM02() + _m21 * matrix.getM12() + _m22 * matrix.getM22() + _m23 - * matrix.getM32(); - final double temp23 = _m20 * matrix.getM03() + _m21 * matrix.getM13() + _m22 * matrix.getM23() + _m23 - * matrix.getM33(); - - final double temp30 = _m30 * matrix.getM00() + _m31 * matrix.getM10() + _m32 * matrix.getM20() + _m33 - * matrix.getM30(); - final double temp31 = _m30 * matrix.getM01() + _m31 * matrix.getM11() + _m32 * matrix.getM21() + _m33 - * matrix.getM31(); - final double temp32 = _m30 * matrix.getM02() + _m31 * matrix.getM12() + _m32 * matrix.getM22() + _m33 - * matrix.getM32(); - final double temp33 = _m30 * matrix.getM03() + _m31 * matrix.getM13() + _m32 * matrix.getM23() + _m33 - * matrix.getM33(); + final double temp00 = _m00 * matrix.getM00() + _m01 * matrix.getM10() + _m02 * matrix.getM20() + + _m03 * matrix.getM30(); + final double temp01 = _m00 * matrix.getM01() + _m01 * matrix.getM11() + _m02 * matrix.getM21() + + _m03 * matrix.getM31(); + final double temp02 = _m00 * matrix.getM02() + _m01 * matrix.getM12() + _m02 * matrix.getM22() + + _m03 * matrix.getM32(); + final double temp03 = _m00 * matrix.getM03() + _m01 * matrix.getM13() + _m02 * matrix.getM23() + + _m03 * matrix.getM33(); + + final double temp10 = _m10 * matrix.getM00() + _m11 * matrix.getM10() + _m12 * matrix.getM20() + + _m13 * matrix.getM30(); + final double temp11 = _m10 * matrix.getM01() + _m11 * matrix.getM11() + _m12 * matrix.getM21() + + _m13 * matrix.getM31(); + final double temp12 = _m10 * matrix.getM02() + _m11 * matrix.getM12() + _m12 * matrix.getM22() + + _m13 * matrix.getM32(); + final double temp13 = _m10 * matrix.getM03() + _m11 * matrix.getM13() + _m12 * matrix.getM23() + + _m13 * matrix.getM33(); + + final double temp20 = _m20 * matrix.getM00() + _m21 * matrix.getM10() + _m22 * matrix.getM20() + + _m23 * matrix.getM30(); + final double temp21 = _m20 * matrix.getM01() + _m21 * matrix.getM11() + _m22 * matrix.getM21() + + _m23 * matrix.getM31(); + final double temp22 = _m20 * matrix.getM02() + _m21 * matrix.getM12() + _m22 * matrix.getM22() + + _m23 * matrix.getM32(); + final double temp23 = _m20 * matrix.getM03() + _m21 * matrix.getM13() + _m22 * matrix.getM23() + + _m23 * matrix.getM33(); + + final double temp30 = _m30 * matrix.getM00() + _m31 * matrix.getM10() + _m32 * matrix.getM20() + + _m33 * matrix.getM30(); + final double temp31 = _m30 * matrix.getM01() + _m31 * matrix.getM11() + _m32 * matrix.getM21() + + _m33 * matrix.getM31(); + final double temp32 = _m30 * matrix.getM02() + _m31 * matrix.getM12() + _m32 * matrix.getM22() + + _m33 * matrix.getM32(); + final double temp33 = _m30 * matrix.getM03() + _m31 * matrix.getM13() + _m32 * matrix.getM23() + + _m33 * matrix.getM33(); result._m00 = temp00; result._m01 = temp01; @@ -1477,7 +1478,7 @@ public class Matrix4 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Internally scales all values of this matrix by the given scalar. - * + * * @param scalar * @return this matrix for chaining. */ @@ -1541,7 +1542,7 @@ public class Matrix4 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Internally adds the values of the given matrix to this matrix. - * + * * @param matrix * the matrix to add to this. * @return this matrix for chaining @@ -1591,7 +1592,7 @@ public class Matrix4 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Internally subtracts the values of the given matrix from this matrix. - * + * * @param matrix * the matrix to subtract from this. * @return this matrix for chaining @@ -1604,7 +1605,7 @@ public class Matrix4 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Applies the given scale to this matrix and returns the result as a new matrix - * + * * @param scale * @param store * a matrix to store the result in. If store is null, a new matrix is created. @@ -1628,7 +1629,7 @@ public class Matrix4 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Applies the given scale to this matrix values internally - * + * * @param scale * @return this matrix for chaining. * @throws NullPointerException @@ -1640,7 +1641,7 @@ public class Matrix4 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * transposes this matrix as a new matrix, basically flipping it across the diagonal - * + * * @param store * a matrix to store the result in. If store is null, a new matrix is created. It is NOT safe for store * to == this. @@ -1676,7 +1677,7 @@ public class Matrix4 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * transposes this matrix in place - * + * * @return this matrix for chaining. * @see <a href="http://en.wikipedia.org/wiki/Transpose">wikipedia.org-Transpose</a> */ @@ -1761,7 +1762,7 @@ public class Matrix4 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * inverts this matrix locally. - * + * * @return this matrix inverted internally. * @throws ArithmeticException * if this matrix can not be inverted. @@ -1846,7 +1847,7 @@ public class Matrix4 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Multiplies the given vector by this matrix (v * M). If supplied, the result is stored into the supplied "store" * vector. - * + * * @param vector * the vector to multiply this matrix by. * @param store @@ -1878,7 +1879,7 @@ public class Matrix4 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Multiplies the given vector by this matrix (M * v). If supplied, the result is stored into the supplied "store" * vector. - * + * * @param vector * the vector to multiply this matrix by. * @param store @@ -1910,7 +1911,7 @@ public class Matrix4 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Multiplies the given point by this matrix (M * p). If supplied, the result is stored into the supplied "store" * vector. - * + * * @param point * the point to multiply against this matrix. * @param store @@ -1940,7 +1941,7 @@ public class Matrix4 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Multiplies the given vector by this matrix (M * v). If supplied, the result is stored into the supplied "store" * vector. - * + * * @param vector * the vector to multiply this matrix by. * @param store @@ -1969,7 +1970,7 @@ public class Matrix4 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Check a matrix... if it is null or its doubles are NaN or infinite, return false. Else return true. - * + * * @param matrix * the vector to check * @return true or false as stated above. @@ -2098,7 +2099,7 @@ public class Matrix4 implements Cloneable, Savable, Externalizable, ReadOnlyMatr */ @Override public String toString() { - final StringBuffer result = new StringBuffer("com.ardor3d.math.Matrix4\n[\n"); + final StringBuilder result = new StringBuilder("com.ardor3d.math.Matrix4\n[\n"); result.append(' '); result.append(_m00); result.append(' '); @@ -2149,45 +2150,11 @@ public class Matrix4 implements Cloneable, Savable, Externalizable, ReadOnlyMatr */ @Override public int hashCode() { - int result = 17; - - long val = Double.doubleToLongBits(_m00); - result += 31 * result + (int) (val ^ val >>> 32); - val = Double.doubleToLongBits(_m01); - result += 31 * result + (int) (val ^ val >>> 32); - val = Double.doubleToLongBits(_m02); - result += 31 * result + (int) (val ^ val >>> 32); - val = Double.doubleToLongBits(_m03); - result += 31 * result + (int) (val ^ val >>> 32); - - val = Double.doubleToLongBits(_m10); - result += 31 * result + (int) (val ^ val >>> 32); - val = Double.doubleToLongBits(_m11); - result += 31 * result + (int) (val ^ val >>> 32); - val = Double.doubleToLongBits(_m12); - result += 31 * result + (int) (val ^ val >>> 32); - val = Double.doubleToLongBits(_m13); - result += 31 * result + (int) (val ^ val >>> 32); - - val = Double.doubleToLongBits(_m20); - result += 31 * result + (int) (val ^ val >>> 32); - val = Double.doubleToLongBits(_m21); - result += 31 * result + (int) (val ^ val >>> 32); - val = Double.doubleToLongBits(_m22); - result += 31 * result + (int) (val ^ val >>> 32); - val = Double.doubleToLongBits(_m23); - result += 31 * result + (int) (val ^ val >>> 32); - - val = Double.doubleToLongBits(_m30); - result += 31 * result + (int) (val ^ val >>> 32); - val = Double.doubleToLongBits(_m31); - result += 31 * result + (int) (val ^ val >>> 32); - val = Double.doubleToLongBits(_m32); - result += 31 * result + (int) (val ^ val >>> 32); - val = Double.doubleToLongBits(_m33); - result += 31 * result + (int) (val ^ val >>> 32); - - return result; + return Objects.hash(Double.valueOf(getM00()), Double.valueOf(getM01()), Double.valueOf(getM02()), + Double.valueOf(getM03()), Double.valueOf(getM10()), Double.valueOf(getM11()), Double.valueOf(getM12()), + Double.valueOf(getM13()), Double.valueOf(getM20()), Double.valueOf(getM21()), Double.valueOf(getM22()), + Double.valueOf(getM23()), Double.valueOf(getM30()), Double.valueOf(getM31()), Double.valueOf(getM32()), + Double.valueOf(getM33())); } /** @@ -2356,7 +2323,7 @@ public class Matrix4 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Used with serialization. Not to be called manually. - * + * * @param in * ObjectInput * @throws IOException @@ -2384,7 +2351,7 @@ public class Matrix4 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Used with serialization. Not to be called manually. - * + * * @param out * ObjectOutput * @throws IOException @@ -2428,7 +2395,7 @@ public class Matrix4 implements Cloneable, Savable, Externalizable, ReadOnlyMatr /** * Releases a Matrix4 back to be used by a future call to fetchTempInstance. TAKE CARE: this Matrix4 object should * no longer have other classes referencing it or "Bad Things" will happen. - * + * * @param mat * the Matrix4 to release. */ diff --git a/ardor3d-math/src/main/java/com/ardor3d/math/ObjectPool.java b/ardor3d-math/src/main/java/com/ardor3d/math/ObjectPool.java index 2c2110b..1defcba 100644 --- a/ardor3d-math/src/main/java/com/ardor3d/math/ObjectPool.java +++ b/ardor3d-math/src/main/java/com/ardor3d/math/ObjectPool.java @@ -24,7 +24,7 @@ public abstract class ObjectPool<T extends Poolable> { private final ThreadLocal<List<T>> _pool = new ThreadLocal<List<T>>() { @Override protected List<T> initialValue() { - return new ArrayList<T>(_maxSize); + return new ArrayList<>(_maxSize); } }; diff --git a/ardor3d-math/src/main/java/com/ardor3d/math/Plane.java b/ardor3d-math/src/main/java/com/ardor3d/math/Plane.java index 7567310..1b73217 100644 --- a/ardor3d-math/src/main/java/com/ardor3d/math/Plane.java +++ b/ardor3d-math/src/main/java/com/ardor3d/math/Plane.java @@ -3,7 +3,7 @@ * * This file is part of Ardor3D. * - * Ardor3D is free software: you can redistribute it and/or modify it + * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ @@ -14,6 +14,7 @@ import java.io.Externalizable; import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; +import java.util.Objects; import com.ardor3d.math.type.ReadOnlyPlane; import com.ardor3d.math.type.ReadOnlyVector3; @@ -48,7 +49,7 @@ public class Plane implements Cloneable, Savable, Externalizable, ReadOnlyPlane, /** * Copy constructor. - * + * * @param source * the plane to copy from. */ @@ -58,7 +59,7 @@ public class Plane implements Cloneable, Savable, Externalizable, ReadOnlyPlane, /** * Constructs a new plane using the supplied normal vector and plane constant - * + * * @param normal * @param constant */ @@ -73,7 +74,7 @@ public class Plane implements Cloneable, Savable, Externalizable, ReadOnlyPlane, } /** - * + * * @return normal as a readable vector */ @Override @@ -83,7 +84,7 @@ public class Plane implements Cloneable, Savable, Externalizable, ReadOnlyPlane, /** * Sets the value of this plane to the constant and normal values of the provided source plane. - * + * * @param source * @return this plane for chaining * @throws NullPointerException @@ -97,7 +98,7 @@ public class Plane implements Cloneable, Savable, Externalizable, ReadOnlyPlane, /** * Sets the constant value of this plane to the given double value. - * + * * @param constant */ public void setConstant(final double constant) { @@ -106,7 +107,7 @@ public class Plane implements Cloneable, Savable, Externalizable, ReadOnlyPlane, /** * Sets the plane normal to the values of the given vector. - * + * * @param normal * @throws NullPointerException * if normal is null. @@ -148,7 +149,7 @@ public class Plane implements Cloneable, Savable, Externalizable, ReadOnlyPlane, /** * Sets this plane to the plane defined by the given three points. - * + * * @param pointA * @param pointB * @param pointC @@ -156,7 +157,8 @@ public class Plane implements Cloneable, Savable, Externalizable, ReadOnlyPlane, * @throws NullPointerException * if one or more of the points are null. */ - public Plane setPlanePoints(final ReadOnlyVector3 pointA, final ReadOnlyVector3 pointB, final ReadOnlyVector3 pointC) { + public Plane setPlanePoints(final ReadOnlyVector3 pointA, final ReadOnlyVector3 pointB, + final ReadOnlyVector3 pointC) { _normal.set(pointB).subtractLocal(pointA); _normal.crossLocal(pointC.getX() - pointA.getX(), pointC.getY() - pointA.getY(), pointC.getZ() - pointA.getZ()) .normalizeLocal(); @@ -166,7 +168,7 @@ public class Plane implements Cloneable, Savable, Externalizable, ReadOnlyPlane, /** * Reflects an incoming vector across the normal of this Plane. - * + * * @param unitVector * the incoming vector. Must be a unit vector. * @param store @@ -189,7 +191,7 @@ public class Plane implements Cloneable, Savable, Externalizable, ReadOnlyPlane, /** * Check a plane... if it is null or its constant, or the doubles of its normal are NaN or infinite, return false. * Else return true. - * + * * @param plane * the plane to check * @return true or false as stated above. @@ -219,14 +221,7 @@ public class Plane implements Cloneable, Savable, Externalizable, ReadOnlyPlane, */ @Override public int hashCode() { - int result = 17; - - result += 31 * result + _normal.hashCode(); - - final long c = Double.doubleToLongBits(getConstant()); - result += 31 * result + (int) (c ^ c >>> 32); - - return result; + return Objects.hash(getNormal(), Double.valueOf(getConstant())); } /** @@ -282,7 +277,7 @@ public class Plane implements Cloneable, Savable, Externalizable, ReadOnlyPlane, /** * Used with serialization. Not to be called manually. - * + * * @param in * ObjectInput * @throws IOException @@ -296,7 +291,7 @@ public class Plane implements Cloneable, Savable, Externalizable, ReadOnlyPlane, /** * Used with serialization. Not to be called manually. - * + * * @param out * ObjectOutput * @throws IOException @@ -326,7 +321,7 @@ public class Plane implements Cloneable, Savable, Externalizable, ReadOnlyPlane, /** * Releases a Plane back to be used by a future call to fetchTempInstance. TAKE CARE: this Plane object should no * longer have other classes referencing it or "Bad Things" will happen. - * + * * @param plane * the Plane to release. */ diff --git a/ardor3d-math/src/main/java/com/ardor3d/math/Quaternion.java b/ardor3d-math/src/main/java/com/ardor3d/math/Quaternion.java index 7cb1b3b..458fa78 100644 --- a/ardor3d-math/src/main/java/com/ardor3d/math/Quaternion.java +++ b/ardor3d-math/src/main/java/com/ardor3d/math/Quaternion.java @@ -3,7 +3,7 @@ * * This file is part of Ardor3D. * - * Ardor3D is free software: you can redistribute it and/or modify it + * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ @@ -14,6 +14,7 @@ import java.io.Externalizable; import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; +import java.util.Objects; import com.ardor3d.math.type.ReadOnlyMatrix3; import com.ardor3d.math.type.ReadOnlyQuaternion; @@ -25,7 +26,7 @@ import com.ardor3d.util.export.Savable; /** * Quaternion represents a 4 value math object used in Ardor3D to describe rotations. It has the advantage of being able * to avoid lock by adding a 4th dimension to rotation. - * + * * Note: some algorithms in this class were ported from Eberly, Wolfram, Game Gems and others to Java. */ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQuaternion, Poolable { @@ -57,7 +58,7 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ /** * Constructs a new quaternion set to the (x, y, z, w) values of the given source quaternion. - * + * * @param source */ public Quaternion(final ReadOnlyQuaternion source) { @@ -66,7 +67,7 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ /** * Constructs a new quaternion set to (x, y, z, w). - * + * * @param x * @param y * @param z @@ -121,7 +122,7 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ /** * Stores the double values of this quaternion in the given double array as (x,y,z,w). - * + * * @param store * The array in which to store the values of this quaternion. If null, a new double[4] array is created. * @return the double array @@ -143,7 +144,7 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ /** * Sets the x component of this quaternion to the given double value. - * + * * @param x */ public void setX(final double x) { @@ -152,7 +153,7 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ /** * Sets the y component of this quaternion to the given double value. - * + * * @param y */ public void setY(final double y) { @@ -161,7 +162,7 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ /** * Sets the z component of this quaternion to the given double value. - * + * * @param z */ public void setZ(final double z) { @@ -170,7 +171,7 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ /** * Sets the w component of this quaternion to the given double value. - * + * * @param w */ public void setW(final double w) { @@ -179,7 +180,7 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ /** * Sets the value of this quaternion to (x, y, z, w) - * + * * @param x * @param y * @param z @@ -196,7 +197,7 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ /** * Sets the value of this quaternion to the (x, y, z, w) values of the provided source quaternion. - * + * * @param source * @return this quaternion for chaining * @throws NullPointerException @@ -213,7 +214,7 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ /** * Updates this quaternion from the given Euler rotation angles, applied in the given order: heading, attitude, * bank. - * + * * @param angles * the Euler angles of rotation (in radians) stored as heading, attitude, and bank. * @return this quaternion for chaining @@ -229,7 +230,7 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ /** * Updates this quaternion from the given Euler rotation angles, applied in the given order: heading, attitude, * bank. - * + * * @param heading * the Euler heading angle in radians. (rotation about the y axis) * @param attitude @@ -237,8 +238,8 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ * @param bank * the Euler bank angle in radians. (rotation about the x axis) * @return this quaternion for chaining - * @see <a - * href="http://www.euclideanspace.com/maths/geometry/rotations/conversions/eulerToQuaternion/index.htm">euclideanspace.com-eulerToQuaternion</a> + * @see <a href="http://www.euclideanspace.com/maths/geometry/rotations/conversions/eulerToQuaternion/index.htm"> + * euclideanspace.com-eulerToQuaternion</a> */ public Quaternion fromEulerAngles(final double heading, final double attitude, final double bank) { double angle = heading * 0.5; @@ -269,14 +270,14 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ /** * Converts this quaternion to Euler rotation angles in radians (heading, attitude, bank). - * + * * @param store * the double[] array to store the computed angles in. If null, a new double[] will be created * @return the double[] array, filled with heading, attitude and bank in that order.. * @throws ArrayIndexOutOfBoundsException * if non-null store is not at least length 3 - * @see <a - * href="http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToEuler/index.htm">euclideanspace.com-quaternionToEuler</a> + * @see <a href="http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToEuler/index.htm"> + * euclideanspace.com-quaternionToEuler</a> * @see #fromEulerAngles(double, double, double) */ @Override @@ -313,7 +314,7 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ /** * Sets the value of this quaternion to the rotation described by the given matrix. - * + * * @param matrix * @return this quaternion for chaining * @throws NullPointerException @@ -326,7 +327,7 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ /** * Sets the value of this quaternion to the rotation described by the given matrix values. - * + * * @param m00 * @param m01 * @param m02 @@ -387,7 +388,7 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ * @param store * the matrix to store our result in. If null, a new matrix is created. * @return the rotation matrix representation of this quaternion (normalized) - * + * * if store is not null and is read only. */ @Override @@ -534,7 +535,7 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ * Sets the values of this quaternion to the values represented by a given angle and axis of rotation. Note that * this method creates an object, so use fromAngleNormalAxis if your axis is already normalized. If axis == 0,0,0 * the quaternion is set to identity. - * + * * @param angle * the angle to rotate (in radians). * @param axis @@ -553,7 +554,7 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ /** * Sets the values of this quaternion to the values represented by a given angle and unit length axis of rotation. * If axis == 0,0,0 the quaternion is set to identity. - * + * * @param angle * the angle to rotate (in radians). * @param axis @@ -578,7 +579,7 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ /** * Returns the rotation angle represented by this quaternion. If a non-null vector is provided, the axis of rotation * is stored in that vector as well. - * + * * @param axisStore * the object we'll store the computed axis in. If null, no computations are done to determine axis. * @return the angle of rotation in radians. @@ -610,7 +611,7 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ /** * Sets this quaternion to that which will rotate vector "from" into vector "to". from and to do not have to be the * same length. - * + * * @param from * the source vector to rotate * @param to @@ -696,7 +697,7 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ * Calculates the <i>multiplicative inverse</i> <code>Q<sup>-1</sup></code> of this quaternion <code>Q</code> such * that <code>QQ<sup>-1</sup> = [0,0,0,1]</code> (the identity quaternion). Note that for unit quaternions, a * quaternion's inverse is equal to its (far easier to calculate) conjugate. - * + * * @param store * the <code>Quaternion</code> to store the result in. If <code>null</code>, a new one is created. * @see #conjugate(Quaternion) @@ -719,9 +720,9 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ * Locally sets this quaternion <code>Q</code> to its <i>multiplicative inverse</i> <code>Q<sup>-1</sup></code> such * that <code>QQ<sup>-1</sup> = [0,0,0,1]</code> (the identity quaternion). Note that for unit quaternions, a * quaternion's inverse is equal to its (far easier to calculate) conjugate. - * + * * @see #conjugate(Quaternion) - * + * * @return this <code>Quaternion</code> for chaining. */ public Quaternion invertLocal() { @@ -736,7 +737,7 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ /** * Creates a new quaternion that is the conjugate <code>[-x, -y, -z, w]</code> of this quaternion. - * + * * @param store * the <code>Quaternion</code> to store the result in. If <code>null</code>, a new one is created. * @return the conjugate to this quaternion. @@ -751,7 +752,7 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ /** * Internally sets this quaternion to its conjugate <code>[-x, -y, -z, w]</code>. - * + * * @return this <code>Quaternion</code> for chaining. */ public Quaternion conjugateLocal() { @@ -760,7 +761,7 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ /** * Adds this quaternion to another and places the result in the given store. - * + * * @param quat * @param store * the Quaternion to store the result in. if null, a new one is created. @@ -778,7 +779,7 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ /** * Internally increments the fields of this quaternion with the field values of the given quaternion. - * + * * @param quat * @return this quaternion for chaining */ @@ -808,7 +809,7 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ /** * Internally decrements the fields of this quaternion by the field values of the given quaternion. - * + * * @param quat * @return this quaternion for chaining. */ @@ -822,7 +823,7 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ /** * Multiplies each value of this quaternion by the given scalar value. - * + * * @param scalar * the quaternion to multiply this quaternion by. * @param store @@ -841,7 +842,7 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ /** * Multiplies each value of this quaternion by the given scalar value. The result is stored in this quaternion. - * + * * @param scalar * the quaternion to multiply this quaternion by. * @return this quaternion for chaining. @@ -857,15 +858,15 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ /** * Multiplies this quaternion by the supplied quaternion. The result is stored in the given store quaternion or a * new quaternion if store is null. - * + * * It IS safe for quat and store to be the same object. - * + * * @param quat * the quaternion to multiply this quaternion by. * @param store * the quaternion to store the result in. * @return the new quaternion. - * + * * if the given store is read only. */ @Override @@ -882,7 +883,7 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ /** * Multiplies this quaternion by the supplied quaternion. The result is stored locally. - * + * * @param quat * The Quaternion to multiply this one by. * @return this quaternion for chaining @@ -895,7 +896,7 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ /** * Multiplies this quaternion by the supplied matrix. The result is stored locally. - * + * * @param matrix * the matrix to apply to this quaternion. * @return this quaternion for chaining @@ -916,7 +917,7 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ /** * Multiplies this quaternion by the supplied quaternion values. The result is stored locally. - * + * * @param qx * @param qy * @param qz @@ -934,7 +935,7 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ /** * Multiply this quaternion by a rotational quaternion made from the given angle and axis. The axis must be a * normalized vector. - * + * * @param angle * in radians * @param x @@ -968,7 +969,7 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ /** * Apply rotation around X - * + * * @param angle * in radians * @return this quaternion for chaining. @@ -988,7 +989,7 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ /** * Apply rotation around Y - * + * * @param angle * in radians * @return this quaternion for chaining. @@ -1008,7 +1009,7 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ /** * Apply rotation around Z - * + * * @param angle * in radians * @return this quaternion for chaining. @@ -1028,7 +1029,7 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ /** * Rotates the given vector by this quaternion. If supplied, the result is stored into the supplied "store" vector. - * + * * @param vec * the vector to multiply this quaternion by. * @param store @@ -1037,7 +1038,7 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ * @return the store vector, or a new vector if store is null. * @throws NullPointerException * if vec is null - * + * * if the given store is read only. */ @Override @@ -1048,15 +1049,15 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ if (vec.equals(Vector3.ZERO)) { store.set(0, 0, 0); } else { - final double x = getW() * getW() * vec.getX() + 2 * getY() * getW() * vec.getZ() - 2 * getZ() * getW() - * vec.getY() + getX() * getX() * vec.getX() + 2 * getY() * getX() * vec.getY() + 2 * getZ() - * getX() * vec.getZ() - getZ() * getZ() * vec.getX() - getY() * getY() * vec.getX(); - final double y = 2 * getX() * getY() * vec.getX() + getY() * getY() * vec.getY() + 2 * getZ() * getY() - * vec.getZ() + 2 * getW() * getZ() * vec.getX() - getZ() * getZ() * vec.getY() + getW() * getW() - * vec.getY() - 2 * getX() * getW() * vec.getZ() - getX() * getX() * vec.getY(); - final double z = 2 * getX() * getZ() * vec.getX() + 2 * getY() * getZ() * vec.getY() + getZ() * getZ() - * vec.getZ() - 2 * getW() * getY() * vec.getX() - getY() * getY() * vec.getZ() + 2 * getW() - * getX() * vec.getY() - getX() * getX() * vec.getZ() + getW() * getW() * vec.getZ(); + final double x = getW() * getW() * vec.getX() + 2 * getY() * getW() * vec.getZ() + - 2 * getZ() * getW() * vec.getY() + getX() * getX() * vec.getX() + 2 * getY() * getX() * vec.getY() + + 2 * getZ() * getX() * vec.getZ() - getZ() * getZ() * vec.getX() - getY() * getY() * vec.getX(); + final double y = 2 * getX() * getY() * vec.getX() + getY() * getY() * vec.getY() + + 2 * getZ() * getY() * vec.getZ() + 2 * getW() * getZ() * vec.getX() - getZ() * getZ() * vec.getY() + + getW() * getW() * vec.getY() - 2 * getX() * getW() * vec.getZ() - getX() * getX() * vec.getY(); + final double z = 2 * getX() * getZ() * vec.getX() + 2 * getY() * getZ() * vec.getY() + + getZ() * getZ() * vec.getZ() - 2 * getW() * getY() * vec.getX() - getY() * getY() * vec.getZ() + + 2 * getW() * getX() * vec.getY() - getX() * getX() * vec.getZ() + getW() * getW() * vec.getZ(); store.set(x, y, z); } return store; @@ -1066,7 +1067,7 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ * Updates this quaternion to represent a rotation formed by the given three axes. These axes are assumed to be * orthogonal and no error checking is applied. It is the user's job to insure that the three axes being provided * indeed represent a proper right handed coordinate system. - * + * * @param xAxis * vector representing the x-axis of the coordinate system. * @param yAxis @@ -1082,7 +1083,7 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ /** * Converts this quaternion to a rotation matrix and then extracts rotation axes. - * + * * @param axes * the array of vectors to be filled. * @throws ArrayIndexOutOfBoundsException @@ -1102,7 +1103,7 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ /** * Does a spherical linear interpolation between this quaternion and the given end quaternion by the given change * amount. - * + * * @param endQuat * @param changeAmnt * @param store @@ -1118,7 +1119,7 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ /** * Does a spherical linear interpolation between this quaternion and the given end quaternion by the given change * amount. Stores the results locally in this quaternion. - * + * * @param endQuat * @param changeAmnt * @return this quaternion for chaining. @@ -1130,7 +1131,7 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ /** * Does a spherical linear interpolation between the given start and end quaternions by the given change amount. * Returns the result as a new quaternion. - * + * * @param startQuat * @param endQuat * @param changeAmnt @@ -1198,7 +1199,7 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ /** * Does a spherical linear interpolation between the given start and end quaternions by the given change amount. * Stores the result locally. - * + * * @param startQuat * @param endQuat * @param changeAmnt @@ -1264,7 +1265,7 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ /** * Does a spherical linear interpolation between the given start and end quaternions by the given change amount. * Stores the result locally. - * + * * @param startQuat * @param endQuat * @param changeAmnt @@ -1283,7 +1284,7 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ /** * Modifies this quaternion to equal the rotation required to point the z-axis at 'direction' and the y-axis to * 'up'. - * + * * @param direction * where to 'look' at * @param up @@ -1351,7 +1352,7 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ /** * Sets the value of this quaternion to (0, 0, 0, 1). Equivalent to calling set(0, 0, 0, 1) - * + * * @return this quaternion for chaining */ public Quaternion setIdentity() { @@ -1368,7 +1369,7 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ /** * Check a quaternion... if it is null or its doubles are NaN or infinite, return false. Else return true. - * + * * @param quat * the quaternion to check * @return true or false as stated above. @@ -1406,21 +1407,8 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ */ @Override public int hashCode() { - int result = 17; - - final long x = Double.doubleToLongBits(getX()); - result += 31 * result + (int) (x ^ x >>> 32); - - final long y = Double.doubleToLongBits(getY()); - result += 31 * result + (int) (y ^ y >>> 32); - - final long z = Double.doubleToLongBits(getZ()); - result += 31 * result + (int) (z ^ z >>> 32); - - final long w = Double.doubleToLongBits(getW()); - result += 31 * result + (int) (w ^ w >>> 32); - - return result; + return Objects.hash(Double.valueOf(getX()), Double.valueOf(getY()), Double.valueOf(getZ()), + Double.valueOf(getW())); } /** @@ -1500,7 +1488,7 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ /** * Used with serialization. Not to be called manually. - * + * * @param in * ObjectInput * @throws IOException @@ -1516,7 +1504,7 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ /** * Used with serialization. Not to be called manually. - * + * * @param out * ObjectOutput * @throws IOException @@ -1548,7 +1536,7 @@ public class Quaternion implements Cloneable, Savable, Externalizable, ReadOnlyQ /** * Releases a Quaternion back to be used by a future call to fetchTempInstance. TAKE CARE: this Quaternion object * should no longer have other classes referencing it or "Bad Things" will happen. - * + * * @param mat * the Quaternion to release. */ diff --git a/ardor3d-math/src/main/java/com/ardor3d/math/Rectangle2.java b/ardor3d-math/src/main/java/com/ardor3d/math/Rectangle2.java index ced2fe8..36b1655 100644 --- a/ardor3d-math/src/main/java/com/ardor3d/math/Rectangle2.java +++ b/ardor3d-math/src/main/java/com/ardor3d/math/Rectangle2.java @@ -3,7 +3,7 @@ * * This file is part of Ardor3D. * - * Ardor3D is free software: you can redistribute it and/or modify it + * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ @@ -14,6 +14,7 @@ import java.io.Externalizable; import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; +import java.util.Objects; import com.ardor3d.math.type.ReadOnlyRectangle2; import com.ardor3d.util.export.InputCapsule; @@ -46,7 +47,7 @@ public class Rectangle2 implements Cloneable, Savable, Externalizable, ReadOnlyR /** * Constructor creates a new <code>Rectangle2</code> with using the given x,y,width and height values. - * + * */ public Rectangle2(final int x, final int y, final int width, final int height) { setX(x); @@ -57,7 +58,7 @@ public class Rectangle2 implements Cloneable, Savable, Externalizable, ReadOnlyR /** * Constructor creates a new <code>Rectangle2</code> using the values of the provided source rectangle. - * + * * @param source * the rectangle to copy from */ @@ -167,14 +168,8 @@ public class Rectangle2 implements Cloneable, Savable, Externalizable, ReadOnlyR */ @Override public int hashCode() { - int result = 17; - - result += 31 * result + _x; - result += 31 * result + _y; - result += 31 * result + _width; - result += 31 * result + _height; - - return result; + return Objects.hash(Integer.valueOf(getX()), Integer.valueOf(getY()), Integer.valueOf(getWidth()), + Integer.valueOf(getHeight())); } /** @@ -235,7 +230,7 @@ public class Rectangle2 implements Cloneable, Savable, Externalizable, ReadOnlyR /** * Used with serialization. Not to be called manually. - * + * * @param in * ObjectInput * @throws IOException @@ -251,7 +246,7 @@ public class Rectangle2 implements Cloneable, Savable, Externalizable, ReadOnlyR /** * Used with serialization. Not to be called manually. - * + * * @param out * ObjectOutput * @throws IOException @@ -283,7 +278,7 @@ public class Rectangle2 implements Cloneable, Savable, Externalizable, ReadOnlyR /** * Releases a Rectangle2 back to be used by a future call to fetchTempInstance. TAKE CARE: this object should no * longer have other classes referencing it or "Bad Things" will happen. - * + * * @param rectangle * the Rectangle2 to release. */ diff --git a/ardor3d-math/src/main/java/com/ardor3d/math/Rectangle3.java b/ardor3d-math/src/main/java/com/ardor3d/math/Rectangle3.java index be10f94..8a2f9ee 100644 --- a/ardor3d-math/src/main/java/com/ardor3d/math/Rectangle3.java +++ b/ardor3d-math/src/main/java/com/ardor3d/math/Rectangle3.java @@ -3,7 +3,7 @@ * * This file is part of Ardor3D. * - * Ardor3D is free software: you can redistribute it and/or modify it + * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ @@ -14,6 +14,7 @@ import java.io.Externalizable; import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; +import java.util.Objects; import com.ardor3d.math.type.ReadOnlyRectangle3; import com.ardor3d.math.type.ReadOnlyVector3; @@ -43,7 +44,7 @@ public class Rectangle3 implements Cloneable, Savable, Externalizable, ReadOnlyR /** * Constructor creates a new Rectangle3 using the values of the provided source rectangle. - * + * * @param source * the rectangle to copy from */ @@ -53,7 +54,7 @@ public class Rectangle3 implements Cloneable, Savable, Externalizable, ReadOnlyR /** * Constructor creates a new Rectangle3 with defined A, B, and C points that define the area of the rectangle. - * + * * @param a * the first corner of the rectangle. * @param b @@ -69,7 +70,7 @@ public class Rectangle3 implements Cloneable, Savable, Externalizable, ReadOnlyR /** * Copy the value of the given source Rectangle3 into this Rectangle3. - * + * * @param source * the source of the data to copy. * @return this rectangle for chaining @@ -85,7 +86,7 @@ public class Rectangle3 implements Cloneable, Savable, Externalizable, ReadOnlyR /** * getA returns the first point of the rectangle. - * + * * @return the first point of the rectangle. */ @Override @@ -95,7 +96,7 @@ public class Rectangle3 implements Cloneable, Savable, Externalizable, ReadOnlyR /** * setA sets the first point of the rectangle. - * + * * @param a * the first point of the rectangle. */ @@ -105,7 +106,7 @@ public class Rectangle3 implements Cloneable, Savable, Externalizable, ReadOnlyR /** * getB returns the second point of the rectangle. - * + * * @return the second point of the rectangle. */ @Override @@ -115,7 +116,7 @@ public class Rectangle3 implements Cloneable, Savable, Externalizable, ReadOnlyR /** * setB sets the second point of the rectangle. - * + * * @param b * the second point of the rectangle. */ @@ -125,7 +126,7 @@ public class Rectangle3 implements Cloneable, Savable, Externalizable, ReadOnlyR /** * getC returns the third point of the rectangle. - * + * * @return the third point of the rectangle. */ @Override @@ -135,7 +136,7 @@ public class Rectangle3 implements Cloneable, Savable, Externalizable, ReadOnlyR /** * setC sets the third point of the rectangle. - * + * * @param c * the third point of the rectangle. */ @@ -145,7 +146,7 @@ public class Rectangle3 implements Cloneable, Savable, Externalizable, ReadOnlyR /** * random returns a random point within the plane defined by: A, B, C, and (B + C) - A. - * + * * @param result * Vector to store result in * @return a random point within the rectangle. @@ -184,13 +185,7 @@ public class Rectangle3 implements Cloneable, Savable, Externalizable, ReadOnlyR */ @Override public int hashCode() { - int result = 17; - - result += 31 * result + _a.hashCode(); - result += 31 * result + _b.hashCode(); - result += 31 * result + _c.hashCode(); - - return result; + return Objects.hash(getA(), getB(), getC()); } /** @@ -248,7 +243,7 @@ public class Rectangle3 implements Cloneable, Savable, Externalizable, ReadOnlyR /** * Used with serialization. Not to be called manually. - * + * * @param in * ObjectInput * @throws IOException @@ -263,7 +258,7 @@ public class Rectangle3 implements Cloneable, Savable, Externalizable, ReadOnlyR /** * Used with serialization. Not to be called manually. - * + * * @param out * ObjectOutput * @throws IOException @@ -294,7 +289,7 @@ public class Rectangle3 implements Cloneable, Savable, Externalizable, ReadOnlyR /** * Releases a Rectangle3 back to be used by a future call to fetchTempInstance. TAKE CARE: this object should no * longer have other classes referencing it or "Bad Things" will happen. - * + * * @param rectangle * the Rectangle3 to release. */ diff --git a/ardor3d-math/src/main/java/com/ardor3d/math/Ring.java b/ardor3d-math/src/main/java/com/ardor3d/math/Ring.java index d734003..aca8ded 100644 --- a/ardor3d-math/src/main/java/com/ardor3d/math/Ring.java +++ b/ardor3d-math/src/main/java/com/ardor3d/math/Ring.java @@ -3,7 +3,7 @@ * * This file is part of Ardor3D. * - * Ardor3D is free software: you can redistribute it and/or modify it + * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ @@ -14,6 +14,7 @@ import java.io.Externalizable; import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; +import java.util.Objects; import com.ardor3d.math.type.ReadOnlyRing; import com.ardor3d.math.type.ReadOnlyVector3; @@ -46,7 +47,7 @@ public class Ring implements Cloneable, Savable, Externalizable, ReadOnlyRing, P /** * Copy constructor. - * + * * @param source * the ring to copy from. */ @@ -56,7 +57,7 @@ public class Ring implements Cloneable, Savable, Externalizable, ReadOnlyRing, P /** * Constructor creates a new <code>Ring</code> with defined center point, up vector, and inner and outer radii. - * + * * @param center * the center of the ring. * @param up @@ -76,7 +77,7 @@ public class Ring implements Cloneable, Savable, Externalizable, ReadOnlyRing, P /** * Copy the value of the given source Ring into this Ring. - * + * * @param source * the source of the data to copy. * @return this ring for chaining @@ -93,7 +94,7 @@ public class Ring implements Cloneable, Savable, Externalizable, ReadOnlyRing, P /** * <code>getCenter</code> returns the center of the ring. - * + * * @return the center of the ring. */ @Override @@ -103,7 +104,7 @@ public class Ring implements Cloneable, Savable, Externalizable, ReadOnlyRing, P /** * <code>setCenter</code> sets the center of the ring. - * + * * @param center * the center of the ring. */ @@ -113,7 +114,7 @@ public class Ring implements Cloneable, Savable, Externalizable, ReadOnlyRing, P /** * <code>getUp</code> returns the ring's up vector. - * + * * @return the ring's up vector. */ @Override @@ -123,7 +124,7 @@ public class Ring implements Cloneable, Savable, Externalizable, ReadOnlyRing, P /** * <code>setUp</code> sets the ring's up vector. - * + * * @param up * the ring's up vector. */ @@ -133,7 +134,7 @@ public class Ring implements Cloneable, Savable, Externalizable, ReadOnlyRing, P /** * <code>getInnerRadius</code> returns the ring's inner radius. - * + * * @return the ring's inner radius. */ @Override @@ -143,7 +144,7 @@ public class Ring implements Cloneable, Savable, Externalizable, ReadOnlyRing, P /** * <code>setInnerRadius</code> sets the ring's inner radius. - * + * * @param innerRadius * the ring's inner radius. */ @@ -153,7 +154,7 @@ public class Ring implements Cloneable, Savable, Externalizable, ReadOnlyRing, P /** * <code>getOuterRadius</code> returns the ring's outer radius. - * + * * @return the ring's outer radius. */ @Override @@ -163,7 +164,7 @@ public class Ring implements Cloneable, Savable, Externalizable, ReadOnlyRing, P /** * <code>setOuterRadius</code> sets the ring's outer radius. - * + * * @param outerRadius * the ring's outer radius. */ @@ -172,9 +173,9 @@ public class Ring implements Cloneable, Savable, Externalizable, ReadOnlyRing, P } /** - * + * * <code>random</code> returns a random point within the ring. - * + * * @param store * Vector to store result in * @return a random point within the ring. @@ -213,7 +214,7 @@ public class Ring implements Cloneable, Savable, Externalizable, ReadOnlyRing, P /** * Check a ring... if it is null or its radii, or the doubles of its center or up are NaN or infinite, return false. * Else return true. - * + * * @param ring * the ring to check * @return true or false as stated above. @@ -247,18 +248,7 @@ public class Ring implements Cloneable, Savable, Externalizable, ReadOnlyRing, P */ @Override public int hashCode() { - int result = 17; - - result += 31 * result + _center.hashCode(); - result += 31 * result + _up.hashCode(); - - final long ir = Double.doubleToLongBits(getInnerRadius()); - result += 31 * result + (int) (ir ^ ir >>> 32); - - final long or = Double.doubleToLongBits(getOuterRadius()); - result += 31 * result + (int) (or ^ or >>> 32); - - return result; + return Objects.hash(getCenter(), getUp(), Double.valueOf(getInnerRadius()), Double.valueOf(getOuterRadius())); } /** @@ -320,7 +310,7 @@ public class Ring implements Cloneable, Savable, Externalizable, ReadOnlyRing, P /** * Used with serialization. Not to be called manually. - * + * * @param in * ObjectInput * @throws IOException @@ -336,7 +326,7 @@ public class Ring implements Cloneable, Savable, Externalizable, ReadOnlyRing, P /** * Used with serialization. Not to be called manually. - * + * * @param out * ObjectOutput * @throws IOException @@ -368,7 +358,7 @@ public class Ring implements Cloneable, Savable, Externalizable, ReadOnlyRing, P /** * Releases a Ring back to be used by a future call to fetchTempInstance. TAKE CARE: this Ring object should no * longer have other classes referencing it or "Bad Things" will happen. - * + * * @param ring * the Ring to release. */ diff --git a/ardor3d-math/src/main/java/com/ardor3d/math/Transform.java b/ardor3d-math/src/main/java/com/ardor3d/math/Transform.java index 47d0a88..629d035 100644 --- a/ardor3d-math/src/main/java/com/ardor3d/math/Transform.java +++ b/ardor3d-math/src/main/java/com/ardor3d/math/Transform.java @@ -3,7 +3,7 @@ * * This file is part of Ardor3D. * - * Ardor3D is free software: you can redistribute it and/or modify it + * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ @@ -16,6 +16,7 @@ import java.io.ObjectInput; import java.io.ObjectOutput; import java.nio.DoubleBuffer; import java.nio.FloatBuffer; +import java.util.Objects; import com.ardor3d.math.type.ReadOnlyMatrix3; import com.ardor3d.math.type.ReadOnlyMatrix4; @@ -78,7 +79,7 @@ public class Transform implements Cloneable, Savable, Externalizable, ReadOnlyTr /** * Constructs a new Transform object from the information stored in the given source Transform. - * + * * @param source * @throws NullPointerException * if source is null. @@ -96,7 +97,7 @@ public class Transform implements Cloneable, Savable, Externalizable, ReadOnlyTr /** * Internal only constructor, generally used for making an immutable transform. - * + * * @param matrix * @param scale * @param translation @@ -158,7 +159,7 @@ public class Transform implements Cloneable, Savable, Externalizable, ReadOnlyTr /** * Resets this transform to identity and resets all flags. - * + * * @return this Transform for chaining. */ public Transform setIdentity() { @@ -173,10 +174,10 @@ public class Transform implements Cloneable, Savable, Externalizable, ReadOnlyTr /** * Sets the matrix portion of this transform to the given value. - * + * * NB: Calling this with a matrix that is not purely rotational (orthonormal) will result in a Transform whose scale * comes from its matrix. Further attempts to set scale directly will throw an error. - * + * * @param rotation * our new matrix. * @return this transform for chaining. @@ -193,7 +194,7 @@ public class Transform implements Cloneable, Savable, Externalizable, ReadOnlyTr /** * Sets the matrix portion of this transform to the rotational value of the given Quaternion. Calling this allows * scale to be set and used. - * + * * @param rotation * @return this transform for chaining. * @throws NullPointerException @@ -207,7 +208,7 @@ public class Transform implements Cloneable, Savable, Externalizable, ReadOnlyTr /** * Sets the translation portion of this transform to the given value. - * + * * @param translation * @return this transform for chaining. * @throws NullPointerException @@ -221,7 +222,7 @@ public class Transform implements Cloneable, Savable, Externalizable, ReadOnlyTr /** * Sets the translation portion of this transform to the given values. - * + * * @param x * @param y * @param z @@ -235,7 +236,7 @@ public class Transform implements Cloneable, Savable, Externalizable, ReadOnlyTr /** * Sets the scale portion of this transform to the given value. - * + * * @param scale * @return this transform for chaining. * @throws NullPointerException @@ -262,7 +263,7 @@ public class Transform implements Cloneable, Savable, Externalizable, ReadOnlyTr /** * Sets the scale portion of this transform to the given values. - * + * * @param x * @param y * @param z @@ -291,7 +292,7 @@ public class Transform implements Cloneable, Savable, Externalizable, ReadOnlyTr /** * Sets the scale portion of this transform to the given value as a vector (u, u, u) - * + * * @param uniformScale * @return this transform for chaining. * @throws TransformException @@ -316,7 +317,7 @@ public class Transform implements Cloneable, Savable, Externalizable, ReadOnlyTr /** * Copies the given transform values into this transform object. - * + * * @param source * @return this transform for chaining. * @throws NullPointerException @@ -339,7 +340,7 @@ public class Transform implements Cloneable, Savable, Externalizable, ReadOnlyTr /** * Locally adds to the translation of this transform. - * + * * @param x * @param y * @param z @@ -353,7 +354,7 @@ public class Transform implements Cloneable, Savable, Externalizable, ReadOnlyTr /** * Locally adds to the translation of this transform. - * + * * @param vec * @return this transform for chaining. */ @@ -365,7 +366,7 @@ public class Transform implements Cloneable, Savable, Externalizable, ReadOnlyTr /** * Locally applies this transform to the given point: P' = M*P+T - * + * * @param point * @return the transformed point. * @throws NullPointerException @@ -402,7 +403,7 @@ public class Transform implements Cloneable, Savable, Externalizable, ReadOnlyTr /** * Applies this transform to the given point and returns the result in the given store vector: P' = M*P+T - * + * * @param point * @param store * the vector to store our result in. if null, a new vector will be created. @@ -422,7 +423,7 @@ public class Transform implements Cloneable, Savable, Externalizable, ReadOnlyTr /** * Locally applies the inverse of this transform to the given point: P' = M^{-1}*(P-T) - * + * * @param point * @return the transformed point. * @throws NullPointerException @@ -467,7 +468,7 @@ public class Transform implements Cloneable, Savable, Externalizable, ReadOnlyTr /** * Applies the inverse of this transform to the given point and returns the result in the given store vector: P' = * M^{-1}*(P-T) - * + * * @param point * @param store * the vector to store our result in. if null, a new vector will be created. @@ -487,7 +488,7 @@ public class Transform implements Cloneable, Savable, Externalizable, ReadOnlyTr /** * Locally applies this transform to the given vector: V' = M*V - * + * * @param vector * @return the transformed vector. * @throws NullPointerException @@ -522,7 +523,7 @@ public class Transform implements Cloneable, Savable, Externalizable, ReadOnlyTr /** * Applies this transform to the given vector and returns the result in the given store vector: V' = M*V - * + * * @param vector * @param store * the vector to store our result in. if null, a new vector will be created. @@ -542,7 +543,7 @@ public class Transform implements Cloneable, Savable, Externalizable, ReadOnlyTr /** * Locally applies the inverse of this transform to the given vector: V' = M^{-1}*V - * + * * @param vector * @return the transformed vector. * @throws NullPointerException @@ -584,7 +585,7 @@ public class Transform implements Cloneable, Savable, Externalizable, ReadOnlyTr /** * Applies the inverse of this transform to the given vector and returns the result in the given store vector: V' = * M^{-1}*V - * + * * @param vector * @param store * the vector to store our result in. if null, a new vector will be created. @@ -605,7 +606,7 @@ public class Transform implements Cloneable, Savable, Externalizable, ReadOnlyTr /** * Calculates the product of this transform with the given "transformBy" transform (P = this * T) and stores this in * store. - * + * * @param transformBy * @param store * the transform to store the result in for return. If null, a new transform object is created and @@ -654,11 +655,12 @@ public class Transform implements Cloneable, Savable, Externalizable, ReadOnlyTr } // In all remaining cases, the matrix cannot be written as R*S*X+T. - final ReadOnlyMatrix3 matrixA = isRotationMatrix() ? _matrix.multiplyDiagonalPost(_scale, - Matrix3.fetchTempInstance()) : _matrix; + final ReadOnlyMatrix3 matrixA = isRotationMatrix() + ? _matrix.multiplyDiagonalPost(_scale, Matrix3.fetchTempInstance()) : _matrix; - final ReadOnlyMatrix3 matrixB = transformBy.isRotationMatrix() ? transformBy.getMatrix().multiplyDiagonalPost( - transformBy.getScale(), Matrix3.fetchTempInstance()) : transformBy.getMatrix(); + final ReadOnlyMatrix3 matrixB = transformBy.isRotationMatrix() + ? transformBy.getMatrix().multiplyDiagonalPost(transformBy.getScale(), Matrix3.fetchTempInstance()) + : transformBy.getMatrix(); final Matrix3 newMatrix = result._matrix; newMatrix.set(matrixA).multiplyLocal(matrixB); @@ -684,7 +686,7 @@ public class Transform implements Cloneable, Savable, Externalizable, ReadOnlyTr /** * Updates _rotationMatrix, _uniformScale and _identity based on the current contents of this Transform. - * + * * @param rotationMatrixGuaranteed * true if we know for sure that the _matrix component is rotational. */ @@ -701,7 +703,7 @@ public class Transform implements Cloneable, Savable, Externalizable, ReadOnlyTr /** * Calculates the inverse of this transform. - * + * * @param store * the transform to store the result in for return. If null, a new transform object is created and * returned. It IS safe for store to be the same object as "this". @@ -744,13 +746,13 @@ public class Transform implements Cloneable, Savable, Externalizable, ReadOnlyTr * @param store * the matrix to store the result in for return. If null, a new matrix object is created and returned. * @return this transform represented as a 4x4 matrix: - * + * * <pre> * R R R Tx * R R R Ty * R R R Tz * 0 0 0 1 - * </pre> + * </pre> */ @Override public Matrix4 getHomogeneousMatrix(final Matrix4 store) { @@ -855,7 +857,7 @@ public class Transform implements Cloneable, Savable, Externalizable, ReadOnlyTr /** * Reads in a 4x4 matrix as a 3x3 matrix and translation. - * + * * @param matrix * @return this matrix for chaining. * @throws NullPointerException @@ -872,10 +874,10 @@ public class Transform implements Cloneable, Savable, Externalizable, ReadOnlyTr /** * Check a transform... if it is null or one of its members are invalid, return false. Else return true. - * + * * @param transform * the transform to check - * + * * @return true or false as stated above. */ public static boolean isValid(final ReadOnlyTransform transform) { @@ -903,13 +905,7 @@ public class Transform implements Cloneable, Savable, Externalizable, ReadOnlyTr */ @Override public int hashCode() { - int result = 17; - - result += 31 * result + _matrix.hashCode(); - result += 31 * result + _scale.hashCode(); - result += 31 * result + _translation.hashCode(); - - return result; + return Objects.hash(getMatrix(), getScale(), getTranslation()); } /** @@ -997,7 +993,7 @@ public class Transform implements Cloneable, Savable, Externalizable, ReadOnlyTr /** * Used with serialization. Not to be called manually. - * + * * @param in * ObjectInput * @throws IOException @@ -1015,9 +1011,9 @@ public class Transform implements Cloneable, Savable, Externalizable, ReadOnlyTr /* * Used with serialization. Not to be called manually. - * + * * @param out ObjectOutput - * + * * @throws IOException */ @Override @@ -1049,7 +1045,7 @@ public class Transform implements Cloneable, Savable, Externalizable, ReadOnlyTr /** * Releases a Transform back to be used by a future call to fetchTempInstance. TAKE CARE: this Transform object * should no longer have other classes referencing it or "Bad Things" will happen. - * + * * @param trans * the Transform to release. */ diff --git a/ardor3d-math/src/main/java/com/ardor3d/math/Triangle.java b/ardor3d-math/src/main/java/com/ardor3d/math/Triangle.java index d1db728..97bdccf 100644 --- a/ardor3d-math/src/main/java/com/ardor3d/math/Triangle.java +++ b/ardor3d-math/src/main/java/com/ardor3d/math/Triangle.java @@ -3,7 +3,7 @@ * * This file is part of Ardor3D. * - * Ardor3D is free software: you can redistribute it and/or modify it + * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ @@ -14,6 +14,7 @@ import java.io.Externalizable; import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; +import java.util.Objects; import com.ardor3d.math.type.ReadOnlyTriangle; import com.ardor3d.math.type.ReadOnlyVector3; @@ -51,7 +52,7 @@ public class Triangle implements Cloneable, Savable, Externalizable, ReadOnlyTri /** * Copy constructor. - * + * * @param source * the triangle to copy from. */ @@ -61,7 +62,7 @@ public class Triangle implements Cloneable, Savable, Externalizable, ReadOnlyTri /** * Construct a new, mutable triangle using the given points and an index of 0. - * + * * @param pointA * @param pointB * @param pointC @@ -72,7 +73,7 @@ public class Triangle implements Cloneable, Savable, Externalizable, ReadOnlyTri /** * Constructs a new triangle using the given points and index. - * + * * @param pointA * @param pointB * @param pointC @@ -88,7 +89,7 @@ public class Triangle implements Cloneable, Savable, Externalizable, ReadOnlyTri /** * Copies the values of the given source Triangle into this Triangle. - * + * * @param source * @return this Triangle for chaining * @throws NullPointerException @@ -138,7 +139,7 @@ public class Triangle implements Cloneable, Savable, Externalizable, ReadOnlyTri /** * Obtains the unit length normal vector of this triangle... Will create and recalculate this normal vector if this * is the first request, or if one of the points on the triangle has changed since the last request. - * + * * @return the normal vector * @throws NullPointerException * if store is null. @@ -165,7 +166,7 @@ public class Triangle implements Cloneable, Savable, Externalizable, ReadOnlyTri /** * Sets the index value of this triangle to the given int value. - * + * * @param index */ public void setIndex(final int index) { @@ -174,7 +175,7 @@ public class Triangle implements Cloneable, Savable, Externalizable, ReadOnlyTri /** * Sets the first point of this triangle to the values of the given vector. - * + * * @param pointA */ public void setA(final ReadOnlyVector3 pointA) { @@ -184,7 +185,7 @@ public class Triangle implements Cloneable, Savable, Externalizable, ReadOnlyTri /** * Sets the second point of this triangle to the values of the given vector. - * + * * @param pointB */ public void setB(final ReadOnlyVector3 pointB) { @@ -194,7 +195,7 @@ public class Triangle implements Cloneable, Savable, Externalizable, ReadOnlyTri /** * Sets the third point of this triangle to the values of the given vector. - * + * * @param pointC */ public void setC(final ReadOnlyVector3 pointC) { @@ -204,7 +205,7 @@ public class Triangle implements Cloneable, Savable, Externalizable, ReadOnlyTri /** * Sets a point to a new value. - * + * * @param index * the index of the point to set (0-2, corresponding to A-C) * @param point @@ -257,7 +258,7 @@ public class Triangle implements Cloneable, Savable, Externalizable, ReadOnlyTri /** * Check a triangle... if it is null or its points are invalid, return false. Else return true. - * + * * @param triangle * the triangle to check * @return true or false as stated above. @@ -289,14 +290,7 @@ public class Triangle implements Cloneable, Savable, Externalizable, ReadOnlyTri */ @Override public int hashCode() { - int result = 17; - - result += 31 * result + _pointA.hashCode(); - result += 31 * result + _pointB.hashCode(); - result += 31 * result + _pointC.hashCode(); - result += 31 * result + _index; - - return result; + return Objects.hash(getA(), getB(), getC(), Integer.valueOf(getIndex())); } /** @@ -357,7 +351,7 @@ public class Triangle implements Cloneable, Savable, Externalizable, ReadOnlyTri /** * Used with serialization. Not to be called manually. - * + * * @param in * ObjectInput * @throws IOException @@ -373,7 +367,7 @@ public class Triangle implements Cloneable, Savable, Externalizable, ReadOnlyTri /** * Used with serialization. Not to be called manually. - * + * * @param out * ObjectOutput * @throws IOException @@ -405,7 +399,7 @@ public class Triangle implements Cloneable, Savable, Externalizable, ReadOnlyTri /** * Releases a Triangle back to be used by a future call to fetchTempInstance. TAKE CARE: this Triangle object should * no longer have other classes referencing it or "Bad Things" will happen. - * + * * @param tri * the Triangle to release. */ diff --git a/ardor3d-math/src/main/java/com/ardor3d/math/Vector2.java b/ardor3d-math/src/main/java/com/ardor3d/math/Vector2.java index c6f1d46..a8de730 100644 --- a/ardor3d-math/src/main/java/com/ardor3d/math/Vector2.java +++ b/ardor3d-math/src/main/java/com/ardor3d/math/Vector2.java @@ -3,7 +3,7 @@ * * This file is part of Ardor3D. * - * Ardor3D is free software: you can redistribute it and/or modify it + * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ @@ -14,6 +14,7 @@ import java.io.Externalizable; import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; +import java.util.Objects; import com.ardor3d.math.type.ReadOnlyVector2; import com.ardor3d.util.export.InputCapsule; @@ -77,7 +78,7 @@ public class Vector2 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Constructs a new vector set to the (x, y) values of the given source vector. - * + * * @param src */ public Vector2(final ReadOnlyVector2 src) { @@ -86,7 +87,7 @@ public class Vector2 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Constructs a new vector set to (x, y). - * + * * @param x * @param y */ @@ -160,7 +161,7 @@ public class Vector2 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Stores the double values of this vector in the given double array. - * + * * @param store * if null, a new double[2] array is created. * @return the double array @@ -180,7 +181,7 @@ public class Vector2 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Sets the first component of this vector to the given double value. - * + * * @param x */ public void setX(final double x) { @@ -189,7 +190,7 @@ public class Vector2 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Sets the second component of this vector to the given double value. - * + * * @param y */ public void setY(final double y) { @@ -198,7 +199,7 @@ public class Vector2 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Sets the value of this vector to (x, y) - * + * * @param x * @param y * @return this vector for chaining @@ -211,7 +212,7 @@ public class Vector2 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Sets the value of this vector to the (x, y) values of the provided source vector. - * + * * @param source * @return this vector for chaining * @throws NullPointerException @@ -225,7 +226,7 @@ public class Vector2 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Sets the value of this vector to (0, 0) - * + * * @return this vector for chaining */ public Vector2 zero() { @@ -235,7 +236,7 @@ public class Vector2 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Adds the given values to those of this vector and returns them in store * @param store the vector to store the * result in for return. If null, a new vector object is created and returned. . - * + * * @param x * @param y * @param store @@ -254,7 +255,7 @@ public class Vector2 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Increments the values of this vector with the given x and y values. - * + * * @param x * @param y * @return this vector for chaining @@ -265,7 +266,7 @@ public class Vector2 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Adds the values of the given source vector to those of this vector and returns them in store. - * + * * @param source * @param store * the vector to store the result in for return. If null, a new vector object is created and returned. @@ -280,7 +281,7 @@ public class Vector2 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Increments the values of this vector with the x and y values of the given vector. - * + * * @param source * @return this vector for chaining * @throws NullPointerException @@ -292,7 +293,7 @@ public class Vector2 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Subtracts the given values from those of this vector and returns them in store. - * + * * @param x * @param y * @param store @@ -311,7 +312,7 @@ public class Vector2 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Decrements the values of this vector by the given x and y values. - * + * * @param x * @param y * @return this vector for chaining @@ -322,7 +323,7 @@ public class Vector2 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Subtracts the values of the given source vector from those of this vector and returns them in store. - * + * * @param source * @param store * the vector to store the result in for return. If null, a new vector object is created and returned. @@ -337,7 +338,7 @@ public class Vector2 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Decrements the values of this vector by the x and y values from the given source vector. - * + * * @param source * @return this vector for chaining * @throws NullPointerException @@ -349,7 +350,7 @@ public class Vector2 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Multiplies the values of this vector by the given scalar value and returns the result in store. - * + * * @param scalar * @param store * the vector to store the result in for return. If null, a new vector object is created and returned. @@ -367,7 +368,7 @@ public class Vector2 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Internally modifies the values of this vector by multiplying them each by the given scalar value. - * + * * @param scalar * @return this vector for chaining */ @@ -377,7 +378,7 @@ public class Vector2 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Multiplies the values of this vector by the given scale values and returns the result in store. - * + * * @param scale * @param store * the vector to store the result in for return. If null, a new vector object is created and returned. @@ -395,7 +396,7 @@ public class Vector2 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Internally modifies the values of this vector by multiplying them each by the values of the given scale. - * + * * @param scale * @return this vector for chaining */ @@ -405,7 +406,7 @@ public class Vector2 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Multiplies the values of this vector by the given scale values and returns the result in store. - * + * * @param x * @param y * @param store @@ -424,7 +425,7 @@ public class Vector2 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Internally modifies the values of this vector by multiplying them each by the values of the given scale. - * + * * @param x * @param y * @return this vector for chaining @@ -435,7 +436,7 @@ public class Vector2 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Divides the values of this vector by the given scalar value and returns the result in store. - * + * * @param scalar * @param store * the vector to store the result in for return. If null, a new vector object is created and returned. @@ -453,7 +454,7 @@ public class Vector2 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Internally modifies the values of this vector by dividing them each by the given scalar value. - * + * * @param scalar * @return this vector for chaining * @throws ArithmeticException @@ -467,7 +468,7 @@ public class Vector2 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Divides the values of this vector by the given scale values and returns the result in store. - * + * * @param scale * @param store * the vector to store the result in for return. If null, a new vector object is created and returned. @@ -485,7 +486,7 @@ public class Vector2 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Internally modifies the values of this vector by dividing them each by the values of the given scale. - * + * * @param scale * @return this vector for chaining */ @@ -495,7 +496,7 @@ public class Vector2 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Divides the values of this vector by the given scale values and returns the result in store. - * + * * @param x * @param y * @param store @@ -514,7 +515,7 @@ public class Vector2 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Internally modifies the values of this vector by dividing them each by the values of the given scale. - * + * * @param x * @param y * @return this vector for chaining @@ -524,10 +525,10 @@ public class Vector2 implements Cloneable, Savable, Externalizable, ReadOnlyVect } /** - * + * * Internally modifies this vector by multiplying its values with a given scale value, then adding a given "add" * value. - * + * * @param scale * the value to multiply this vector by. * @param add @@ -543,7 +544,7 @@ public class Vector2 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Scales this vector by multiplying its values with a given scale value, then adding a given "add" value. The * result is store in the given store parameter. - * + * * @param scale * the value to multiply by. * @param add @@ -584,7 +585,7 @@ public class Vector2 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Creates a new unit length vector from this one by dividing by length. If the length is 0, (ie, if the vector is * 0, 0) then a new vector (0, 0) is returned. - * + * * @param store * the vector to store the result in for return. If null, a new vector object is created and returned. * @return a new unit vector (or 0, 0 if this unit is 0 length) @@ -602,7 +603,7 @@ public class Vector2 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Converts this vector into a unit vector by dividing it internally by its length. If the length is 0, (ie, if the * vector is 0, 0) then no action is taken. - * + * * @return this vector for chaining */ public Vector2 normalizeLocal() { @@ -616,7 +617,7 @@ public class Vector2 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Creates a new vector representing this vector rotated around 0,0 by a specified angle in a given direction. - * + * * @param angle * in radians * @param clockwise @@ -642,7 +643,7 @@ public class Vector2 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Internally rotates this vector around 0,0 by a specified angle in a given direction. - * + * * @param angle * in radians * @param clockwise @@ -662,7 +663,7 @@ public class Vector2 implements Cloneable, Savable, Externalizable, ReadOnlyVect * Performs a linear interpolation between this vector and the given end vector, using the given scalar as a * percent. iow, if changeAmnt is closer to 0, the result will be closer to the current value of this vector and if * it is closer to 1, the result will be closer to the end value. The result is returned as a new vector object. - * + * * @param endVec * @param scalar * @param store @@ -687,7 +688,7 @@ public class Vector2 implements Cloneable, Savable, Externalizable, ReadOnlyVect * Performs a linear interpolation between this vector and the given end vector, using the given scalar as a * percent. iow, if changeAmnt is closer to 0, the result will be closer to the current value of this vector and if * it is closer to 1, the result will be closer to the end value. The result is stored back in this vector. - * + * * @param endVec * @param scalar * @return this vector for chaining @@ -704,7 +705,7 @@ public class Vector2 implements Cloneable, Savable, Externalizable, ReadOnlyVect * Performs a linear interpolation between the given begin and end vectors, using the given scalar as a percent. * iow, if changeAmnt is closer to 0, the result will be closer to the begin value and if it is closer to 1, the * result will be closer to the end value. The result is returned as a new vector object. - * + * * @param beginVec * @param endVec * @param scalar @@ -731,7 +732,7 @@ public class Vector2 implements Cloneable, Savable, Externalizable, ReadOnlyVect * Performs a linear interpolation between the given begin and end vectors, using the given scalar as a percent. * iow, if changeAmnt is closer to 0, the result will be closer to the begin value and if it is closer to 1, the * result will be closer to the end value. The result is stored back in this vector. - * + * * @param beginVec * @param endVec * @param changeAmnt @@ -834,8 +835,8 @@ public class Vector2 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * @return the angle - in radians [-pi, pi) - represented by this Vector2 as expressed by a conversion from - * rectangular coordinates (<code>x</code>, <code>y</code>) to polar coordinates - * (r, <i>theta</i>). + * rectangular coordinates (<code>x</code>, <code>y</code>) to polar coordinates (r, <i>theta</i> + * ). */ @Override public double getPolarAngle() { @@ -872,7 +873,7 @@ public class Vector2 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Check a vector... if it is null or its doubles are NaN or infinite, return false. Else return true. - * + * * @param vector * the vector to check * @return true or false as stated above. @@ -904,15 +905,7 @@ public class Vector2 implements Cloneable, Savable, Externalizable, ReadOnlyVect */ @Override public int hashCode() { - int result = 17; - - final long x = Double.doubleToLongBits(getX()); - result += 31 * result + (int) (x ^ x >>> 32); - - final long y = Double.doubleToLongBits(getY()); - result += 31 * result + (int) (y ^ y >>> 32); - - return result; + return Objects.hash(Double.valueOf(getX()), Double.valueOf(getY())); } /** @@ -968,7 +961,7 @@ public class Vector2 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Used with serialization. Not to be called manually. - * + * * @param in * ObjectInput * @throws IOException @@ -982,7 +975,7 @@ public class Vector2 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Used with serialization. Not to be called manually. - * + * * @param out * ObjectOutput * @throws IOException @@ -1012,7 +1005,7 @@ public class Vector2 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Releases a Vector2 back to be used by a future call to fetchTempInstance. TAKE CARE: this Vector2 object should * no longer have other classes referencing it or "Bad Things" will happen. - * + * * @param vec * the Vector2 to release. */ diff --git a/ardor3d-math/src/main/java/com/ardor3d/math/Vector3.java b/ardor3d-math/src/main/java/com/ardor3d/math/Vector3.java index f8754b2..d23814b 100644 --- a/ardor3d-math/src/main/java/com/ardor3d/math/Vector3.java +++ b/ardor3d-math/src/main/java/com/ardor3d/math/Vector3.java @@ -3,7 +3,7 @@ * * This file is part of Ardor3D. * - * Ardor3D is free software: you can redistribute it and/or modify it + * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ @@ -14,6 +14,7 @@ import java.io.Externalizable; import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; +import java.util.Objects; import com.ardor3d.math.type.ReadOnlyVector3; import com.ardor3d.util.export.InputCapsule; @@ -88,7 +89,7 @@ public class Vector3 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Constructs a new vector set to the (x, y, z) values of the given source vector. - * + * * @param src */ public Vector3(final ReadOnlyVector3 src) { @@ -97,7 +98,7 @@ public class Vector3 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Constructs a new vector set to (x, y, z). - * + * * @param x * @param y * @param z @@ -191,7 +192,7 @@ public class Vector3 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Stores the double values of this vector in the given double array. - * + * * @param store * if null, a new double[3] array is created. * @return the double array @@ -213,7 +214,7 @@ public class Vector3 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Stores the double values of this vector in the given float array. - * + * * @param store * if null, a new float[3] array is created. * @return the float array @@ -236,7 +237,7 @@ public class Vector3 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Sets the first component of this vector to the given double value. - * + * * @param x */ public void setX(final double x) { @@ -245,7 +246,7 @@ public class Vector3 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Sets the second component of this vector to the given double value. - * + * * @param y */ public void setY(final double y) { @@ -254,7 +255,7 @@ public class Vector3 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Sets the third component of this vector to the given double value. - * + * * @param z */ public void setZ(final double z) { @@ -263,7 +264,7 @@ public class Vector3 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Sets the value of this vector to (x, y, z) - * + * * @param x * @param y * @param z @@ -278,7 +279,7 @@ public class Vector3 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Sets the value of this vector to the (x, y, z) values of the provided source vector. - * + * * @param source * @return this vector for chaining * @throws NullPointerException @@ -293,7 +294,7 @@ public class Vector3 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Sets the value of this vector to (0, 0, 0) - * + * * @return this vector for chaining */ public Vector3 zero() { @@ -303,7 +304,7 @@ public class Vector3 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Adds the given values to those of this vector and returns them in store * @param store the vector to store the * result in for return. If null, a new vector object is created and returned. . - * + * * @param x * @param y * @param z @@ -323,7 +324,7 @@ public class Vector3 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Increments the values of this vector with the given x, y and z values. - * + * * @param x * @param y * @param z @@ -335,7 +336,7 @@ public class Vector3 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Adds the values of the given source vector to those of this vector and returns them in store. - * + * * @param source * @param store * the vector to store the result in for return. If null, a new vector object is created and returned. @@ -350,7 +351,7 @@ public class Vector3 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Increments the values of this vector with the x, y and z values of the given vector. - * + * * @param source * @return this vector for chaining * @throws NullPointerException @@ -362,7 +363,7 @@ public class Vector3 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Subtracts the given values from those of this vector and returns them in store. - * + * * @param x * @param y * @param z @@ -382,7 +383,7 @@ public class Vector3 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Decrements the values of this vector by the given x, y and z values. - * + * * @param x * @param y * @param z @@ -394,7 +395,7 @@ public class Vector3 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Subtracts the values of the given source vector from those of this vector and returns them in store. - * + * * @param source * @param store * the vector to store the result in for return. If null, a new vector object is created and returned. @@ -409,7 +410,7 @@ public class Vector3 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Decrements the values of this vector by the x, y and z values from the given source vector. - * + * * @param source * @return this vector for chaining * @throws NullPointerException @@ -421,7 +422,7 @@ public class Vector3 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Multiplies the values of this vector by the given scalar value and returns the result in store. - * + * * @param scalar * @param store * the vector to store the result in for return. If null, a new vector object is created and returned. @@ -439,7 +440,7 @@ public class Vector3 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Internally modifies the values of this vector by multiplying them each by the given scalar value. - * + * * @param scalar * @return this vector for chaining */ @@ -449,7 +450,7 @@ public class Vector3 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Multiplies the values of this vector by the given scale values and returns the result in store. - * + * * @param scale * @param store * the vector to store the result in for return. If null, a new vector object is created and returned. @@ -467,7 +468,7 @@ public class Vector3 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Internally modifies the values of this vector by multiplying them each by the given scale values. - * + * * @param scalar * @return this vector for chaining */ @@ -477,7 +478,7 @@ public class Vector3 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Multiplies the values of this vector by the given scale values and returns the result in store. - * + * * @param x * @param y * @param z @@ -497,7 +498,7 @@ public class Vector3 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Internally modifies the values of this vector by multiplying them each by the given scale values. - * + * * @param x * @param y * @param z @@ -509,7 +510,7 @@ public class Vector3 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Divides the values of this vector by the given scalar value and returns the result in store. - * + * * @param scalar * @param store * the vector to store the result in for return. If null, a new vector object is created and returned. @@ -527,7 +528,7 @@ public class Vector3 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Internally modifies the values of this vector by dividing them each by the given scalar value. - * + * * @param scalar * @return this vector for chaining * @throws ArithmeticException @@ -541,7 +542,7 @@ public class Vector3 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Divides the values of this vector by the given scale values and returns the result in store. - * + * * @param scale * @param store * the vector to store the result in for return. If null, a new vector object is created and returned. @@ -559,7 +560,7 @@ public class Vector3 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Internally modifies the values of this vector by dividing them each by the given scale values. - * + * * @param scale * @return this vector for chaining */ @@ -569,7 +570,7 @@ public class Vector3 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Divides the values of this vector by the given scale values and returns the result in store. - * + * * @param x * @param y * @param z @@ -589,7 +590,7 @@ public class Vector3 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Internally modifies the values of this vector by dividing them each by the given scale values. - * + * * @param x * @param y * @param z @@ -600,10 +601,10 @@ public class Vector3 implements Cloneable, Savable, Externalizable, ReadOnlyVect } /** - * + * * Internally modifies this vector by multiplying its values with a given scale value, then adding a given "add" * value. - * + * * @param scale * the value to multiply this vector by. * @param add @@ -620,7 +621,7 @@ public class Vector3 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Scales this vector by multiplying its values with a given scale value, then adding a given "add" value. The * result is store in the given store parameter. - * + * * @param scale * the value to multiply by. * @param add @@ -662,7 +663,7 @@ public class Vector3 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Creates a new unit length vector from this one by dividing by length. If the length is 0, (ie, if the vector is * 0, 0, 0) then a new vector (0, 0, 0) is returned. - * + * * @param store * the vector to store the result in for return. If null, a new vector object is created and returned. * @return a new unit vector (or 0, 0, 0 if this unit is 0 length) @@ -680,7 +681,7 @@ public class Vector3 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Converts this vector into a unit vector by dividing it internally by its length. If the length is 0, (ie, if the * vector is 0, 0, 0) then no action is taken. - * + * * @return this vector for chaining */ public Vector3 normalizeLocal() { @@ -696,7 +697,7 @@ public class Vector3 implements Cloneable, Savable, Externalizable, ReadOnlyVect * Performs a linear interpolation between this vector and the given end vector, using the given scalar as a * percent. iow, if changeAmnt is closer to 0, the result will be closer to the current value of this vector and if * it is closer to 1, the result will be closer to the end value. The result is returned as a new vector object. - * + * * @param endVec * @param scalar * @param store @@ -722,7 +723,7 @@ public class Vector3 implements Cloneable, Savable, Externalizable, ReadOnlyVect * Performs a linear interpolation between this vector and the given end vector, using the given scalar as a * percent. iow, if changeAmnt is closer to 0, the result will be closer to the current value of this vector and if * it is closer to 1, the result will be closer to the end value. The result is stored back in this vector. - * + * * @param endVec * @param scalar * @return this vector for chaining @@ -740,7 +741,7 @@ public class Vector3 implements Cloneable, Savable, Externalizable, ReadOnlyVect * Performs a linear interpolation between the given begin and end vectors, using the given scalar as a percent. * iow, if changeAmnt is closer to 0, the result will be closer to the begin value and if it is closer to 1, the * result will be closer to the end value. The result is returned as a new vector object. - * + * * @param beginVec * @param endVec * @param scalar @@ -774,7 +775,7 @@ public class Vector3 implements Cloneable, Savable, Externalizable, ReadOnlyVect * Performs a linear interpolation between the given begin and end vectors, using the given scalar as a percent. * iow, if changeAmnt is closer to 0, the result will be closer to the begin value and if it is closer to 1, the * result will be closer to the end value. The result is stored back in this vector. - * + * * @param beginVec * @param endVec * @param changeAmnt @@ -959,7 +960,7 @@ public class Vector3 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Check a vector... if it is null or its doubles are NaN or infinite, return false. Else return true. - * + * * @param vector * the vector to check * @return true or false as stated above. @@ -979,7 +980,7 @@ public class Vector3 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Check if a vector is non-null and has infinite values. - * + * * @param vector * the vector to check * @return true or false as stated above. @@ -1008,18 +1009,7 @@ public class Vector3 implements Cloneable, Savable, Externalizable, ReadOnlyVect */ @Override public int hashCode() { - int result = 17; - - final long x = Double.doubleToLongBits(getX()); - result += 31 * result + (int) (x ^ x >>> 32); - - final long y = Double.doubleToLongBits(getY()); - result += 31 * result + (int) (y ^ y >>> 32); - - final long z = Double.doubleToLongBits(getZ()); - result += 31 * result + (int) (z ^ z >>> 32); - - return result; + return Objects.hash(Double.valueOf(getX()), Double.valueOf(getY()), Double.valueOf(getZ())); } /** @@ -1077,7 +1067,7 @@ public class Vector3 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Used with serialization. Not to be called manually. - * + * * @param in * ObjectInput * @throws IOException @@ -1092,7 +1082,7 @@ public class Vector3 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Used with serialization. Not to be called manually. - * + * * @param out * ObjectOutput * @throws IOException @@ -1123,7 +1113,7 @@ public class Vector3 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Releases a Vector3 back to be used by a future call to fetchTempInstance. TAKE CARE: this Vector3 object should * no longer have other classes referencing it or "Bad Things" will happen. - * + * * @param vec * the Vector3 to release. */ diff --git a/ardor3d-math/src/main/java/com/ardor3d/math/Vector4.java b/ardor3d-math/src/main/java/com/ardor3d/math/Vector4.java index 74927d6..53e57b7 100644 --- a/ardor3d-math/src/main/java/com/ardor3d/math/Vector4.java +++ b/ardor3d-math/src/main/java/com/ardor3d/math/Vector4.java @@ -3,7 +3,7 @@ * * This file is part of Ardor3D. * - * Ardor3D is free software: you can redistribute it and/or modify it + * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ @@ -14,6 +14,7 @@ import java.io.Externalizable; import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; +import java.util.Objects; import com.ardor3d.math.type.ReadOnlyVector4; import com.ardor3d.util.export.InputCapsule; @@ -99,7 +100,7 @@ public class Vector4 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Constructs a new vector set to the (x, y, z, w) values of the given source vector. - * + * * @param src */ public Vector4(final ReadOnlyVector4 src) { @@ -108,7 +109,7 @@ public class Vector4 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Constructs a new vector set to (x, y, z, w). - * + * * @param x * @param y * @param z @@ -201,7 +202,7 @@ public class Vector4 implements Cloneable, Savable, Externalizable, ReadOnlyVect * to set to one of x, y, z or w. * @throws IllegalArgumentException * if index is not one of 0, 1, 2, 3. - * + * * if this vector is read only */ public void setValue(final int index, final double value) { @@ -224,7 +225,7 @@ public class Vector4 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Stores the double values of this vector in the given double array. - * + * * @param store * if null, a new double[4] array is created. * @return the double array @@ -246,7 +247,7 @@ public class Vector4 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Sets the first component of this vector to the given double value. - * + * * @param x */ public void setX(final double x) { @@ -255,7 +256,7 @@ public class Vector4 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Sets the second component of this vector to the given double value. - * + * * @param y */ public void setY(final double y) { @@ -264,7 +265,7 @@ public class Vector4 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Sets the third component of this vector to the given double value. - * + * * @param z */ public void setZ(final double z) { @@ -273,7 +274,7 @@ public class Vector4 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Sets the fourth component of this vector to the given double value. - * + * * @param w */ public void setW(final double w) { @@ -282,7 +283,7 @@ public class Vector4 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Sets the value of this vector to (x, y, z, w) - * + * * @param x * @param y * @param z @@ -299,7 +300,7 @@ public class Vector4 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Sets the value of this vector to the (x, y, z, w) values of the provided source vector. - * + * * @param source * @return this vector for chaining * @throws NullPointerException @@ -315,7 +316,7 @@ public class Vector4 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Sets the value of this vector to (0, 0, 0, 0) - * + * * @return this vector for chaining */ public Vector4 zero() { @@ -324,7 +325,7 @@ public class Vector4 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Adds the given values to those of this vector and returns them in store. - * + * * @param x * @param y * @param z @@ -345,7 +346,7 @@ public class Vector4 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Increments the values of this vector with the given x, y, z and w values. - * + * * @param x * @param y * @param z @@ -358,7 +359,7 @@ public class Vector4 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Adds the values of the given source vector to those of this vector and returns them in store. - * + * * @param source * @param store * the vector to store the result in for return. If null, a new vector object is created and returned. @@ -373,7 +374,7 @@ public class Vector4 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Increments the values of this vector with the x, y, z and w values of the given vector. - * + * * @param source * @return this vector for chaining * @throws NullPointerException @@ -385,7 +386,7 @@ public class Vector4 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Subtracts the given values from those of this vector and returns them in store. - * + * * @param x * @param y * @param z @@ -406,7 +407,7 @@ public class Vector4 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Decrements the values of this vector by the given x, y, z and w values. - * + * * @param x * @param y * @param z @@ -419,7 +420,7 @@ public class Vector4 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Subtracts the values of the given source vector from those of this vector and returns them in store. - * + * * @param source * @param store * the vector to store the result in for return. If null, a new vector object is created and returned. @@ -434,7 +435,7 @@ public class Vector4 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Decrements the values of this vector by the x, y, z and w values from the given source vector. - * + * * @param source * @return this vector for chaining * @throws NullPointerException @@ -446,7 +447,7 @@ public class Vector4 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Multiplies the values of this vector by the given scalar value and returns the result in store. - * + * * @param scalar * @param store * the vector to store the result in for return. If null, a new vector object is created and returned. @@ -464,7 +465,7 @@ public class Vector4 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Internally modifies the values of this vector by multiplying them each by the given scalar value. - * + * * @param scalar * @return this vector for chaining */ @@ -474,7 +475,7 @@ public class Vector4 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Multiplies the values of this vector by the given scalar value and returns the result in store. - * + * * @param scale * @param store * the vector to store the result in for return. If null, a new vector object is created and returned. @@ -492,7 +493,7 @@ public class Vector4 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Internally modifies the values of this vector by multiplying them each by the given scale values. - * + * * @param scale * @return this vector for chaining */ @@ -502,7 +503,7 @@ public class Vector4 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Multiplies the values of this vector by the given scalar value and returns the result in store. - * + * * @param x * @param y * @param z @@ -523,7 +524,7 @@ public class Vector4 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Internally modifies the values of this vector by multiplying them each by the given scale values. - * + * * @param x * @param y * @param z @@ -536,7 +537,7 @@ public class Vector4 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Divides the values of this vector by the given scalar value and returns the result in store. - * + * * @param scalar * @param store * the vector to store the result in for return. If null, a new vector object is created and returned. @@ -554,11 +555,11 @@ public class Vector4 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Internally modifies the values of this vector by dividing them each by the given scalar value. - * + * * @param scalar * @return this vector for chaining - * - * + * + * * @throws ArithmeticException * if scalar is 0 */ @@ -570,7 +571,7 @@ public class Vector4 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Divides the values of this vector by the given scale values and returns the result in store. - * + * * @param scale * @param store * the vector to store the result in for return. If null, a new vector object is created and returned. @@ -588,7 +589,7 @@ public class Vector4 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Internally modifies the values of this vector by dividing them each by the given scale values. - * + * * @param scale * @return this vector for chaining */ @@ -598,7 +599,7 @@ public class Vector4 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Divides the values of this vector by the given scale values and returns the result in store. - * + * * @param x * @param y * @param z @@ -619,7 +620,7 @@ public class Vector4 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Internally modifies the values of this vector by dividing them each by the given scale values. - * + * * @param x * @param y * @param z @@ -631,10 +632,10 @@ public class Vector4 implements Cloneable, Savable, Externalizable, ReadOnlyVect } /** - * + * * Internally modifies this vector by multiplying its values with a given scale value, then adding a given "add" * value. - * + * * @param scale * the value to multiply this vector by. * @param add @@ -652,7 +653,7 @@ public class Vector4 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Scales this vector by multiplying its values with a given scale value, then adding a given "add" value. The * result is store in the given store parameter. - * + * * @param scale * the value to multiply by. * @param add @@ -695,7 +696,7 @@ public class Vector4 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Creates a new unit length vector from this one by dividing by length. If the length is 0, (ie, if the vector is * 0, 0, 0, 0) then a new vector (0, 0, 0, 0) is returned. - * + * * @param store * the vector to store the result in for return. If null, a new vector object is created and returned. * @return a new unit vector (or 0, 0, 0, 0 if this unit is 0 length) @@ -713,7 +714,7 @@ public class Vector4 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Converts this vector into a unit vector by dividing it internally by its length. If the length is 0, (ie, if the * vector is 0, 0, 0, 0) then no action is taken. - * + * * @return this vector for chaining */ public Vector4 normalizeLocal() { @@ -729,7 +730,7 @@ public class Vector4 implements Cloneable, Savable, Externalizable, ReadOnlyVect * Performs a linear interpolation between this vector and the given end vector, using the given scalar as a * percent. iow, if changeAmnt is closer to 0, the result will be closer to the current value of this vector and if * it is closer to 1, the result will be closer to the end value. The result is returned as a new vector object. - * + * * @param endVec * @param scalar * @param store @@ -756,12 +757,12 @@ public class Vector4 implements Cloneable, Savable, Externalizable, ReadOnlyVect * Performs a linear interpolation between this vector and the given end vector, using the given scalar as a * percent. iow, if changeAmnt is closer to 0, the result will be closer to the current value of this vector and if * it is closer to 1, the result will be closer to the end value. The result is stored back in this vector. - * + * * @param endVec * @param scalar * @return this vector for chaining - * - * + * + * * @throws NullPointerException * if endVec is null. */ @@ -777,7 +778,7 @@ public class Vector4 implements Cloneable, Savable, Externalizable, ReadOnlyVect * Performs a linear interpolation between the given begin and end vectors, using the given scalar as a percent. * iow, if changeAmnt is closer to 0, the result will be closer to the begin value and if it is closer to 1, the * result will be closer to the end value. The result is returned as a new vector object. - * + * * @param beginVec * @param endVec * @param scalar @@ -806,14 +807,14 @@ public class Vector4 implements Cloneable, Savable, Externalizable, ReadOnlyVect * Performs a linear interpolation between the given begin and end vectors, using the given scalar as a percent. * iow, if changeAmnt is closer to 0, the result will be closer to the begin value and if it is closer to 1, the * result will be closer to the end value. The result is stored back in this vector. - * + * * @param beginVec * @param endVec * @param changeAmnt * the scalar as a percent. * @return this vector for chaining - * - * + * + * * @throws NullPointerException * if beginVec or endVec are null. */ @@ -922,7 +923,7 @@ public class Vector4 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Check a vector... if it is null or its doubles are NaN or infinite, return false. Else return true. - * + * * @param vector * the vector to check * @return true or false as stated above. @@ -956,21 +957,8 @@ public class Vector4 implements Cloneable, Savable, Externalizable, ReadOnlyVect */ @Override public int hashCode() { - int result = 17; - - final long x = Double.doubleToLongBits(getX()); - result += 31 * result + (int) (x ^ x >>> 32); - - final long y = Double.doubleToLongBits(getY()); - result += 31 * result + (int) (y ^ y >>> 32); - - final long z = Double.doubleToLongBits(getZ()); - result += 31 * result + (int) (z ^ z >>> 32); - - final long w = Double.doubleToLongBits(getW()); - result += 31 * result + (int) (w ^ w >>> 32); - - return result; + return Objects.hash(Double.valueOf(getX()), Double.valueOf(getY()), Double.valueOf(getZ()), + Double.valueOf(getW())); } /** @@ -1030,7 +1018,7 @@ public class Vector4 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Used with serialization. Not to be called manually. - * + * * @param in * ObjectInput * @throws IOException @@ -1046,7 +1034,7 @@ public class Vector4 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Used with serialization. Not to be called manually. - * + * * @param out * ObjectOutput * @throws IOException @@ -1078,7 +1066,7 @@ public class Vector4 implements Cloneable, Savable, Externalizable, ReadOnlyVect /** * Releases a Vector4 back to be used by a future call to fetchTempInstance. TAKE CARE: this Vector4 object should * no longer have other classes referencing it or "Bad Things" will happen. - * + * * @param vec * the Vector4 to release. */ diff --git a/ardor3d-math/src/main/java/com/ardor3d/math/functions/MapperFunction3D.java b/ardor3d-math/src/main/java/com/ardor3d/math/functions/MapperFunction3D.java index 1a64086..9fbe781 100644 --- a/ardor3d-math/src/main/java/com/ardor3d/math/functions/MapperFunction3D.java +++ b/ardor3d-math/src/main/java/com/ardor3d/math/functions/MapperFunction3D.java @@ -3,7 +3,7 @@ * * This file is part of Ardor3D. * - * Ardor3D is free software: you can redistribute it and/or modify it + * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ @@ -22,12 +22,12 @@ import com.ardor3d.math.MathUtils; public class MapperFunction3D implements Function3D { private Function3D _mapFunction; - private final List<Entry> _entries = new ArrayList<Entry>(); + private final List<Entry> _entries = new ArrayList<>(); private double _domainStart, _domainEnd; /** * Construct a mapper function using the given map function and a start and end for the domain we'll use. - * + * * @param mapFunction * @param domainStart * @param domainEnd @@ -38,6 +38,7 @@ public class MapperFunction3D implements Function3D { _domainEnd = domainEnd; } + @SuppressWarnings("null") @Override public double eval(final double x, final double y, final double z) { // grab a value from our map function. @@ -66,7 +67,7 @@ public class MapperFunction3D implements Function3D { // check if we are in the ease-out region and have a next function. else if (next != null && mappingValue > end - current.easeOut) { // ...interpolate with a quintic S-curve. - final double ratio = ((mappingValue - end) / current.easeOut) + 1; + final double ratio = (mappingValue - end) / current.easeOut + 1; final double amount = MathUtils.scurve5(ratio); return MathUtils.lerp(amount, current.source.eval(x, y, z), next.source.eval(x, y, z)); } @@ -108,7 +109,7 @@ public class MapperFunction3D implements Function3D { /** * Add a new source function to the end of our set of ranged functions. Our place in the range is based on the place * of the previous source function and the offsetStart provided. - * + * * @param source * the new function to add * @param offsetStart @@ -120,7 +121,8 @@ public class MapperFunction3D implements Function3D { * a "fade out" range between this function and the next function, starting at the next function's * offsetStart - easeOut. Over this range we'll lerp between the two functions. */ - public void addFunction(final Function3D source, final double offsetStart, final double easeIn, final double easeOut) { + public void addFunction(final Function3D source, final double offsetStart, final double easeIn, + final double easeOut) { final Entry e = new Entry(); e.source = source; e.offsetStart = offsetStart; diff --git a/ardor3d-math/src/main/java/com/ardor3d/math/functions/VoroniFunction3D.java b/ardor3d-math/src/main/java/com/ardor3d/math/functions/VoroniFunction3D.java index 149db66..96b26bd 100644 --- a/ardor3d-math/src/main/java/com/ardor3d/math/functions/VoroniFunction3D.java +++ b/ardor3d-math/src/main/java/com/ardor3d/math/functions/VoroniFunction3D.java @@ -31,7 +31,7 @@ public class VoroniFunction3D implements Function3D { private int _seed = 0; // A cache for cube values - private final Map<Key, Vector3> _points = new HashMap<Key, Vector3>(); + private final Map<Key, Vector3> _points = new HashMap<>(); /** * Construct with default values. |