mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-26 22:38:00 +01:00
Don't try to strafe at angles of NaN
This commit is contained in:
parent
2a32b74b5b
commit
a9abab820e
3 changed files with 17 additions and 4 deletions
|
@ -21,6 +21,11 @@ public class BasicEasingInterpolator implements IInterpolator {
|
||||||
|
|
||||||
from += (to - from) / scalingFactor;
|
from += (to - from) / scalingFactor;
|
||||||
|
|
||||||
|
if (Float.isNaN(from) || Float.isInfinite(from)) {
|
||||||
|
System.err.println("Error: Animation frame for " + key + " is NaN or Infinite.");
|
||||||
|
from = to;
|
||||||
|
}
|
||||||
|
|
||||||
properties.put(key, from);
|
properties.put(key, from);
|
||||||
|
|
||||||
return from;
|
return from;
|
||||||
|
|
|
@ -47,7 +47,7 @@ public class PonyData implements IPonyData {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PonyRace getRace() {
|
public PonyRace getRace() {
|
||||||
return race.isHuman() ? race : PonyRace.PEGASUS;
|
return race;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -77,7 +77,7 @@ public class PonyData implements IPonyData {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isWearing(PonyWearable wearable) {
|
public boolean isWearing(PonyWearable wearable) {
|
||||||
return true;//wearables[wearable.ordinal()];
|
return wearables[wearable.ordinal()];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -43,7 +43,13 @@ public class RenderPonyPlayer extends RenderPonyBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ayyy magic numbers (after 5 - an approximation of nice looking coefficients calculated by hand)
|
// ayyy magic numbers (after 5 - an approximation of nice looking coefficients calculated by hand)
|
||||||
roll *= horMotion * 5 * (3.6884f * Math.pow(Math.abs(roll), -0.191));
|
|
||||||
|
// roll might be zero, in which case Math.pow produces +Infinity. Anything x Infinity = NaN.
|
||||||
|
double pow = roll != 0 ? Math.pow(Math.abs(roll), -0.191) : 0;
|
||||||
|
|
||||||
|
roll *= horMotion * 5 * (3.6884f * pow);
|
||||||
|
|
||||||
|
assert !Float.isNaN((float)roll);
|
||||||
|
|
||||||
return MathHelper.clamp(roll, -54, 54);
|
return MathHelper.clamp(roll, -54, 54);
|
||||||
}
|
}
|
||||||
|
@ -67,7 +73,9 @@ public class RenderPonyPlayer extends RenderPonyBase {
|
||||||
|
|
||||||
GlStateManager.rotate(ponyModel.motionPitch, 1, 0, 0);
|
GlStateManager.rotate(ponyModel.motionPitch, 1, 0, 0);
|
||||||
|
|
||||||
float roll = getPony().getMetadata().getInterpolator().interpolate("pegasusRoll", (float)calculateRoll(player, motionX, motionY, motionZ), 10);
|
float roll = (float)calculateRoll(player, motionX, motionY, motionZ);
|
||||||
|
|
||||||
|
roll = getPony().getMetadata().getInterpolator().interpolate("pegasusRoll", roll, 10);
|
||||||
|
|
||||||
GlStateManager.rotate((float)roll, 0, 0, 1);
|
GlStateManager.rotate((float)roll, 0, 0, 1);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue