Added support for searching for user objects from a given startPosition in the UserDataContainer object.
This commit is contained in:
parent
3a5ef17ca7
commit
71a961ccc3
@ -203,8 +203,8 @@ class OSG_EXPORT Object : public Referenced
|
||||
const Referenced* getUserData() const;
|
||||
|
||||
|
||||
/** Add user data object.*/
|
||||
void addUserObject(Object* obj);
|
||||
/** Add user data object. Returns the index position of object added. */
|
||||
unsigned int addUserObject(Object* obj);
|
||||
|
||||
/** Add element to list of user data objects.*/
|
||||
void setUserObject(unsigned int i, Object* obj);
|
||||
@ -213,10 +213,10 @@ class OSG_EXPORT Object : public Referenced
|
||||
void removeUserObject(unsigned int i);
|
||||
|
||||
/** Get the index position of specified user data object.*/
|
||||
unsigned int getUserObjectIndex(const osg::Object* obj) const;
|
||||
unsigned int getUserObjectIndex(const osg::Object* obj, unsigned int startPos=0) const;
|
||||
|
||||
/** Get the index position of first user data object that matches specified name.*/
|
||||
unsigned int getUserObjectIndex(const std::string& name) const;
|
||||
unsigned int getUserObjectIndex(const std::string& name, unsigned int startPos=0) const;
|
||||
|
||||
/** Get user data object as specified index position. */
|
||||
Object* getUserObject(unsigned int i);
|
||||
@ -225,10 +225,10 @@ class OSG_EXPORT Object : public Referenced
|
||||
const Object* getUserObject(unsigned int i) const;
|
||||
|
||||
/** Get first user data object with specified name. */
|
||||
Object* getUserObject(const std::string& name);
|
||||
Object* getUserObject(const std::string& name, unsigned int startPos=0);
|
||||
|
||||
/** Get first const user data object with specified name. */
|
||||
const Object* getUserObject(const std::string& name) const;
|
||||
const Object* getUserObject(const std::string& name, unsigned int startPos=0) const;
|
||||
|
||||
/** Get number of user objects assigned to this object.*/
|
||||
unsigned int getNumUserObjects() const;
|
||||
|
@ -85,7 +85,10 @@ void Object::removeUserObject(unsigned int i)
|
||||
|
||||
void Object::setUserObject(unsigned int i, Object* obj)
|
||||
{
|
||||
if (_userDataContainer.valid() && i<_userDataContainer->_objectList.size())
|
||||
// make sure the UserDataContainer exists
|
||||
getOrCreateUserDataContainer();
|
||||
|
||||
if (i<_userDataContainer->_objectList.size())
|
||||
{
|
||||
_userDataContainer->_objectList[i] = obj;
|
||||
}
|
||||
@ -109,11 +112,11 @@ const Object* Object::getUserObject(unsigned int i) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned int Object::getUserObjectIndex(const osg::Object* obj) const
|
||||
unsigned int Object::getUserObjectIndex(const osg::Object* obj, unsigned int startPos) const
|
||||
{
|
||||
if (_userDataContainer.valid())
|
||||
{
|
||||
for(unsigned int i = 0; i < _userDataContainer->_objectList.size(); ++i)
|
||||
for(unsigned int i = startPos; i < _userDataContainer->_objectList.size(); ++i)
|
||||
{
|
||||
if (_userDataContainer->_objectList[i]==obj) return i;
|
||||
}
|
||||
@ -122,11 +125,11 @@ unsigned int Object::getUserObjectIndex(const osg::Object* obj) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned int Object::getUserObjectIndex(const std::string& name) const
|
||||
unsigned int Object::getUserObjectIndex(const std::string& name, unsigned int startPos) const
|
||||
{
|
||||
if (_userDataContainer.valid())
|
||||
{
|
||||
for(unsigned int i = 0; i < _userDataContainer->_objectList.size(); ++i)
|
||||
for(unsigned int i = startPos; i < _userDataContainer->_objectList.size(); ++i)
|
||||
{
|
||||
Object* obj = _userDataContainer->_objectList[i].get();
|
||||
if (obj && obj->getName()==name) return i;
|
||||
@ -136,11 +139,11 @@ unsigned int Object::getUserObjectIndex(const std::string& name) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
Object* Object::getUserObject(const std::string& name)
|
||||
Object* Object::getUserObject(const std::string& name, unsigned int startPos)
|
||||
{
|
||||
if (_userDataContainer.valid())
|
||||
{
|
||||
unsigned int i = getUserObjectIndex(name);
|
||||
unsigned int i = getUserObjectIndex(name, startPos);
|
||||
return (i<_userDataContainer->_objectList.size()) ? _userDataContainer->_objectList[i].get() : 0;
|
||||
}
|
||||
else
|
||||
@ -149,11 +152,11 @@ Object* Object::getUserObject(const std::string& name)
|
||||
}
|
||||
}
|
||||
|
||||
const Object* Object::getUserObject(const std::string& name) const
|
||||
const Object* Object::getUserObject(const std::string& name, unsigned int startPos) const
|
||||
{
|
||||
if (_userDataContainer.valid())
|
||||
{
|
||||
unsigned int i = getUserObjectIndex(name);
|
||||
unsigned int i = getUserObjectIndex(name, startPos);
|
||||
return (i<_userDataContainer->_objectList.size()) ? _userDataContainer->_objectList[i].get() : 0;
|
||||
}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user