BoundingBox
without initializing it.
*/
@@ -114,7 +114,7 @@ public class BoundingBox extends BoundingVolume {
/**
* computeFromPoints
creates a new Bounding Box from a given
* set of points. It uses the containAABB
method as default.
- *
+ *
* @param points
* the points to contain.
*/
@@ -126,7 +126,7 @@ public class BoundingBox extends BoundingVolume {
/**
* computeFromTris
creates a new Bounding Box from a given
* set of triangles. It is used in OBBTree calculations.
- *
+ *
* @param tris
* @param start
* @param end
@@ -138,8 +138,10 @@ public class BoundingBox extends BoundingVolume {
TempVars vars = TempVars.get();
- Vector3f min = vars.vect1.set(new Vector3f(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY));
- Vector3f max = vars.vect2.set(new Vector3f(Float.NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY));
+ Vector3f min = vars.vect1.set(new Vector3f(Float.POSITIVE_INFINITY,
+ Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY));
+ Vector3f max = vars.vect2.set(new Vector3f(Float.NEGATIVE_INFINITY,
+ Float.NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY));
Vector3f point;
for (int i = start; i < end; i++) {
@@ -221,7 +223,7 @@ public class BoundingBox extends BoundingVolume {
* containAABB
creates a minimum-volume axis-aligned bounding
* box of the points, then selects the smallest enclosing sphere of the box
* with the sphere centered at the boxes center.
- *
+ *
* @param points
* the list of points.
*/
@@ -237,12 +239,16 @@ public class BoundingBox extends BoundingVolume {
}
TempVars vars = TempVars.get();
-
+
float[] tmpArray = vars.skinPositions;
- float minX = Float.POSITIVE_INFINITY, minY = Float.POSITIVE_INFINITY, minZ = Float.POSITIVE_INFINITY;
- float maxX = Float.NEGATIVE_INFINITY, maxY = Float.NEGATIVE_INFINITY, maxZ = Float.NEGATIVE_INFINITY;
-
+ float minX = Float.POSITIVE_INFINITY,
+ minY = Float.POSITIVE_INFINITY,
+ minZ = Float.POSITIVE_INFINITY;
+ float maxX = Float.NEGATIVE_INFINITY,
+ maxY = Float.NEGATIVE_INFINITY,
+ maxZ = Float.NEGATIVE_INFINITY;
+
int iterations = (int) FastMath.ceil(points.limit() / ((float) tmpArray.length));
for (int i = iterations - 1; i >= 0; i--) {
int bufLength = Math.min(tmpArray.length, points.remaining());
@@ -250,9 +256,9 @@ public class BoundingBox extends BoundingVolume {
for (int j = 0; j < bufLength; j += 3) {
vars.vect1.x = tmpArray[j];
- vars.vect1.y = tmpArray[j+1];
- vars.vect1.z = tmpArray[j+2];
-
+ vars.vect1.y = tmpArray[j + 1];
+ vars.vect1.z = tmpArray[j + 2];
+
if (vars.vect1.x < minX) {
minX = vars.vect1.x;
}
@@ -289,8 +295,8 @@ public class BoundingBox extends BoundingVolume {
/**
* transform
modifies the center of the box to reflect the
* change made via a rotation, translation and scale.
- *
- * @param trans
+ *
+ * @param trans
* the transform to apply
* @param store
* box to store result in
@@ -317,7 +323,9 @@ public class BoundingBox extends BoundingVolume {
transMatrix.absoluteLocal();
Vector3f scale = trans.getScale();
- vars.vect1.set(xExtent * FastMath.abs(scale.x), yExtent * FastMath.abs(scale.y), zExtent * FastMath.abs(scale.z));
+ vars.vect1.set(xExtent * FastMath.abs(scale.x),
+ yExtent * FastMath.abs(scale.y),
+ zExtent * FastMath.abs(scale.z));
transMatrix.mult(vars.vect1, vars.vect2);
// Assign the biggest rotations after scales.
box.xExtent = FastMath.abs(vars.vect2.getX());
@@ -339,7 +347,6 @@ public class BoundingBox extends BoundingVolume {
}
TempVars vars = TempVars.get();
-
float w = trans.multProj(center, box.center);
box.center.divideLocal(w);
@@ -365,7 +372,7 @@ public class BoundingBox extends BoundingVolume {
/**
* whichSide
takes a plane (typically provided by a view
* frustum) to determine which side this bound is on.
- *
+ *
* @param plane
* the plane to check against.
*/
@@ -432,15 +439,14 @@ public class BoundingBox extends BoundingVolume {
// case OBB: {
// return mergeOBB((OrientedBoundingBox) volume);
// }
-
default:
return null;
}
}
- /**
+ /*
* Merges this AABB with the given OBB.
- *
+ *
* @param volume
* the OBB to merge this AABB with.
* @return This AABB extended to fit the given OBB.
@@ -481,6 +487,7 @@ public class BoundingBox extends BoundingVolume {
// zExtent = max.z - center.z;
// return this;
// }
+
/**
* mergeLocal
combines this bounding box locally with a second
* bounding box described by its center and extents.
@@ -549,7 +556,7 @@ public class BoundingBox extends BoundingVolume {
/**
* clone
creates a new BoundingBox object containing the same
* data as this one.
- *
+ *
* @param store
* where to store the cloned information. if null or wrong class,
* a new store is created.
@@ -589,8 +596,8 @@ public class BoundingBox extends BoundingVolume {
/**
* intersects determines if this Bounding Box intersects with another given
* bounding volume. If so, true is returned, otherwise, false is returned.
- *
- * @see BoundingVolume#intersects(com.jme3.bounding.BoundingVolume)
+ *
+ * @see BoundingVolume#intersects(com.jme3.bounding.BoundingVolume)
*/
@Override
public boolean intersects(BoundingVolume bv) {
@@ -599,7 +606,7 @@ public class BoundingBox extends BoundingVolume {
/**
* determines if this bounding box intersects a given bounding sphere.
- *
+ *
* @see BoundingVolume#intersectsSphere(com.jme3.bounding.BoundingSphere)
*/
@Override
@@ -611,7 +618,7 @@ public class BoundingBox extends BoundingVolume {
* determines if this bounding box intersects a given bounding box. If the
* two boxes intersect in any way, true is returned. Otherwise, false is
* returned.
- *
+ *
* @see BoundingVolume#intersectsBoundingBox(com.jme3.bounding.BoundingBox)
*/
@Override
@@ -632,10 +639,10 @@ public class BoundingBox extends BoundingVolume {
}
}
- /**
+ /*
* determines if this bounding box intersects with a given oriented bounding
* box.
- *
+ *
* @see com.jme.bounding.BoundingVolume#intersectsOrientedBoundingBox(com.jme.bounding.OrientedBoundingBox)
*/
// public boolean intersectsOrientedBoundingBox(OrientedBoundingBox obb) {
@@ -644,8 +651,8 @@ public class BoundingBox extends BoundingVolume {
/**
* determines if this bounding box intersects with a given ray object. If an
* intersection has occurred, true is returned, otherwise false is returned.
- *
- * @see BoundingVolume#intersects(com.jme3.math.Ray)
+ *
+ * @see BoundingVolume#intersects(com.jme3.math.Ray)
*/
@Override
public boolean intersects(Ray ray) {
@@ -722,14 +729,14 @@ public class BoundingBox extends BoundingVolume {
*/
private int collideWithRay(Ray ray, CollisionResults results) {
TempVars vars = TempVars.get();
- try {
+ try {
Vector3f diff = vars.vect1.set(ray.origin).subtractLocal(center);
Vector3f direction = vars.vect2.set(ray.direction);
//float[] t = {0f, Float.POSITIVE_INFINITY};
float[] t = vars.fWdU; // use one of the tempvars arrays
t[0] = 0;
- t[1] = Float.POSITIVE_INFINITY;
+ t[1] = Float.POSITIVE_INFINITY;
float saveT0 = t[0], saveT1 = t[1];
boolean notEntirelyClipped = clip(+direction.x, -diff.x - xExtent, t)
@@ -744,14 +751,14 @@ public class BoundingBox extends BoundingVolume {
float[] distances = t;
Vector3f point0 = new Vector3f(ray.direction).multLocal(distances[0]).addLocal(ray.origin);
Vector3f point1 = new Vector3f(ray.direction).multLocal(distances[1]).addLocal(ray.origin);
-
+
CollisionResult result = new CollisionResult(point0, distances[0]);
results.addCollision(result);
result = new CollisionResult(point1, distances[1]);
results.addCollision(result);
return 2;
}
-
+
Vector3f point = new Vector3f(ray.direction).multLocal(t[0]).addLocal(ray.origin);
CollisionResult result = new CollisionResult(point, t[0]);
results.addCollision(result);
@@ -765,14 +772,14 @@ public class BoundingBox extends BoundingVolume {
private int collideWithRay(Ray ray) {
TempVars vars = TempVars.get();
- try {
+ try {
Vector3f diff = vars.vect1.set(ray.origin).subtractLocal(center);
Vector3f direction = vars.vect2.set(ray.direction);
//float[] t = {0f, Float.POSITIVE_INFINITY};
float[] t = vars.fWdU; // use one of the tempvars arrays
t[0] = 0;
- t[1] = Float.POSITIVE_INFINITY;
+ t[1] = Float.POSITIVE_INFINITY;
float saveT0 = t[0], saveT1 = t[1];
boolean notEntirelyClipped = clip(+direction.x, -diff.x - xExtent, t)
@@ -783,15 +790,18 @@ public class BoundingBox extends BoundingVolume {
&& clip(-direction.z, +diff.z - zExtent, t);
if (notEntirelyClipped && (t[0] != saveT0 || t[1] != saveT1)) {
- if (t[1] > t[0]) return 2;
- else return 1;
+ if (t[1] > t[0]) {
+ return 2;
+ } else {
+ return 1;
+ }
}
return 0;
} finally {
vars.release();
}
}
-
+
@Override
public int collideWith(Collidable other, CollisionResults results) {
if (other instanceof Ray) {
@@ -818,7 +828,7 @@ public class BoundingBox extends BoundingVolume {
throw new UnsupportedCollisionException("With: " + other.getClass().getSimpleName());
}
}
-
+
@Override
public int collideWith(Collidable other) {
if (other instanceof Ray) {
@@ -868,10 +878,10 @@ public class BoundingBox extends BoundingVolume {
@Override
public float distanceToEdge(Vector3f point) {
// compute coordinates of point in box coordinate system
- TempVars vars= TempVars.get();
+ TempVars vars = TempVars.get();
Vector3f closest = vars.vect1;
-
- point.subtract(center,closest);
+
+ point.subtract(center, closest);
// project test point onto box
float sqrDistance = 0.0f;
@@ -906,7 +916,7 @@ public class BoundingBox extends BoundingVolume {
sqrDistance += delta * delta;
closest.z = zExtent;
}
-
+
vars.release();
return FastMath.sqrt(sqrDistance);
}
@@ -914,7 +924,7 @@ public class BoundingBox extends BoundingVolume {
/**
* clip
determines if a line segment intersects the current
* test plane.
- *
+ *
* @param denom
* the denominator of the line segment.
* @param numer
@@ -936,26 +946,26 @@ public class BoundingBox extends BoundingVolume {
// work out the same but in floating point there can
// be subtle math errors. The multiply will exaggerate
// errors that may have been introduced when the value
- // was originally divided.
+ // was originally divided.
//
// This is especially true when the bounding box has zero
// extents in some plane because the error rate is critical.
// comparing a to b * c is not the same as comparing a/b to c
- // in this case. In fact, I tried converting this method to
- // double and the and the error was in the last decimal place.
+ // in this case. In fact, I tried converting this method to
+ // double and the and the error was in the last decimal place.
//
// So, instead, we now compare the divided version to the divided
// version. We lose some slight performance here as divide
// will be more expensive than the divide. Some microbenchmarks
// show divide to be 3x slower than multiple on Java 1.6.
- // BUT... we also saved a multiply in the non-clipped case because
+ // BUT... we also saved a multiply in the non-clipped case because
// we can reuse the divided version in both if checks.
// I think it's better to be right in this case.
//
// Bug that I'm fixing: rays going right through quads at certain
// angles and distances because they fail the bounding box test.
- // Many Bothans died bring you this fix.
- // -pspeed
+ // Many Bothans died bring you this fix.
+ // -pspeed
float newT = numer / denom;
if (newT > t[1]) {
return false;
@@ -972,7 +982,7 @@ public class BoundingBox extends BoundingVolume {
// When we move it over to the other side we have to flip
// the comparison. Algebra for the win.
float newT = numer / denom;
- if (newT < t[0]) {
+ if (newT < t[0]) {
return false;
}
if (newT < t[1]) {
@@ -986,7 +996,7 @@ public class BoundingBox extends BoundingVolume {
/**
* Query extent.
- *
+ *
* @param store
* where extent gets stored - null to return a new vector
* @return store / new vector
diff --git a/jme3-core/src/main/java/com/jme3/bounding/BoundingVolume.java b/jme3-core/src/main/java/com/jme3/bounding/BoundingVolume.java
index 8ee6788ee..c5dc9b75b 100644
--- a/jme3-core/src/main/java/com/jme3/bounding/BoundingVolume.java
+++ b/jme3-core/src/main/java/com/jme3/bounding/BoundingVolume.java
@@ -44,12 +44,11 @@ import java.nio.FloatBuffer;
/**
* BoundingVolume
defines an interface for dealing with
* containment of a collection of points.
- *
+ *
* @author Mark Powell
* @version $Id: BoundingVolume.java,v 1.24 2007/09/21 15:45:32 nca Exp $
*/
public abstract class BoundingVolume implements Savable, Cloneable, Collidable {
-
/**
* The type of bounding volume being used.
*/
@@ -57,13 +56,11 @@ public abstract class BoundingVolume implements Savable, Cloneable, Collidable {
/**
* {@link BoundingSphere}
*/
- Sphere,
-
+ Sphere,
/**
* {@link BoundingBox}.
*/
- AABB,
-
+ AABB,
/**
* Currently unsupported by jME3.
*/
@@ -82,7 +79,6 @@ public abstract class BoundingVolume implements Savable, Cloneable, Collidable {
/**
* Grabs the checkplane we should check first.
- *
*/
public int getCheckPlane() {
return checkPlane;
@@ -103,7 +99,6 @@ public abstract class BoundingVolume implements Savable, Cloneable, Collidable {
public abstract Type getType();
/**
- *
* transform
alters the location of the bounding volume by a
* rotation, translation and a scalar.
*
@@ -116,7 +111,6 @@ public abstract class BoundingVolume implements Savable, Cloneable, Collidable {
}
/**
- *
* transform
alters the location of the bounding volume by a
* rotation, translation and a scalar.
*
@@ -131,7 +125,6 @@ public abstract class BoundingVolume implements Savable, Cloneable, Collidable {
public abstract BoundingVolume transform(Matrix4f trans, BoundingVolume store);
/**
- *
* whichSide
returns the side on which the bounding volume
* lies on a plane. Possible values are POSITIVE_SIDE, NEGATIVE_SIDE, and
* NO_SIDE.
@@ -143,7 +136,6 @@ public abstract class BoundingVolume implements Savable, Cloneable, Collidable {
public abstract Plane.Side whichSide(Plane plane);
/**
- *
* computeFromPoints
generates a bounding volume that
* encompasses a collection of points.
*
@@ -204,7 +196,7 @@ public abstract class BoundingVolume implements Savable, Cloneable, Collidable {
/**
* Find the distance from the center of this Bounding Volume to the given
* point.
- *
+ *
* @param point
* The point to get the distance to
* @return distance
@@ -216,7 +208,7 @@ public abstract class BoundingVolume implements Savable, Cloneable, Collidable {
/**
* Find the squared distance from the center of this Bounding Volume to the
* given point.
- *
+ *
* @param point
* The point to get the distance to
* @return distance
@@ -228,7 +220,7 @@ public abstract class BoundingVolume implements Savable, Cloneable, Collidable {
/**
* Find the distance from the nearest edge of this Bounding Volume to the given
* point.
- *
+ *
* @param point
* The point to get the distance to
* @return distance
@@ -255,7 +247,6 @@ public abstract class BoundingVolume implements Savable, Cloneable, Collidable {
*/
public abstract boolean intersects(Ray ray);
-
/**
* determines if this bounding volume and a given bounding sphere are
* intersecting.
@@ -276,7 +267,7 @@ public abstract class BoundingVolume implements Savable, Cloneable, Collidable {
*/
public abstract boolean intersectsBoundingBox(BoundingBox bb);
- /**
+ /*
* determines if this bounding volume and a given bounding box are
* intersecting.
*
@@ -286,11 +277,10 @@ public abstract class BoundingVolume implements Savable, Cloneable, Collidable {
*/
// public abstract boolean intersectsOrientedBoundingBox(OrientedBoundingBox bb);
/**
- *
* determines if a given point is contained within this bounding volume.
* If the point is on the edge of the bounding volume, this method will
* return false. Use intersects(Vector3f) to check for edge intersection.
- *
+ *
* @param point
* the point to check
* @return true if the point lies within this bounding volume.
@@ -299,6 +289,7 @@ public abstract class BoundingVolume implements Savable, Cloneable, Collidable {
/**
* Determines if a given point intersects (touches or is inside) this bounding volume.
+ *
* @param point the point to check
* @return true if the point lies within this bounding volume.
*/
@@ -308,11 +299,11 @@ public abstract class BoundingVolume implements Savable, Cloneable, Collidable {
@Override
public BoundingVolume clone() {
- try{
+ try {
BoundingVolume clone = (BoundingVolume) super.clone();
clone.center = center.clone();
return clone;
- }catch (CloneNotSupportedException ex){
+ } catch (CloneNotSupportedException ex) {
throw new AssertionError();
}
}
@@ -326,7 +317,7 @@ public abstract class BoundingVolume implements Savable, Cloneable, Collidable {
public void read(JmeImporter e) throws IOException {
center = (Vector3f) e.getCapsule(this).readSavable("center", Vector3f.ZERO.clone());
}
-
+
public int collideWith(Collidable other) {
TempVars tempVars = TempVars.get();
try {
@@ -338,4 +329,3 @@ public abstract class BoundingVolume implements Savable, Cloneable, Collidable {
}
}
}
-
diff --git a/jme3-core/src/main/java/com/jme3/math/CurveAndSurfaceMath.java b/jme3-core/src/main/java/com/jme3/math/CurveAndSurfaceMath.java
index 522821e03..79374825f 100644
--- a/jme3-core/src/main/java/com/jme3/math/CurveAndSurfaceMath.java
+++ b/jme3-core/src/main/java/com/jme3/math/CurveAndSurfaceMath.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009-2012 jMonkeyEngine
+ * Copyright (c) 2009-2020 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -36,130 +36,129 @@ import java.util.List;
/**
* This class offers methods to help with curves and surfaces calculations.
+ *
* @author Marcin Roguski (Kealthas)
*/
public class CurveAndSurfaceMath {
- private static final float KNOTS_MINIMUM_DELTA = 0.0001f;
+ private static final float KNOTS_MINIMUM_DELTA = 0.0001f;
+
+ /**
+ * A private constructor is defined to avoid instantiation of this class.
+ */
+ private CurveAndSurfaceMath() {
+ }
- /**
- * A private constructor is defined to avoid instantiation of this
- * class.
- */
- private CurveAndSurfaceMath() {}
-
- /**
- * This method interpolates the data for the nurbs curve.
- * @param u
- * the u value
- * @param nurbSpline
- * the nurbs spline definition
- * @param store
- * the resulting point in 3D space
- */
- public static void interpolateNurbs(float u, Spline nurbSpline, Vector3f store) {
- if (nurbSpline.getType() != SplineType.Nurb) {
- throw new IllegalArgumentException("Given spline is not of a NURB type!");
- }
- ListMatrix3f
object. The
* initial values for the matrix is that of the identity matrix.
- *
*/
public Matrix3f() {
loadIdentity();
@@ -69,25 +68,16 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
/**
* constructs a matrix with the given values.
- *
- * @param m00
- * 0x0 in the matrix.
- * @param m01
- * 0x1 in the matrix.
- * @param m02
- * 0x2 in the matrix.
- * @param m10
- * 1x0 in the matrix.
- * @param m11
- * 1x1 in the matrix.
- * @param m12
- * 1x2 in the matrix.
- * @param m20
- * 2x0 in the matrix.
- * @param m21
- * 2x1 in the matrix.
- * @param m22
- * 2x2 in the matrix.
+ *
+ * @param m00 0x0 in the matrix.
+ * @param m01 0x1 in the matrix.
+ * @param m02 0x2 in the matrix.
+ * @param m10 1x0 in the matrix.
+ * @param m11 1x1 in the matrix.
+ * @param m12 1x2 in the matrix.
+ * @param m20 2x0 in the matrix.
+ * @param m21 2x1 in the matrix.
+ * @param m22 2x2 in the matrix.
*/
public Matrix3f(float m00, float m01, float m02, float m10, float m11,
float m12, float m20, float m21, float m22) {
@@ -106,7 +96,7 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
/**
* Copy constructor that creates a new Matrix3f
object that
* is the same as the provided matrix.
- *
+ *
* @param mat
* the matrix to copy.
*/
@@ -133,7 +123,7 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
* copy
transfers the contents of a given matrix to this
* matrix. If a null matrix is supplied, this matrix is set to the identity
* matrix.
- *
+ *
* @param matrix
* the matrix to copy.
* @return this
@@ -159,11 +149,9 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
* get
retrieves a value from the matrix at the given
* position. If the position is invalid a JmeException
is
* thrown.
- *
- * @param i
- * the row index.
- * @param j
- * the colum index.
+ *
+ * @param i the row index.
+ * @param j the colum index.
* @return the value at (i, j).
*/
@SuppressWarnings("fallthrough")
@@ -261,11 +249,11 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
throw new IndexOutOfBoundsException("Array size must be 9 or 16 in Matrix3f.get().");
}
}
-
+
/**
* Normalize this matrix and store the result in the store parameter that is
* returned.
- *
+ *
* Note that the original matrix is not altered.
*
* @param store the matrix to store the result of the normalization. If this
@@ -303,6 +291,7 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
/**
* Normalize this matrix
+ *
* @return this matrix once normalized.
*/
public Matrix3f normalizeLocal() {
@@ -312,7 +301,7 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
/**
* getColumn
returns one of three columns specified by the
* parameter. This column is returned as a Vector3f
object.
- *
+ *
* @param i
* the column to retrieve. Must be between 0 and 2.
* @return the column specified by the index.
@@ -324,7 +313,7 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
/**
* getColumn
returns one of three columns specified by the
* parameter. This column is returned as a Vector3f
object.
- *
+ *
* @param i
* the column to retrieve. Must be between 0 and 2.
* @param store
@@ -362,7 +351,7 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
/**
* getColumn
returns one of three rows as specified by the
* parameter. This row is returned as a Vector3f
object.
- *
+ *
* @param i
* the row to retrieve. Must be between 0 and 2.
* @return the row specified by the index.
@@ -374,7 +363,7 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
/**
* getRow
returns one of three rows as specified by the
* parameter. This row is returned as a Vector3f
object.
- *
+ *
* @param i
* the row to retrieve. Must be between 0 and 2.
* @param store
@@ -412,7 +401,7 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
/**
* toFloatBuffer
returns a FloatBuffer object that contains
* the matrix data.
- *
+ *
* @return matrix data as a FloatBuffer.
*/
public FloatBuffer toFloatBuffer() {
@@ -428,7 +417,7 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
/**
* fillFloatBuffer
fills a FloatBuffer object with the matrix
* data.
- *
+ *
* @param fb
* the buffer to fill, starting at current position. Must have
* room for 9 more floats.
@@ -448,7 +437,6 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
TempVars vars = TempVars.get();
-
fillFloatArray(vars.matrixWrite, columnMajor);
fb.put(vars.matrixWrite, 0, 9);
@@ -459,33 +447,32 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
public void fillFloatArray(float[] f, boolean columnMajor) {
if (columnMajor) {
- f[ 0] = m00;
- f[ 1] = m10;
- f[ 2] = m20;
- f[ 3] = m01;
- f[ 4] = m11;
- f[ 5] = m21;
- f[ 6] = m02;
- f[ 7] = m12;
- f[ 8] = m22;
+ f[0] = m00;
+ f[1] = m10;
+ f[2] = m20;
+ f[3] = m01;
+ f[4] = m11;
+ f[5] = m21;
+ f[6] = m02;
+ f[7] = m12;
+ f[8] = m22;
} else {
- f[ 0] = m00;
- f[ 1] = m01;
- f[ 2] = m02;
- f[ 3] = m10;
- f[ 4] = m11;
- f[ 5] = m12;
- f[ 6] = m20;
- f[ 7] = m21;
- f[ 8] = m22;
+ f[0] = m00;
+ f[1] = m01;
+ f[2] = m02;
+ f[3] = m10;
+ f[4] = m11;
+ f[5] = m12;
+ f[6] = m20;
+ f[7] = m21;
+ f[8] = m22;
}
}
/**
- *
* setColumn
sets a particular column of this matrix to that
* represented by the provided vector.
- *
+ *
* @param i
* the column to set.
* @param column
@@ -522,10 +509,9 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
}
/**
- *
* setRow
sets a particular row of this matrix to that
* represented by the provided vector.
- *
+ *
* @param i
* the row to set.
* @param row
@@ -565,7 +551,7 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
* set
places a given value into the matrix at the given
* position. If the position is invalid a JmeException
is
* thrown.
- *
+ *
* @param i
* the row index.
* @param j
@@ -620,10 +606,9 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
}
/**
- *
* set
sets the values of the matrix to those supplied by the
* 3x3 two dimenion array.
- *
+ *
* @param matrix
* the new values of the matrix.
* @throws JmeException
@@ -651,13 +636,10 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
/**
* Recreate Matrix using the provided axis.
- *
- * @param uAxis
- * Vector3f
- * @param vAxis
- * Vector3f
- * @param wAxis
- * Vector3f
+ *
+ * @param uAxis Vector3f
+ * @param vAxis Vector3f
+ * @param wAxis Vector3f
*/
public void fromAxes(Vector3f uAxis, Vector3f vAxis, Vector3f wAxis) {
m00 = uAxis.x;
@@ -676,7 +658,7 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
/**
* set
sets the values of this matrix from an array of
* values assuming that the data is rowMajor order;
- *
+ *
* @param matrix
* the matrix to set the value to.
* @return this
@@ -688,7 +670,7 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
/**
* set
sets the values of this matrix from an array of
* values;
- *
+ *
* @param matrix
* the matrix to set the value to.
* @param rowMajor
@@ -726,11 +708,10 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
}
/**
- *
* set
defines the values of the matrix based on a supplied
* Quaternion
. It should be noted that all previous values
* will be overridden.
- *
+ *
* @param quaternion
* the quaternion to create a rotational matrix from.
* @return this
@@ -742,7 +723,6 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
/**
* loadIdentity
sets this matrix to the identity matrix.
* Where all values are zero except those along the diagonal which are one.
- *
*/
public void loadIdentity() {
m01 = m02 = m10 = m12 = m20 = m21 = 0;
@@ -762,7 +742,7 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
* fromAngleAxis
sets this matrix4f to the values specified
* by an angle and an axis of rotation. This method creates an object, so
* use fromAngleNormalAxis if your axis is already normalized.
- *
+ *
* @param angle
* the angle to rotate (in radians).
* @param axis
@@ -776,7 +756,7 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
/**
* fromAngleNormalAxis
sets this matrix4f to the values
* specified by an angle and a normalized axis of rotation.
- *
+ *
* @param angle
* the angle to rotate (in radians).
* @param axis
@@ -811,7 +791,7 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
* mult
multiplies this matrix by a given matrix. The result
* matrix is returned as a new object. If the given matrix is null, a null
* matrix is returned.
- *
+ *
* @param mat
* the matrix to multiply this matrix by.
* @return the result matrix.
@@ -823,7 +803,7 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
/**
* mult
multiplies this matrix by a given matrix. The result
* matrix is returned as a new object.
- *
+ *
* @param mat
* the matrix to multiply this matrix by.
* @param product
@@ -867,7 +847,7 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
* mult
multiplies this matrix by a given
* Vector3f
object. The result vector is returned. If the
* given vector is null, null will be returned.
- *
+ *
* @param vec
* the vector to multiply this matrix by.
* @return the result vector.
@@ -879,7 +859,7 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
/**
* Multiplies this 3x3 matrix by the 1x3 Vector vec and stores the result in
* product.
- *
+ *
* @param vec
* The Vector3f to multiply.
* @param product
@@ -904,9 +884,9 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
}
/**
- * multLocal
multiplies this matrix internally by
+ * multLocal
multiplies this matrix internally by
* a given float scale factor.
- *
+ *
* @param scale
* the value to scale by.
* @return this Matrix3f
@@ -929,7 +909,7 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
* Vector3f
object. The result vector is stored inside the
* passed vector, then returned . If the given vector is null, null will be
* returned.
- *
+ *
* @param vec
* the vector to multiply this matrix by.
* @return The passed vector after multiplication
@@ -951,7 +931,7 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
* matrix is saved in the current matrix. If the given matrix is null,
* nothing happens. The current matrix is returned. This is equivalent to
* this*=mat
- *
+ *
* @param mat
* the matrix to multiply this matrix by.
* @return This matrix, after the multiplication
@@ -962,7 +942,7 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
/**
* Transposes this matrix in place. Returns this matrix for chaining
- *
+ *
* @return This matrix after transpose
*/
public Matrix3f transposeLocal() {
@@ -987,7 +967,7 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
/**
* Inverts this matrix as a new Matrix3f.
- *
+ *
* @return The new inverse matrix
*/
public Matrix3f invert() {
@@ -996,7 +976,7 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
/**
* Inverts this matrix and stores it in the given store.
- *
+ *
* @return The store
*/
public Matrix3f invert(Matrix3f store) {
@@ -1025,7 +1005,7 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
/**
* Inverts this matrix locally.
- *
+ *
* @return this
*/
public Matrix3f invertLocal() {
@@ -1060,7 +1040,7 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
/**
* Returns a new matrix representing the adjoint of this matrix.
- *
+ *
* @return The adjoint matrix
*/
public Matrix3f adjoint() {
@@ -1069,7 +1049,7 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
/**
* Places the adjoint of this matrix in store (creates store if null.)
- *
+ *
* @param store
* The matrix to store the result in. If null, a new matrix is created.
* @return store
@@ -1094,7 +1074,7 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
/**
* determinant
generates the determinant of this matrix.
- *
+ *
* @return the determinant
*/
public float determinant() {
@@ -1107,7 +1087,7 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
/**
* Sets all of the values in this matrix to zero.
- *
+ *
* @return this matrix
*/
public Matrix3f zero() {
@@ -1120,7 +1100,7 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
* This is inconsistent with general value vs local semantics, but is
* preserved for backwards compatibility. Use transposeNew() to transpose
* to a new object (value).
- *
+ *
* @return this object for chaining.
*/
public Matrix3f transpose() {
@@ -1144,7 +1124,7 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
* 1.0 0.0 0.0 hashCode
returns the hash code value as an integer and is
* supported for the benefit of hashing based collection classes such as
* Hashtable, HashMap, HashSet etc.
- *
+ *
* @return the hashcode for this instance of Matrix4f.
* @see java.lang.Object#hashCode()
*/
@@ -1283,7 +1262,7 @@ public final class Matrix3f implements Savable, Cloneable, java.io.Serializable
/**
* 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
diff --git a/jme3-core/src/main/java/com/jme3/math/Matrix4f.java b/jme3-core/src/main/java/com/jme3/math/Matrix4f.java
index 6e7064f26..bc8318688 100644
--- a/jme3-core/src/main/java/com/jme3/math/Matrix4f.java
+++ b/jme3-core/src/main/java/com/jme3/math/Matrix4f.java
@@ -41,10 +41,10 @@ import java.util.logging.Logger;
/**
* Matrix4f
defines and maintains a 4x4 matrix in row major order.
- * This matrix is intended for use in a translation and rotational capacity.
- * It provides convenience methods for creating the matrix from a multitude
+ * This matrix is intended for use in a translation and rotational capacity.
+ * It provides convenience methods for creating the matrix from a multitude
* of sources.
- *
+ *
* Matrices are stored assuming column vectors on the right, with the translation
* in the rightmost column. Element numbering is row,column, so m03 is the zeroth
* row, third column, which is the "x" translation part. This means that the implicit
@@ -69,7 +69,6 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
/**
* Constructor instantiates a new Matrix
that is set to the
* identity matrix.
- *
*/
public Matrix4f() {
loadIdentity();
@@ -105,7 +104,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
* Create a new Matrix4f, given data in column-major format.
*
* @param array
- * An array of 16 floats in column-major format (translation in elements 12, 13 and 14).
+ * An array of 16 floats in column-major format (translation in elements 12, 13 and 14).
*/
public Matrix4f(float[] array) {
set(array, false);
@@ -115,7 +114,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
* Constructor instantiates a new Matrix
that is set to the
* provided matrix. This constructor copies a given Matrix. If the provided
* matrix is null, the constructor sets the matrix to the identity.
- *
+ *
* @param mat
* the matrix to copy.
*/
@@ -127,7 +126,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
* copy
transfers the contents of a given matrix to this
* matrix. If a null matrix is supplied, this matrix is set to the identity
* matrix.
- *
+ *
* @param matrix
* the matrix to copy.
*/
@@ -188,7 +187,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
/**
* get
retrieves the values of this object into
* a float array in row-major order.
- *
+ *
* @param matrix
* the matrix to set the values into.
*/
@@ -199,7 +198,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
/**
* set
retrieves the values of this object into
* a float array.
- *
+ *
* @param matrix
* the matrix to set the values into.
* @param rowMajor
@@ -252,11 +251,9 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
* get
retrieves a value from the matrix at the given
* position. If the position is invalid a JmeException
is
* thrown.
- *
- * @param i
- * the row index.
- * @param j
- * the colum index.
+ *
+ * @param i the row index.
+ * @param j the colum index.
* @return the value at (i, j).
*/
@SuppressWarnings("fallthrough")
@@ -315,9 +312,8 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
/**
* getColumn
returns one of three columns specified by the
* parameter. This column is returned as a float array of length 4.
- *
- * @param i
- * the column to retrieve. Must be between 0 and 3.
+ *
+ * @param i the column to retrieve. Must be between 0 and 3.
* @return the column specified by the index.
*/
public float[] getColumn(int i) {
@@ -327,9 +323,8 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
/**
* getColumn
returns one of three columns specified by the
* parameter. This column is returned as a float[4].
- *
- * @param i
- * the column to retrieve. Must be between 0 and 3.
+ *
+ * @param i the column to retrieve. Must be between 0 and 3.
* @param store
* the float array to store the result in. if null, a new one
* is created.
@@ -372,12 +367,10 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
}
/**
- *
* setColumn
sets a particular column of this matrix to that
* represented by the provided vector.
- *
- * @param i
- * the column to set.
+ *
+ * @param i the column to set.
* @param column
* the data to set.
*/
@@ -422,11 +415,9 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
* set
places a given value into the matrix at the given
* position. If the position is invalid a JmeException
is
* thrown.
- *
- * @param i
- * the row index.
- * @param j
- * the colum index.
+ *
+ * @param i the row index.
+ * @param j the colum index.
* @param value
* the value for (i, j).
*/
@@ -502,7 +493,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
/**
* set
sets the values of this matrix from an array of
* values.
- *
+ *
* @param matrix
* the matrix to set the value to.
* @throws JmeException
@@ -531,8 +522,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
m32 = matrix[3][2];
m33 = matrix[3][3];
}
-
-
+
/**
* Sets the values of this matrix
*/
@@ -588,7 +578,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
/**
* set
sets the values of this matrix from an array of
* values assuming that the data is rowMajor order;
- *
+ *
* @param matrix
* the matrix to set the value to.
*/
@@ -599,7 +589,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
/**
* set
sets the values of this matrix from an array of
* values;
- *
+ *
* @param matrix
* the matrix to set the value to.
* @param rowMajor
@@ -657,7 +647,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
/**
* transpose
locally transposes this Matrix.
- *
+ *
* @return this object for chaining.
*/
public Matrix4f transposeLocal() {
@@ -691,7 +681,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
/**
* toFloatBuffer
returns a FloatBuffer object that contains
* the matrix data.
- *
+ *
* @return matrix data as a FloatBuffer.
*/
public FloatBuffer toFloatBuffer() {
@@ -701,7 +691,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
/**
* toFloatBuffer
returns a FloatBuffer object that contains the
* matrix data.
- *
+ *
* @param columnMajor
* if true, this buffer should be filled with column major data,
* otherwise it will be filled row major.
@@ -718,6 +708,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
/**
* fillFloatBuffer
fills a FloatBuffer object with
* the matrix data.
+ *
* @param fb the buffer to fill, must be correct size
* @return matrix data as a FloatBuffer.
*/
@@ -728,7 +719,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
/**
* fillFloatBuffer
fills a FloatBuffer object with the matrix
* data.
- *
+ *
* @param fb
* the buffer to fill, starting at current position. Must have
* room for 16 more floats.
@@ -753,7 +744,6 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
TempVars vars = TempVars.get();
-
fillFloatArray(vars.matrixWrite, columnMajor);
fb.put(vars.matrixWrite, 0, 16);
@@ -764,16 +754,16 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
public void fillFloatArray(float[] f, boolean columnMajor) {
if (columnMajor) {
- f[ 0] = m00;
- f[ 1] = m10;
- f[ 2] = m20;
- f[ 3] = m30;
- f[ 4] = m01;
- f[ 5] = m11;
- f[ 6] = m21;
- f[ 7] = m31;
- f[ 8] = m02;
- f[ 9] = m12;
+ f[0] = m00;
+ f[1] = m10;
+ f[2] = m20;
+ f[3] = m30;
+ f[4] = m01;
+ f[5] = m11;
+ f[6] = m21;
+ f[7] = m31;
+ f[8] = m02;
+ f[9] = m12;
f[10] = m22;
f[11] = m32;
f[12] = m03;
@@ -781,16 +771,16 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
f[14] = m23;
f[15] = m33;
} else {
- f[ 0] = m00;
- f[ 1] = m01;
- f[ 2] = m02;
- f[ 3] = m03;
- f[ 4] = m10;
- f[ 5] = m11;
- f[ 6] = m12;
- f[ 7] = m13;
- f[ 8] = m20;
- f[ 9] = m21;
+ f[0] = m00;
+ f[1] = m01;
+ f[2] = m02;
+ f[3] = m03;
+ f[4] = m10;
+ f[5] = m11;
+ f[6] = m12;
+ f[7] = m13;
+ f[8] = m20;
+ f[9] = m21;
f[10] = m22;
f[11] = m23;
f[12] = m30;
@@ -802,6 +792,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
/**
* readFloatBuffer
reads value for this matrix from a FloatBuffer.
+ *
* @param fb the buffer to read from, must be correct size
* @return this data as a FloatBuffer.
*/
@@ -811,9 +802,10 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
/**
* readFloatBuffer
reads value for this matrix from a FloatBuffer.
+ *
* @param fb the buffer to read from, must be correct size
* @param columnMajor if true, this buffer should be filled with column
- * major data, otherwise it will be filled row major.
+ * major data, otherwise it will be filled row major.
* @return this data as a FloatBuffer.
*/
public Matrix4f readFloatBuffer(FloatBuffer fb, boolean columnMajor) {
@@ -859,7 +851,6 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
/**
* loadIdentity
sets this matrix to the identity matrix,
* namely all zeros with ones along the diagonal.
- *
*/
public void loadIdentity() {
m01 = m02 = m03 = 0.0f;
@@ -869,7 +860,8 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
m00 = m11 = m22 = m33 = 1.0f;
}
- public void fromFrustum(float near, float far, float left, float right, float top, float bottom, boolean parallel) {
+ public void fromFrustum(float near, float far, float left, float right,
+ float top, float bottom, boolean parallel) {
loadIdentity();
if (parallel) {
// scale
@@ -893,7 +885,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
// A
m02 = (right + left) / (right - left);
- // B
+ // B
m12 = (top + bottom) / (top - bottom);
// C
@@ -908,7 +900,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
* fromAngleAxis
sets this matrix4f to the values specified
* by an angle and an axis of rotation. This method creates an object, so
* use fromAngleNormalAxis if your axis is already normalized.
- *
+ *
* @param angle
* the angle to rotate (in radians).
* @param axis
@@ -922,7 +914,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
/**
* fromAngleNormalAxis
sets this matrix4f to the values
* specified by an angle and a normalized axis of rotation.
- *
+ *
* @param angle
* the angle to rotate (in radians).
* @param axis
@@ -958,7 +950,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
/**
* mult
multiplies this matrix by a scalar.
- *
+ *
* @param scalar
* the scalar to multiply this matrix by.
*/
@@ -998,7 +990,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
* mult
multiplies this matrix with another matrix. The
* result matrix will then be returned. This matrix will be on the left hand
* side, while the parameter matrix will be on the right.
- *
+ *
* @param in2
* the matrix to multiply this matrix by.
* @return the resultant matrix
@@ -1011,7 +1003,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
* mult
multiplies this matrix with another matrix. The
* result matrix will then be returned. This matrix will be on the left hand
* side, while the parameter matrix will be on the right.
- *
+ *
* @param in2
* the matrix to multiply this matrix by.
* @param store
@@ -1095,7 +1087,6 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
+ m32 * in2.m23
+ m33 * in2.m33;
-
store.m00 = m[0];
store.m01 = m[1];
store.m02 = m[2];
@@ -1118,10 +1109,10 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
/**
* mult
multiplies this matrix with another matrix. The
- * results are stored internally and a handle to this matrix will
+ * results are stored internally and a handle to this matrix will
* then be returned. This matrix will be on the left hand
* side, while the parameter matrix will be on the right.
- *
+ *
* @param in2
* the matrix to multiply this matrix by.
* @return the resultant matrix
@@ -1133,7 +1124,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
/**
* mult
multiplies a vector about a rotation matrix. The
* resulting vector is returned as a new Vector3f.
- *
+ *
* @param vec
* vec to multiply against.
* @return the rotated vector.
@@ -1145,7 +1136,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
/**
* mult
multiplies a vector about a rotation matrix and adds
* translation. The resulting vector is returned.
- *
+ *
* @param vec
* vec to multiply against.
* @param store
@@ -1211,7 +1202,6 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
*
* @param vec
* vec to multiply against.
- *
* @return the rotated vector.
*/
public Vector4f multAcross(Vector4f vec) {
@@ -1296,11 +1286,11 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
* mult
multiplies a vector about a rotation matrix and adds
* translation. The w value is returned as a result of
* multiplying the last column of the matrix by 1.0
- *
+ *
* @param vec
* vec to multiply against.
* @param store
- * a vector to store the result in.
+ * a vector to store the result in.
* @return the W value
*/
public float multProj(Vector3f vec, Vector3f store) {
@@ -1314,7 +1304,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
/**
* mult
multiplies a vector about a rotation matrix. The
* resulting vector is returned.
- *
+ *
* @param vec
* vec to multiply against.
* @param store
@@ -1371,9 +1361,9 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
}
/**
- * mult
multiplies an array of 4 floats against this rotation
+ * mult
multiplies an array of 4 floats against this rotation
* matrix. The results are stored directly in the array. (vec4f x mat4f)
- *
+ *
* @param vec4f
* float array (size 4) to multiply against the matrix.
* @return the vec4f for chaining.
@@ -1395,9 +1385,9 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
}
/**
- * mult
multiplies an array of 4 floats against this rotation
+ * mult
multiplies an array of 4 floats against this rotation
* matrix. The results are stored directly in the array. (vec4f x mat4f)
- *
+ *
* @param vec4f
* float array (size 4) to multiply against the matrix.
* @return the vec4f for chaining.
@@ -1420,7 +1410,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
/**
* Inverts this matrix as a new Matrix4f.
- *
+ *
* @return The new inverse matrix
*/
public Matrix4f invert() {
@@ -1429,7 +1419,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
/**
* Inverts this matrix and stores it in the given store.
- *
+ *
* @return The store
*/
public Matrix4f invert(Matrix4f store) {
@@ -1480,7 +1470,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
/**
* Inverts this matrix locally.
- *
+ *
* @return this
*/
public Matrix4f invertLocal() {
@@ -1545,7 +1535,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
/**
* Returns a new matrix representing the adjoint of this matrix.
- *
+ *
* @return The adjoint matrix
*/
public Matrix4f adjoint() {
@@ -1581,7 +1571,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
/**
* Places the adjoint of this matrix in store (creates store if null.)
- *
+ *
* @param store
* The matrix to store the result in. If null, a new matrix is created.
* @return store
@@ -1626,7 +1616,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
/**
* determinant
generates the determinate of this matrix.
- *
+ *
* @return the determinate
*/
public float determinant() {
@@ -1648,7 +1638,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
/**
* Sets all of the values in this matrix to zero.
- *
+ *
* @return this matrix
*/
public Matrix4f zero() {
@@ -1682,7 +1672,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
/**
* add
adds the values of a parameter matrix to this matrix.
- *
+ *
* @param mat
* the matrix to add to this.
*/
@@ -1738,18 +1728,18 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
mat.m20 = m20;
mat.m21 = m21;
mat.m22 = m22;
- }
+ }
- /**
- * Retrieves the scale vector from the matrix.
- *
- * @return the scale vector
- */
- public Vector3f toScaleVector() {
- Vector3f result = new Vector3f();
- this.toScaleVector(result);
- return result;
- }
+ /**
+ * Retrieves the scale vector from the matrix.
+ *
+ * @return the scale vector
+ */
+ public Vector3f toScaleVector() {
+ Vector3f result = new Vector3f();
+ this.toScaleVector(result);
+ return result;
+ }
/**
* Retrieves the scale vector from the matrix and stores it into a given
@@ -1759,16 +1749,16 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
* @return the store vector
*/
public Vector3f toScaleVector(Vector3f store) {
- float scaleX = (float) Math.sqrt(m00 * m00 + m10 * m10 + m20 * m20);
- float scaleY = (float) Math.sqrt(m01 * m01 + m11 * m11 + m21 * m21);
- float scaleZ = (float) Math.sqrt(m02 * m02 + m12 * m12 + m22 * m22);
+ float scaleX = (float) Math.sqrt(m00 * m00 + m10 * m10 + m20 * m20);
+ float scaleY = (float) Math.sqrt(m01 * m01 + m11 * m11 + m21 * m21);
+ float scaleZ = (float) Math.sqrt(m02 * m02 + m12 * m12 + m22 * m22);
store.set(scaleX, scaleY, scaleZ);
return store;
}
/**
* Sets the scale.
- *
+ *
* @param x
* the X scale
* @param y
@@ -1805,7 +1795,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
/**
* Sets the scale.
- *
+ *
* @param scale
* the scale vector to set
*/
@@ -1815,7 +1805,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
/**
* setTranslation
will set the matrix's translation values.
- *
+ *
* @param translation
* the new values for the translation.
* @throws JmeException
@@ -1833,13 +1823,10 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
/**
* setTranslation
will set the matrix's translation values.
- *
- * @param x
- * value of the translation on the x axis
- * @param y
- * value of the translation on the y axis
- * @param z
- * value of the translation on the z axis
+ *
+ * @param x value of the translation on the x axis
+ * @param y value of the translation on the y axis
+ * @param z value of the translation on the z axis
*/
public void setTranslation(float x, float y, float z) {
m03 = x;
@@ -1862,7 +1849,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
/**
* setInverseTranslation
will set the matrix's inverse
* translation values.
- *
+ *
* @param translation
* the new values for the inverse translation.
* @throws JmeException
@@ -1883,7 +1870,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
* three axes (x, y, z). Where each axis has a specified rotation in
* degrees. These rotations are expressed in a single Vector3f
* object.
- *
+ *
* @param angles
* the angles to rotate.
*/
@@ -1919,7 +1906,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
/**
* setRotationQuaternion
builds a rotation from a
* Quaternion
.
- *
+ *
* @param quat
* the quaternion to build the rotation from.
* @throws NullPointerException
@@ -1932,7 +1919,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
/**
* setInverseRotationRadians
builds an inverted rotation from
* Euler angles that are in radians.
- *
+ *
* @param angles
* the Euler angles in radians.
* @throws JmeException
@@ -1969,7 +1956,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
/**
* setInverseRotationDegrees
builds an inverted rotation from
* Euler angles that are in degrees.
- *
+ *
* @param angles
* the Euler angles in degrees.
* @throws JmeException
@@ -1988,10 +1975,9 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
}
/**
- *
* inverseTranslateVect
translates a given Vector3f by the
* translation part of this matrix.
- *
+ *
* @param vec
* the Vector3f data to be translated.
* @throws JmeException
@@ -2009,10 +1995,9 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
}
/**
- *
* inverseTranslateVect
translates a given Vector3f by the
* translation part of this matrix.
- *
+ *
* @param data
* the Vector3f to be translated.
* @throws JmeException
@@ -2025,10 +2010,9 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
}
/**
- *
* inverseTranslateVect
translates a given Vector3f by the
* translation part of this matrix.
- *
+ *
* @param data
* the Vector3f to be translated.
* @throws JmeException
@@ -2041,10 +2025,9 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
}
/**
- *
* inverseRotateVect
rotates a given Vector3f by the rotation
* part of this matrix.
- *
+ *
* @param vec
* the Vector3f to be rotated.
*/
@@ -2072,7 +2055,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
* 0.0 1.0 0.0 0.0 hashCode
returns the hash code value as an integer and is
* supported for the benefit of hashing based collection classes such as
* Hashtable, HashMap, HashSet etc.
- *
+ *
* @return the hashcode for this instance of Matrix4f.
* @see java.lang.Object#hashCode()
*/
@@ -2279,7 +2261,7 @@ public final class Matrix4f implements Savable, Cloneable, java.io.Serializable
/**
* Apply a scale to this matrix.
- *
+ *
* @param scale
* the scale to apply
*/
diff --git a/jme3-core/src/main/java/com/jme3/math/Plane.java b/jme3-core/src/main/java/com/jme3/math/Plane.java
index 078f8a335..0b6e562a1 100644
--- a/jme3-core/src/main/java/com/jme3/math/Plane.java
+++ b/jme3-core/src/main/java/com/jme3/math/Plane.java
@@ -40,7 +40,7 @@ import java.util.logging.Logger;
* This provides methods for calculating a "distance" of a point from this
* plane. The distance is pseudo due to the fact that it can be negative if the
* point is on the non-normal side of the plane.
- *
+ *
* @author Mark Powell
* @author Joshua Slack
* @author Ian McClean
@@ -58,12 +58,12 @@ public class Plane implements Savable, Cloneable, java.io.Serializable {
Negative
}
- /**
+ /**
* Vector normal to the plane.
*/
protected Vector3f normal = new Vector3f();
- /**
+ /**
* Constant of the plane. See formula in class definition.
*/
protected float constant;
@@ -78,7 +78,7 @@ public class Plane implements Savable, Cloneable, java.io.Serializable {
/**
* Constructor instantiates a new Plane
object. The normal
* and constant values are set at creation.
- *
+ *
* @param normal
* the normal of the plane.
* @param constant
@@ -105,7 +105,7 @@ public class Plane implements Savable, Cloneable, java.io.Serializable {
/**
* setNormal
sets the normal of the plane.
- *
+ *
* @param normal
* the new normal of the plane.
*/
@@ -121,12 +121,12 @@ public class Plane implements Savable, Cloneable, java.io.Serializable {
*
*/
public void setNormal(float x, float y, float z) {
- this.normal.set(x,y,z);
+ this.normal.set(x, y, z);
}
/**
* getNormal
retrieves the normal of the plane.
- *
+ *
* @return the normal of the plane.
*/
public Vector3f getNormal() {
@@ -136,7 +136,7 @@ public class Plane implements Savable, Cloneable, java.io.Serializable {
/**
* setConstant
sets the constant value that helps define the
* plane.
- *
+ *
* @param constant
* the new constant value.
*/
@@ -146,27 +146,28 @@ public class Plane implements Savable, Cloneable, java.io.Serializable {
/**
* getConstant
returns the constant of the plane.
- *
+ *
* @return the constant of the plane.
*/
public float getConstant() {
return constant;
}
- public Vector3f getClosestPoint(Vector3f point, Vector3f store){
+ public Vector3f getClosestPoint(Vector3f point, Vector3f store) {
// float t = constant - normal.dot(point);
// return store.set(normal).multLocal(t).addLocal(point);
float t = (constant - normal.dot(point)) / normal.dot(normal);
return store.set(normal).multLocal(t).addLocal(point);
}
- public Vector3f getClosestPoint(Vector3f point){
+ public Vector3f getClosestPoint(Vector3f point) {
return getClosestPoint(point, new Vector3f());
}
- public Vector3f reflect(Vector3f point, Vector3f store){
- if (store == null)
+ public Vector3f reflect(Vector3f point, Vector3f store) {
+ if (store == null) {
store = new Vector3f();
+ }
float d = pseudoDistance(point);
store.set(normal).negateLocal().multLocal(d * 2f);
@@ -179,7 +180,7 @@ public class Plane implements Savable, Cloneable, java.io.Serializable {
* a provided point. If the point is on the negative side of the plane the
* distance returned is negative, otherwise it is positive. If the point is
* on the plane, it is zero.
- *
+ *
* @param point
* the point to check.
* @return the signed distance from the plane to a point.
@@ -192,7 +193,7 @@ public class Plane implements Savable, Cloneable, java.io.Serializable {
* whichSide
returns the side at which a point lies on the
* plane. The positive values returned are: NEGATIVE_SIDE, POSITIVE_SIDE and
* NO_SIDE.
- *
+ *
* @param point
* the point to check.
* @return the side at which the point lies.
@@ -208,19 +209,19 @@ public class Plane implements Savable, Cloneable, java.io.Serializable {
}
}
- public boolean isOnPlane(Vector3f point){
+ public boolean isOnPlane(Vector3f point) {
float dist = pseudoDistance(point);
- if (dist < FastMath.FLT_EPSILON && dist > -FastMath.FLT_EPSILON)
+ if (dist < FastMath.FLT_EPSILON && dist > -FastMath.FLT_EPSILON) {
return true;
- else
+ } else {
return false;
+ }
}
/**
* Initialize this plane using the three points of the given triangle.
- *
- * @param t
- * the triangle
+ *
+ * @param t the triangle
*/
public void setPlanePoints(AbstractTriangle t) {
setPlanePoints(t.get1(), t.get2(), t.get3());
@@ -232,14 +233,14 @@ public class Plane implements Savable, Cloneable, java.io.Serializable {
* @param origin
* @param normal
*/
- public void setOriginNormal(Vector3f origin, Vector3f normal){
+ public void setOriginNormal(Vector3f origin, Vector3f normal) {
this.normal.set(normal);
this.constant = normal.x * origin.x + normal.y * origin.y + normal.z * origin.z;
}
/**
* Initialize the Plane using the given 3 points as coplanar.
- *
+ *
* @param v1
* the first point
* @param v2
@@ -260,7 +261,7 @@ public class Plane implements Savable, Cloneable, java.io.Serializable {
* Vector3f
object, so the format is the following:
* com.jme.math.Plane [Normal: org.jme.math.Vector3f [X=XX.XXXX, Y=YY.YYYY,
* Z=ZZ.ZZZZ] - Constant: CC.CCCCC]
- *
+ *
* @return the string representation of this plane.
*/
@Override
diff --git a/jme3-core/src/main/java/com/jme3/math/Quaternion.java b/jme3-core/src/main/java/com/jme3/math/Quaternion.java
index 84671660d..8093f20d0 100644
--- a/jme3-core/src/main/java/com/jme3/math/Quaternion.java
+++ b/jme3-core/src/main/java/com/jme3/math/Quaternion.java
@@ -42,10 +42,9 @@ import java.util.logging.Logger;
* hypercomplex numbers. Quaternions extends a rotation in three dimensions to a
* rotation in four dimensions. This avoids "gimbal lock" and allows for smooth
* continuous rotation.
- *
- * Quaternion
is defined by four floating point numbers: {x y z
- * w}.
- *
+ *
+ * Quaternion
is defined by four floating point numbers: {x y z w}.
+ *
* @author Mark Powell
* @author Joshua Slack
*/
@@ -60,7 +59,7 @@ public final class Quaternion implements Savable, Cloneable, java.io.Serializabl
public static final Quaternion IDENTITY = new Quaternion();
public static final Quaternion DIRECTION_Z = new Quaternion();
public static final Quaternion ZERO = new Quaternion(0, 0, 0, 0);
-
+
static {
DIRECTION_Z.fromAxes(Vector3f.UNIT_X, Vector3f.UNIT_Y, Vector3f.UNIT_Z);
}
@@ -82,14 +81,10 @@ public final class Quaternion implements Savable, Cloneable, java.io.Serializabl
* Constructor instantiates a new Quaternion
object from the
* given list of parameters.
*
- * @param x
- * the x value of the quaternion.
- * @param y
- * the y value of the quaternion.
- * @param z
- * the z value of the quaternion.
- * @param w
- * the w value of the quaternion.
+ * @param x the x value of the quaternion.
+ * @param y the y value of the quaternion.
+ * @param z the z value of the quaternion.
+ * @param w the w value of the quaternion.
*/
public Quaternion(float x, float y, float z, float w) {
this.x = x;
@@ -115,17 +110,13 @@ public final class Quaternion implements Savable, Cloneable, java.io.Serializabl
}
/**
- * sets the data in a Quaternion
object from the given list
- * of parameters.
+ * sets the data in a Quaternion
object from the given list of
+ * parameters.
*
- * @param x
- * the x value of the quaternion.
- * @param y
- * the y value of the quaternion.
- * @param z
- * the z value of the quaternion.
- * @param w
- * the w value of the quaternion.
+ * @param x the x value of the quaternion.
+ * @param y the y value of the quaternion.
+ * @param z the z value of the quaternion.
+ * @param w the w value of the quaternion.
* @return this
*/
public Quaternion set(float x, float y, float z, float w) {
@@ -141,8 +132,7 @@ public final class Quaternion implements Savable, Cloneable, java.io.Serializabl
* passed Quaternion
object. The values are copied producing
* a new object.
*
- * @param q
- * The Quaternion to copy values from.
+ * @param q The Quaternion to copy values from.
* @return this
*/
public Quaternion set(Quaternion q) {
@@ -184,8 +174,7 @@ public final class Quaternion implements Savable, Cloneable, java.io.Serializabl
* Constructor instantiates a new Quaternion
object from an
* existing quaternion, creating a copy.
*
- * @param q
- * the quaternion to copy.
+ * @param q the quaternion to copy.
*/
public Quaternion(Quaternion q) {
this.x = q.x;
@@ -195,7 +184,7 @@ public final class Quaternion implements Savable, Cloneable, java.io.Serializabl
}
/**
- * Sets this Quaternion to {0, 0, 0, 1}. Same as calling set(0,0,0,1).
+ * Sets this Quaternion to {0, 0, 0, 1}. Same as calling set(0,0,0,1).
*/
public void loadIdentity() {
x = y = z = 0;
@@ -231,10 +220,12 @@ public final class Quaternion implements Savable, Cloneable, java.io.Serializabl
/**
* fromAngles
builds a Quaternion from the Euler rotation
- * angles (x,y,z) aka (pitch, yaw, roll)). Note that we are applying in order: (y, z, x) aka (yaw, roll, pitch) but
- * we've ordered them in x, y, and z for convenience.
+ * angles (x,y,z) aka (pitch, yaw, roll)).
+ * Note that we are applying in order: (y, z, x) aka (yaw, roll, pitch)
+ * but we've ordered them in x, y, and z for convenience.
+ *
* @see http://www.euclideanspace.com/maths/geometry/rotations/conversions/eulerToQuaternion/index.htm
- *
+ *
* @param xAngle
* the Euler pitch of rotation (in radians). (aka Attitude, often rot
* around x)
@@ -275,10 +266,10 @@ public final class Quaternion implements Savable, Cloneable, java.io.Serializabl
/**
* toAngles
returns this quaternion converted to Euler rotation
- * angles (x,y,z) aka (pitch, yaw, roll).fromRotationMatrix
generates a quaternion from a supplied
* matrix. This matrix is assumed to be a rotational matrix.
- *
+ *
* @param matrix
* the matrix that defines the rotation.
*/
@@ -353,7 +343,7 @@ public final class Quaternion implements Savable, Cloneable, java.io.Serializabl
m22 *= lengthSquared;
}
- // Use the Graphics Gems code, from
+ // Use the Graphics Gems code, from
// ftp://ftp.cis.upenn.edu/pub/graphics/shoemake/quatut.ps.Z
// *NOT* the "Matrix and Quaternions FAQ", which has errors!
@@ -398,7 +388,7 @@ public final class Quaternion implements Savable, Cloneable, java.io.Serializabl
/**
* toRotationMatrix
converts this quaternion to a rotational
* matrix. Note: the result is created from a normalized version of this quat.
- *
+ *
* @return the rotation matrix representation of this quaternion.
*/
public Matrix3f toRotationMatrix() {
@@ -409,7 +399,7 @@ public final class Quaternion implements Savable, Cloneable, java.io.Serializabl
/**
* toRotationMatrix
converts this quaternion to a rotational
* matrix. The result is stored in result.
- *
+ *
* @param result
* The Matrix3f to store the result in.
* @return the rotation matrix representation of this quaternion.
@@ -805,6 +795,7 @@ public final class Quaternion implements Savable, Cloneable, java.io.Serializabl
/**
* Sets the values of this quaternion to the nlerp from itself to q2 by blend.
+ *
* @param q2
* @param blend
*/
@@ -829,8 +820,7 @@ public final class Quaternion implements Savable, Cloneable, java.io.Serializabl
* add
adds the values of this quaternion to those of the
* parameter quaternion. The result is returned as a new quaternion.
*
- * @param q
- * the quaternion to add to this.
+ * @param q the quaternion to add to this.
* @return the new quaternion.
*/
public Quaternion add(Quaternion q) {
@@ -841,8 +831,7 @@ public final class Quaternion implements Savable, Cloneable, java.io.Serializabl
* add
adds the values of this quaternion to those of the
* parameter quaternion. The result is stored in this Quaternion.
*
- * @param q
- * the quaternion to add to this.
+ * @param q the quaternion to add to this.
* @return This Quaternion after addition.
*/
public Quaternion addLocal(Quaternion q) {
@@ -858,8 +847,7 @@ public final class Quaternion implements Savable, Cloneable, java.io.Serializabl
* from those of this quaternion. The result is returned as a new
* quaternion.
*
- * @param q
- * the quaternion to subtract from this.
+ * @param q the quaternion to subtract from this.
* @return the new quaternion.
*/
public Quaternion subtract(Quaternion q) {
@@ -870,8 +858,7 @@ public final class Quaternion implements Savable, Cloneable, java.io.Serializabl
* subtract
subtracts the values of the parameter quaternion
* from those of this quaternion. The result is stored in this Quaternion.
*
- * @param q
- * the quaternion to subtract from this.
+ * @param q the quaternion to subtract from this.
* @return This Quaternion after subtraction.
*/
public Quaternion subtractLocal(Quaternion q) {
@@ -903,8 +890,7 @@ public final class Quaternion implements Savable, Cloneable, java.io.Serializabl
* It IS safe for q and res to be the same object.
* It IS NOT safe for this and res to be the same object.
*
- * @param q
- * the quaternion to multiply this quaternion by.
+ * @param q the quaternion to multiply this quaternion by.
* @param res
* the quaternion to store the result in.
* @return the new quaternion.
@@ -982,8 +968,7 @@ public final class Quaternion implements Savable, Cloneable, java.io.Serializabl
* corresponds to an axis of the coordinate system defined by the quaternion
* rotation.
*
- * @param axis
- * the array of vectors to be filled.
+ * @param axis the array of vectors to be filled.
*/
public void toAxes(Vector3f axis[]) {
Matrix3f tempMat = toRotationMatrix();
@@ -996,8 +981,7 @@ public final class Quaternion implements Savable, Cloneable, java.io.Serializabl
* mult
multiplies this quaternion by a parameter vector. The
* result is returned as a new vector.
*
- * @param v
- * the vector to multiply this quaternion by.
+ * @param v the vector to multiply this quaternion by.
* @return the new vector.
*/
public Vector3f mult(Vector3f v) {
@@ -1008,8 +992,7 @@ public final class Quaternion implements Savable, Cloneable, java.io.Serializabl
* mult
multiplies this quaternion by a parameter vector. The
* result is stored in the supplied vector
*
- * @param v
- * the vector to multiply this quaternion by.
+ * @param v the vector to multiply this quaternion by.
* @return v
*/
public Vector3f multLocal(Vector3f v) {
@@ -1031,8 +1014,7 @@ public final class Quaternion implements Savable, Cloneable, java.io.Serializabl
* stored in this Quaternion, which is also returned for chaining. Similar
* to this *= q.
*
- * @param q
- * The Quaternion to multiply this one by.
+ * @param q The Quaternion to multiply this one by.
* @return This Quaternion, after multiplication.
*/
public Quaternion multLocal(Quaternion q) {
@@ -1051,14 +1033,10 @@ public final class Quaternion implements Savable, Cloneable, java.io.Serializabl
* stored in this Quaternion, which is also returned for chaining. Similar
* to this *= q.
*
- * @param qx -
- * quat x value
- * @param qy -
- * quat y value
- * @param qz -
- * quat z value
- * @param qw -
- * quat w value
+ * @param qx quat x value
+ * @param qy quat y value
+ * @param qz quat z value
+ * @param qw quat w value
*
* @return This Quaternion, after multiplication.
*/
@@ -1076,7 +1054,7 @@ public final class Quaternion implements Savable, Cloneable, java.io.Serializabl
/**
* mult
multiplies this quaternion by a parameter vector. The
* result is returned as a new vector.
- *
+ *
* @param v
* the vector to multiply this quaternion by.
* @param store
@@ -1279,7 +1257,7 @@ public final class Quaternion implements Savable, Cloneable, java.io.Serializabl
}
return true;
}
-
+
/**
* Returns true if this quaternion is similar to the specified quaternion
* within some value of epsilon.
@@ -1304,11 +1282,10 @@ public final class Quaternion implements Savable, Cloneable, java.io.Serializabl
}
/**
- *
* hashCode
returns the hash code value as an integer and is
* supported for the benefit of hashing based collection classes such as
* Hashtable, HashMap, HashSet etc.
- *
+ *
* @return the hashcode for this instance of Quaternion.
* @see java.lang.Object#hashCode()
*/
@@ -1327,7 +1304,7 @@ public final class Quaternion implements Savable, Cloneable, java.io.Serializabl
* readExternal
builds a quaternion from an
* ObjectInput
object. writeExternal
writes this quaternion out to a
* ObjectOutput
object. NOTE: Used with serialization. Not to
* be called manually.
- *
+ *
* @param out
* the object to write to.
* @throws IOException
diff --git a/jme3-core/src/main/java/com/jme3/math/Spline.java b/jme3-core/src/main/java/com/jme3/math/Spline.java
index 33c2f2a34..103ce24d9 100644
--- a/jme3-core/src/main/java/com/jme3/math/Spline.java
+++ b/jme3-core/src/main/java/com/jme3/math/Spline.java
@@ -49,11 +49,11 @@ public class Spline implements Savable {
Bezier,
Nurb
}
-
+
private Listadd
adds a provided vector to this vector creating a
* resultant vector which is returned. If the provided vector is null, null
* is returned.
@@ -174,7 +167,6 @@ public final class Vector3f implements Savable, Cloneable, java.io.Serializable
}
/**
- *
* add
adds the values of a provided vector storing the
* values in the supplied vector.
*
@@ -212,7 +204,6 @@ public final class Vector3f implements Savable, Cloneable, java.io.Serializable
}
/**
- *
* add
adds the provided values to this vector, creating a
* new vector that is then returned.
*
@@ -249,7 +240,6 @@ public final class Vector3f implements Savable, Cloneable, java.io.Serializable
}
/**
- *
* scaleAdd
multiplies this vector by a scalar then adds the
* given Vector3f.
*
@@ -266,7 +256,6 @@ public final class Vector3f implements Savable, Cloneable, java.io.Serializable
}
/**
- *
* scaleAdd
multiplies the given vector by a scalar then adds
* the given vector.
*
@@ -285,7 +274,6 @@ public final class Vector3f implements Savable, Cloneable, java.io.Serializable
}
/**
- *
* dot
calculates the dot product of this vector with a
* provided vector. If the provided vector is null, 0 is returned.
*
@@ -323,7 +311,7 @@ public final class Vector3f implements Savable, Cloneable, java.io.Serializable
* the vector to store the cross product result.
* @return result, after receiving the cross product vector.
*/
- public Vector3f cross(Vector3f v,Vector3f result) {
+ public Vector3f cross(Vector3f v, Vector3f result) {
return cross(v.x, v.y, v.z, result);
}
@@ -342,8 +330,10 @@ public final class Vector3f implements Savable, Cloneable, java.io.Serializable
* @return result, after receiving the cross product vector.
*/
public Vector3f cross(float otherX, float otherY, float otherZ, Vector3f result) {
- if (result == null) result = new Vector3f();
- float resX = ((y * otherZ) - (z * otherY));
+ if (result == null) {
+ result = new Vector3f();
+ }
+ float resX = ((y * otherZ) - (z * otherY));
float resY = ((z * otherX) - (x * otherZ));
float resZ = ((x * otherY) - (y * otherX));
result.set(resX, resY, resZ);
@@ -375,8 +365,8 @@ public final class Vector3f implements Savable, Cloneable, java.io.Serializable
* @return this.
*/
public Vector3f crossLocal(float otherX, float otherY, float otherZ) {
- float tempx = ( y * otherZ ) - ( z * otherY );
- float tempy = ( z * otherX ) - ( x * otherZ );
+ float tempx = (y * otherZ) - (z * otherY);
+ float tempy = (z * otherX) - (x * otherZ);
z = (x * otherY) - (y * otherX);
x = tempx;
y = tempy;
@@ -389,10 +379,10 @@ public final class Vector3f implements Savable, Cloneable, java.io.Serializable
* @param other The vector to project this vector onto
* @return A new vector with the projection result
*/
- public Vector3f project(Vector3f other){
+ public Vector3f project(Vector3f other) {
float n = this.dot(other); // A . B
float d = other.lengthSquared(); // |B|^2
- return new Vector3f(other).multLocal(n/d);
+ return new Vector3f(other).multLocal(n / d);
}
/**
@@ -402,20 +392,20 @@ public final class Vector3f implements Savable, Cloneable, java.io.Serializable
* @param other The vector to project this vector onto
* @return This Vector3f, set to the projection result
*/
- public Vector3f projectLocal(Vector3f other){
+ public Vector3f projectLocal(Vector3f other) {
float n = this.dot(other); // A . B
float d = other.lengthSquared(); // |B|^2
- return set(other).multLocal(n/d);
+ return set(other).multLocal(n / d);
}
-
+
/**
* Returns true if this vector is a unit vector (length() ~= 1),
* returns false otherwise.
- *
+ *
* @return true if this vector is a unit vector (length() ~= 1),
* or false otherwise.
*/
- public boolean isUnitVector(){
+ public boolean isUnitVector() {
float len = length();
return 0.99f < len && len < 1.01f;
}
@@ -465,7 +455,6 @@ public final class Vector3f implements Savable, Cloneable, java.io.Serializable
}
/**
- *
* mult
multiplies this vector by a scalar. The resultant
* vector is returned.
*
@@ -478,7 +467,6 @@ public final class Vector3f implements Savable, Cloneable, java.io.Serializable
}
/**
- *
* mult
multiplies this vector by a scalar. The resultant
* vector is supplied as the second parameter and returned.
*
@@ -581,11 +569,12 @@ public final class Vector3f implements Savable, Cloneable, java.io.Serializable
logger.warning("Provided vector is null, null returned.");
return null;
}
- if (store == null) store = new Vector3f();
+ if (store == null) {
+ store = new Vector3f();
+ }
return store.set(x * vec.x, y * vec.y, z * vec.z);
}
-
/**
* divide
divides the values of this vector by a scalar and
* returns the result. The values of this vector remain untouched.
@@ -595,7 +584,7 @@ public final class Vector3f implements Savable, Cloneable, java.io.Serializable
* @return the result Vector
.
*/
public Vector3f divide(float scalar) {
- scalar = 1f/scalar;
+ scalar = 1f / scalar;
return new Vector3f(x * scalar, y * scalar, z * scalar);
}
@@ -609,14 +598,13 @@ public final class Vector3f implements Savable, Cloneable, java.io.Serializable
* @return this
*/
public Vector3f divideLocal(float scalar) {
- scalar = 1f/scalar;
+ scalar = 1f / scalar;
x *= scalar;
y *= scalar;
z *= scalar;
return this;
}
-
/**
* divide
divides the values of this vector by a scalar and
* returns the result. The values of this vector remain untouched.
@@ -646,7 +634,6 @@ public final class Vector3f implements Savable, Cloneable, java.io.Serializable
}
/**
- *
* negate
returns the negative of this vector. All values are
* negated and set to a new vector.
*
@@ -657,7 +644,6 @@ public final class Vector3f implements Savable, Cloneable, java.io.Serializable
}
/**
- *
* negateLocal
negates the internal values of this vector.
*
* @return this.
@@ -670,7 +656,6 @@ public final class Vector3f implements Savable, Cloneable, java.io.Serializable
}
/**
- *
* subtract
subtracts the values of a given vector from those
* of this vector creating a new vector object. If the provided vector is
* null, null is returned.
@@ -704,7 +689,6 @@ public final class Vector3f implements Savable, Cloneable, java.io.Serializable
}
/**
- *
* subtract
*
* @param vec
@@ -714,7 +698,7 @@ public final class Vector3f implements Savable, Cloneable, java.io.Serializable
* @return result
*/
public Vector3f subtract(Vector3f vec, Vector3f result) {
- if(result == null) {
+ if (result == null) {
result = new Vector3f();
}
result.x = x - vec.x;
@@ -724,7 +708,6 @@ public final class Vector3f implements Savable, Cloneable, java.io.Serializable
}
/**
- *
* subtract
subtracts the provided values from this vector,
* creating a new vector that is then returned.
*
@@ -773,7 +756,7 @@ public final class Vector3f implements Savable, Cloneable, java.io.Serializable
//
// return divide(1);
float length = x * x + y * y + z * z;
- if (length != 1f && length != 0f){
+ if (length != 1f && length != 0f) {
length = 1.0f / FastMath.sqrt(length);
return new Vector3f(x * length, y * length, z * length);
}
@@ -791,7 +774,7 @@ public final class Vector3f implements Savable, Cloneable, java.io.Serializable
// than the old jme normalize as this method
// is commonly used.
float length = x * x + y * y + z * z;
- if (length != 1f && length != 0f){
+ if (length != 1f && length != 0f) {
length = 1.0f / FastMath.sqrt(length);
x *= length;
y *= length;
@@ -801,12 +784,13 @@ public final class Vector3f implements Savable, Cloneable, java.io.Serializable
}
/**
- * maxLocal
computes the maximum value for each
+ * maxLocal
computes the maximum value for each
* component in this and other
vector. The result is stored
* in this vector.
- * @param other
+ *
+ * @param other
*/
- public Vector3f maxLocal(Vector3f other){
+ public Vector3f maxLocal(Vector3f other) {
x = other.x > x ? other.x : x;
y = other.y > y ? other.y : y;
z = other.z > z ? other.z : z;
@@ -817,9 +801,10 @@ public final class Vector3f implements Savable, Cloneable, java.io.Serializable
* minLocal
computes the minimum value for each
* component in this and other
vector. The result is stored
* in this vector.
+ *
* @param other
*/
- public Vector3f minLocal(Vector3f other){
+ public Vector3f minLocal(Vector3f other) {
x = other.x < x ? other.x : x;
y = other.y < y ? other.y : y;
z = other.z < z ? other.z : z;
@@ -837,7 +822,7 @@ public final class Vector3f implements Savable, Cloneable, java.io.Serializable
/**
* angleBetween
returns (in radians) the angle between two vectors.
* It is assumed that both this vector and the given vector are unit vectors (iow, normalized).
- *
+ *
* @param otherVector a unit vector to find the angle against
* @return the angle in radians.
*/
@@ -846,51 +831,60 @@ public final class Vector3f implements Savable, Cloneable, java.io.Serializable
float angle = FastMath.acos(dotProduct);
return angle;
}
-
+
/**
* Sets this vector to the interpolation by changeAmnt from this to the finalVec
* this=(1-changeAmnt)*this + changeAmnt * finalVec
+ *
* @param finalVec The final vector to interpolate towards
* @param changeAmnt An amount between 0.0 - 1.0 representing a percentage
* change from this towards finalVec
*/
public Vector3f interpolateLocal(Vector3f finalVec, float changeAmnt) {
- this.x=(1-changeAmnt)*this.x + changeAmnt*finalVec.x;
- this.y=(1-changeAmnt)*this.y + changeAmnt*finalVec.y;
- this.z=(1-changeAmnt)*this.z + changeAmnt*finalVec.z;
+ this.x = (1 - changeAmnt) * this.x + changeAmnt * finalVec.x;
+ this.y = (1 - changeAmnt) * this.y + changeAmnt * finalVec.y;
+ this.z = (1 - changeAmnt) * this.z + changeAmnt * finalVec.z;
return this;
}
/**
* Sets this vector to the interpolation by changeAmnt from beginVec to finalVec
* this=(1-changeAmnt)*beginVec + changeAmnt * finalVec
+ *
* @param beginVec the beginning vector (changeAmnt=0)
* @param finalVec The final vector to interpolate towards
* @param changeAmnt An amount between 0.0 - 1.0 representing a percentage
* change from beginVec towards finalVec
*/
- public Vector3f interpolateLocal(Vector3f beginVec,Vector3f finalVec, float changeAmnt) {
- this.x=(1-changeAmnt)*beginVec.x + changeAmnt*finalVec.x;
- this.y=(1-changeAmnt)*beginVec.y + changeAmnt*finalVec.y;
- this.z=(1-changeAmnt)*beginVec.z + changeAmnt*finalVec.z;
+ public Vector3f interpolateLocal(Vector3f beginVec, Vector3f finalVec, float changeAmnt) {
+ this.x = (1 - changeAmnt) * beginVec.x + changeAmnt * finalVec.x;
+ this.y = (1 - changeAmnt) * beginVec.y + changeAmnt * finalVec.y;
+ this.z = (1 - changeAmnt) * beginVec.z + changeAmnt * finalVec.z;
return this;
}
/**
* Check a vector... if it is null or its floats are NaN or infinite,
* return false. Else return true.
+ *
* @param vector the vector to check
* @return true or false as stated above.
*/
public static boolean isValidVector(Vector3f vector) {
- if (vector == null) return false;
- if (Float.isNaN(vector.x) ||
- Float.isNaN(vector.y) ||
- Float.isNaN(vector.z)) return false;
- if (Float.isInfinite(vector.x) ||
- Float.isInfinite(vector.y) ||
- Float.isInfinite(vector.z)) return false;
- return true;
+ if (vector == null) {
+ return false;
+ }
+ if (Float.isNaN(vector.x)
+ || Float.isNaN(vector.y)
+ || Float.isNaN(vector.z)) {
+ return false;
+ }
+ if (Float.isInfinite(vector.x)
+ || Float.isInfinite(vector.y)
+ || Float.isInfinite(vector.z)) {
+ return false;
+ }
+ return true;
}
public static void generateOrthonormalBasis(Vector3f u, Vector3f v, Vector3f w) {
@@ -934,7 +928,7 @@ public final class Vector3f implements Savable, Cloneable, java.io.Serializable
/**
* Saves this Vector3f into the given float[] object.
- *
+ *
* @param floats
* The float[] to take this Vector3f. If null, a new float[3] is
* created.
@@ -960,17 +954,27 @@ public final class Vector3f implements Savable, Cloneable, java.io.Serializable
*/
@Override
public boolean equals(Object o) {
- if (!(o instanceof Vector3f)) { return false; }
+ if (!(o instanceof Vector3f)) {
+ return false;
+ }
- if (this == o) { return true; }
+ if (this == o) {
+ return true;
+ }
Vector3f comp = (Vector3f) o;
- if (Float.compare(x,comp.x) != 0) return false;
- if (Float.compare(y,comp.y) != 0) return false;
- if (Float.compare(z,comp.z) != 0) return false;
+ if (Float.compare(x, comp.x) != 0) {
+ return false;
+ }
+ if (Float.compare(y, comp.y) != 0) {
+ return false;
+ }
+ if (Float.compare(z, comp.z) != 0) {
+ return false;
+ }
return true;
}
-
+
/**
* Returns true if this vector is similar to the specified vector within
* some value of epsilon.
@@ -995,6 +999,7 @@ public final class Vector3f implements Savable, Cloneable, java.io.Serializable
* hashCode
returns a unique code for this vector object based
* on its values. If two vectors are logically equivalent, they will return
* the same hash code value.
+ *
* @return the hash code value of this vector.
*/
@Override
@@ -1061,7 +1066,7 @@ public final class Vector3f implements Savable, Cloneable, java.io.Serializable
this.z = z;
return this;
}
-
+
/**
* @param index
* @return x value if index == 0, y value if index == 1 or z value if index ==
@@ -1080,7 +1085,7 @@ public final class Vector3f implements Savable, Cloneable, java.io.Serializable
}
throw new IllegalArgumentException("index must be either 0, 1 or 2");
}
-
+
/**
* @param index
* which field index in this vector to set.
@@ -1103,5 +1108,4 @@ public final class Vector3f implements Savable, Cloneable, java.io.Serializable
}
throw new IllegalArgumentException("index must be either 0, 1 or 2");
}
-
}
diff --git a/jme3-core/src/main/java/com/jme3/scene/mesh/VirtualIndexBuffer.java b/jme3-core/src/main/java/com/jme3/scene/mesh/VirtualIndexBuffer.java
index dd57abee4..163cf6127 100644
--- a/jme3-core/src/main/java/com/jme3/scene/mesh/VirtualIndexBuffer.java
+++ b/jme3-core/src/main/java/com/jme3/scene/mesh/VirtualIndexBuffer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009-2012 jMonkeyEngine
+ * Copyright (c) 2009-2020 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -49,7 +49,7 @@ import java.nio.Buffer;
*
* FrameBuffer
s are rendering surfaces allowing
* off-screen rendering and render-to-texture functionality.
- * Instead of the scene rendering to the screen, it is rendered into the
+ * Instead of the scene rendering to the screen, it is rendered into the
* FrameBuffer, the result can be either a texture or a buffer.
*
- * A FrameBuffer
supports two methods of rendering,
- * using a {@link Texture} or using a buffer.
+ * A FrameBuffer
supports two methods of rendering,
+ * using a {@link Texture} or using a buffer.
* When using a texture, the result of the rendering will be rendered
* onto the texture, after which the texture can be placed on an object
* and rendered as if the texture was uploaded from disk.
- * When using a buffer, the result is rendered onto
+ * When using a buffer, the result is rendered onto
* a buffer located on the GPU, the data of this buffer is not accessible
* to the user. buffers are useful if one
* wishes to retrieve only the color content of the scene, but still desires
- * depth testing (which requires a depth buffer).
+ * depth testing (which requires a depth buffer).
* Buffers can be copied to other framebuffers
- * including the main screen, by using
+ * including the main screen, by using
* {@link Renderer#copyFrameBuffer(com.jme3.texture.FrameBuffer, com.jme3.texture.FrameBuffer, boolean)}.
- * The content of a {@link RenderBuffer} can be retrieved by using
+ * The content of a {@link RenderBuffer} can be retrieved by using
* {@link Renderer#readFrameBuffer(com.jme3.texture.FrameBuffer, java.nio.ByteBuffer) }.
*
- * FrameBuffer
s have several attachment points, there are
- * several color attachment points and a single depth
+ * FrameBuffer
s have several attachment points, there are
+ * several color attachment points and a single depth
* attachment point.
* The color attachment points support image formats such as
* {@link Format#RGBA8}, allowing rendering the color content of the scene.
- * The depth attachment point requires a depth image format.
- *
- * @see Renderer#setFrameBuffer(com.jme3.texture.FrameBuffer)
- *
+ * The depth attachment point requires a depth image format.
+ *
+ * @see Renderer#setFrameBuffer(com.jme3.texture.FrameBuffer)
+ *
* @author Kirill Vainer
*/
public class FrameBuffer extends NativeObject {
-
+
public static final int SLOT_UNDEF = -1;
public static final int SLOT_DEPTH = -100;
public static final int SLOT_DEPTH_STENCIL = -101;
@@ -86,7 +86,7 @@ public class FrameBuffer extends NativeObject {
private boolean srgb;
/**
- * RenderBuffer
represents either a texture or a
+ * RenderBuffer
represents either a texture or a
* buffer that will be rendered to. RenderBuffer
s
* are attached to an attachment slot on a FrameBuffer
.
*/
@@ -98,7 +98,7 @@ public class FrameBuffer extends NativeObject {
int slot = SLOT_UNDEF;
int face = -1;
int layer = -1;
-
+
/**
* @return The image format of the render buffer.
*/
@@ -110,7 +110,7 @@ public class FrameBuffer extends NativeObject {
* @return The texture to render to for this RenderBuffer
* or null if content should be rendered into a buffer.
*/
- public Texture getTexture(){
+ public Texture getTexture() {
return tex;
}
@@ -124,7 +124,7 @@ public class FrameBuffer extends NativeObject {
/**
* Do not use.
*/
- public void setId(int id){
+ public void setId(int id) {
this.id = id;
}
@@ -134,30 +134,30 @@ public class FrameBuffer extends NativeObject {
public int getSlot() {
return slot;
}
-
+
public int getFace() {
return face;
}
- public void resetObject(){
+ public void resetObject() {
id = -1;
}
- public RenderBuffer createDestructableClone(){
- if (tex != null){
+ public RenderBuffer createDestructableClone() {
+ if (tex != null) {
return null;
- }else{
- RenderBuffer destructClone = new RenderBuffer();
+ } else {
+ RenderBuffer destructClone = new RenderBuffer();
destructClone.id = id;
return destructClone;
}
}
@Override
- public String toString(){
- if (tex != null){
+ public String toString() {
+ if (tex != null) {
return "TextureTarget[format=" + format + "]";
- }else{
+ } else {
return "BufferTarget[format=" + format + "]";
}
}
@@ -173,28 +173,29 @@ public class FrameBuffer extends NativeObject {
* of samples. If any textures are attached to this FrameBuffer, then
* they must have the same number of samples as given in this constructor.
*
- * Note that if the {@link Renderer} does not expose the
+ * Note that if the {@link Renderer} does not expose the
* {@link Caps#NonPowerOfTwoTextures}, then an exception will be thrown
* if the width and height arguments are not power of two.
- *
+ *
* @param width The width to use
* @param height The height to use
* @param samples The number of samples to use for a multisampled
* framebuffer, or 1 if the framebuffer should be singlesampled.
- *
+ *
* @throws IllegalArgumentException If width or height are not positive.
*/
- public FrameBuffer(int width, int height, int samples){
+ public FrameBuffer(int width, int height, int samples) {
super();
- if (width <= 0 || height <= 0)
- throw new IllegalArgumentException("FrameBuffer must have valid size.");
+ if (width <= 0 || height <= 0) {
+ throw new IllegalArgumentException("FrameBuffer must have valid size.");
+ }
this.width = width;
this.height = height;
this.samples = samples == 0 ? 1 : samples;
}
- protected FrameBuffer(FrameBuffer src){
+ protected FrameBuffer(FrameBuffer src) {
super(src.id);
/*
for (RenderBuffer renderBuf : src.colorBufs){
@@ -209,60 +210,68 @@ public class FrameBuffer extends NativeObject {
/**
* Enables the use of a depth buffer for this FrameBuffer
.
- *
+ *
* @param format The format to use for the depth buffer.
* @throws IllegalArgumentException If format
is not a depth format.
*/
- public void setDepthBuffer(Image.Format format){
- if (id != -1)
+ public void setDepthBuffer(Image.Format format) {
+ if (id != -1) {
throw new UnsupportedOperationException("FrameBuffer already initialized.");
+ }
- if (!format.isDepthFormat())
+ if (!format.isDepthFormat()) {
throw new IllegalArgumentException("Depth buffer format must be depth.");
-
+ }
+
depthBuf = new RenderBuffer();
- depthBuf.slot = format.isDepthStencilFormat() ? SLOT_DEPTH_STENCIL : SLOT_DEPTH;
+ depthBuf.slot = format.isDepthStencilFormat() ? SLOT_DEPTH_STENCIL : SLOT_DEPTH;
depthBuf.format = format;
}
/**
* Enables the use of a color buffer for this FrameBuffer
.
- *
+ *
* @param format The format to use for the color buffer.
* @throws IllegalArgumentException If format
is not a color format.
*/
- public void setColorBuffer(Image.Format format){
- if (id != -1)
+ public void setColorBuffer(Image.Format format) {
+ if (id != -1) {
throw new UnsupportedOperationException("FrameBuffer already initialized.");
+ }
- if (format.isDepthFormat())
+ if (format.isDepthFormat()) {
throw new IllegalArgumentException("Color buffer format must be color/luminance.");
-
+ }
+
RenderBuffer colorBuf = new RenderBuffer();
colorBuf.slot = 0;
colorBuf.format = format;
-
+
colorBufs.clear();
colorBufs.add(colorBuf);
}
- private void checkSetTexture(Texture tex, boolean depth){
+ private void checkSetTexture(Texture tex, boolean depth) {
Image img = tex.getImage();
- if (img == null)
+ if (img == null) {
throw new IllegalArgumentException("Texture not initialized with RTT.");
+ }
- if (depth && !img.getFormat().isDepthFormat())
+ if (depth && !img.getFormat().isDepthFormat()) {
throw new IllegalArgumentException("Texture image format must be depth.");
- else if (!depth && img.getFormat().isDepthFormat())
+ } else if (!depth && img.getFormat().isDepthFormat()) {
throw new IllegalArgumentException("Texture image format must be color/luminance.");
+ }
// check that resolution matches texture resolution
- if (width != img.getWidth() || height != img.getHeight())
- throw new IllegalArgumentException("Texture image resolution " +
- "must match FB resolution");
+ if (width != img.getWidth() || height != img.getHeight()) {
+ throw new IllegalArgumentException("Texture image resolution "
+ + "must match FB resolution");
+ }
- if (samples != tex.getImage().getMultiSamples())
+ if (samples != tex.getImage().getMultiSamples()) {
throw new IllegalStateException("Texture samples must match framebuffer samples");
+ }
}
/**
@@ -270,38 +279,43 @@ public class FrameBuffer extends NativeObject {
* will be able to write several results into the renderbuffers
* by using the gl_FragData
array. Every slot in that
* array maps into a color buffer attached to this framebuffer.
- *
+ *
* @param enabled True to enable MRT (multiple rendering targets).
*/
- public void setMultiTarget(boolean enabled){
- if (enabled) colorBufIndex = -1;
- else colorBufIndex = 0;
+ public void setMultiTarget(boolean enabled) {
+ if (enabled) {
+ colorBufIndex = -1;
+ } else {
+ colorBufIndex = 0;
+ }
}
/**
* @return True if MRT (multiple rendering targets) is enabled.
* @see FrameBuffer#setMultiTarget(boolean)
*/
- public boolean isMultiTarget(){
+ public boolean isMultiTarget() {
return colorBufIndex == -1;
}
-
+
/**
* If MRT is not enabled ({@link FrameBuffer#setMultiTarget(boolean) } is false)
* then this specifies the color target to which the scene should be rendered.
*
* By default the value is 0.
- *
+ *
* @param index The color attachment index.
* @throws IllegalArgumentException If index is negative or doesn't map
* to any attachment on this framebuffer.
*/
- public void setTargetIndex(int index){
- if (index < 0 || index >= 16)
+ public void setTargetIndex(int index) {
+ if (index < 0 || index >= 16) {
throw new IllegalArgumentException("Target index must be between 0 and 16");
+ }
- if (colorBufs.size() < index)
+ if (colorBufs.size() < index) {
throw new IllegalArgumentException("The target at " + index + " is not set!");
+ }
colorBufIndex = index;
setUpdateNeeded();
@@ -309,10 +323,10 @@ public class FrameBuffer extends NativeObject {
/**
* @return The color target to which the scene should be rendered.
- *
- * @see FrameBuffer#setTargetIndex(int)
+ *
+ * @see FrameBuffer#setTargetIndex(int)
*/
- public int getTargetIndex(){
+ public int getTargetIndex() {
return colorBufIndex;
}
@@ -321,27 +335,27 @@ public class FrameBuffer extends NativeObject {
* This automatically clears all existing textures added previously
* with {@link FrameBuffer#addColorTexture } and adds this texture as the
* only target.
- *
+ *
* @param tex The color texture to set.
*/
- public void setColorTexture(Texture2D tex){
+ public void setColorTexture(Texture2D tex) {
clearColorTargets();
addColorTexture(tex);
}
-
+
/**
* Set the color texture array to use for this framebuffer.
* This automatically clears all existing textures added previously
* with {@link FrameBuffer#addColorTexture } and adds this texture as the
* only target.
- *
+ *
* @param tex The color texture array to set.
*/
- public void setColorTexture(TextureArray tex, int layer){
+ public void setColorTexture(TextureArray tex, int layer) {
clearColorTargets();
addColorTexture(tex, layer);
}
-
+
/**
* Set the color texture to use for this framebuffer.
* This automatically clears all existing textures added previously
@@ -359,47 +373,50 @@ public class FrameBuffer extends NativeObject {
/**
* Clears all color targets that were set or added previously.
*/
- public void clearColorTargets(){
+ public void clearColorTargets() {
colorBufs.clear();
}
- /**
+ /**
* Add a color buffer without a texture bound to it.
* If MRT is enabled, then each subsequently added texture or buffer can be
* rendered to through a shader that writes to the array gl_FragData
.
* If MRT is not enabled, then the index set with {@link FrameBuffer#setTargetIndex(int) }
* is rendered to by the shader.
- *
+ *
* @param format the format of the color buffer
- * @see #addColorTexture(com.jme3.texture.Texture2D)
+ * @see #addColorTexture(com.jme3.texture.Texture2D)
*/
- public void addColorBuffer(Image.Format format){
- if (id != -1)
+ public void addColorBuffer(Image.Format format) {
+ if (id != -1) {
throw new UnsupportedOperationException("FrameBuffer already initialized.");
+ }
- if (format.isDepthFormat())
+ if (format.isDepthFormat()) {
throw new IllegalArgumentException("Color buffer format must be color/luminance.");
-
+ }
+
RenderBuffer colorBuf = new RenderBuffer();
colorBuf.slot = colorBufs.size();
colorBuf.format = format;
-
+
colorBufs.add(colorBuf);
}
-
+
/**
* Add a color texture to use for this framebuffer.
* If MRT is enabled, then each subsequently added texture can be
* rendered to through a shader that writes to the array gl_FragData
.
* If MRT is not enabled, then the index set with {@link FrameBuffer#setTargetIndex(int) }
* is rendered to by the shader.
- *
+ *
* @param tex The texture to add.
- * @see #addColorBuffer(com.jme3.texture.Image.Format)
+ * @see #addColorBuffer(com.jme3.texture.Image.Format)
*/
public void addColorTexture(Texture2D tex) {
- if (id != -1)
+ if (id != -1) {
throw new UnsupportedOperationException("FrameBuffer already initialized.");
+ }
Image img = tex.getImage();
checkSetTexture(tex, false);
@@ -411,19 +428,20 @@ public class FrameBuffer extends NativeObject {
colorBufs.add(colorBuf);
}
-
+
/**
* Add a color texture array to use for this framebuffer.
* If MRT is enabled, then each subsequently added texture can be
* rendered to through a shader that writes to the array gl_FragData
.
* If MRT is not enabled, then the index set with {@link FrameBuffer#setTargetIndex(int) }
* is rendered to by the shader.
- *
+ *
* @param tex The texture array to add.
*/
public void addColorTexture(TextureArray tex, int layer) {
- if (id != -1)
+ if (id != -1) {
throw new UnsupportedOperationException("FrameBuffer already initialized.");
+ }
Image img = tex.getImage();
checkSetTexture(tex, false);
@@ -436,8 +454,8 @@ public class FrameBuffer extends NativeObject {
colorBufs.add(colorBuf);
}
-
- /**
+
+ /**
* Add a color texture to use for this framebuffer.
* If MRT is enabled, then each subsequently added texture can be
* rendered to through a shader that writes to the array gl_FragData
.
@@ -448,8 +466,9 @@ public class FrameBuffer extends NativeObject {
* @param face The face of the cube-map to render to.
*/
public void addColorTexture(TextureCubeMap tex, TextureCubeMap.Face face) {
- if (id != -1)
+ if (id != -1) {
throw new UnsupportedOperationException("FrameBuffer already initialized.");
+ }
Image img = tex.getImage();
checkSetTexture(tex, false);
@@ -465,39 +484,42 @@ public class FrameBuffer extends NativeObject {
/**
* Set the depth texture to use for this framebuffer.
- *
+ *
* @param tex The color texture to set.
*/
- public void setDepthTexture(Texture2D tex){
- if (id != -1)
+ public void setDepthTexture(Texture2D tex) {
+ if (id != -1) {
throw new UnsupportedOperationException("FrameBuffer already initialized.");
+ }
Image img = tex.getImage();
checkSetTexture(tex, true);
-
+
depthBuf = new RenderBuffer();
- depthBuf.slot = img.getFormat().isDepthStencilFormat() ? SLOT_DEPTH_STENCIL : SLOT_DEPTH;
+ depthBuf.slot = img.getFormat().isDepthStencilFormat() ? SLOT_DEPTH_STENCIL : SLOT_DEPTH;
depthBuf.tex = tex;
depthBuf.format = img.getFormat();
}
- public void setDepthTexture(TextureArray tex, int layer){
- if (id != -1)
+
+ public void setDepthTexture(TextureArray tex, int layer) {
+ if (id != -1) {
throw new UnsupportedOperationException("FrameBuffer already initialized.");
+ }
Image img = tex.getImage();
checkSetTexture(tex, true);
-
+
depthBuf = new RenderBuffer();
- depthBuf.slot = img.getFormat().isDepthStencilFormat() ? SLOT_DEPTH_STENCIL : SLOT_DEPTH;
+ depthBuf.slot = img.getFormat().isDepthStencilFormat() ? SLOT_DEPTH_STENCIL : SLOT_DEPTH;
depthBuf.tex = tex;
depthBuf.format = img.getFormat();
depthBuf.layer = layer;
}
-
+
/**
- * @return The number of color buffers attached to this texture.
+ * @return The number of color buffers attached to this texture.
*/
- public int getNumColorBuffers(){
+ public int getNumColorBuffers() {
return colorBufs.size();
}
@@ -505,21 +527,22 @@ public class FrameBuffer extends NativeObject {
* @param index
* @return The color buffer at the given index.
*/
- public RenderBuffer getColorBuffer(int index){
+ public RenderBuffer getColorBuffer(int index) {
return colorBufs.get(index);
}
/**
* @return The color buffer with the index set by {@link #setTargetIndex(int)}, or null
* if no color buffers are attached.
- * If MRT is disabled, the first color buffer is returned.
+ * If MRT is disabled, the first color buffer is returned.
*/
public RenderBuffer getColorBuffer() {
- if (colorBufs.isEmpty())
+ if (colorBufs.isEmpty()) {
return null;
- if (colorBufIndex<0 || colorBufIndex>=colorBufs.size()) {
- return colorBufs.get(0);
- }
+ }
+ if (colorBufIndex < 0 || colorBufIndex >= colorBufs.size()) {
+ return colorBufs.get(0);
+ }
return colorBufs.get(colorBufIndex);
}
@@ -554,16 +577,17 @@ public class FrameBuffer extends NativeObject {
}
@Override
- public String toString(){
+ public String toString() {
StringBuilder sb = new StringBuilder();
String mrtStr = colorBufIndex >= 0 ? "" + colorBufIndex : "mrt";
sb.append("FrameBuffer[format=").append(width).append("x").append(height)
- .append("x").append(samples).append(", drawBuf=").append(mrtStr).append("]\n");
- if (depthBuf != null)
+ .append("x").append(samples).append(", drawBuf=").append(mrtStr).append("]\n");
+ if (depthBuf != null) {
sb.append("Depth => ").append(depthBuf).append("\n");
- for (RenderBuffer colorBuf : colorBufs){
+ }
+ for (RenderBuffer colorBuf : colorBufs) {
sb.append("Color(").append(colorBuf.slot)
- .append(") => ").append(colorBuf).append("\n");
+ .append(") => ").append(colorBuf).append("\n");
}
return sb.toString();
}
@@ -571,32 +595,33 @@ public class FrameBuffer extends NativeObject {
@Override
public void resetObject() {
this.id = -1;
-
+
for (int i = 0; i < colorBufs.size(); i++) {
colorBufs.get(i).resetObject();
}
-
- if (depthBuf != null)
+
+ if (depthBuf != null) {
depthBuf.resetObject();
+ }
setUpdateNeeded();
}
@Override
public void deleteObject(Object rendererObject) {
- ((Renderer)rendererObject).deleteFrameBuffer(this);
+ ((Renderer) rendererObject).deleteFrameBuffer(this);
}
@Override
- public NativeObject createDestructableClone(){
+ public NativeObject createDestructableClone() {
return new FrameBuffer(this);
}
-
+
@Override
public long getUniqueId() {
- return ((long)OBJTYPE_FRAMEBUFFER << 32) | ((long)id);
+ return ((long) OBJTYPE_FRAMEBUFFER << 32) | ((long) id);
}
-
+
/**
* Specifies that the color values stored in this framebuffer are in SRGB
* format.
@@ -632,5 +657,4 @@ public class FrameBuffer extends NativeObject {
public boolean isSrgb() {
return srgb;
}
-
}
diff --git a/jme3-core/src/main/java/com/jme3/util/BufferUtils.java b/jme3-core/src/main/java/com/jme3/util/BufferUtils.java
index 180297096..c81926f91 100644
--- a/jme3-core/src/main/java/com/jme3/util/BufferUtils.java
+++ b/jme3-core/src/main/java/com/jme3/util/BufferUtils.java
@@ -54,7 +54,7 @@ import java.util.concurrent.ConcurrentHashMap;
/**
* BufferUtils
is a helper class for generating nio buffers from
* jME data classes such as Vectors and ColorRGBA.
- *
+ *
* @author Joshua Slack
* @version $Id: BufferUtils.java,v 1.16 2007/10/29 16:56:18 nca Exp $
*/
@@ -74,7 +74,7 @@ public final class BufferUtils {
* Set it to true if you want to enable direct memory tracking for debugging
* purpose. Default is false. To print direct memory usage use
* BufferUtils.printCurrentDirectMemory(StringBuilder store);
- *
+ *
* @param enabled
*/
public static void setTrackDirectMemoryEnabled(boolean enabled) {
@@ -84,7 +84,7 @@ public final class BufferUtils {
/**
* Creates a clone of the given buffer. The clone's capacity is equal to the
* given buffer's limit.
- *
+ *
* @param buf
* The buffer to clone
* @return The cloned buffer
@@ -141,7 +141,7 @@ public final class BufferUtils {
* Generate a new FloatBuffer using the given array of Vector3f objects. The
* FloatBuffer will be 3 * data.length long and contain the vector data as
* data[0].x, data[0].y, data[0].z, data[1].x... etc.
- *
+ *
* @param data
* array of Vector3f objects to place into a new FloatBuffer
*/
@@ -164,7 +164,7 @@ public final class BufferUtils {
/**
* Generate a new FloatBuffer using the given array of Quaternion objects.
* The FloatBuffer will be 4 * data.length long and contain the vector data.
- *
+ *
* @param data
* array of Quaternion objects to place into a new FloatBuffer
*/
@@ -232,7 +232,7 @@ public final class BufferUtils {
/**
* Generate a new FloatBuffer using the given array of float primitives.
- *
+ *
* @param data
* array of float primitives to place into a new FloatBuffer
*/
@@ -250,7 +250,7 @@ public final class BufferUtils {
/**
* Create a new FloatBuffer of an appropriate size to hold the specified
* number of Vector3f object data.
- *
+ *
* @param vertices
* number of vertices that need to be held by the newly created
* buffer
@@ -265,7 +265,7 @@ public final class BufferUtils {
* Create a new FloatBuffer of an appropriate size to hold the specified
* number of Vector3f object data only if the given buffer if not already
* the right size.
- *
+ *
* @param buf
* the buffer to first check and rewind
* @param vertices
@@ -285,7 +285,7 @@ public final class BufferUtils {
/**
* Sets the data contained in the given color into the FloatBuffer at the
* specified index.
- *
+ *
* @param color
* the data to insert
* @param buf
@@ -304,7 +304,7 @@ public final class BufferUtils {
/**
* Sets the data contained in the given quaternion into the FloatBuffer at
* the specified index.
- *
+ *
* @param quat
* the {@link Quaternion} to insert
* @param buf
@@ -343,7 +343,7 @@ public final class BufferUtils {
/**
* Sets the data contained in the given Vector3F into the FloatBuffer at the
* specified index.
- *
+ *
* @param vector
* the data to insert
* @param buf
@@ -369,7 +369,7 @@ public final class BufferUtils {
/**
* Updates the values of the given vector from the specified buffer at the
* index provided.
- *
+ *
* @param vector
* the vector to set data on
* @param buf
@@ -387,7 +387,7 @@ public final class BufferUtils {
/**
* Updates the values of the given vector from the specified buffer at the
* index provided.
- *
+ *
* @param vector
* the vector to set data on
* @param buf
@@ -405,7 +405,7 @@ public final class BufferUtils {
/**
* Generates a Vector3f array from the given FloatBuffer.
- *
+ *
* @param buff
* the FloatBuffer to read from
* @return a newly generated array of Vector3f objects
@@ -424,7 +424,7 @@ public final class BufferUtils {
* Copies a Vector3f from one position in the buffer to another. The index
* values are in terms of vector number (eg, vector number 0 is positions
* 0-2 in the FloatBuffer.)
- *
+ *
* @param buf
* the buffer to copy from/to
* @param fromPos
@@ -438,7 +438,7 @@ public final class BufferUtils {
/**
* Normalize a Vector3f in-buffer.
- *
+ *
* @param buf
* the buffer to find the Vector3f within
* @param index
@@ -456,7 +456,7 @@ public final class BufferUtils {
/**
* Add to a Vector3f in-buffer.
- *
+ *
* @param toAdd
* the vector to add from
* @param buf
@@ -476,7 +476,7 @@ public final class BufferUtils {
/**
* Multiply and store a Vector3f in-buffer.
- *
+ *
* @param toMult
* the vector to multiply against
* @param buf
@@ -497,7 +497,7 @@ public final class BufferUtils {
/**
* Checks to see if the given Vector3f is equals to the data stored in the
* buffer at the given data index.
- *
+ *
* @param check
* the vector to check against - null will return false.
* @param buf
@@ -521,7 +521,7 @@ public final class BufferUtils {
* Generate a new FloatBuffer using the given array of Vector2f objects. The
* FloatBuffer will be 2 * data.length long and contain the vector data as
* data[0].x, data[0].y, data[1].x... etc.
- *
+ *
* @param data
* array of Vector2f objects to place into a new FloatBuffer
*/
@@ -544,7 +544,7 @@ public final class BufferUtils {
/**
* Create a new FloatBuffer of an appropriate size to hold the specified
* number of Vector2f object data.
- *
+ *
* @param vertices
* number of vertices that need to be held by the newly created
* buffer
@@ -559,7 +559,7 @@ public final class BufferUtils {
* Create a new FloatBuffer of an appropriate size to hold the specified
* number of Vector2f object data only if the given buffer if not already
* the right size.
- *
+ *
* @param buf
* the buffer to first check and rewind
* @param vertices
@@ -579,7 +579,7 @@ public final class BufferUtils {
/**
* Sets the data contained in the given Vector2F into the FloatBuffer at the
* specified index.
- *
+ *
* @param vector
* the data to insert
* @param buf
@@ -595,7 +595,7 @@ public final class BufferUtils {
/**
* Updates the values of the given vector from the specified buffer at the
* index provided.
- *
+ *
* @param vector
* the vector to set data on
* @param buf
@@ -611,7 +611,7 @@ public final class BufferUtils {
/**
* Generates a Vector2f array from the given FloatBuffer.
- *
+ *
* @param buff
* the FloatBuffer to read from
* @return a newly generated array of Vector2f objects
@@ -630,7 +630,7 @@ public final class BufferUtils {
* Copies a Vector2f from one position in the buffer to another. The index
* values are in terms of vector number (eg, vector number 0 is positions
* 0-1 in the FloatBuffer.)
- *
+ *
* @param buf
* the buffer to copy from/to
* @param fromPos
@@ -644,7 +644,7 @@ public final class BufferUtils {
/**
* Normalize a Vector2f in-buffer.
- *
+ *
* @param buf
* the buffer to find the Vector2f within
* @param index
@@ -662,7 +662,7 @@ public final class BufferUtils {
/**
* Add to a Vector2f in-buffer.
- *
+ *
* @param toAdd
* the vector to add from
* @param buf
@@ -682,7 +682,7 @@ public final class BufferUtils {
/**
* Multiply and store a Vector2f in-buffer.
- *
+ *
* @param toMult
* the vector to multiply against
* @param buf
@@ -703,7 +703,7 @@ public final class BufferUtils {
/**
* Checks to see if the given Vector2f is equals to the data stored in the
* buffer at the given data index.
- *
+ *
* @param check
* the vector to check against - null will return false.
* @param buf
@@ -727,7 +727,7 @@ public final class BufferUtils {
* Generate a new IntBuffer using the given array of ints. The IntBuffer
* will be data.length long and contain the int data as data[0], data[1]...
* etc.
- *
+ *
* @param data
* array of ints to place into a new IntBuffer
*/
@@ -745,7 +745,7 @@ public final class BufferUtils {
/**
* Create a new int[] array and populate it with the given IntBuffer's
* contents.
- *
+ *
* @param buff
* the IntBuffer to read from
* @return a new int array populated from the IntBuffer
@@ -765,7 +765,7 @@ public final class BufferUtils {
/**
* Create a new float[] array and populate it with the given FloatBuffer's
* contents.
- *
+ *
* @param buff
* the FloatBuffer to read from
* @return a new float array populated from the FloatBuffer
@@ -785,7 +785,7 @@ public final class BufferUtils {
//// -- GENERAL DOUBLE ROUTINES -- ////
/**
* Create a new DoubleBuffer of the specified size.
- *
+ *
* @param size
* required number of double to store.
* @return the new DoubleBuffer
@@ -800,7 +800,7 @@ public final class BufferUtils {
/**
* Create a new DoubleBuffer of an appropriate size to hold the specified
* number of doubles only if the given buffer if not already the right size.
- *
+ *
* @param buf
* the buffer to first check and rewind
* @param size
@@ -823,7 +823,7 @@ public final class BufferUtils {
* DoubleBuffer. The new DoubleBuffer is separate from the old one and
* changes are not reflected across. If you want to reflect changes,
* consider using Buffer.duplicate().
- *
+ *
* @param buf
* the DoubleBuffer to copy
* @return the copy
@@ -848,7 +848,7 @@ public final class BufferUtils {
//// -- GENERAL FLOAT ROUTINES -- ////
/**
* Create a new FloatBuffer of the specified size.
- *
+ *
* @param size
* required number of floats to store.
* @return the new FloatBuffer
@@ -862,7 +862,7 @@ public final class BufferUtils {
/**
* Copies floats from one position in the buffer to another.
- *
+ *
* @param buf
* the buffer to copy from/to
* @param fromPos
@@ -885,7 +885,7 @@ public final class BufferUtils {
* FloatBuffer. The new FloatBuffer is separate from the old one and changes
* are not reflected across. If you want to reflect changes, consider using
* Buffer.duplicate().
- *
+ *
* @param buf
* the FloatBuffer to copy
* @return the copy
@@ -910,7 +910,7 @@ public final class BufferUtils {
//// -- GENERAL INT ROUTINES -- ////
/**
* Create a new IntBuffer of the specified size.
- *
+ *
* @param size
* required number of ints to store.
* @return the new IntBuffer
@@ -925,7 +925,7 @@ public final class BufferUtils {
/**
* Create a new IntBuffer of an appropriate size to hold the specified
* number of ints only if the given buffer if not already the right size.
- *
+ *
* @param buf
* the buffer to first check and rewind
* @param size
@@ -948,7 +948,7 @@ public final class BufferUtils {
* The new IntBuffer is separate from the old one and changes are not
* reflected across. If you want to reflect changes, consider using
* Buffer.duplicate().
- *
+ *
* @param buf
* the IntBuffer to copy
* @return the copy
@@ -973,7 +973,7 @@ public final class BufferUtils {
//// -- GENERAL BYTE ROUTINES -- ////
/**
* Create a new ByteBuffer of the specified size.
- *
+ *
* @param size
* required number of ints to store.
* @return the new IntBuffer
@@ -988,7 +988,7 @@ public final class BufferUtils {
/**
* Create a new ByteBuffer of an appropriate size to hold the specified
* number of ints only if the given buffer if not already the right size.
- *
+ *
* @param buf
* the buffer to first check and rewind
* @param size
@@ -1030,7 +1030,7 @@ public final class BufferUtils {
* The new ByteBuffer is separate from the old one and changes are not
* reflected across. If you want to reflect changes, consider using
* Buffer.duplicate().
- *
+ *
* @param buf
* the ByteBuffer to copy
* @return the copy
@@ -1055,7 +1055,7 @@ public final class BufferUtils {
//// -- GENERAL SHORT ROUTINES -- ////
/**
* Create a new ShortBuffer of the specified size.
- *
+ *
* @param size
* required number of shorts to store.
* @return the new ShortBuffer
@@ -1070,7 +1070,7 @@ public final class BufferUtils {
/**
* Create a new ShortBuffer of an appropriate size to hold the specified
* number of shorts only if the given buffer if not already the right size.
- *
+ *
* @param buf
* the buffer to first check and rewind
* @param size
@@ -1104,7 +1104,7 @@ public final class BufferUtils {
* ShortBuffer. The new ShortBuffer is separate from the old one and changes
* are not reflected across. If you want to reflect changes, consider using
* Buffer.duplicate().
- *
+ *
* @param buf
* the ShortBuffer to copy
* @return the copy
@@ -1130,7 +1130,7 @@ public final class BufferUtils {
* Ensures there is at least the required
number of entries
* left after the current position of the buffer. If the buffer is too small
* a larger one is created and the old one copied to the new buffer.
- *
+ *
* @param buffer
* buffer that should be checked/copied (may be null)
* @param required
@@ -1269,7 +1269,7 @@ public final class BufferUtils {
* and cleans the direct buffers. However, as this doesn't happen
* immediately after discarding all references to a direct buffer, it's easy
* to OutOfMemoryError yourself using direct buffers.
- **/
+ */
public static void destroyDirectBuffer(Buffer toBeDestroyed) {
if (!isDirect(toBeDestroyed)) {
return;
@@ -1318,5 +1318,4 @@ public final class BufferUtils {
}
}
}
-
}
diff --git a/jme3-core/src/main/java/com/jme3/util/ReflectionAllocator.java b/jme3-core/src/main/java/com/jme3/util/ReflectionAllocator.java
index a55d7c918..6564463b2 100644
--- a/jme3-core/src/main/java/com/jme3/util/ReflectionAllocator.java
+++ b/jme3-core/src/main/java/com/jme3/util/ReflectionAllocator.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009-2012 jMonkeyEngine
+ * Copyright (c) 2009-2020 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -81,74 +81,74 @@ public final class ReflectionAllocator implements BufferAllocator {
} catch (ClassNotFoundException ex) {
return null; // the direct buffer implementation was not found
} catch (Throwable t) {
- if (t.getClass().getName().equals("java.lang.reflect.InaccessibleObjectException")) {
- return null;// the class is in an unexported module
- } else {
- throw t;
- }
+ if (t.getClass().getName().equals("java.lang.reflect.InaccessibleObjectException")) {
+ return null;// the class is in an unexported module
+ } else {
+ throw t;
+ }
}
}
@Override
/**
* This function explicitly calls the Cleaner method of a direct buffer.
- *
+ *
* @param toBeDestroyed
* The direct buffer that will be "cleaned". Utilizes reflection.
- *
+ *
*/
public void destroyDirectBuffer(Buffer toBeDestroyed) {
try {
if (freeMethod != null) {
freeMethod.invoke(toBeDestroyed);
} else {
- //TODO load the methods only once, store them into a cache (only for Java >= 9)
- Method localCleanerMethod;
- if (cleanerMethod == null) {
- localCleanerMethod = loadMethod(toBeDestroyed.getClass().getName(), "cleaner");
- } else {
- localCleanerMethod = cleanerMethod;
- }
- if (localCleanerMethod == null) {
- Logger.getLogger(BufferUtils.class.getName()).log(Level.SEVERE,
- "Buffer cannot be destroyed: {0}", toBeDestroyed);
- } else {
- Object cleaner = localCleanerMethod.invoke(toBeDestroyed);
- if (cleaner != null) {
- Method localCleanMethod;
- if (cleanMethod == null) {
- if (cleaner instanceof Runnable) {
- // jdk.internal.ref.Cleaner implements Runnable in Java 9
- localCleanMethod = loadMethod(Runnable.class.getName(), "run");
- } else {
- // sun.misc.Cleaner does not implement Runnable in Java < 9
- localCleanMethod = loadMethod(cleaner.getClass().getName(), "clean");
- }
- } else {
- localCleanMethod = cleanMethod;
- }
- if (localCleanMethod == null) {
- Logger.getLogger(BufferUtils.class.getName()).log(Level.SEVERE,
- "Buffer cannot be destroyed: {0}", toBeDestroyed);
- } else {
- localCleanMethod.invoke(cleaner);
- }
- } else {
- Method localViewedBufferMethod;
- if (viewedBufferMethod == null) {
- localViewedBufferMethod = loadMethod(toBeDestroyed.getClass().getName(), "viewedBuffer");
- } else {
- localViewedBufferMethod = viewedBufferMethod;
- }
- if (localViewedBufferMethod == null) {
- Logger.getLogger(BufferUtils.class.getName()).log(Level.SEVERE,
- "Buffer cannot be destroyed: {0}", toBeDestroyed);
- } else {
- // Try the alternate approach of getting the viewed
- // buffer
- // first
- Object viewedBuffer = localViewedBufferMethod.invoke(toBeDestroyed);
- if (viewedBuffer != null) {
+ //TODO load the methods only once, store them into a cache (only for Java >= 9)
+ Method localCleanerMethod;
+ if (cleanerMethod == null) {
+ localCleanerMethod = loadMethod(toBeDestroyed.getClass().getName(), "cleaner");
+ } else {
+ localCleanerMethod = cleanerMethod;
+ }
+ if (localCleanerMethod == null) {
+ Logger.getLogger(BufferUtils.class.getName()).log(Level.SEVERE,
+ "Buffer cannot be destroyed: {0}", toBeDestroyed);
+ } else {
+ Object cleaner = localCleanerMethod.invoke(toBeDestroyed);
+ if (cleaner != null) {
+ Method localCleanMethod;
+ if (cleanMethod == null) {
+ if (cleaner instanceof Runnable) {
+ // jdk.internal.ref.Cleaner implements Runnable in Java 9
+ localCleanMethod = loadMethod(Runnable.class.getName(), "run");
+ } else {
+ // sun.misc.Cleaner does not implement Runnable in Java < 9
+ localCleanMethod = loadMethod(cleaner.getClass().getName(), "clean");
+ }
+ } else {
+ localCleanMethod = cleanMethod;
+ }
+ if (localCleanMethod == null) {
+ Logger.getLogger(BufferUtils.class.getName()).log(Level.SEVERE,
+ "Buffer cannot be destroyed: {0}", toBeDestroyed);
+ } else {
+ localCleanMethod.invoke(cleaner);
+ }
+ } else {
+ Method localViewedBufferMethod;
+ if (viewedBufferMethod == null) {
+ localViewedBufferMethod = loadMethod(toBeDestroyed.getClass().getName(), "viewedBuffer");
+ } else {
+ localViewedBufferMethod = viewedBufferMethod;
+ }
+ if (localViewedBufferMethod == null) {
+ Logger.getLogger(BufferUtils.class.getName()).log(Level.SEVERE,
+ "Buffer cannot be destroyed: {0}", toBeDestroyed);
+ } else {
+ // Try the alternate approach of getting the viewed
+ // buffer
+ // first
+ Object viewedBuffer = localViewedBufferMethod.invoke(toBeDestroyed);
+ if (viewedBuffer != null) {
if (viewedBuffer instanceof Buffer) {
destroyDirectBuffer((Buffer) viewedBuffer);
}
@@ -157,10 +157,10 @@ public final class ReflectionAllocator implements BufferAllocator {
} else {
Logger.getLogger(BufferUtils.class.getName()).log(Level.SEVERE,
"Buffer cannot be destroyed: {0}", toBeDestroyed);
- }
- }
- }
- }
+ }
+ }
+ }
+ }
}
} catch (IllegalAccessException ex) {
Logger.getLogger(BufferUtils.class.getName()).log(Level.SEVERE, "{0}", ex);