Fixed Slider.getPointAt() returning an incorrect end point.

Also some additional tweaks to #61.

Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
Jeffrey Han 2015-03-30 23:58:11 -04:00
parent 4b91018b70
commit e83e0da70f
2 changed files with 9 additions and 16 deletions

View File

@ -463,10 +463,8 @@ public class Slider implements HitObject {
else if (trackPosition >= hitObject.getTime() + sliderTimeTotal) { else if (trackPosition >= hitObject.getTime() + sliderTimeTotal) {
if (hitObject.getRepeatCount() % 2 == 0) if (hitObject.getRepeatCount() % 2 == 0)
return new float[] { x, y }; return new float[] { x, y };
else { else
int lastIndex = hitObject.getSliderX().length; return curve.pointAt(1);
return new float[] { curve.getX(lastIndex), curve.getY(lastIndex) };
}
} else } else
return curve.pointAt(getT(trackPosition, false)); return curve.pointAt(getT(trackPosition, false));
} }

View File

@ -1609,8 +1609,7 @@ public class Game extends BasicGameState {
/** /**
* Performs stacking calculations on all hit objects, and updates their * Performs stacking calculations on all hit objects, and updates their
* positions if necessary. * positions if necessary.
* https://gist.github.com/peppy/1167470 * @author peppy (https://gist.github.com/peppy/1167470)
* @author peppy
*/ */
private void calculateStacks() { private void calculateStacks() {
// reverse pass for stack calculation // reverse pass for stack calculation
@ -1636,21 +1635,17 @@ public class Game extends BasicGameState {
// possible special case: if slider end in the stack, // possible special case: if slider end in the stack,
// all next hit objects in stack move right down // all next hit objects in stack move right down
if (hitObjectN.isSlider()) { if (hitObjectN.isSlider()) {
Slider slider = (Slider) hitObjects[n]; float[] p1 = hitObjects[i].getPointAt(hitObjectI.getTime());
float x1 = hitObjects[i].getPointAt(hitObjectI.getTime())[0]; float[] p2 = hitObjects[n].getPointAt(hitObjects[n].getEndTime());
float y1 = hitObjects[i].getPointAt(hitObjectI.getTime())[1]; float distance = Utils.distance(p1[0], p1[1], p2[0], p2[1]);
float x2 = slider.getPointAt(slider.getEndTime())[0];
float y2 = slider.getPointAt(slider.getEndTime())[1];
float distance = Utils.distance(x1, y1, x2, y2);
// check if hit object part of this stack // check if hit object part of this stack
if (distance < STACK_LENIENCE * OsuHitObject.getXMultiplier()) { if (distance < STACK_LENIENCE * OsuHitObject.getXMultiplier()) {
int offset = hitObjectI.getStack() - hitObjectN.getStack() + 1; int offset = hitObjectI.getStack() - hitObjectN.getStack() + 1;
for (int j = n + 1; j <= i; j++) { for (int j = n + 1; j <= i; j++) {
OsuHitObject hitObjectJ = osu.objects[j]; OsuHitObject hitObjectJ = osu.objects[j];
x1 = hitObjects[j].getPointAt(hitObjectJ.getTime())[0]; p1 = hitObjects[j].getPointAt(hitObjectJ.getTime());
y1 = hitObjects[j].getPointAt(hitObjectJ.getTime())[1]; distance = Utils.distance(p1[0], p1[1], p2[0], p2[1]);
distance = Utils.distance(x1, y1, x2, y2);
// hit object below slider end // hit object below slider end
if (distance < STACK_LENIENCE * OsuHitObject.getXMultiplier()) if (distance < STACK_LENIENCE * OsuHitObject.getXMultiplier())