Added osg::Geometry::setPrimtiveSet,removePrimtiiveSet, insertPrimitiveSet
and getPrimitiveSetIndex(). Renamed osg::Group::findChildNum(..) to getChildIndex(). Renamed osg::Geode::findDrawableNum(..) to getDrawableIndex().
This commit is contained in:
@@ -84,7 +84,7 @@ bool Geode::replaceDrawable( Drawable *origDrawable, Drawable *newDrawable )
|
||||
{
|
||||
if (newDrawable==NULL || origDrawable==newDrawable) return false;
|
||||
|
||||
unsigned int pos = findDrawableNum(origDrawable);
|
||||
unsigned int pos = getDrawableIndex(origDrawable);
|
||||
if (pos<_drawables.size())
|
||||
{
|
||||
return setDrawable(pos,newDrawable);
|
||||
|
||||
@@ -269,6 +269,86 @@ const IndexArray* Geometry::getTexCoordIndices(unsigned int unit) const
|
||||
else return 0;
|
||||
}
|
||||
|
||||
bool Geometry::addPrimitiveSet(PrimitiveSet* primitiveset)
|
||||
{
|
||||
if (primitiveset)
|
||||
{
|
||||
_primitives.push_back(primitiveset);
|
||||
dirtyDisplayList();
|
||||
dirtyBound();
|
||||
return true;
|
||||
}
|
||||
notify(WARN)<<"Warning: invalid index i or primitiveset passed to osg::Geometry::addPrimitiveSet(i,primitiveset), ignoring call."<<std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Geometry::setPrimitiveSet(unsigned int i,PrimitiveSet* primitiveset)
|
||||
{
|
||||
if (i<_primitives.size() && primitiveset)
|
||||
{
|
||||
_primitives[i] = primitiveset;
|
||||
dirtyDisplayList();
|
||||
dirtyBound();
|
||||
return true;
|
||||
}
|
||||
notify(WARN)<<"Warning: invalid index i or primitiveset passed to osg::Geometry::setPrimitiveSet(i,primitiveset), ignoring call."<<std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Geometry::insertPrimitiveSet(unsigned int i,PrimitiveSet* primitiveset)
|
||||
{
|
||||
if (primitiveset)
|
||||
{
|
||||
if (i<_primitives.size())
|
||||
{
|
||||
_primitives.insert(_primitives.begin()+i,primitiveset);
|
||||
dirtyDisplayList();
|
||||
dirtyBound();
|
||||
return true;
|
||||
}
|
||||
else if (i==_primitives.size())
|
||||
{
|
||||
return addPrimitiveSet(primitiveset);
|
||||
}
|
||||
}
|
||||
notify(WARN)<<"Warning: invalid index i or primitiveset passed to osg::Geometry::insertPrimitiveSet(i,primitiveset), ignoring call."<<std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Geometry::removePrimitiveSet(unsigned int i, unsigned int numElementsToRemove)
|
||||
{
|
||||
if (i<_primitives.size() && numElementsToRemove>0)
|
||||
{
|
||||
if (i+numElementsToRemove<_primitives.size())
|
||||
{
|
||||
_primitives.erase(_primitives.begin()+i,_primitives.begin()+i+numElementsToRemove);
|
||||
}
|
||||
else
|
||||
{
|
||||
// asking to delete too many elements, report a warning, and delete to
|
||||
// the end of the primitive list.
|
||||
notify(WARN)<<"Warning: osg::Geometry::removePrimitiveSet(i,numElementsToRemove) has been asked to remove more elements than are available,"<<std::endl;
|
||||
notify(WARN)<<" removing on from i to the end of the list of primitive sets."<<endl;
|
||||
_primitives.erase(_primitives.begin()+i,_primitives.end());
|
||||
}
|
||||
|
||||
dirtyDisplayList();
|
||||
dirtyBound();
|
||||
return true;
|
||||
}
|
||||
notify(WARN)<<"Warning: invalid index i passed to osg::Geometry::removePrimitiveSet(i,numElementsToRemove), ignoring call."<<std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned int Geometry::getPrimitiveSetIndex(const PrimitiveSet* primitiveset) const
|
||||
{
|
||||
for (unsigned int primitiveSetIndex=0;primitiveSetIndex<_primitives.size();++primitiveSetIndex)
|
||||
{
|
||||
if (_primitives[primitiveSetIndex]==primitiveset) return primitiveSetIndex;
|
||||
}
|
||||
return _primitives.size(); // node not found.
|
||||
}
|
||||
|
||||
bool Geometry::areFastPathsUsed() const
|
||||
{
|
||||
if (_fastPathComputed) return _fastPath;
|
||||
|
||||
@@ -146,7 +146,7 @@ bool Group::replaceChild( Node *origNode, Node *newNode )
|
||||
{
|
||||
if (newNode==NULL || origNode==newNode) return false;
|
||||
|
||||
unsigned int pos = findChildNum(origNode);
|
||||
unsigned int pos = getChildIndex(origNode);
|
||||
if (pos<_children.size())
|
||||
{
|
||||
return setChild(pos,newNode);
|
||||
|
||||
@@ -69,7 +69,7 @@ bool LOD::addChild(Node *child, float min, float max)
|
||||
bool LOD::removeChild( Node *child )
|
||||
{
|
||||
// find the child's position.
|
||||
unsigned int pos=findChildNum(child);
|
||||
unsigned int pos=getChildIndex(child);
|
||||
if (pos==_children.size()) return false;
|
||||
|
||||
_rangeList.erase(_rangeList.begin()+pos);
|
||||
|
||||
@@ -61,7 +61,7 @@ bool Switch::addChild( Node *child, bool value )
|
||||
bool Switch::removeChild( Node *child )
|
||||
{
|
||||
// find the child's position.
|
||||
unsigned int pos=findChildNum(child);
|
||||
unsigned int pos=getChildIndex(child);
|
||||
if (pos==_children.size()) return false;
|
||||
|
||||
_values.erase(_values.begin()+pos);
|
||||
@@ -78,7 +78,7 @@ void Switch::setValue(unsigned int pos,bool value)
|
||||
void Switch::setValue(const Node* child,bool value)
|
||||
{
|
||||
// find the child's position.
|
||||
unsigned int pos=findChildNum(child);
|
||||
unsigned int pos=getChildIndex(child);
|
||||
if (pos==_children.size()) return;
|
||||
|
||||
_values[pos]=value;
|
||||
@@ -93,7 +93,7 @@ bool Switch::getValue(unsigned int pos) const
|
||||
bool Switch::getValue(const Node* child) const
|
||||
{
|
||||
// find the child's position.
|
||||
unsigned int pos=findChildNum(child);
|
||||
unsigned int pos=getChildIndex(child);
|
||||
if (pos==_children.size()) return false;
|
||||
|
||||
return _values[pos];
|
||||
|
||||
Reference in New Issue
Block a user