Huge optimization
This commit is contained in:
@@ -8,6 +8,14 @@ class NoteGroup extends FlxTypedGroup<Note> {
|
||||
var i:Int = 0;
|
||||
var __currentlyLooping:Bool = false;
|
||||
|
||||
/**
|
||||
* Preallocates the members array with nulls, but if theres anything before it clears it
|
||||
**/
|
||||
public inline function preallocate(len:Int) {
|
||||
members = cast new haxe.ds.Vector<Note>(len);
|
||||
length = len;
|
||||
}
|
||||
|
||||
public inline function addNotes(notes:Array<Note>) {
|
||||
for(e in notes) add(e);
|
||||
sortNotes();
|
||||
|
||||
@@ -97,18 +97,41 @@ class StrumLine extends FlxTypedGroup<Strum> {
|
||||
}
|
||||
|
||||
public function generate(strumLine:ChartStrumLine, ?startTime:Float) {
|
||||
// TODO: implement double generate call support if needed
|
||||
|
||||
var total = 0;
|
||||
if (strumLine.notes != null) for(note in strumLine.notes) {
|
||||
if (startTime != null && startTime > note.time)
|
||||
continue;
|
||||
|
||||
notes.add(new Note(this, note, false));
|
||||
total++;
|
||||
|
||||
if (note.sLen > Conductor.stepCrochet * 0.75) {
|
||||
var len:Float = note.sLen;
|
||||
while(len > 10) {
|
||||
total++;
|
||||
len -= Math.min(len, Conductor.stepCrochet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
notes.preallocate(total);
|
||||
notes.length = total;
|
||||
|
||||
var il = 0;
|
||||
|
||||
if (strumLine.notes != null) for(note in strumLine.notes) {
|
||||
if (startTime != null && startTime > note.time)
|
||||
continue;
|
||||
|
||||
notes.members[total-(il++)-1] = new Note(this, note, false);
|
||||
|
||||
if (note.sLen > Conductor.stepCrochet * 0.75) {
|
||||
var len:Float = note.sLen;
|
||||
var curLen:Float = 0;
|
||||
while(len > 10) {
|
||||
curLen = Math.min(len, Conductor.stepCrochet);
|
||||
notes.add(new Note(this, note, true, curLen, note.sLen - len));
|
||||
notes.members[total-(il++)-1] = new Note(this, note, true, curLen, note.sLen - len);
|
||||
len -= curLen;
|
||||
}
|
||||
}
|
||||
@@ -248,6 +271,12 @@ class StrumLine extends FlxTypedGroup<Strum> {
|
||||
add(createStrum(i));
|
||||
}
|
||||
|
||||
override function destroy() {
|
||||
super.destroy();
|
||||
if(startingPos != null)
|
||||
startingPos.put();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a strum and returns the created strum (needs to be added manually).
|
||||
* @param i Index of the strum
|
||||
|
||||
@@ -48,8 +48,6 @@ class Assets
|
||||
{
|
||||
public static var cache:IAssetCache = new AssetCache();
|
||||
|
||||
public static var forceAssetLibrary:LimeAssetLibrary = null;
|
||||
|
||||
@:noCompletion private static var dispatcher:EventDispatcher #if !macro = new EventDispatcher() #end;
|
||||
private static var libraryBindings:Map<String, AssetLibrary> = new Map();
|
||||
|
||||
@@ -78,9 +76,6 @@ class Assets
|
||||
**/
|
||||
public static function exists(id:String, type:AssetType = null):Bool
|
||||
{
|
||||
if(forceAssetLibrary != null) {
|
||||
return forceAssetLibrary.exists(id, cast type);
|
||||
}
|
||||
#if lime
|
||||
return LimeAssets.exists(id, cast type);
|
||||
#else
|
||||
@@ -265,9 +260,6 @@ class Assets
|
||||
**/
|
||||
public static function getPath(id:String):String
|
||||
{
|
||||
if(forceAssetLibrary != null) {
|
||||
return forceAssetLibrary.getPath(id);
|
||||
}
|
||||
#if lime
|
||||
return LimeAssets.getPath(id);
|
||||
#else
|
||||
@@ -325,9 +317,6 @@ class Assets
|
||||
**/
|
||||
public static function getText(id:String):String
|
||||
{
|
||||
if(forceAssetLibrary != null) {
|
||||
return forceAssetLibrary.getText(id);
|
||||
}
|
||||
#if lime
|
||||
return LimeAssets.getText(id);
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user