1.1.3 Running path in level can create thousands of extra nodes.
by Dave Calabrese · in Torque Game Builder · 12/11/2006 (9:39 am) · 8 replies
I've managed to create a path which every single time I 'play' the level that it is in, the node count goes from 11 to anywhere between 88 and 1400 (which slows down TGB, and sometimes outright causes a total freeze / crash). The path code is this:
new t2dPath(WindowPath) {
pathType = "LINEAR";
canSaveDynamicFields = "1";
position = "18.984 43.064";
size = "211.968 0.234";
FlipY = "1";
MountOffset = "0.193 0.003";
MountOwned = "0";
MountInheritAttributes = "0";
mountID = "3";
mountToID = "2";
node0 = "124.950203 43.185276 0.000000 10.000000";
node1 = "87.251961 43.099064 0.000000 10.000000";
node10 = "-87.017738 42.951481 0.000000 10.000000";
node2 = "67.887749 42.957108 0.000000 10.000000";
node3 = "48.523758 42.957016 0.000000 10.000000";
node4 = "29.143747 43.123287 0.000000 10.000000";
node5 = "9.800861 43.135723 0.000000 10.000000";
node6 = "-9.575010 42.980633 0.000000 10.000000";
node7 = "-28.930784 43.042992 0.000000 10.000000";
node8 = "-48.285950 43.136963 0.000000 10.000000";
node9 = "-67.621315 42.981621 0.000000 10.000000";
nodeCount = "11";
object0 = "4 10 1 150.000000 1 1 0.000000 1 WRAP";
objectCount = "0";
};About the author
Recent Threads
#2
Here's a repro:
Place down a path with 3 nodes in it.
Place down an object (like a static sprite or a scroller or whatever).
Save the game (the path in the level.t2d will have 3 nodes).
Copy the sprite/scroller and paste.
Save the game (the path in the level.t2d will have 6 nodes).
Every time you paste you'll paste down an extra 3 nodes.
If you copy something else, and paste that, you'll be copying all the duplicate nodes too, so basically every time you copy+paste you double the amount of nodes in the level :(
I'll keep looking...
12/11/2006 (3:55 pm)
Okay. Earlier on I noticed copying and pasting going slower.Here's a repro:
Place down a path with 3 nodes in it.
Place down an object (like a static sprite or a scroller or whatever).
Save the game (the path in the level.t2d will have 3 nodes).
Copy the sprite/scroller and paste.
Save the game (the path in the level.t2d will have 6 nodes).
Every time you paste you'll paste down an extra 3 nodes.
If you copy something else, and paste that, you'll be copying all the duplicate nodes too, so basically every time you copy+paste you double the amount of nodes in the level :(
I'll keep looking...
#3
12/14/2006 (12:21 pm)
Okay, I can also now confirm that this is caused by copy/pasting _ANYTHING_ while paths exist in the level. All paths present in the open level will have their nodes doubled every time you press Ctrl-V, it doesn't matter what you are copying and pasting.
#4
This is similar, if not exactly what was happening in 1.1.2.
Although anoying, it seemed pretty specific to those instances where you've recently created the path.
http://www.garagegames.com/mg/forums/result.thread.php?qt=52519
However, I haven't tried in v1.1.3 so maybe it's worse... ?
12/30/2006 (12:56 pm)
Heya guys,This is similar, if not exactly what was happening in 1.1.2.
Although anoying, it seemed pretty specific to those instances where you've recently created the path.
http://www.garagegames.com/mg/forums/result.thread.php?qt=52519
However, I haven't tried in v1.1.3 so maybe it's worse... ?
#5
1.) Open any saved level that contains a path.
2.) Copy any object in your level. Anything, doesn't matter what.
3.) Paste the object.
Now look at all your paths. Their node counts have all been doubled. Every time you hit 'Paste', they will be doubled again.
Pretty severe bug, imo. I don't have the time myself to fish through engine code to see what the problem may be, however I hope someone else does because this is very difficult to work with! For now, I've copied all path data out of my levels and stored them in a text file, then when I finish the level I place the paths back into the .T2D files.
01/06/2007 (1:11 pm)
This actually occurs, at least in v1.1.3, if any path exists in your level. I can duplicate it by doing the following, and this never fails:1.) Open any saved level that contains a path.
2.) Copy any object in your level. Anything, doesn't matter what.
3.) Paste the object.
Now look at all your paths. Their node counts have all been doubled. Every time you hit 'Paste', they will be doubled again.
Pretty severe bug, imo. I don't have the time myself to fish through engine code to see what the problem may be, however I hope someone else does because this is very difficult to work with! For now, I've copied all path data out of my levels and stored them in a text file, then when I finish the level I place the paths back into the .T2D files.
#6
Can any official garage games team member tell us if there's a fix in the pipeline?
01/08/2007 (10:53 am)
Yeah, I haven't had the chance to look into it. I've just deleted my splines and don't use copy and paste for now.Can any official garage games team member tell us if there's a fix in the pipeline?
#7
I had a moment tonight to check out this problem. Turns out it was a problem in the readFieldsPostLoad method that was mentioned above. I've fashioned together a fix for those of you that are Pro users.
This fix will exist in the next release of TGB, thanks!
t2dPath.h - Add the bold method declaration below
t2dPath.cc - Add the findNode method body somewhere (I put mine near addNode)
t2dPath.cc - Add the sanity check to readFieldsPostLoad
The problem was that this function is being called when objects are pasted onto the level. The reason it's being called is because this method (readFieldsPostLoad) is called by the scenegraph during post load processing of mount points and the like. Anyways, thanks for finding and reporting this, sorry it's taken so long to get back to you all.
Cheers,
-Justin
01/10/2007 (9:44 pm)
Hey Guys,I had a moment tonight to check out this problem. Turns out it was a problem in the readFieldsPostLoad method that was mentioned above. I've fashioned together a fix for those of you that are Pro users.
This fix will exist in the next release of TGB, thanks!
t2dPath.h - Add the bold method declaration below
// Node management.
S32 addNode(t2dVector position, F32 rotation, F32 weight, S32 location = -1);
[b] // Returns the node index or -1 if no matches
S32 findNode( t2dVector position, F32 rotation, F32 weight );
[/b] S32 removeNode(U32 index);
void clear();
S32 getNodeCount() const { return mNodes.size(); };t2dPath.cc - Add the findNode method body somewhere (I put mine near addNode)
S32 t2dPath::findNode( t2dVector position, F32 rotation, F32 weight )
{
S32 nodeCount = mNodes.size();
for( S32 nI = 0; nI < nodeCount; nI++ )
{
PathNode &pNode = mNodes[ nI ];
// Check P/R/W
if( pNode.position == position &&
pNode.rotation == rotation &&
pNode.weight == weight )
return nI;
}
// No match
return -1;
}t2dPath.cc - Add the sanity check to readFieldsPostLoad
void t2dPath::readFieldsPostLoad()
{
...
for (S32 i = 0; i < nodeCount; i++)
{
char nodeIndex[4];
dSprintf(nodeIndex, 4, "%d", i);
const char* nodeData = getDataField(StringTable->insert("node"), nodeIndex);
t2dVector position;
F32 rotation, weight;
dSscanf(nodeData, "%f %f %f %f", &position.mX, &position.mY, &rotation, &weight);
[b] // Only add if this node doesn't exist
if( findNode( position, rotation, weight ) == -1 )[/b]
addNode(position, rotation, weight);
setDataField(StringTable->insert("node"), nodeIndex, "");
}
...The problem was that this function is being called when objects are pasted onto the level. The reason it's being called is because this method (readFieldsPostLoad) is called by the scenegraph during post load processing of mount points and the like. Anyways, thanks for finding and reporting this, sorry it's taken so long to get back to you all.
Cheers,
-Justin
#8
01/10/2007 (9:46 pm)
Justin... you just became my personal savior. Well... next to Sepheroth. I'll hang a wallscroll of you next to one of him.
Torque Owner Mark Rose
Now the levels are loading slower and slower. Even in the editor, let alone in game. Started debugging, I found that the following function was taking *ages*.
void t2dPath::readFieldsPostLoad()
The biggest path I have has just 4 nodes.
S32 nodeCount = dAtoi(getDataField(StringTable->insert("nodeCount"), NULL));
nodeCount was 24,576 :O
I've looked in the Level.t2d file, and sure enough, the nodes have been duplicated. I now have paths with 10's of thousands of nodes in them, instead of just a few.
I gotta go to bed soon, so won't post a fix until probably Wednesday at the earliest. If anyone else gets a chance to look into it that'd be sweet :)
hint: the nodes are all duplicated.. see this extract from my level...
node992 = "4808.000000 -56.000008 0.000000 10.000000";
node993 = "4696.000000 -56.000008 0.000000 10.000000";
node994 = "4696.000000 56.000011 0.000000 10.000000";
node995 = "4808.000000 56.000011 0.000000 10.000000";
// repeats
node996 = "4808.000000 -56.000008 0.000000 10.000000";
node997 = "4696.000000 -56.000008 0.000000 10.000000";
node998 = "4696.000000 56.000011 0.000000 10.000000";
node999 = "4808.000000 56.000011 0.000000 10.000000";
I'm gonna delete them by hand so I can load my level for now :)