From 61d00627cfa7f921937a92c7657ff63afeeff2cd Mon Sep 17 00:00:00 2001 From: fd Date: Mon, 13 Apr 2015 22:56:07 -0400 Subject: [PATCH] More curve types #76 fix? --- src/itdelatrisu/opsu/objects/curves/CatmullCurve.java | 6 +++++- src/itdelatrisu/opsu/objects/curves/CurveType.java | 2 +- .../opsu/objects/curves/EqualDistanceMultiCurve.java | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/itdelatrisu/opsu/objects/curves/CatmullCurve.java b/src/itdelatrisu/opsu/objects/curves/CatmullCurve.java index 07f78d67..11f53497 100644 --- a/src/itdelatrisu/opsu/objects/curves/CatmullCurve.java +++ b/src/itdelatrisu/opsu/objects/curves/CatmullCurve.java @@ -44,10 +44,12 @@ public class CatmullCurve extends EqualDistanceMultiCurve { LinkedList points = new LinkedList(); // temporary list of points to separate different curves // repeat the first and last points as controls points + // only if the first/last two points are different // aabb // aabc abcc // aabc abcd bcdd - points.addLast(new Vec2f(getX(0), getY(0))); + if (getX(0) != getX(1) || getY(0) != getY(1)) + points.addLast(new Vec2f(getX(0), getY(0))); for (int i = 0; i < ncontrolPoints; i++) { points.addLast(new Vec2f(getX(i), getY(i))); if (points.size() >= 4) { @@ -59,6 +61,8 @@ public class CatmullCurve extends EqualDistanceMultiCurve { points.removeFirst(); } } + if (getX(ncontrolPoints - 1) != getX(ncontrolPoints - 2) + ||getY(ncontrolPoints - 1) != getY(ncontrolPoints - 2)) points.addLast(new Vec2f(getX(ncontrolPoints - 1), getY(ncontrolPoints - 1))); if (points.size() >= 4) { try { diff --git a/src/itdelatrisu/opsu/objects/curves/CurveType.java b/src/itdelatrisu/opsu/objects/curves/CurveType.java index c6cec272..4af02a62 100644 --- a/src/itdelatrisu/opsu/objects/curves/CurveType.java +++ b/src/itdelatrisu/opsu/objects/curves/CurveType.java @@ -50,7 +50,7 @@ public abstract class CurveType { */ public void init(float approxlength) { // subdivide the curve - this.ncurve = (int) (approxlength / 4) + 1; + this.ncurve = (int) (approxlength / 4) + 2; this.curve = new Vec2f[ncurve]; for (int i = 0; i < ncurve; i++) curve[i] = pointAt(i / (float) (ncurve - 1)); diff --git a/src/itdelatrisu/opsu/objects/curves/EqualDistanceMultiCurve.java b/src/itdelatrisu/opsu/objects/curves/EqualDistanceMultiCurve.java index 5f19e9b4..4cb06694 100644 --- a/src/itdelatrisu/opsu/objects/curves/EqualDistanceMultiCurve.java +++ b/src/itdelatrisu/opsu/objects/curves/EqualDistanceMultiCurve.java @@ -73,7 +73,7 @@ public abstract class EqualDistanceMultiCurve extends Curve { while (distanceAt < prefDistance) { lastDistanceAt = distanceAt; lastCurve = curCurve.getCurvePoint()[curPoint]; - distanceAt += curCurve.getCurveDistances()[curPoint++]; + curPoint++; if (curPoint >= curCurve.getCurvesCount()) { if (iter.hasNext()) { @@ -87,6 +87,7 @@ public abstract class EqualDistanceMultiCurve extends Curve { } } } + distanceAt += curCurve.getCurveDistances()[curPoint]; } Vec2f thisCurve = curCurve.getCurvePoint()[curPoint];