Skip to content

Commit

Permalink
Fix bug with some oddly setup locomotives
Browse files Browse the repository at this point in the history
Example: Shaded's Coggers
  • Loading branch information
cam72cam committed Dec 9, 2023
1 parent bd7ab33 commit 3d67674
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import cam72cam.immersiverailroading.thirdparty.trackapi.ITrack;
import cam72cam.immersiverailroading.util.VecUtil;
import cam72cam.mod.math.Vec3d;
import cam72cam.mod.util.DegreeFuncs;
import cam72cam.mod.world.World;
import util.Matrix4;

Expand Down Expand Up @@ -84,6 +85,17 @@ public Matrix4 getMatrix() {

yawReadout = toPointYaw + atPointYaw;

float min = this.min;
// TODO This implies the code above is broken, but works around some of the weirder edge cases.
if (DegreeFuncs.delta(0, toPointYaw) > 90) {
min = -min;
toPointYaw = toPointYaw - 180;
}
if (DegreeFuncs.delta(0, atPointYaw) > 90) {
atPointYaw -= 180;
min = -min;
}

matrix.setIdentity();
matrix.rotate(Math.toRadians(toPointYaw), 0, 1, 0);
matrix.rotate(Math.toRadians(toPointPitch), 0, 0, 1);
Expand Down

0 comments on commit 3d67674

Please sign in to comment.