fix some error in modify anim

This commit is contained in:
zimzaza4
2024-09-28 15:40:39 +08:00
parent 45c9de0337
commit 8e40bc4246

View File

@@ -59,6 +59,9 @@ public class Animation {
if (animation.has("loop")) { if (animation.has("loop")) {
if (animation.get("loop").getAsJsonPrimitive().isString()) { if (animation.get("loop").getAsJsonPrimitive().isString()) {
if (animation.get("loop").getAsString().equals("hold_on_last_frame")) { if (animation.get("loop").getAsString().equals("hold_on_last_frame")) {
if (!animation.has("bones")) {
continue;
}
for (Map.Entry<String, JsonElement> bone : animation.get("bones").getAsJsonObject().entrySet()) { for (Map.Entry<String, JsonElement> bone : animation.get("bones").getAsJsonObject().entrySet()) {
for (Map.Entry<String, JsonElement> anim : bone.getValue().getAsJsonObject().entrySet()) { for (Map.Entry<String, JsonElement> anim : bone.getValue().getAsJsonObject().entrySet()) {
@@ -67,15 +70,17 @@ public class Animation {
if (!anim.getValue().isJsonObject()) { if (!anim.getValue().isJsonObject()) {
continue; continue;
} }
for (Map.Entry<String, JsonElement> timeline : anim.getValue().getAsJsonObject().entrySet()) { try {
float time = Float.parseFloat(timeline.getKey()); for (Map.Entry<String, JsonElement> timeline : anim.getValue().getAsJsonObject().entrySet()) {
if (time > max) { float time = Float.parseFloat(timeline.getKey());
max = time; if (time > max) {
if (timeline.getValue().isJsonObject()) { max = time;
end = timeline.getValue().getAsJsonObject(); if (timeline.getValue().isJsonObject()) {
end = timeline.getValue().getAsJsonObject();
}
} }
} }
} } catch (Throwable t) {}
if (end != null && end.get("lerp_mode").getAsString().equals("catmullrom")) { if (end != null && end.get("lerp_mode").getAsString().equals("catmullrom")) {
end.addProperty("lerp_mode", "linear"); end.addProperty("lerp_mode", "linear");
} }