Skip to content

Commit 08d6984

Browse files
authored
solve issue #1933 (unsupported operation in FbxNode) (#1936)
1 parent c0efec4 commit 08d6984

File tree

2 files changed

+72
-3
lines changed

2 files changed

+72
-3
lines changed

jme3-core/src/main/java/com/jme3/math/Matrix4f.java

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009-2022 jMonkeyEngine
2+
* Copyright (c) 2009-2023 jMonkeyEngine
33
* All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
@@ -2460,6 +2460,75 @@ public void multLocal(Quaternion rotation) {
24602460
multLocal(matrix4f);
24612461
}
24622462

2463+
/**
2464+
* Tests for approximate equality with the specified matrix, using the
2465+
* specified tolerance. If {@code other} is null, false is returned. Either
2466+
* way, the current instance is unaffected.
2467+
*
2468+
* @param other the matrix to compare (unaffected) or null for none
2469+
* @param epsilon the tolerance for each element
2470+
* @return true if all 16 elements are within tolerance, otherwise false
2471+
*/
2472+
public boolean isSimilar(Matrix4f other, float epsilon) {
2473+
if (other == null) {
2474+
return false;
2475+
}
2476+
2477+
if (Float.compare(Math.abs(other.m00 - m00), epsilon) > 0) {
2478+
return false;
2479+
}
2480+
if (Float.compare(Math.abs(other.m01 - m01), epsilon) > 0) {
2481+
return false;
2482+
}
2483+
if (Float.compare(Math.abs(other.m02 - m02), epsilon) > 0) {
2484+
return false;
2485+
}
2486+
if (Float.compare(Math.abs(other.m03 - m03), epsilon) > 0) {
2487+
return false;
2488+
}
2489+
2490+
if (Float.compare(Math.abs(other.m10 - m10), epsilon) > 0) {
2491+
return false;
2492+
}
2493+
if (Float.compare(Math.abs(other.m11 - m11), epsilon) > 0) {
2494+
return false;
2495+
}
2496+
if (Float.compare(Math.abs(other.m12 - m12), epsilon) > 0) {
2497+
return false;
2498+
}
2499+
if (Float.compare(Math.abs(other.m13 - m13), epsilon) > 0) {
2500+
return false;
2501+
}
2502+
2503+
if (Float.compare(Math.abs(other.m20 - m20), epsilon) > 0) {
2504+
return false;
2505+
}
2506+
if (Float.compare(Math.abs(other.m21 - m21), epsilon) > 0) {
2507+
return false;
2508+
}
2509+
if (Float.compare(Math.abs(other.m22 - m22), epsilon) > 0) {
2510+
return false;
2511+
}
2512+
if (Float.compare(Math.abs(other.m23 - m23), epsilon) > 0) {
2513+
return false;
2514+
}
2515+
2516+
if (Float.compare(Math.abs(other.m30 - m30), epsilon) > 0) {
2517+
return false;
2518+
}
2519+
if (Float.compare(Math.abs(other.m31 - m31), epsilon) > 0) {
2520+
return false;
2521+
}
2522+
if (Float.compare(Math.abs(other.m32 - m32), epsilon) > 0) {
2523+
return false;
2524+
}
2525+
if (Float.compare(Math.abs(other.m33 - m33), epsilon) > 0) {
2526+
return false;
2527+
}
2528+
2529+
return true;
2530+
}
2531+
24632532
/**
24642533
* Creates a copy. The current instance is unaffected.
24652534
*

jme3-plugins/src/fbx/java/com/jme3/scene/plugins/fbx/node/FbxNode.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009-2021 jMonkeyEngine
2+
* Copyright (c) 2009-2023 jMonkeyEngine
33
* All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
@@ -159,7 +159,7 @@ public Transform computeFbxLocalTransform() {
159159

160160
public void setWorldBindPose(Matrix4f worldBindPose) {
161161
if (cachedWorldBindPose != null) {
162-
if (!cachedWorldBindPose.equals(worldBindPose)) {
162+
if (!cachedWorldBindPose.isSimilar(worldBindPose, 1e-6f)) {
163163
throw new UnsupportedOperationException("Bind poses don't match");
164164
}
165165
}

0 commit comments

Comments
 (0)