+ minor queue optimization

+ reordered parseAsync params to group them logically
This commit is contained in:
makc
2012-11-29 21:26:03 +01:00
parent be72116dc8
commit 5ed4708034

View File

@@ -89,8 +89,8 @@ package alternativa.engine3d.loaders {
* If you need to download textures, use class <code>TexturesLoader</code>. * If you need to download textures, use class <code>TexturesLoader</code>.
* <p>Path to collada file should match with <code>URI</code> specification. E.g., <code>file:///C:/test.dae</code> or <code>/C:/test.dae</code> for the full paths and <code>test.dae</code>, <code>./test.dae</code> in case of relative.</p> * <p>Path to collada file should match with <code>URI</code> specification. E.g., <code>file:///C:/test.dae</code> or <code>/C:/test.dae</code> for the full paths and <code>test.dae</code>, <code>./test.dae</code> in case of relative.</p>
* *
* @param data <code>XML</code> data type of collada.
* @param onComplete Callback function accepting ParserCollada object as its argument. * @param onComplete Callback function accepting ParserCollada object as its argument.
* @param data <code>XML</code> data type of collada.
* @param baseURL Path to textures relative to swf-file (Or file name only in case of <code>trimPaths=true</code>). * @param baseURL Path to textures relative to swf-file (Or file name only in case of <code>trimPaths=true</code>).
* @param trimPaths Use file names only, without paths. * @param trimPaths Use file names only, without paths.
* *
@@ -99,7 +99,7 @@ package alternativa.engine3d.loaders {
* @see #hierarchy * @see #hierarchy
* @see #materials * @see #materials
*/ */
public function parseAsync(data:XML, onComplete:Function, baseURL:String = null, trimPaths:Boolean = false):void { public function parseAsync(onComplete:Function, data:XML, baseURL:String = null, trimPaths:Boolean = false):void {
init(); init();
var document:DaeDocument = new DaeDocument(data, 0); var document:DaeDocument = new DaeDocument(data, 0);
@@ -220,12 +220,17 @@ package alternativa.engine3d.loaders {
private var queue:Vector.<QueueElement> = new Vector.<QueueElement> (); private var queue:Vector.<QueueElement> = new Vector.<QueueElement> ();
private function addNodesToQueue(nodes:Vector.<DaeNode>, parent:Object3D, skinsOnly:Boolean):void { private function addNodesToQueue(nodes:Vector.<DaeNode>, parent:Object3D, skinsOnly:Boolean):void {
for (var j:int = 0; j < queue.length; j++) {
if (queue[j].element is DaeNode) {
break;
}
}
for (var i:int = nodes.length; i > 0; i--) { for (var i:int = nodes.length; i > 0; i--) {
var args:QueueElement = new QueueElement; var args:QueueElement = new QueueElement;
args.element = nodes[i - 1]; args.element = nodes[i - 1];
args.parent = parent; args.parent = parent;
args.skinsOnly = skinsOnly; args.skinsOnly = skinsOnly;
queue.unshift(args); queue.splice(j, 0, args);
} }
} }