Skip to content

Commit

Permalink
Update several math objects to reset when pulling from pool. Was hitt…
Browse files Browse the repository at this point in the history
…ing some problems with code assuming pool-fetched math objects were clean.
  • Loading branch information
Renanse committed Aug 20, 2020
1 parent 579380c commit 0bc3ae2
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion ardor3d-math/src/main/java/com/ardor3d/math/Matrix3.java
Original file line number Diff line number Diff line change
Expand Up @@ -1913,7 +1913,7 @@ public void writeExternal(final ObjectOutput out) throws IOException {
*/
public final static Matrix3 fetchTempInstance() {
if (MathConstants.useMathPools) {
return Matrix3.MAT_POOL.fetch();
return Matrix3.MAT_POOL.fetch().setIdentity();
} else {
return new Matrix3();
}
Expand Down
2 changes: 1 addition & 1 deletion ardor3d-math/src/main/java/com/ardor3d/math/Matrix4.java
Original file line number Diff line number Diff line change
Expand Up @@ -2382,7 +2382,7 @@ public void writeExternal(final ObjectOutput out) throws IOException {
*/
public final static Matrix4 fetchTempInstance() {
if (MathConstants.useMathPools) {
return Matrix4.MAT_POOL.fetch();
return Matrix4.MAT_POOL.fetch().setIdentity();
} else {
return new Matrix4();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1530,7 +1530,7 @@ public void writeExternal(final ObjectOutput out) throws IOException {
*/
public final static Quaternion fetchTempInstance() {
if (MathConstants.useMathPools) {
return Quaternion.QUAT_POOL.fetch();
return Quaternion.QUAT_POOL.fetch().setIdentity();
} else {
return new Quaternion();
}
Expand Down
2 changes: 1 addition & 1 deletion ardor3d-math/src/main/java/com/ardor3d/math/Transform.java
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,7 @@ public void writeExternal(final ObjectOutput out) throws IOException {
*/
public final static Transform fetchTempInstance() {
if (MathConstants.useMathPools) {
return Transform.TRANS_POOL.fetch();
return Transform.TRANS_POOL.fetch().setIdentity();
} else {
return new Transform();
}
Expand Down
2 changes: 1 addition & 1 deletion ardor3d-math/src/main/java/com/ardor3d/math/Vector2.java
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@ public void writeExternal(final ObjectOutput out) throws IOException {
*/
public final static Vector2 fetchTempInstance() {
if (MathConstants.useMathPools) {
return Vector2.VEC_POOL.fetch();
return Vector2.VEC_POOL.fetch().zero();
} else {
return new Vector2();
}
Expand Down
2 changes: 1 addition & 1 deletion ardor3d-math/src/main/java/com/ardor3d/math/Vector3.java
Original file line number Diff line number Diff line change
Expand Up @@ -1119,7 +1119,7 @@ public void writeExternal(final ObjectOutput out) throws IOException {
*/
public final static Vector3 fetchTempInstance() {
if (MathConstants.useMathPools) {
return Vector3.VEC_POOL.fetch();
return Vector3.VEC_POOL.fetch().zero();
} else {
return new Vector3();
}
Expand Down
2 changes: 1 addition & 1 deletion ardor3d-math/src/main/java/com/ardor3d/math/Vector4.java
Original file line number Diff line number Diff line change
Expand Up @@ -1067,7 +1067,7 @@ public void writeExternal(final ObjectOutput out) throws IOException {
*/
public final static Vector4 fetchTempInstance() {
if (MathConstants.useMathPools) {
return Vector4.VEC_POOL.fetch();
return Vector4.VEC_POOL.fetch().zero();
} else {
return new Vector4();
}
Expand Down

0 comments on commit 0bc3ae2

Please sign in to comment.