attemt to fix shrinking sliders with odd amount of repeats with merged slider rendering

This commit is contained in:
yugecin 2016-12-04 21:52:15 +01:00
parent 50f475e0f7
commit a3af1c71b8
4 changed files with 32 additions and 8 deletions

View File

@ -383,9 +383,7 @@ public class Slider extends GameObject {
if (repeats % 2 == 0 && curveIntervalTo == 1 && !reversed) {
// fix shrinking sliders for odd repeating sliders
reversed = true;
if (Options.isMergingSliders()) {
} else {
if (!Options.isMergingSliders()) {
curve.reverse();
}
}
@ -396,7 +394,12 @@ public class Slider extends GameObject {
}
if (Options.isMergingSliders()) {
if (Options.isShrinkingSliders() && curveIntervalFrom > 0) {
game.setSlidercurveFrom(baseSliderFrom + (int) (curveIntervalFrom * curve.getCurvePoints().length));
int curvelen = curve.getCurvePoints().length;
if (repeats % 2 == 0) {
game.spliceSliderCurve(baseSliderFrom + (int) ((1f - curveIntervalFrom) * curvelen), baseSliderFrom + curvelen);
} else {
game.setSlidercurveFrom(baseSliderFrom + (int) (curveIntervalFrom * curvelen));
}
}
game.setSlidercurveTo(baseSliderFrom + (int) (curveIntervalTo * curve.getCurvePoints().length));
} else {
@ -587,7 +590,7 @@ public class Slider extends GameObject {
// calculate and send slider result
hitResult();
if (Options.isMergingSliders()) {
game.setSlidercurveFrom(baseSliderFrom + curve.getCurvePoints().length);
game.setSlidercurveFrom(baseSliderFrom + curve.getCurvePoints().length + 1);
}
return true;
}

View File

@ -160,11 +160,13 @@ public abstract class Curve {
}
public void reverse() {
if (renderState == null)
renderState = new CurveRenderState(hitObject, curve);
renderState.reverse();
}
public void splice(int from, int to) {
renderState.splice(from, to);
}
/**
* Returns the angle of the first control point.
*/

View File

@ -68,6 +68,9 @@ public class CurveRenderState {
private boolean reversed;
private int spliceFrom;
private int spliceTo;
/**
* Set the width and height of the container that Curves get drawn into.
* Should be called before any curves are drawn.
@ -113,12 +116,20 @@ public class CurveRenderState {
//write impossible value to make sure the fbo is cleared
lastPointDrawn = -1;
reversed = false;
spliceFrom = spliceTo = -1;
}
public void reverse() {
reversed = !reversed;
}
public void splice(int from, int to) {
spliceFrom = from * 2;
spliceTo = to * 2;
firstPointDrawn = -1; // force redraw
lastPointDrawn = -1; // force redraw
}
/**
* Draw a curve to the screen that's tinted with `color`. The first time
* this is called this caches the image result of the curve and on subsequent
@ -336,8 +347,12 @@ public class CurveRenderState {
from = curve.length * 2 - 1 - to;
to = curve.length * 2 - 1 - a;
}
for (int i = from; i < to; ++i)
for (int i = from; i < to; ++i) {
if (spliceFrom <= i && i <= spliceTo) {
continue;
}
GL11.glDrawArrays(GL11.GL_TRIANGLE_FAN, i * (NewCurveStyleState.DIVIDES + 2), NewCurveStyleState.DIVIDES + 2);
}
GL11.glFlush();
GL20.glDisableVertexAttribArray(staticState.texCoordLoc);
GL20.glDisableVertexAttribArray(staticState.attribLoc);

View File

@ -1523,6 +1523,10 @@ public class Game extends BasicGameState {
this.slidercurveTo = Math.max(pos, this.slidercurveTo);
}
public void spliceSliderCurve(int from, int to) {
this.knorkesliders.splice(from, to);
}
/**
* Draws hit objects, hit results, and follow points.
* @param g the graphics context