[BUG 1.1B1] GuiListBoxCtrl::getItemObject is broken - RESOLVED
by Dusty Monk · in Torque 3D Professional · 07/08/2010 (9:12 pm) · 2 replies
in the function SimObject *GuiListBoxCtrl::getItemObject it's doing the wrong thing. Here is the original code:
It uses the itemData member as if it were an ID to an object. But if you examine the code above this in the module, you'll see that insertItem already does the lookup, and what is actually stored at itemData is the actual pointer to the object already. So no lookup is necessary.. we just cast and return. Here's my fix:
Word.
Coincidentally, this fixed another problem that I was tracking down, which was that exporting interior objects as collada was not working. They simply weren't getting pulled out of the list if you selected one. Once the list was working correctly, the objects are now exporting correctly. This is huge for me, and might be good for you, because it means I can now create simple objects in Constructor, using my l33t programmer art skillz, bring them into the mission editor as .DIF's, export them as collada's, and then actually insert them into the level as .DTS's. This keeps everything as a static mesh, and gives me much finer control over the material parameters using the shape editor.
Dusty
SimObject* GuiListBoxCtrl::getItemObject( S32 index )
{
// Range Checking
if( index > mItems.size() || index < 0 )
{
Con::warnf( "GuiListBoxCtrl::getItemObject - index out of range!" );
return NULL;
}
SimObject *outObj;
Sim::findObject( (SimObjectId)(mItems[ index ]->itemData), outObj );
return outObj;
}It uses the itemData member as if it were an ID to an object. But if you examine the code above this in the module, you'll see that insertItem already does the lookup, and what is actually stored at itemData is the actual pointer to the object already. So no lookup is necessary.. we just cast and return. Here's my fix:
SimObject* GuiListBoxCtrl::getItemObject( S32 index )
{
// Range Checking
if( index > mItems.size() || index < 0 )
{
Con::warnf( "GuiListBoxCtrl::getItemObject - index out of range!" );
return NULL;
}
// WS START - Bug Fix - this does the wrong thing. The item inserted into
// the list is *already* the pointer to the object. Not its ID.
SimObject *outObj;
//Sim::findObject( (SimObjectId)(mItems[ index ]->itemData), outObj );
outObj = static_cast<SimObject *>(mItems[index]->itemData);
return outObj;
}Word.
Coincidentally, this fixed another problem that I was tracking down, which was that exporting interior objects as collada was not working. They simply weren't getting pulled out of the list if you selected one. Once the list was working correctly, the objects are now exporting correctly. This is huge for me, and might be good for you, because it means I can now create simple objects in Constructor, using my l33t programmer art skillz, bring them into the mission editor as .DIF's, export them as collada's, and then actually insert them into the level as .DTS's. This keeps everything as a static mesh, and gives me much finer control over the material parameters using the shape editor.
Dusty
About the author
Dusty Monk is founder and president of Windstorm Studios, an independant game studio. Formerly a sr. programmer at Ensemble Studios, Dusty has worked on AAA titles such as Age of Empires II & III, and Halo Wars.
Full Sail QA&U Lab Intern