UserData field for MovableObject

What it says on the tin: a place to discuss proposed new features.
Post Reply
User avatar
KungFooMasta
OGRE Contributor
OGRE Contributor
Posts: 2087
Joined: Thu Mar 03, 2005 7:11 am
Location: WA, USA
x 16
Contact:

UserData field for MovableObject

Post by KungFooMasta »

This idea comes from PhysX.

Often times entities are part of a higher level class used in our applications. (GameObject) Currently there is no easy way to obtain a GameObject from a MovableObject. What we need is a simple member:

Code: Select all

void* MovableObject::userData
We could either have this be public and directly accessible, or add get/set functions to wrap it. This is very easy to add in, and does not force us to name our MovableObject instance to match the name of our GameObject. In fact, if you have 2 MovableObjects with the same name you will get an exception.

Please add this in. :)
Creator of QuickGUI!
User avatar
nullsquared
Old One
Posts: 3245
Joined: Tue Apr 24, 2007 8:23 pm
Location: NY, NY, USA
x 11

Re: UserData field for MovableObject

Post by nullsquared »

KungFooMasta wrote:This idea comes from PhysX.

Often times entities are part of a higher level class used in our applications. (GameObject) Currently there is no easy way to obtain a GameObject from a MovableObject. What we need is a simple member:

Code: Select all

void* MovableObject::userData
We could either have this be public and directly accessible, or add get/set functions to wrap it. This is very easy to add in, and does not force us to name our MovableObject instance to match the name of our GameObject. In fact, if you have 2 MovableObjects with the same name you will get an exception.

Please add this in. :)
http://www.ogre3d.org/docs/api/html/cla ... dingBoxa34

Code: Select all

struct GameObject: public Ogre::UserDefinedObject {
// foo
};
someMovableObject->setUserObject(myGameObject);
-or-
http://www.ogre3d.org/docs/api/html/cla ... dingBoxa36

Code: Select all

someMovableObject->setUserAny(Ogre::Any(myGameObject));
Just not both - the value itself is shared.
Last edited by nullsquared on Fri Mar 21, 2008 6:30 pm, edited 1 time in total.
User avatar
KungFooMasta
OGRE Contributor
OGRE Contributor
Posts: 2087
Joined: Thu Mar 03, 2005 7:11 am
Location: WA, USA
x 16
Contact:

Post by KungFooMasta »

I was just looking at the API and found the same thing! :)

I guess I would derive a class from UserDefinedObject to include a GameObject*, and then cast it to get access.
Creator of QuickGUI!
User avatar
nullsquared
Old One
Posts: 3245
Joined: Tue Apr 24, 2007 8:23 pm
Location: NY, NY, USA
x 11

Post by nullsquared »

KungFooMasta wrote:I was just looking at the API and found the same thing! :)

I guess I would derive a class from UserDefinedObject to include a GameObject*, and then cast it to get access.
Just use an Ogre::Any.
CABAListic
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 2903
Joined: Thu Jan 18, 2007 2:48 pm
x 58
Contact:

Post by CABAListic »

You don't even need to derive anymore. The Any object is a templated wrapper around any type, so you can store whatever you want. It's basically a save variant to a void* pointer.
User avatar
KungFooMasta
OGRE Contributor
OGRE Contributor
Posts: 2087
Joined: Thu Mar 03, 2005 7:11 am
Location: WA, USA
x 16
Contact:

Post by KungFooMasta »

Awesome! Thanks for the input, Ogre community ftw!
Creator of QuickGUI!
Post Reply