[osg-users] Error: 'Debug Assertion Failure!'
Robert Osfield
robert.osfield at gmail.com
Thu Jan 3 08:52:48 PST 2008
Hi Gordon,
On Jan 3, 2008 4:43 PM, Gordon Tomlinson <gordon at gordon-tomlinson.com> wrote:
> You might also want to see if the parent has any children first, as we know
> has a getChildIndex slight bug in that it returns zero even if there are no
> children which is a valid index ..
I have just reviewed the Group::getChildIndex(const Node*) method can
clarfify that the behaviour is correct, and there isn't a bug. Why?
0 isn't a valid index when there are 0 children...
You only have a valid index when the index returned is less than the
number of children. The getChildIndex() method works in a similar way
to std find methods returning the end() when nothing has been found.
Use code should look like:
unsigned int i = group->getChildIndex(childWeAreLookingFor);
if (i<group->getNumChildren())
{
// we have a valid index
}
else
{
// we have a invalid index
}
More information about the osg-users
mailing list