mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-12-26 15:07:14 +00:00
Resolved lag issues caused by creating too many notes in the pool.
This commit is contained in:
parent
3c218ec01c
commit
a6daf3b0d6
|
@ -146,7 +146,7 @@ class ChartEditorEventSprite extends FlxSprite
|
|||
/**
|
||||
* Return whether this event is currently visible.
|
||||
*/
|
||||
public function isNoteVisible(viewAreaBottom:Float, viewAreaTop:Float):Bool
|
||||
public function isEventVisible(viewAreaBottom:Float, viewAreaTop:Float):Bool
|
||||
{
|
||||
// True if the note is above the view area.
|
||||
var aboveViewArea = (this.y + this.height < viewAreaTop);
|
||||
|
@ -160,7 +160,7 @@ class ChartEditorEventSprite extends FlxSprite
|
|||
/**
|
||||
* Return whether an event, if placed in the scene, would be visible.
|
||||
*/
|
||||
public static function wouldNoteBeVisible(viewAreaBottom:Float, viewAreaTop:Float, eventData:SongEventData, ?origin:FlxObject):Bool
|
||||
public static function wouldEventBeVisible(viewAreaBottom:Float, viewAreaTop:Float, eventData:SongEventData, ?origin:FlxObject):Bool
|
||||
{
|
||||
var noteHeight:Float = ChartEditorState.GRID_SIZE;
|
||||
var notePosY:Float = eventData.stepTime * ChartEditorState.GRID_SIZE;
|
||||
|
|
|
@ -52,6 +52,7 @@ class ChartEditorHoldNoteSprite extends SustainTrail
|
|||
strumTime = 999999999;
|
||||
missedNote = false;
|
||||
hitNote = false;
|
||||
active = true;
|
||||
visible = true;
|
||||
alpha = 1.0;
|
||||
width = graphic.width / 8 * zoom; // amount of notes * 2
|
||||
|
@ -64,6 +65,19 @@ class ChartEditorHoldNoteSprite extends SustainTrail
|
|||
setup();
|
||||
}
|
||||
|
||||
public override function kill():Void
|
||||
{
|
||||
super.kill();
|
||||
|
||||
active = false;
|
||||
visible = false;
|
||||
noteData = null;
|
||||
strumTime = 999999999;
|
||||
noteDirection = 0;
|
||||
sustainLength = 0;
|
||||
fullSustainLength = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether this note is currently visible.
|
||||
*/
|
||||
|
|
|
@ -2329,8 +2329,11 @@ class ChartEditorState extends HaxeUIState
|
|||
if (!ChartEditorHoldNoteSprite.wouldHoldNoteBeVisible(viewAreaBottomPixels, viewAreaTopPixels, noteData, renderedHoldNotes)) continue;
|
||||
|
||||
// Hold note should be rendered.
|
||||
var holdNoteSprite:ChartEditorHoldNoteSprite = renderedHoldNotes.recycle(() -> new ChartEditorHoldNoteSprite(this));
|
||||
trace('Creating new HoldNote... (${renderedHoldNotes.members.length})');
|
||||
var holdNoteFactory = function() {
|
||||
// TODO: Print some kind of warning if `renderedHoldNotes.members` is too high?
|
||||
return new ChartEditorHoldNoteSprite(this);
|
||||
}
|
||||
var holdNoteSprite:ChartEditorHoldNoteSprite = renderedHoldNotes.recycle(holdNoteFactory);
|
||||
|
||||
var noteLengthPixels:Float = noteData.stepLength * GRID_SIZE;
|
||||
|
||||
|
@ -2388,6 +2391,12 @@ class ChartEditorState extends HaxeUIState
|
|||
// Sort the events DESCENDING. This keeps the sustain behind the associated note.
|
||||
renderedEvents.sort(FlxSort.byY, FlxSort.DESCENDING);
|
||||
}
|
||||
|
||||
// Add a debug value which displays the current size of the note pool.
|
||||
// The pool will grow as more notes need to be rendered at once.
|
||||
// If this gets too big, something needs to be optimized somewhere! -Eric
|
||||
FlxG.watch.addQuick("tapNotesRendered", renderedNotes.members.length);
|
||||
FlxG.watch.addQuick("holdNotesRendered", renderedHoldNotes.members.length);
|
||||
}
|
||||
|
||||
function buildSelectionSquare():FlxSprite
|
||||
|
@ -3095,6 +3104,17 @@ class ChartEditorState extends HaxeUIState
|
|||
#end
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the voices group.
|
||||
*/
|
||||
public function clearVocals():Void
|
||||
{
|
||||
audioVocalTrackGroup.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a vocal track for a given song and character and add it to the voices group.
|
||||
*/
|
||||
public function loadVocalsFromAsset(path:String, charKey:String = null):Bool
|
||||
{
|
||||
var vocalTrack:FlxSound = FlxG.sound.load(path, 1.0, false);
|
||||
|
@ -3156,6 +3176,8 @@ class ChartEditorState extends HaxeUIState
|
|||
|
||||
sortChartData();
|
||||
|
||||
clearVocals();
|
||||
|
||||
loadInstrumentalFromAsset(Paths.inst(songId));
|
||||
|
||||
var voiceList:Array<String> = song.getDifficulty(selectedDifficulty).buildVoiceList();
|
||||
|
|
Loading…
Reference in a new issue