Allow pointers in place of names

What it says on the tin: a place to discuss proposed new features.
Post Reply
User avatar
ImpalerWrG
Gnoblar
Posts: 15
Joined: Sat Feb 27, 2010 7:42 am

Allow pointers in place of names

Post by ImpalerWrG »

I'm CONSTANTLY running into situations ware their is NOT OPTION other then to use string based names to create and reference common objects in OGRE. This whole string system for most of the key objects is nice and I can see how it lets you quickly get a simple application off the group or reference your resources easily. But it is a major pain when your forced to use it, especially if your procedurally generating most of your resources as I am. It should be trivial to provide both a Create(const String & name) and Create(objectPtr sourceObject), especially when the former is just going to pass the name argument into some search to get back the pointer anyways, have it call the later and we will have both options without having to write more then a few lines.

This has happened several times but my current mess is with creating Entities, I have no choice but to provide a Mesh name, their is no way to create from a MeshPtr. The docs graciously say that the Mesh will be loaded if it isn't already which is good just-in-time, but from what I can tell their is no way to check if a Mesh exists by name (why bother when its JIT). But no one seems to have considered how this screws Meshes procedurally generated from manualObjects. I'm having to generate every possible Mesh that might be needed at startup as I have no way to test for and do a just-in-time myself, at least not without reinventing the wheel and doing a whole system of hashing the Manual Object inputs into some ugly strings, and give that string to the SceneManager all just to get back the pointer that was returned when I made the Mesh but can't use!

This is far from the only instance of this problem, it's all through the code, a total over-reliance of this design for everything! It's nearly impossible to use pointers in an Ogre program, the code needs to be systematically gone through and have pointer argument functions added in the places ware they are missing so we have the option of using either type of argument.
Companions the creator seeks, not corpses, not herds and believers. Fellow creators, the creator seeks - those who write new values on new tablets. Companions the creator seeks, and fellow harvesters; for everything about him is ripe for the harvest.
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: Allow pointers in place of names

Post by Kojack »

but from what I can tell their is no way to check if a Mesh exists by name
if(MeshManager::getSingleton().getByName("mymesh").isNull())
{
//the mesh doesn't exist
}

Removing the need for names in everything was going to be one of the features of Ogre 2.0 (as part of the scene manager redesign), although with Sinbad gone the roadmap for 2.0 could end up being different.
It's definitely something many of us would like.
User avatar
PolyVox
OGRE Contributor
OGRE Contributor
Posts: 1316
Joined: Tue Nov 21, 2006 11:28 am
Location: Groningen, The Netherlands
x 18
Contact:

Re: Allow pointers in place of names

Post by PolyVox »

Personally I just convert my pointer into a string :-)

Using Qt:

Code: Select all

std::string objAddressAsString = QString::number(reinterpret_cast<qulonglong>(pObj), 16).toStdString();
User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
x 56
Contact:

Re: Allow pointers in place of names

Post by Klaim »

Removing the need for names in everything was going to be one of the features of Ogre 2.0 (as part of the scene manager redesign), although with Sinbad gone the roadmap for 2.0 could end up being different.
It's definitely something many of us would like.
It wasn't for Ogre 1.8?
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: Allow pointers in place of names

Post by Kojack »

Hmm, it might have been for 1.8. It's not in the wiki roadmap for 1.8 or 2.0.
I thought it was scheduled for 2.0 because that's when the new scene manager design was going to be implemented (scenenodes optional, async updates, large world, render one scene with multiple scenemanagers, etc).
User avatar
ImpalerWrG
Gnoblar
Posts: 15
Joined: Sat Feb 27, 2010 7:42 am

Re: Allow pointers in place of names

Post by ImpalerWrG »

Thanks for the help and I'm glad to hear this is at least planned (however nebulous it may be), If I ever start compiling OGRE for myself (I'm currently using SDK) I may try to send you some patches to add a few of these, though I'm not going to be able to be systematic about it.

I suspected the MeshManager was the place to check but I just assumed that asking it for a non-existent Mesh would cause it to go boom because that's generally the behavior I've come to expect from asking for any non-existent object by name, thus I was looking for something with a bool return which would clearly be safe, such as SceneManager::hasEntity.
Companions the creator seeks, not corpses, not herds and believers. Fellow creators, the creator seeks - those who write new values on new tablets. Companions the creator seeks, and fellow harvesters; for everything about him is ripe for the harvest.
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: Allow pointers in place of names

Post by Kojack »

Yep, it's a little confusing. I didn't actually know getByName returned a null instead of throwing an exception like some other functions until your question, I went into the source to check if there was a hasMesh or similar query, but noticed the comments on the getByName instead. :)
CABAListic
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 2903
Joined: Thu Jan 18, 2007 2:48 pm
x 58
Contact:

Re: Allow pointers in place of names

Post by CABAListic »

For this particular instance you might want to submit a papercut ;)
On more general terms, yes, a string-less interface is on our agenda, but no concrete work has been done yet.
User avatar
ImpalerWrG
Gnoblar
Posts: 15
Joined: Sat Feb 27, 2010 7:42 am

Re: Allow pointers in place of names

Post by ImpalerWrG »

Ok I hope I got the various settings correct for the Report, have a look see

http://www.ogre3d.org/mantis/view.php?id=368

Are you interested in more Pointer-vs-String type Functions which might be useful being submitted under this same Papercut class in order to chip away at the string-less interface goal?
Companions the creator seeks, not corpses, not herds and believers. Fellow creators, the creator seeks - those who write new values on new tablets. Companions the creator seeks, and fellow harvesters; for everything about him is ripe for the harvest.
CABAListic
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 2903
Joined: Thu Jan 18, 2007 2:48 pm
x 58
Contact:

Re: Allow pointers in place of names

Post by CABAListic »

By all means, go ahead. :)
Post Reply