Replaced Widget::GraphicsSubgraph with GraphicsSubgraphMap to allow finer control of when the rendering subgraphs are done.
This commit is contained in:
@@ -126,5 +126,5 @@ void ComboBox::createGraphicsImplementation()
|
||||
_switch->setSingleChildOn(_currentItem);
|
||||
|
||||
style->setupClipStateSet(_extents, getOrCreateStateSet());
|
||||
setGraphicsSubgraph(_switch.get());
|
||||
setGraphicsSubgraph(0, _switch.get());
|
||||
}
|
||||
|
||||
@@ -87,5 +87,9 @@ void Dialog::createGraphicsImplementation()
|
||||
style->setupDialogStateSet(getOrCreateStateSet());
|
||||
style->setupClipStateSet(dialogWithTileExtents, getOrCreateStateSet());
|
||||
|
||||
setGraphicsSubgraph(_group.get());
|
||||
// render before the subgraph
|
||||
setGraphicsSubgraph(-1, _group.get());
|
||||
|
||||
// render after the subgraph
|
||||
setGraphicsSubgraph(1, style->createDepthSetPanel(dialogWithTileExtents));
|
||||
}
|
||||
|
||||
@@ -38,5 +38,5 @@ void Label::createGraphicsImplementation()
|
||||
_textDrawable = dynamic_cast<osgText::Text*>(node.get());
|
||||
|
||||
style->setupClipStateSet(_extents, getOrCreateStateSet());
|
||||
setGraphicsSubgraph(node.get());
|
||||
setGraphicsSubgraph(0, node.get());
|
||||
}
|
||||
|
||||
@@ -83,5 +83,5 @@ void LineEdit::createGraphicsImplementation()
|
||||
|
||||
style->setupClipStateSet(_extents, getOrCreateStateSet());
|
||||
|
||||
setGraphicsSubgraph(_textDrawable.get());
|
||||
setGraphicsSubgraph(0, _textDrawable.get());
|
||||
}
|
||||
|
||||
@@ -77,5 +77,10 @@ void Popup::createGraphicsImplementation()
|
||||
style->setupDialogStateSet(getOrCreateStateSet());
|
||||
style->setupClipStateSet(_extents, getOrCreateStateSet());
|
||||
|
||||
setGraphicsSubgraph(_transform.get());
|
||||
|
||||
// render before the subgraph
|
||||
setGraphicsSubgraph(-1, _transform.get());
|
||||
|
||||
// render after the subgraph
|
||||
setGraphicsSubgraph(1, style->createDepthSetPanel(_extents));
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ void PushButton::createGraphicsImplementation()
|
||||
|
||||
style->setupClipStateSet(_extents, getOrCreateStateSet());
|
||||
|
||||
setGraphicsSubgraph(group.get());
|
||||
setGraphicsSubgraph(0, group.get());
|
||||
}
|
||||
|
||||
void PushButton::pressedImplementation()
|
||||
|
||||
@@ -76,6 +76,27 @@ osg::Node* Style::createPanel(const osg::BoundingBox& extents, const osg::Vec4&
|
||||
return geometry.release();
|
||||
}
|
||||
|
||||
osg::Node* Style::createDepthSetPanel(const osg::BoundingBox& extents)
|
||||
{
|
||||
osg::ref_ptr<osg::Geometry> geometry = new osg::Geometry;
|
||||
|
||||
osg::ref_ptr<osg::Vec3Array> vertices = new osg::Vec3Array;
|
||||
geometry->setVertexArray(vertices.get());
|
||||
|
||||
vertices->push_back( osg::Vec3(extents.xMin(), extents.yMin(), extents.zMin()) );
|
||||
vertices->push_back( osg::Vec3(extents.xMin(), extents.yMax(), extents.zMin()) );
|
||||
vertices->push_back( osg::Vec3(extents.xMax(), extents.yMin(), extents.zMin()) );
|
||||
vertices->push_back( osg::Vec3(extents.xMax(), extents.yMax(), extents.zMin()) );
|
||||
|
||||
geometry->addPrimitiveSet( new osg::DrawArrays(GL_TRIANGLE_STRIP, 0, 4) );
|
||||
|
||||
osg::ref_ptr<osg::StateSet> stateset = geometry->getOrCreateStateSet();
|
||||
stateset->setAttributeAndModes( new osg::Depth(osg::Depth::LESS,0.0, 1.0,true), osg::StateAttribute::ON);
|
||||
stateset->setAttributeAndModes( new osg::ColorMask(false, false, false, false));
|
||||
|
||||
return geometry.release();
|
||||
}
|
||||
|
||||
osg::Node* Style::createFrame(const osg::BoundingBox& extents, const FrameSettings* frameSettings)
|
||||
{
|
||||
return 0;
|
||||
|
||||
@@ -225,20 +225,22 @@ void Widget::traverseImplementation(osg::NodeVisitor& nv)
|
||||
osg::Group::traverse(nv);
|
||||
}
|
||||
}
|
||||
|
||||
else if (nv.getVisitorType()==osg::NodeVisitor::UPDATE_VISITOR ||
|
||||
nv.getVisitorType()==osg::NodeVisitor::CULL_VISITOR)
|
||||
else if (_visible || (nv.getVisitorType()!=osg::NodeVisitor::UPDATE_VISITOR && nv.getVisitorType()!=osg::NodeVisitor::CULL_VISITOR))
|
||||
{
|
||||
if (_visible)
|
||||
GraphicsSubgraphMap::iterator itr = _graphicsSubgraphMap.begin();
|
||||
while(itr!= _graphicsSubgraphMap.end() && itr->first<=0)
|
||||
{
|
||||
if (_graphicsSubgraph.valid()) _graphicsSubgraph->accept(nv);
|
||||
osg::Group::traverse(nv);
|
||||
itr->second->accept(nv);
|
||||
++itr;
|
||||
}
|
||||
|
||||
Group::traverse(nv);
|
||||
|
||||
while(itr!= _graphicsSubgraphMap.end())
|
||||
{
|
||||
itr->second->accept(nv);
|
||||
++itr;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_graphicsSubgraph.valid()) _graphicsSubgraph->accept(nv);
|
||||
osg::Group::traverse(nv);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -308,13 +310,25 @@ osg::BoundingSphere Widget::computeBound() const
|
||||
|
||||
void Widget::resizeGLObjectBuffers(unsigned int maxSize)
|
||||
{
|
||||
if (_graphicsSubgraph.valid()) _graphicsSubgraph->resizeGLObjectBuffers(maxSize);
|
||||
for(GraphicsSubgraphMap::iterator itr = _graphicsSubgraphMap.begin();
|
||||
itr != _graphicsSubgraphMap.end();
|
||||
++itr)
|
||||
{
|
||||
itr->second->resizeGLObjectBuffers(maxSize);
|
||||
}
|
||||
|
||||
Group::resizeGLObjectBuffers(maxSize);
|
||||
}
|
||||
|
||||
|
||||
void Widget::releaseGLObjects(osg::State* state) const
|
||||
{
|
||||
if (_graphicsSubgraph.valid()) _graphicsSubgraph->releaseGLObjects(state);
|
||||
for(GraphicsSubgraphMap::const_iterator itr = _graphicsSubgraphMap.begin();
|
||||
itr != _graphicsSubgraphMap.end();
|
||||
++itr)
|
||||
{
|
||||
itr->second->releaseGLObjects(state);
|
||||
}
|
||||
|
||||
Group::releaseGLObjects(state);
|
||||
}
|
||||
|
||||
@@ -38,10 +38,6 @@ static bool writeColorMap( osgDB::OutputStream& os, const osg::TransferFunction1
|
||||
}
|
||||
#endif
|
||||
|
||||
#define ADD_MAP_SERIALIZER(PROP, TYPE, KEYTYPE, ELEMENTTYPE) \
|
||||
wrapper->addSerializer( new osgDB::MapSerializer< MyClass, TYPE >( \
|
||||
#PROP, &MyClass::get##PROP, &MyClass::get##PROP, &MyClass::set##PROP, KEYTYPE, ELEMENTTYPE), osgDB::BaseSerializer::RW_MAP )
|
||||
|
||||
|
||||
REGISTER_OBJECT_WRAPPER( TransferFunction1D,
|
||||
new osg::TransferFunction1D,
|
||||
|
||||
@@ -69,7 +69,7 @@ REGISTER_OBJECT_WRAPPER( Widget,
|
||||
|
||||
ADD_BOOL_SERIALIZER(HasEventFocus, false);
|
||||
|
||||
ADD_OBJECT_SERIALIZER( GraphicsSubgraph, osg::Node, NULL );
|
||||
ADD_MAP_SERIALIZER(GraphicsSubgraphMap, osgUI::Widget::GraphicsSubgraphMap, osgDB::BaseSerializer::RW_INT, osgDB::BaseSerializer::RW_OBJECT);
|
||||
|
||||
ADD_BOUNDINGBOXF_SERIALIZER(Extents, osg::BoundingBoxf());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user