Skip to content

Commit 9d96400

Browse files
authored
NoteGroup optimize (#881)
* NoteGroup optimize * CoolUtil.bound faster
1 parent 8fc1493 commit 9d96400

2 files changed

Lines changed: 10 additions & 15 deletions

File tree

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;

0 commit comments

Comments
 (0)