Skip to content

Commit 3307094

Browse files
YoshiCrafter29HEIHUAaFrakits
authored
Merge changes from main (#892)
* repair ScriptableShader.shader = null (#877) * optimize updateInput (#878) * optimize updateInput * resize optimize * __notePerStrum optimize * Update StrumLine.hx * NoteGroup optimize (#881) * NoteGroup optimize * CoolUtil.bound faster * makes commit with github desktop W FRAKITS * Use fastSinCos for notes (#889) * Update Strum.hx * Update Strum.hx --------- Co-authored-by: HEIHUAa <112499486+HEIHUAa@users.noreply.github.com> Co-authored-by: Frakits <90983918+Frakits@users.noreply.github.com>
1 parent e9dc588 commit 3307094

6 files changed

Lines changed: 32 additions & 32 deletions

File tree

FEATURES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ _**QOL = Quality of Life**_
7373
- If you need to rearrange the weeks in-game, you can use the `data/weeks/weeks.txt` file.
7474
- Editors for Charts and Characters (Stage coming soon)
7575
- Undos/Redos supported
76-
- Warning on closing unsaved work
76+
- Warning on closing unsaved work.
7777
- Clean UI (for ocd freaks)
7878
- Mature Chart editor (Character editor rework soon)
7979
- Features not found in other editors!

source/funkin/backend/shaders/ScriptableShader.hx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ class ScriptableShader extends FlxBasic implements IHScriptCustomBehaviour {
3030
if((shader is CustomShader)) scriptName = cast(shader, CustomShader).fileName;
3131
else throw "Missing name for shader script, please provide a scriptName, or use CustomShader";
3232

33+
this.shader = shader;
34+
3335
script = Script.create(Paths.script('shaders/$scriptName'));
3436
script.setParent(shader);
3537
script.set("shader", shader);

source/funkin/game/Note.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ class Note extends FlxSprite
311311
}
312312

313313
public function updateSustainClip() if (wasGoodHit && !noSustainClip) {
314-
var t = FlxMath.bound((Conductor.songPosition - strumTime) / height * 0.45 * lastScrollSpeed, 0, 1);
314+
var t = CoolUtil.bound((Conductor.songPosition - strumTime) / height * 0.45 * lastScrollSpeed, 0, 1);
315315
var rect = clipRect == null ? FlxRect.get() : clipRect;
316316
clipRect = rect.set(0, frameHeight * t, frameWidth, frameHeight * (1 - t));
317317
}

source/funkin/game/NoteGroup.hx

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,11 @@ class NoteGroup extends FlxTypedGroup<Note> {
5353
public override function update(elapsed:Float) {
5454
i = length-1;
5555
__loopSprite = null;
56-
__time = __getSongPos();
56+
__time = __getSongPos() + limit;
5757
while(i >= 0) {
5858
__loopSprite = members[i--];
59-
if (__loopSprite == null || !__loopSprite.exists || !__loopSprite.active) {
60-
continue;
61-
}
62-
if (__loopSprite.strumTime - __time > limit)
63-
break;
59+
if (__loopSprite == null || !__loopSprite.exists || !__loopSprite.active) continue;
60+
if (__loopSprite.strumTime > __time) break;
6461
__loopSprite.update(elapsed);
6562
}
6663
}
@@ -74,12 +71,11 @@ class NoteGroup extends FlxTypedGroup<Note> {
7471

7572
i = length-1;
7673
__loopSprite = null;
77-
__time = __getSongPos();
74+
__time = __getSongPos() + limit;
7875
while(i >= 0) {
7976
__loopSprite = members[i--];
80-
if (__loopSprite == null || !__loopSprite.exists || !__loopSprite.visible)
81-
continue;
82-
if (__loopSprite.strumTime - __time > limit) break;
77+
if (__loopSprite == null || !__loopSprite.exists || !__loopSprite.visible) continue;
78+
if (__loopSprite.strumTime > __time) break;
8379
__loopSprite.draw();
8480
}
8581
__currentlyLooping = oldCur;
@@ -97,16 +93,15 @@ class NoteGroup extends FlxTypedGroup<Note> {
9793
public override function forEach(noteFunc:Note->Void, recursive:Bool = false) {
9894
i = length-1;
9995
__loopSprite = null;
100-
__time = __getSongPos();
96+
__time = __getSongPos() + limit;
10197

10298
var oldCur = __currentlyLooping;
10399
__currentlyLooping = true;
104100

105101
while(i >= 0) {
106102
__loopSprite = members[i--];
107-
if (__loopSprite == null || !__loopSprite.exists)
108-
continue;
109-
if (__loopSprite.strumTime - __time > limit) break;
103+
if (__loopSprite == null || !__loopSprite.exists) continue;
104+
if (__loopSprite.strumTime > __time) break;
110105
noteFunc(__loopSprite);
111106
}
112107
__currentlyLooping = oldCur;

source/funkin/game/Strum.hx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,9 @@ class Strum extends FlxSprite {
174174
if (daNote.isSustainNote) offset.y -= height * 0.5;
175175

176176
if (Std.int(daNote.__noteAngle % 360) != 0) {
177-
var noteAngleCos = FlxMath.fastCos(daNote.__noteAngle / PIX180);
178-
var noteAngleSin = FlxMath.fastSin(daNote.__noteAngle / PIX180);
177+
var noteAngle = FlxMath.fastSinCos(daNote.__noteAngle / PIX180);
178+
var noteAngleCos = noteAngle.cos;
179+
var noteAngleSin = noteAngle.sin;
179180

180181
var aOffset:FlxPoint = FlxPoint.get(
181182
(daNote.origin.x / daNote.scale.x) - daNote.offset.x,

source/funkin/game/StrumLine.hx

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ class StrumLine extends FlxTypedGroup<Strum> {
253253
var __notePerStrum:Array<Note> = [];
254254

255255
function __inputProcessPressed(note:Note) {
256-
if (__pressed[note.strumID] && note.isSustainNote && note.sustainParent.wasGoodHit && note.strumTime < __updateNote_songPos && !note.wasGoodHit) {
256+
if (__pressed[note.strumID] && note.isSustainNote && note.strumTime < __updateNote_songPos && !note.wasGoodHit && note.sustainParent.wasGoodHit) {
257257
PlayState.instance.goodNoteHit(this, note);
258258
}
259259
}
@@ -284,9 +284,11 @@ class StrumLine extends FlxTypedGroup<Strum> {
284284

285285
if (cpu) return;
286286

287-
__pressed.resize(members.length);
288-
__justPressed.resize(members.length);
289-
__justReleased.resize(members.length);
287+
if (__pressed.length != members.length) {
288+
__pressed.resize(members.length);
289+
__justPressed.resize(members.length);
290+
__justReleased.resize(members.length);
291+
}
290292

291293
for (i in 0...members.length) {
292294
__pressed[i] = members[i].__getPressed(this);
@@ -304,17 +306,17 @@ class StrumLine extends FlxTypedGroup<Strum> {
304306

305307
__notePerStrum = cast new haxe.ds.Vector(members.length); // [for(_ in 0...members.length) null];
306308

307-
if (__justPressed.contains(true)) {
308-
notes.forEachAlive(__inputProcessJustPressed);
309+
if (__pressed.contains(true)) {
310+
if (__justPressed.contains(true)) {
311+
notes.forEachAlive(__inputProcessJustPressed);
309312

310-
if (!ghostTapping) for (k => pr in __justPressed) if (pr && __notePerStrum[k] == null)
311-
PlayState.instance.noteMiss(this, null, k, ID); // FUCK YOU
312-
}
313+
if (!ghostTapping) for (k => pr in __justPressed) if (pr && __notePerStrum[k] == null)
314+
PlayState.instance.noteMiss(this, null, k, ID); // FUCK YOU
313315

314-
if (__pressed.contains(true)) {
315-
for (e in __notePerStrum)
316-
if (e != null)
317-
PlayState.instance.goodNoteHit(this, e);
316+
for (e in __notePerStrum)
317+
if (e != null)
318+
PlayState.instance.goodNoteHit(this, e);
319+
}
318320

319321
for (c in characters)
320322
if (c.lastAnimContext != DANCE)
@@ -324,7 +326,7 @@ class StrumLine extends FlxTypedGroup<Strum> {
324326
}
325327

326328
forEach(function(str:Strum) {
327-
str.updatePlayerInput(str.__getPressed(this), str.__getJustPressed(this), str.__getJustReleased(this));
329+
str.updatePlayerInput(__pressed[str.ID], __justPressed[str.ID], __justReleased[str.ID]);
328330
});
329331

330332
PlayState.instance.gameAndCharsCall("onPostInputUpdate");

0 commit comments

Comments
 (0)