Why so many IDs for new objects?
by Jared Schnelle · in Torque Game Engine · 12/14/2002 (11:19 pm) · 5 replies
I've been digging through the ID system in the source, and I notice that when you create a new SimObject, that the function registerObject() gets called quite a few times.
For my new GUI element that I just made, when I add it to the game it takes up 40 ID numbers.
I do a printf to find out what these id numbers are and I get something like:
SimObject Registered ID: 1598
New Gui Element Added: (null)
SimObject Registered ID: 1599 <--Actual Gui Number
New Gui Element Added: (null)
SimObject Registered ID: 1600
New Gui Element Added: InspectStaticprofile_24
SimObject Registered ID: 1601
New Gui Element Added: (null)
SimObject Registered ID: 1602
New Gui Element Added: InspectStatichorizSizing_10
SimObject Registered ID: 1603
New Gui Element Added: (null)
SimObject Registered ID: 1604
New Gui Element Added: InspectStaticvertSizing_10
SimObject Registered ID: 1605
You get the picture, it seems like it assigns an ID number to every element that makes up the GUI. I'm assuming the (null)s are the value that is in the field.
Anyhow, it doesnt seem to do this for datablocks, so why does it do it for Guis? Does it do this to speed up the loading of GUIs? I thought that it worked within the class of the Gui element to look for information that pertains to it, not the ID number.
Anyhow, it's just an obversvation that made me curious.
Any clue?
For my new GUI element that I just made, when I add it to the game it takes up 40 ID numbers.
I do a printf to find out what these id numbers are and I get something like:
SimObject Registered ID: 1598
New Gui Element Added: (null)
SimObject Registered ID: 1599 <--Actual Gui Number
New Gui Element Added: (null)
SimObject Registered ID: 1600
New Gui Element Added: InspectStaticprofile_24
SimObject Registered ID: 1601
New Gui Element Added: (null)
SimObject Registered ID: 1602
New Gui Element Added: InspectStatichorizSizing_10
SimObject Registered ID: 1603
New Gui Element Added: (null)
SimObject Registered ID: 1604
New Gui Element Added: InspectStaticvertSizing_10
SimObject Registered ID: 1605
You get the picture, it seems like it assigns an ID number to every element that makes up the GUI. I'm assuming the (null)s are the value that is in the field.
Anyhow, it doesnt seem to do this for datablocks, so why does it do it for Guis? Does it do this to speed up the loading of GUIs? I thought that it worked within the class of the Gui element to look for information that pertains to it, not the ID number.
Anyhow, it's just an obversvation that made me curious.
Any clue?
About the author
#2
12/15/2002 (1:04 am)
Very interesting... Why is this? Why so many ids? Especially ones associated with null?
#3
const char *name = getName();
Con::printf("New Gui Element Added: %s", name);
If the controls that are being added dont have a "name" because they only hold values, that could explain the nulls. That's why I'm thinking the (null) after every single element, is the value, whether it is a bool, a float, an int, etc.
I did, notice, however that in one of my Gui Controls, that it required 40 IDs to create it. 20 of them were like the above, and the next 20 were a copy of them.
I knew I didnt accidentally create 2 copies, because in the GuiTree in the GuiEditor I'd have something like:
1245 - GuiElementBlah
1285 - GuiElementBlah
1325 - GuiYouGetThePicture
So... got me
12/15/2002 (2:05 am)
I think the null is because:const char *name = getName();
Con::printf("New Gui Element Added: %s", name);
If the controls that are being added dont have a "name" because they only hold values, that could explain the nulls. That's why I'm thinking the (null) after every single element, is the value, whether it is a bool, a float, an int, etc.
I did, notice, however that in one of my Gui Controls, that it required 40 IDs to create it. 20 of them were like the above, and the next 20 were a copy of them.
I knew I didnt accidentally create 2 copies, because in the GuiTree in the GuiEditor I'd have something like:
1245 - GuiElementBlah
1285 - GuiElementBlah
1325 - GuiYouGetThePicture
So... got me
#4
12/19/2002 (9:58 am)
One should be the "template" for the control and the other should be an instance of that control.
#5
12/19/2002 (10:01 am)
If you create GUIs from within the GUI editor, the GUI editor immediately "inspects" the control you just created. As part of the inspection it generates a bunch of controls for the display/editing of the GUI control's fields. During the normal course of execution of the program, these controls will not be created.
Torque Owner Jared Schnelle
%profile = QuickBarSlot1.profile.getId();
echo("Profile ID: " @ %profile);
Sure enough, that echos the ID that is assigned to it. Anyhow, just incase you didnt believe me ;)