RC3: Copy and Paste really slow
by Tom Spilman · in Torque Game Builder · 06/19/2006 (8:17 pm) · 1 replies
We're working on a fairly large level in LevelBuilder and we've come across some performance problems with Copy and Paste operations.
Our current level has over 400 scene objects in it. When we started Copy and Paste was really quick and we used to populate a lot of the level like that, but now it's super slow. The copy part is fast actually and isn't a problem. The paste can take upwards of 15 seconds to complete.
Aside from this issue our level performs beautifully... we get over 200 fps on my X1800 and 90 fps on my 6600 GT.
Our current level has over 400 scene objects in it. When we started Copy and Paste was really quick and we used to populate a lot of the level like that, but now it's super slow. The copy part is fast actually and isn't a problem. The paste can take upwards of 15 seconds to complete.
Aside from this issue our level performs beautifully... we get over 200 fps on my X1800 and 90 fps on my 6600 GT.
About the author
Tom is a programmer and co-owner of Sickhead Games, LLC.
Associate Tom Spilman
Sickhead Games
function levelBuilderPaste(%val) { if (%val) { %undo = new UndoScriptAction() { actionName = "Paste"; class = UndoPasteAction; }; %undo.objectList = new SimSet(); // When we make the switch to fileObject.writeObject for loading and saving, this // will be much nicer. %objectList = $currentSceneGraph.getSceneObjectList(); addToLevelCallback($levelBuilderClipboardFile); %newObjectList = $currentSceneGraph.getSceneObjectList(); // Anything in the new list but not in the old list was just added. for (%i = 0; %i < getWordCount(%newObjectList); %i++) { %obj = getWord(%newObjectList, %i); %found = false; for (%j = 0; %j < getWordCount(%objectList); %j++) { if (getWord(%objectList, %j) == %obj) %found = true; } if (!%found) %undo.objectList.add(%obj); } if (%undo.objectList.getCount() > 0) %undo.addToManager(LevelBuilderUndoManager); } }This is gonna be ungodly slow on big levels. Gonna look into optimizing the script some, but it might be best to to convert some of this to C++ code.