I've found a bug in the BezierCurve of jME
You are supposed to ask for points along the curve in a range from 0 to 1, but if you ask for the point at position/time = 1 the point returned is [NaN,NaN,NaN].
The reason for this is a "divide by zero" in the code on line 121
The JavaDock states:
If the value is zero or less, the first control point is returned. If the value is one or more, the last control point is returned
This is not the case either for 0 nor 1 in the code
See diff in the attached .patch file
Can you please add the patch within code tags? A few of us on the forum are having issues with attachments.
Index: BezierCurve.java
===================================================================
--- BezierCurve.java (revision 4220)
+++ BezierCurve.java (working copy)
@@ -97,12 +97,12 @@
*/
public Vector3f getPoint(float time, Vector3f point) {
//first point
- if (time < 0) {
+ if (time <= 0) {
BufferUtils.populateFromBuffer(point, getVertexBuffer(), 0);
return point;
}
//last point.
- if (time > 1) {
+ if (time >= 1) {
BufferUtils.populateFromBuffer(point, getVertexBuffer(), getVertexCount() - 1);
return point;
}