Change Entities name after creation?

What it says on the tin: a place to discuss proposed new features.
mude
Halfling
Posts: 47
Joined: Tue Dec 21, 2010 1:46 pm

Change Entities name after creation?

Post by mude »

Is it possible? I can't find anything about it, why it's not allowed?
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 538

Re: Change Entities name after creation?

Post by Kojack »

All entities are stored in a map, using the name as the key. It's not possible to change the key of an item in a map (it would break the tree hierarchy used for searching).
bstone
OGRE Expert User
OGRE Expert User
Posts: 1920
Joined: Sun Feb 19, 2012 9:24 pm
Location: Russia
x 201

Re: Change Entities name after creation?

Post by bstone »

Yeah, if you want to associate entity with a name that can be updated you could use Entity::setUserAny() and Entity::getUserAny().
User avatar
mmixLinus
Silver Sponsor
Silver Sponsor
Posts: 199
Joined: Thu Apr 21, 2011 3:08 pm
Location: Lund, Sweden
x 12

Re: Change Entities name after creation?

Post by mmixLinus »

Or, if you REALLY want to use the Entity by a different name, clone it:

Code: Select all

//Entity * 	clone (const String &newName) const
renamedEntity = oldEntity->clone("NewName");
Powered by Ogre3D:
MMiX.Me 3D - 3D Music Player
Galaxy Navigator 3D - 2 million stars (ESA's Gaia satellite)
YouTube|Facebook