Skip to content

Commit

Permalink
correct 2 bugs in com.jme3.math.Spline serialization/deserialization
Browse files Browse the repository at this point in the history
  • Loading branch information
stephengold committed Feb 10, 2025
1 parent 98c0f9d commit f268e69
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions jme3-core/src/main/java/com/jme3/math/Spline.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2021 jMonkeyEngine
* Copyright (c) 2009-2025 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -480,7 +480,18 @@ public void write(JmeExporter ex) throws IOException {
oc.writeSavableArrayList((ArrayList) CRcontrolPoints, "CRControlPoints", null);
oc.write(curveTension, "curveTension", 0.5f);
oc.write(cycle, "cycle", false);
oc.writeSavableArrayList((ArrayList<Float>) knots, "knots", null);

float[] knotArray;
if (knots == null) {
knotArray = null;
} else {
knotArray = new float[knots.size()];
for (int i = 0; i < knotArray.length; ++i) {
knotArray[i] = knots.get(i);
}
}
oc.write(knotArray, "knots", null);

oc.write(weights, "weights", null);
oc.write(basisFunctionDegree, "basisFunctionDegree", 0);
}
Expand All @@ -506,12 +517,22 @@ public void read(JmeImporter im) throws IOException {
segmentsLength.add(list[i]);
}
}
type = in.readEnum("pathSplineType", SplineType.class, SplineType.CatmullRom);
type = in.readEnum("type", SplineType.class, SplineType.CatmullRom);
totalLength = in.readFloat("totalLength", 0);
CRcontrolPoints = in.readSavableArrayList("CRControlPoints", null);
curveTension = in.readFloat("curveTension", 0.5f);
cycle = in.readBoolean("cycle", false);
knots = in.readSavableArrayList("knots", null);

float[] knotArray = in.readFloatArray("knots", null);
if (knotArray == null) {
this.knots = null;
} else {
this.knots = new ArrayList<>(knotArray.length);
for (float knot : knotArray) {
knots.add(knot);
}
}

weights = in.readFloatArray("weights", null);
basisFunctionDegree = in.readInt("basisFunctionDegree", 0);
}
Expand Down

0 comments on commit f268e69

Please sign in to comment.