From 74f91037a7a78b742be008973ac010047638b911 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 14 May 2014 16:01:40 +0000 Subject: [PATCH] Further work on Bound class/Node::getBound() and Drawable::getBound() and usage in OSG codebase --- examples/osgdepthpeeling/DePee.cpp | 2 +- examples/osghud/osghud.cpp | 2 +- examples/osgoit/HeatMap.cpp | 4 + examples/osgposter/PosterPrinter.cpp | 42 ++--- examples/osgqfont/osgqfont.cpp | 118 ++++++------- examples/osgtext/osgtext.cpp | 166 +++++++++--------- include/osg/CullingSet | 3 +- include/osg/Drawable | 14 ++ include/osg/Node | 4 +- src/osg/Billboard.cpp | 4 +- src/osg/ComputeBoundsVisitor.cpp | 2 +- src/osg/Geode.cpp | 4 +- src/osg/Group.cpp | 3 +- src/osg/KdTree.cpp | 2 +- src/osg/Switch.cpp | 10 +- src/osgPlugins/OpenFlight/GeometryRecords.cpp | 4 +- src/osgPlugins/fbx/WriterCompareTriangle.cpp | 2 +- src/osgPlugins/txp/TXPParser.cpp | 6 +- .../deprecated/PickEventHandler.cpp | 4 +- .../deprecated/SlideShowConstructor.cpp | 4 +- src/osgShadow/MinimalCullBoundsShadowMap.cpp | 6 +- src/osgShadow/ViewDependentShadowMap.cpp | 4 +- src/osgUtil/CullVisitor.cpp | 6 +- src/osgUtil/IntersectVisitor.cpp | 2 +- src/osgUtil/LineSegmentIntersector.cpp | 2 +- src/osgUtil/Optimizer.cpp | 2 +- src/osgUtil/RayIntersector.cpp | 2 +- src/osgViewer/HelpHandler.cpp | 2 +- src/osgViewer/StatsHandler.cpp | 24 +-- src/osgWidget/Label.cpp | 2 +- 30 files changed, 239 insertions(+), 213 deletions(-) diff --git a/examples/osgdepthpeeling/DePee.cpp b/examples/osgdepthpeeling/DePee.cpp index c3c4ab405..4b352d4ea 100644 --- a/examples/osgdepthpeeling/DePee.cpp +++ b/examples/osgdepthpeeling/DePee.cpp @@ -303,7 +303,7 @@ bool DePee::createHUD() osg::BoundingBox bb; for(unsigned int i=0;igetNumDrawables();++i) { - bb.expandBy(geode->getDrawable(i)->getBound()); + bb.expandBy(geode->getDrawable(i)->getBoundingBox()); } osg::Geometry* geom = new osg::Geometry; diff --git a/examples/osghud/osghud.cpp b/examples/osghud/osghud.cpp index a5aa4e29d..f1c98a397 100644 --- a/examples/osghud/osghud.cpp +++ b/examples/osghud/osghud.cpp @@ -151,7 +151,7 @@ osg::Camera* createHUD() osg::BoundingBox bb; for(unsigned int i=0;igetNumDrawables();++i) { - bb.expandBy(geode->getDrawable(i)->getBound()); + bb.expandBy(geode->getDrawable(i)->getBoundingBox()); } osg::Geometry* geom = new osg::Geometry; diff --git a/examples/osgoit/HeatMap.cpp b/examples/osgoit/HeatMap.cpp index 7e069c5d9..15f6f3e1b 100644 --- a/examples/osgoit/HeatMap.cpp +++ b/examples/osgoit/HeatMap.cpp @@ -82,7 +82,11 @@ public: // an attempt to return a reasonable bounding box. Still does not prevent clipping of the heat map. virtual const osg::BoundingBox& getBoundingBox() const {return m_bounds;} virtual osg::BoundingBox computeBoundingBox() const {return m_bounds;} +#ifdef OSG_USE_BOUND + virtual osg::Bound getBound() const { return osg::Bound(m_bounds, m_bounds); } +#else virtual const osg::BoundingSphere& getBound() const {return m_bsphere;} +#endif protected: osg::BoundingBox m_bounds; diff --git a/examples/osgposter/PosterPrinter.cpp b/examples/osgposter/PosterPrinter.cpp index ba5928fb8..fe12da772 100644 --- a/examples/osgposter/PosterPrinter.cpp +++ b/examples/osgposter/PosterPrinter.cpp @@ -44,13 +44,13 @@ public: { double timeStamp = nv->getFrameStamp()?nv->getFrameStamp()->getReferenceTime():0.0; unsigned int frameNumber = nv->getFrameStamp()?nv->getFrameStamp()->getFrameNumber():0; - + pagedLOD->setFrameNumberOfLastTraversal( frameNumber ); pagedLOD->setTimeStamp( numChildren-1, timeStamp ); pagedLOD->setFrameNumber( numChildren-1, frameNumber ); pagedLOD->getChild(numChildren-1)->accept(*nv); } - + // Request for new child if ( !pagedLOD->getDisableExternalChildrenPaging() && nv->getDatabaseRequestHandler() && @@ -114,7 +114,7 @@ void PosterVisitor::apply( osg::PagedLOD& node ) for ( unsigned int i=0; i pi = new PosterIntersector( transformedPolytope ); pi->_intersectionVisitor = &iv; pi->_parent = this; @@ -187,9 +187,9 @@ void PosterIntersector::reset() void PosterIntersector::intersect( osgUtil::IntersectionVisitor& iv, osg::Drawable* drawable ) { - if ( !_polytope.contains(drawable->getBound()) ) return; + if ( !_polytope.contains(drawable->getBoundingBox()) ) return; if ( iv.getDoDummyTraversal() ) return; - + // Find and collect all paged LODs in the node path osg::NodePath& nodePath = iv.getNodePath(); for ( osg::NodePath::iterator itr=nodePath.begin(); itr!=nodePath.end(); ++itr ) @@ -208,7 +208,7 @@ void PosterIntersector::intersect( osgUtil::IntersectionVisitor& iv, osg::Drawab } continue; } - + /*osg::LOD* lod = dynamic_cast(*itr); if ( lod ) { @@ -258,7 +258,7 @@ void PosterPrinter::frame( const osg::FrameStamp* fs, osg::Node* node ) // and advance frame when all callbacks are dispatched. if ( addCullCallbacks(fs, node) ) return; - + if ( _isFinishing ) { if ( (fs->getFrameNumber()-_lastBindingFrame)>2 ) @@ -270,16 +270,16 @@ void PosterPrinter::frame( const osg::FrameStamp* fs, osg::Node* node ) std::cout << "Writing final result to file..." << std::endl; osgDB::writeImageFile( *_finalPoster, _outputPosterName ); } - + // Release all cull callbacks to free unused paged nodes removeCullCallbacks( node ); _visitor->clearNames(); - + _isFinishing = false; std::cout << "Recording images finished." << std::endl; } } - + if ( _isRunning ) { // Every "copy-to-image" process seems to be finished in 2 frames. @@ -288,11 +288,11 @@ void PosterPrinter::frame( const osg::FrameStamp* fs, osg::Node* node ) { // Record images and unref them to free memory recordImages(); - + // Release all cull callbacks to free unused paged nodes removeCullCallbacks( node ); _visitor->clearNames(); - + if ( _camera.valid() ) { std::cout << "Binding sub-camera " << _currentRow << "_" << _currentColumn @@ -325,11 +325,11 @@ bool PosterPrinter::addCullCallbacks( const osg::FrameStamp* fs, osg::Node* node { if ( !_visitor->inQueue() || done() ) return false; - + _visitor->setAddingCallbacks( true ); _camera->accept( *_visitor ); _lastBindingFrame = fs->getFrameNumber(); - + std::cout << "Dispatching callbacks to paged nodes... " << _visitor->inQueue() << std::endl; return true; @@ -345,19 +345,19 @@ void PosterPrinter::bindCameraToImage( osg::Camera* camera, int row, int col ) { std::stringstream stream; stream << "image_" << row << "_" << col; - + osg::ref_ptr image = new osg::Image; image->setName( stream.str() ); image->allocateImage( (int)_tileSize.x(), (int)_tileSize.y(), 1, GL_RGBA, GL_UNSIGNED_BYTE ); _images[TilePosition(row,col)] = image.get(); - + // Calculate projection matrix offset of each tile osg::Matrix offsetMatrix = osg::Matrix::scale(_tileColumns, _tileRows, 1.0) * osg::Matrix::translate(_tileColumns-1-2*col, _tileRows-1-2*row, 0.0); camera->setViewMatrix( _currentViewMatrix ); camera->setProjectionMatrix( _currentProjectionMatrix * offsetMatrix ); - + // Check intersections between the image-tile box and the model osgUtil::IntersectionVisitor iv( _intersector.get() ); iv.setReadCallback( g_pagedLoadingCallback.get() ); @@ -368,7 +368,7 @@ void PosterPrinter::bindCameraToImage( osg::Camera* camera, int row, int col ) // Apply a cull calback to every paged node obtained, to force the highest level displaying. // This will be done by the PosterVisitor, who already records all the paged nodes. } - + // Reattach cameras and new allocated images camera->setRenderingCache( NULL ); // FIXME: Uses for reattaching camera with image, maybe inefficient? camera->detach( osg::Camera::COLOR_BUFFER ); @@ -391,7 +391,7 @@ void PosterPrinter::recordImages() memcpy( target, source, image->s() * 4 * sizeof(unsigned char) ); } } - + if ( _outputTiles ) osgDB::writeImageFile( *image, image->getName()+"."+_outputTileExt ); } diff --git a/examples/osgqfont/osgqfont.cpp b/examples/osgqfont/osgqfont.cpp index 615cc57e8..40be99795 100644 --- a/examples/osgqfont/osgqfont.cpp +++ b/examples/osgqfont/osgqfont.cpp @@ -57,13 +57,13 @@ osg::Group* createHUDText() //////////////////////////////////////////////////////////////////////////////////////////////////////// -// +// // Examples of how to set up different text layout // osg::Vec4 layoutColor(1.0f,1.0f,0.0f,1.0f); - float layoutCharacterSize = 20.0f; - + float layoutCharacterSize = 20.0f; + { osgText::Text* text = new osgText::Text; text->setFont(font); @@ -107,32 +107,32 @@ osg::Group* createHUDText() text->setText("text->setLayout(osgText::Text::VERTICAL);"); geode->addDrawable(text); } - - + + //////////////////////////////////////////////////////////////////////////////////////////////////////// -// +// // Examples of how to set up different font resolution // osg::Vec4 fontSizeColor(0.0f,1.0f,1.0f,1.0f); float fontSizeCharacterSize = 30; - + osg::Vec3 cursor = osg::Vec3(margin*2,windowHeight-margin*2,0.0f); - + { osgText::Text* text = new osgText::Text; text->setFont(font); text->setColor(fontSizeColor); text->setCharacterSize(fontSizeCharacterSize); text->setPosition(cursor); - + // use text that uses 10 by 10 texels as a target resolution for fonts. text->setFontResolution(10,10); // blocky but small texture memory usage - + text->setText("text->setFontResolution(10,10); // blocky but small texture memory usage"); geode->addDrawable(text); } - + cursor.y() -= fontSizeCharacterSize; { osgText::Text* text = new osgText::Text; @@ -140,14 +140,14 @@ osg::Group* createHUDText() text->setColor(fontSizeColor); text->setCharacterSize(fontSizeCharacterSize); text->setPosition(cursor); - + // use text that uses 20 by 20 texels as a target resolution for fonts. text->setFontResolution(20,20); // smoother but higher texture memory usage (but still quite low). - + text->setText("text->setFontResolution(20,20); // smoother but higher texture memory usage (but still quite low)."); geode->addDrawable(text); } - + cursor.y() -= fontSizeCharacterSize; { osgText::Text* text = new osgText::Text; @@ -155,38 +155,38 @@ osg::Group* createHUDText() text->setColor(fontSizeColor); text->setCharacterSize(fontSizeCharacterSize); text->setPosition(cursor); - + // use text that uses 40 by 40 texels as a target resolution for fonts. text->setFontResolution(40,40); // even smoother but again higher texture memory usage. - + text->setText("text->setFontResolution(40,40); // even smoother but again higher texture memory usage."); geode->addDrawable(text); } //////////////////////////////////////////////////////////////////////////////////////////////////////// -// +// // Examples of how to set up different sized text // osg::Vec4 characterSizeColor(1.0f,0.0f,1.0f,1.0f); - + cursor.y() -= fontSizeCharacterSize*2.0f; - + { osgText::Text* text = new osgText::Text; text->setFont(font); text->setColor(characterSizeColor); text->setFontResolution(20,20); text->setPosition(cursor); - + // use text that is 20 units high. text->setCharacterSize(20); // small - + text->setText("text->setCharacterSize(20.0f); // small"); geode->addDrawable(text); } - + cursor.y() -= 30.0f; { osgText::Text* text = new osgText::Text; @@ -194,14 +194,14 @@ osg::Group* createHUDText() text->setColor(characterSizeColor); text->setFontResolution(30,30); text->setPosition(cursor); - + // use text that is 30 units high. text->setCharacterSize(30.0f); // medium - + text->setText("text->setCharacterSize(30.0f); // medium"); geode->addDrawable(text); } - + cursor.y() -= 50.0f; { osgText::Text* text = new osgText::Text; @@ -209,17 +209,17 @@ osg::Group* createHUDText() text->setColor(characterSizeColor); text->setFontResolution(40,40); text->setPosition(cursor); - + // use text that is 60 units high. text->setCharacterSize(60.0f); // large - + text->setText("text->setCharacterSize(60.0f); // large"); geode->addDrawable(text); } //////////////////////////////////////////////////////////////////////////////////////////////////////// -// +// // Examples of how to set up different alignments // @@ -227,7 +227,7 @@ osg::Group* createHUDText() float alignmentCharacterSize = 25.0f; cursor.x() = 640; cursor.y() = margin*4.0f; - + typedef std::pair AlignmentPair; typedef std::vector AlignmentList; AlignmentList alignmentList; @@ -264,49 +264,49 @@ osg::Group* createHUDText() text->setCharacterSize(alignmentCharacterSize); text->setPosition(cursor); text->setDrawMode(osgText::Text::TEXT|osgText::Text::ALIGNMENT|osgText::Text::BOUNDINGBOX); - + text->setAlignment(itr->first); text->setText(itr->second); - + alignmentGeode->addDrawable(text); } - + } sequence->setMode(osg::Sequence::START); sequence->setInterval(osg::Sequence::LOOP, 0, -1); sequence->setDuration(1.0f, -1); - + rootNode->addChild(sequence); //////////////////////////////////////////////////////////////////////////////////////////////////////// -// +// // Examples of how to set up different fonts... // cursor.x() = margin*2.0f; cursor.y() = margin*2.0f; - + osg::Vec4 fontColor(1.0f,0.5f,0.0f,1.0f); float fontCharacterSize = 20.0f; float spacing = 40.0f; - + { osgText::Text* text = new osgText::Text; text->setColor(fontColor); text->setPosition(cursor); text->setCharacterSize(fontCharacterSize); - + text->setFont(0); text->setText("text->setFont(0); // inbuilt font."); geode->addDrawable(text); - cursor.x() = text->getBound().xMax() + spacing ; + cursor.x() = text->getBoundingBox().xMax() + spacing ; } - + { osgText::Font* arial = new osgText::Font(new osgQt::QFontImplementation(QFont("Arial"))); @@ -314,16 +314,16 @@ osg::Group* createHUDText() text->setColor(fontColor); text->setPosition(cursor); text->setCharacterSize(fontCharacterSize); - + text->setFont(arial); text->setText(arial!=0? "text->setFont(\"fonts/arial.ttf\");": "unable to load \"fonts/arial.ttf\""); geode->addDrawable(text); - cursor.x() = text->getBound().xMax() + spacing ; + cursor.x() = text->getBoundingBox().xMax() + spacing ; } - + { osgText::Font* times = new osgText::Font(new osgQt::QFontImplementation(QFont("Times"))); @@ -331,16 +331,16 @@ osg::Group* createHUDText() text->setColor(fontColor); text->setPosition(cursor); text->setCharacterSize(fontCharacterSize); - + geode->addDrawable(text); text->setFont(times); text->setText(times!=0? "text->setFont(\"fonts/times.ttf\");": "unable to load \"fonts/times.ttf\""); - cursor.x() = text->getBound().xMax() + spacing ; + cursor.x() = text->getBoundingBox().xMax() + spacing ; } - + cursor.x() = margin*2.0f; cursor.y() = margin; @@ -351,34 +351,34 @@ osg::Group* createHUDText() text->setColor(fontColor); text->setPosition(cursor); text->setCharacterSize(fontCharacterSize); - + text->setFont(dirtydoz); text->setText(dirtydoz!=0? "text->setFont(\"fonts/dirtydoz.ttf\");": "unable to load \"fonts/dirtydoz.ttf\""); geode->addDrawable(text); - cursor.x() = text->getBound().xMax() + spacing ; + cursor.x() = text->getBoundingBox().xMax() + spacing ; } - + { osgText::Font* fudd = new osgText::Font(new osgQt::QFontImplementation(QFont("Times"))); - + osgText::Text* text = new osgText::Text; text->setColor(fontColor); text->setPosition(cursor); text->setCharacterSize(fontCharacterSize); - + text->setFont(fudd); text->setText(fudd!=0? "text->setFont(\"fonts/fudd.ttf\");": "unable to load \"fonts/fudd.ttf\""); geode->addDrawable(text); - cursor.x() = text->getBound().xMax() + spacing ; + cursor.x() = text->getBoundingBox().xMax() + spacing ; } - - return rootNode; + + return rootNode; } @@ -391,12 +391,12 @@ osg::Group* create3DText(const osg::Vec3& center,float radius) osg::Geode* geode = new osg::Geode; //////////////////////////////////////////////////////////////////////////////////////////////////////// -// +// // Examples of how to set up axis/orientation alignments // float characterSize=radius*0.2f; - + osg::Vec3 pos(center.x()-radius*.5f,center.y()-radius*.5f,center.z()-radius*.5f); osgText::Text* text1 = new osgText::Text; @@ -479,7 +479,7 @@ osg::Group* create3DText(const osg::Vec3& center,float radius) osg::Group* rootNode = new osg::Group; rootNode->addChild(geode); - return rootNode; + return rootNode; } class MainWindow : public QWidget { @@ -535,7 +535,7 @@ int main(int argc, char** argv) // prepare scene. osg::Vec3 center(0.0f,0.0f,0.0f); float radius = 1.0f; - + // create the hud. osg::ref_ptr camera = new osg::Camera; camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF); @@ -544,7 +544,7 @@ int main(int argc, char** argv) camera->setClearMask(GL_DEPTH_BUFFER_BIT); camera->addChild(createHUDText()); camera->getOrCreateStateSet()->setMode(GL_LIGHTING,osg::StateAttribute::OFF); - + // make sure the root node is group so we can add extra nodes to it. osg::ref_ptr group = new osg::Group; group->addChild(camera.get()); @@ -552,7 +552,7 @@ int main(int argc, char** argv) // The qt window MainWindow widget; - + // set the scene to render widget.setSceneData(group.get()); widget.setCameraManipulator(new osgGA::TrackballManipulator); diff --git a/examples/osgtext/osgtext.cpp b/examples/osgtext/osgtext.cpp index df713e24e..71a02065c 100644 --- a/examples/osgtext/osgtext.cpp +++ b/examples/osgtext/osgtext.cpp @@ -53,13 +53,13 @@ osg::Group* createHUDText() //////////////////////////////////////////////////////////////////////////////////////////////////////// -// +// // Examples of how to set up different text layout // osg::Vec4 layoutColor(1.0f,1.0f,0.0f,1.0f); - float layoutCharacterSize = 20.0f; - + float layoutCharacterSize = 20.0f; + { osgText::Text* text = new osgText::Text; text->setFont(font); @@ -103,32 +103,32 @@ osg::Group* createHUDText() text->setText("text->setLayout(osgText::Text::VERTICAL);"); geode->addDrawable(text); } - - + + //////////////////////////////////////////////////////////////////////////////////////////////////////// -// +// // Examples of how to set up different font resolution // osg::Vec4 fontSizeColor(0.0f,1.0f,1.0f,1.0f); float fontSizeCharacterSize = 30; - + osg::Vec3 cursor = osg::Vec3(margin*2,windowHeight-margin*2,0.0f); - + { osgText::Text* text = new osgText::Text; text->setFont(font); text->setColor(fontSizeColor); text->setCharacterSize(fontSizeCharacterSize); text->setPosition(cursor); - + // use text that uses 10 by 10 texels as a target resolution for fonts. text->setFontResolution(10,10); // blocky but small texture memory usage - + text->setText("text->setFontResolution(10,10); // blocky but small texture memory usage"); geode->addDrawable(text); } - + cursor.y() -= fontSizeCharacterSize; { osgText::Text* text = new osgText::Text; @@ -136,14 +136,14 @@ osg::Group* createHUDText() text->setColor(fontSizeColor); text->setCharacterSize(fontSizeCharacterSize); text->setPosition(cursor); - + // use text that uses 20 by 20 texels as a target resolution for fonts. text->setFontResolution(20,20); // smoother but higher texture memory usage (but still quite low). - + text->setText("text->setFontResolution(20,20); // smoother but higher texture memory usage (but still quite low)."); geode->addDrawable(text); } - + cursor.y() -= fontSizeCharacterSize; { osgText::Text* text = new osgText::Text; @@ -151,38 +151,38 @@ osg::Group* createHUDText() text->setColor(fontSizeColor); text->setCharacterSize(fontSizeCharacterSize); text->setPosition(cursor); - + // use text that uses 40 by 40 texels as a target resolution for fonts. text->setFontResolution(40,40); // even smoother but again higher texture memory usage. - + text->setText("text->setFontResolution(40,40); // even smoother but again higher texture memory usage."); geode->addDrawable(text); } //////////////////////////////////////////////////////////////////////////////////////////////////////// -// +// // Examples of how to set up different sized text // osg::Vec4 characterSizeColor(1.0f,0.0f,1.0f,1.0f); - + cursor.y() -= fontSizeCharacterSize*2.0f; - + { osgText::Text* text = new osgText::Text; text->setFont(font); text->setColor(characterSizeColor); text->setFontResolution(20,20); text->setPosition(cursor); - + // use text that is 20 units high. text->setCharacterSize(20); // small - + text->setText("text->setCharacterSize(20.0f); // small"); geode->addDrawable(text); } - + cursor.y() -= 30.0f; { osgText::Text* text = new osgText::Text; @@ -190,14 +190,14 @@ osg::Group* createHUDText() text->setColor(characterSizeColor); text->setFontResolution(30,30); text->setPosition(cursor); - + // use text that is 30 units high. text->setCharacterSize(30.0f); // medium - + text->setText("text->setCharacterSize(30.0f); // medium"); geode->addDrawable(text); } - + cursor.y() -= 50.0f; { osgText::Text* text = new osgText::Text; @@ -205,17 +205,17 @@ osg::Group* createHUDText() text->setColor(characterSizeColor); text->setFontResolution(40,40); text->setPosition(cursor); - + // use text that is 60 units high. text->setCharacterSize(60.0f); // large - + text->setText("text->setCharacterSize(60.0f); // large"); geode->addDrawable(text); } //////////////////////////////////////////////////////////////////////////////////////////////////////// -// +// // Examples of how to set up different alignments // @@ -223,7 +223,7 @@ osg::Group* createHUDText() float alignmentCharacterSize = 25.0f; cursor.x() = 640; cursor.y() = margin*4.0f; - + typedef std::pair AlignmentPair; typedef std::vector AlignmentList; AlignmentList alignmentList; @@ -260,49 +260,49 @@ osg::Group* createHUDText() text->setCharacterSize(alignmentCharacterSize); text->setPosition(cursor); text->setDrawMode(osgText::Text::TEXT|osgText::Text::ALIGNMENT|osgText::Text::BOUNDINGBOX); - + text->setAlignment(itr->first); text->setText(itr->second); - + alignmentGeode->addDrawable(text); } - + } sequence->setMode(osg::Sequence::START); sequence->setInterval(osg::Sequence::LOOP, 0, -1); sequence->setDuration(1.0f, -1); - + rootNode->addChild(sequence); //////////////////////////////////////////////////////////////////////////////////////////////////////// -// +// // Examples of how to set up different fonts... // cursor.x() = margin*2.0f; cursor.y() = margin*2.0f; - + osg::Vec4 fontColor(1.0f,0.5f,0.0f,1.0f); float fontCharacterSize = 20.0f; float spacing = 40.0f; - + { osgText::Text* text = new osgText::Text; text->setColor(fontColor); text->setPosition(cursor); text->setCharacterSize(fontCharacterSize); - + text->setFont(0); text->setText("text->setFont(0); // inbuilt font."); geode->addDrawable(text); - cursor.x() = text->getBound().xMax() + spacing ; + cursor.x() = text->getBoundingBox().xMax() + spacing ; } - + { osgText::Font* arial = osgText::readFontFile("fonts/arial.ttf"); @@ -310,16 +310,16 @@ osg::Group* createHUDText() text->setColor(fontColor); text->setPosition(cursor); text->setCharacterSize(fontCharacterSize); - + text->setFont(arial); text->setText(arial!=0? "text->setFont(\"fonts/arial.ttf\");": "unable to load \"fonts/arial.ttf\""); geode->addDrawable(text); - cursor.x() = text->getBound().xMax() + spacing ; + cursor.x() = text->getBoundingBox().xMax() + spacing ; } - + { osgText::Font* times = osgText::readFontFile("fonts/times.ttf"); @@ -327,16 +327,16 @@ osg::Group* createHUDText() text->setColor(fontColor); text->setPosition(cursor); text->setCharacterSize(fontCharacterSize); - + geode->addDrawable(text); text->setFont(times); text->setText(times!=0? "text->setFont(\"fonts/times.ttf\");": "unable to load \"fonts/times.ttf\""); - cursor.x() = text->getBound().xMax() + spacing ; + cursor.x() = text->getBoundingBox().xMax() + spacing ; } - + cursor.x() = margin*2.0f; cursor.y() = margin; @@ -347,34 +347,34 @@ osg::Group* createHUDText() text->setColor(fontColor); text->setPosition(cursor); text->setCharacterSize(fontCharacterSize); - + text->setFont(dirtydoz); text->setText(dirtydoz!=0? "text->setFont(\"fonts/dirtydoz.ttf\");": "unable to load \"fonts/dirtydoz.ttf\""); geode->addDrawable(text); - cursor.x() = text->getBound().xMax() + spacing ; + cursor.x() = text->getBoundingBox().xMax() + spacing ; } - + { osgText::Font* fudd = osgText::readFontFile("fonts/fudd.ttf"); - + osgText::Text* text = new osgText::Text; text->setColor(fontColor); text->setPosition(cursor); text->setCharacterSize(fontCharacterSize); - + text->setFont(fudd); text->setText(fudd!=0? "text->setFont(\"fonts/fudd.ttf\");": "unable to load \"fonts/fudd.ttf\""); geode->addDrawable(text); - cursor.x() = text->getBound().xMax() + spacing ; + cursor.x() = text->getBoundingBox().xMax() + spacing ; } - - return rootNode; + + return rootNode; } @@ -386,9 +386,9 @@ osg::Group* create3DText(const osg::Vec3& center,float radius) osg::Geode* geode = new osg::Geode; - + //////////////////////////////////////////////////////////////////////////////////////////////////////// -// +// // Examples of how to set up axis/orientation alignments // @@ -477,14 +477,14 @@ osg::Group* create3DText(const osg::Vec3& center,float radius) osg::Group* rootNode = new osg::Group; rootNode->addChild(geode); - return rootNode; + return rootNode; } class UpdateTextOperation : public osg::Operation { public: - UpdateTextOperation(const osg::Vec3& center, float diameter, osg::Group* group): + UpdateTextOperation(const osg::Vec3& center, float diameter, osg::Group* group): Operation("UpdateTextOperation", true), _center(center), _diameter(diameter), @@ -502,13 +502,13 @@ public: if (viewer) update(); else load(); } - + void update() { // osg::notify(osg::NOTICE)<<"*** Doing update"< lock(_mutex); - + if (_mergeSubgraph.valid()) { _group->addChild(_mergeSubgraph.get()); @@ -525,14 +525,14 @@ public: } _group->removeChild(0,1); } - + _waitOnMergeBlock.release(); - } + } } - + void load() { - + // osg::notify(osg::NOTICE)<<"Doing load"< geode; @@ -544,7 +544,7 @@ public: _availableSubgraph.pop_front(); } } - + if (!geode) geode = new osg::Geode; for(unsigned int i=0; i<_maxNumTextPerGeode; ++i) @@ -560,7 +560,7 @@ public: { str.push_back(char(32.0 + (float(rand())/float(RAND_MAX))*128.0f)); } - + osgText::Text* text = new osgText::Text; text->setDataVariance(osg::Object::DYNAMIC); text->setPosition(_center + position * _diameter); @@ -568,22 +568,22 @@ public: text->setText(str); text->setCharacterSize(0.025f * _diameter); text->setAxisAlignment(osgText::Text::SCREEN); - + geode->addDrawable(text); } - { + { OpenThreads::ScopedLock lock(_mutex); _mergeSubgraph = geode; } - + // osg::notify(osg::NOTICE)<<"Waiting on merge"< _group; osg::ref_ptr _mergeSubgraph; AvailableList _availableSubgraph; OpenThreads::Block _waitOnMergeBlock; - + unsigned int _counter; }; @@ -613,7 +613,7 @@ int main(int argc, char** argv) // construct the viewer. osgViewer::Viewer viewer(arguments); - + typedef std::list< osg::ref_ptr > Threads; Threads operationThreads; @@ -624,22 +624,22 @@ int main(int argc, char** argv) { // construct a multi-threaded text updating test. if (numThreads==0) numThreads = 1; - + // create a group to add everything into. osg::Group* mainGroup = new osg::Group; - + osg::Vec3 center(0.5f,0.5f,0.5f); float diameter = 1.0f; - + osg::ref_ptr loadedModel = osgDB::readNodeFiles(arguments); if (loadedModel.valid()) { mainGroup->addChild(loadedModel.get()); - + center = loadedModel->getBound().center(); diameter = loadedModel->getBound().radius() * 2.0f; } - + for(unsigned int i=0; iaddChild(geode); } - - viewer.setSceneData(mainGroup); + + viewer.setSceneData(mainGroup); } else { // prepare scene. osg::Vec3 center(0.0f,0.0f,0.0f); float radius = 1.0f; - + // make sure the root node is group so we can add extra nodes to it. osg::Group* group = new osg::Group; @@ -715,7 +715,7 @@ int main(int argc, char** argv) viewer.addEventHandler(new osgViewer::StatsHandler()); viewer.run(); - + if (!operationThreads.empty()) { for(Threads::iterator itr = operationThreads.begin(); diff --git a/include/osg/CullingSet b/include/osg/CullingSet index d0b00693f..728089da4 100644 --- a/include/osg/CullingSet +++ b/include/osg/CullingSet @@ -271,12 +271,13 @@ class OSG_EXPORT CullingSet : public Referenced return false; } +#ifdef OSG_USE_BOUND inline bool isCulled(const Bound& bound) { if (bound.bb) return isCulled(*bound.bb); else return isCulled(*bound.bs); } - +#endif inline void pushCurrentMask() { _frustum.pushCurrentMask(); diff --git a/include/osg/Drawable b/include/osg/Drawable index 17a75f374..457ed2f01 100644 --- a/include/osg/Drawable +++ b/include/osg/Drawable @@ -128,6 +128,20 @@ class OSG_EXPORT Drawable : public Node /** Set the initial bounding volume to use when computing the overall bounding volume.*/ const BoundingBox& getInitialBound() const { return _initialBound; } +#ifdef OSG_USE_BOUND + virtual Bound getBound() const + { + if(!_boundingSphereComputed) getBoundingBox(); + return Bound(_boundingSphere, _boundingBox); + } +#else + inline const BoundingSphere& getBound() const + { + if(!_boundingSphereComputed) getBoundingBox(); + return _boundingSphere; + } +#endif + /** Get BoundingBox of Drawable. * If the BoundingBox is not up to date then its updated via an internal call to computeBond(). */ diff --git a/include/osg/Node b/include/osg/Node index bfbc851cf..6cefbc0fe 100644 --- a/include/osg/Node +++ b/include/osg/Node @@ -437,7 +437,7 @@ class OSG_EXPORT Node : public Object /** Get the bounding sphere of node. Using lazy evaluation computes the bounding sphere if it is 'dirty'.*/ #ifdef OSG_USE_BOUND - inline Bound getBound() const + virtual Bound getBound() const { if(!_boundingSphereComputed) { @@ -452,7 +452,7 @@ class OSG_EXPORT Node : public Object return Bound(_boundingSphere); } #else - inline BoundingSphere getBound() const + inline const BoundingSphere& getBound() const { if(!_boundingSphereComputed) { diff --git a/src/osg/Billboard.cpp b/src/osg/Billboard.cpp index 1c5fbf967..d8d8d2263 100644 --- a/src/osg/Billboard.cpp +++ b/src/osg/Billboard.cpp @@ -317,7 +317,7 @@ BoundingSphere Billboard::computeBound() const for( i = 0; i < ngsets; i++ ) { const Drawable *gset = _drawables[i].get(); - const BoundingBox& bbox = gset->getBound(); + const BoundingBox& bbox = gset->getBoundingBox(); bsphere._center += bbox.center(); bsphere._center += _positionList[i]; @@ -329,7 +329,7 @@ BoundingSphere Billboard::computeBound() const for( i = 0; i < ngsets; ++i ) { const Drawable *gset = _drawables[i].get(); - const BoundingBox& bbox = gset->getBound(); + const BoundingBox& bbox = gset->getBoundingBox(); Vec3 local_center = bsphere._center-_positionList[i]; for(unsigned int c=0;c<8;++c) { diff --git a/src/osg/ComputeBoundsVisitor.cpp b/src/osg/ComputeBoundsVisitor.cpp index 871a09ffb..d7108aed0 100644 --- a/src/osg/ComputeBoundsVisitor.cpp +++ b/src/osg/ComputeBoundsVisitor.cpp @@ -77,7 +77,7 @@ void ComputeBoundsVisitor::apply(osg::Geode& geode) void ComputeBoundsVisitor::applyDrawable(osg::Drawable* drawable) { - applyBoundingBox(drawable->getBound()); + applyBoundingBox(drawable->getBoundingBox()); } void ComputeBoundsVisitor::applyBoundingBox(const osg::BoundingBox& bbox) diff --git a/src/osg/Geode.cpp b/src/osg/Geode.cpp index 56cb7554d..de48b835b 100644 --- a/src/osg/Geode.cpp +++ b/src/osg/Geode.cpp @@ -65,7 +65,7 @@ bool Geode::addDrawable( Drawable *drawable ) // fallback for handling geometry with deprecated data osg::Geometry* geometry = drawable->asGeometry(); if (geometry && geometry->containsDeprecatedData()) geometry->fixDeprecatedData(); - + // note ref_ptr<> automatically handles incrementing drawable's reference count. _drawables.push_back(drawable); @@ -204,7 +204,7 @@ BoundingSphere Geode::computeBound() const itr!=_drawables.end(); ++itr) { - _bbox.expandBy((*itr)->getBound()); + _bbox.expandBy((*itr)->getBoundingBox()); } if (_bbox.valid()) diff --git a/src/osg/Group.cpp b/src/osg/Group.cpp index 39e3aa330..d792c9430 100644 --- a/src/osg/Group.cpp +++ b/src/osg/Group.cpp @@ -369,7 +369,8 @@ BoundingSphere Group::computeBound() const const osg::Transform* transform = (*itr)->asTransform(); if (!transform || transform->getReferenceFrame()==osg::Transform::RELATIVE_RF) { - bb.expandBy((*itr)->getBound()); + const osg::BoundingSphere& bs = (*itr)->getBound(); + bb.expandBy(bs); } } diff --git a/src/osg/KdTree.cpp b/src/osg/KdTree.cpp index 3ab82dc90..bf6bf8041 100644 --- a/src/osg/KdTree.cpp +++ b/src/osg/KdTree.cpp @@ -110,7 +110,7 @@ bool BuildKdTree::build(KdTree::BuildOptions& options, osg::Geometry* geometry) if (vertices->size() <= options._targetNumTrianglesPerLeaf) return false; - _bb = geometry->getBound(); + _bb = geometry->getBoundingBox(); _kdTree.setVertices(vertices); unsigned int estimatedSize = (unsigned int)(2.0*float(vertices->size())/float(options._targetNumTrianglesPerLeaf)); diff --git a/src/osg/Switch.cpp b/src/osg/Switch.cpp index 7fd22b463..c3fed6672 100644 --- a/src/osg/Switch.cpp +++ b/src/osg/Switch.cpp @@ -196,7 +196,10 @@ BoundingSphere Switch::computeBound() const if (!transform || transform->getReferenceFrame()==osg::Transform::RELATIVE_RF) { if( _values[pos] == true ) - bb.expandBy(_children[pos]->getBound()); + { + const osg::BoundingSphere& bs = _children[pos]->getBound(); + bb.expandBy(bs); + } } } @@ -213,7 +216,10 @@ BoundingSphere Switch::computeBound() const if (!transform || transform->getReferenceFrame()==osg::Transform::RELATIVE_RF) { if( _values[pos] == true ) - bsphere.expandRadiusBy(static_cast(_children[pos]->getBound())); + { + const osg::BoundingSphere& bs = _children[pos]->getBound(); + bsphere.expandRadiusBy(bs); + } } } return bsphere; diff --git a/src/osgPlugins/OpenFlight/GeometryRecords.cpp b/src/osgPlugins/OpenFlight/GeometryRecords.cpp index 315e0aa98..575d3faeb 100644 --- a/src/osgPlugins/OpenFlight/GeometryRecords.cpp +++ b/src/osgPlugins/OpenFlight/GeometryRecords.cpp @@ -654,7 +654,7 @@ protected: { for (unsigned int i=0; igetNumDrawables(); ++i) { - osg::BoundingBox bb = billboard->getDrawable(i)->getBound(); + const osg::BoundingBox& bb = billboard->getDrawable(i)->getBoundingBox(); billboard->setPosition(i,bb.center()); osgUtil::TransformAttributeFunctor tf(osg::Matrix::translate(-bb.center())); @@ -1168,7 +1168,7 @@ protected: { for (unsigned int i=0; igetNumDrawables(); ++i) { - osg::BoundingBox bb = billboard->getDrawable(i)->getBound(); + const osg::BoundingBox& bb = billboard->getDrawable(i)->getBoundingBox(); billboard->setPosition(i,bb.center()); osgUtil::TransformAttributeFunctor tf(osg::Matrix::translate(-bb.center())); diff --git a/src/osgPlugins/fbx/WriterCompareTriangle.cpp b/src/osgPlugins/fbx/WriterCompareTriangle.cpp index d7cb3f0cb..686abc8d9 100644 --- a/src/osgPlugins/fbx/WriterCompareTriangle.cpp +++ b/src/osgPlugins/fbx/WriterCompareTriangle.cpp @@ -4,7 +4,7 @@ WriterCompareTriangle::WriterCompareTriangle(const osg::Geode& geode, unsigned int nbVertices) : geode(geode) { - cutscene(nbVertices, geode.getDrawable(0)->asGeometry()->getBound()); + cutscene(nbVertices, geode.getDrawable(0)->asGeometry()->getBoundingBox()); } bool diff --git a/src/osgPlugins/txp/TXPParser.cpp b/src/osgPlugins/txp/TXPParser.cpp index 485b1c98c..4cccde3b9 100644 --- a/src/osgPlugins/txp/TXPParser.cpp +++ b/src/osgPlugins/txp/TXPParser.cpp @@ -1074,7 +1074,7 @@ void* labelRead::Parse(trpgToken /*tok*/,trpgReadBuffer &buf) { osg::Group* group = new osg::Group; - osg::BoundingBox box = text->getBound(); + const osg::BoundingBox& box = text->getBoundingBox(); float shift = box.radius()+1.f; // front @@ -1518,8 +1518,8 @@ void* geomRead::Parse(trpgToken /*tok*/,trpgReadBuffer &buf) case trpgBillboard::Individual: { // compute center of billboard geometry - const osg::BoundingBox& bbox = geometry->getBound(); - osg::Vec3 center ((bbox._min + bbox._max) * 0.5f); + const osg::BoundingBox& bbox = geometry->getBoundingBox(); + osg::Vec3 center (bbox.center()); // make billboard geometry coordinates relative to computed center osg::Matrix matrix; diff --git a/src/osgPresentation/deprecated/PickEventHandler.cpp b/src/osgPresentation/deprecated/PickEventHandler.cpp index bbad67000..05265347c 100644 --- a/src/osgPresentation/deprecated/PickEventHandler.cpp +++ b/src/osgPresentation/deprecated/PickEventHandler.cpp @@ -80,7 +80,7 @@ bool PickEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionA cloned_ea->setTouchData(NULL); // reproject mouse-coord - const osg::BoundingBox bb(hitr->drawable->getBound()); + const osg::BoundingBox bb(hitr->drawable->getBoundingBox()); const osg::Vec3& p(hitr->localIntersectionPoint); float transformed_x = (p.x() - bb.xMin()) / (bb.xMax() - bb.xMin()); @@ -106,7 +106,7 @@ bool PickEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionA // reproject touch-points - const osg::BoundingBox bb(hitr->drawable->getBound()); + const osg::BoundingBox bb(hitr->drawable->getBoundingBox()); osg::Camera* camera = viewer->getCamera(); osg::Matrix matrix = osg::computeLocalToWorld(hitr->nodePath, false) * camera->getViewMatrix() * camera->getProjectionMatrix(); diff --git a/src/osgPresentation/deprecated/SlideShowConstructor.cpp b/src/osgPresentation/deprecated/SlideShowConstructor.cpp index 5ff591498..f9f5a5eb2 100644 --- a/src/osgPresentation/deprecated/SlideShowConstructor.cpp +++ b/src/osgPresentation/deprecated/SlideShowConstructor.cpp @@ -833,7 +833,7 @@ void SlideShowConstructor::addBullet(const std::string& bullet, PositionData& po text->setText(bullet); - osg::BoundingBox bb = text->getBound(); + const osg::BoundingBox& bb = text->getBoundingBox(); // note, this increment is only "correct" when text is on the plane of the slide.. // will need to make this more general later. @@ -882,7 +882,7 @@ void SlideShowConstructor::addParagraph(const std::string& paragraph, PositionDa } text->setText(paragraph); - osg::BoundingBox bb = text->getBound(); + const osg::BoundingBox& bb = text->getBoundingBox(); // note, this increment is only "correct" when text is on the plane of the slide.. // will need to make this more general later. diff --git a/src/osgShadow/MinimalCullBoundsShadowMap.cpp b/src/osgShadow/MinimalCullBoundsShadowMap.cpp index 14725ab3d..b01193848 100644 --- a/src/osgShadow/MinimalCullBoundsShadowMap.cpp +++ b/src/osgShadow/MinimalCullBoundsShadowMap.cpp @@ -264,7 +264,7 @@ osg::BoundingBox MinimalCullBoundsShadowMap::ViewData::ComputeRenderLeavesBounds // Stay as long as possible in model space to minimize matrix ops if( rl && rl->_modelview == modelview && rl->_projection == projection ){ - bb.expandBy( rl->_drawable->getBound() ); + bb.expandBy( rl->_drawable->getBoundingBox() ); } else { if( bb.valid() ) { // Conditions to avoid matrix multiplications @@ -292,7 +292,7 @@ osg::BoundingBox MinimalCullBoundsShadowMap::ViewData::ComputeRenderLeavesBounds bbResult.expandBy( bb.corner( i ) * *ptrModelToWorld ); } if( !rl ) break; - bb = rl->_drawable->getBound(); + bb = rl->_drawable->getBoundingBox(); modelview = rl->_modelview; projection = rl->_projection; } @@ -331,7 +331,7 @@ osg::BoundingBox MinimalCullBoundsShadowMap::ViewData::ComputeRenderLeavesBounds if(rl->_modelview == NULL ) rl->_drawable->dirtyBound(); - bb = rl->_drawable->getBound(); + bb = rl->_drawable->getBoundingBox(); if( !bb.valid() ) continue; // Stay as long as possible in model space to minimize matrix ops diff --git a/src/osgShadow/ViewDependentShadowMap.cpp b/src/osgShadow/ViewDependentShadowMap.cpp index 88b3c772c..04c6092af 100644 --- a/src/osgShadow/ViewDependentShadowMap.cpp +++ b/src/osgShadow/ViewDependentShadowMap.cpp @@ -285,7 +285,7 @@ public: { if (node.getDrawable(i)) { - updateBound(node.getDrawable(i)->getBound()); + updateBound(node.getDrawable(i)->getBoundingBox()); } } @@ -1870,7 +1870,7 @@ struct RenderLeafBounds // OSG_INFO<<"Reusing light_mvp "<_drawable->getBound(); + const osg::BoundingBox& bb = renderLeaf->_drawable->getBoundingBox(); if (bb.valid()) { // OSG_NOTICE<<"checked extents of "<_drawable->getName()<getBound().valid()) updateCalculatedNearFar(*billboard_matrix,*drawable,true); + if (_computeNearFar && drawable->getBoundingBox().valid()) updateCalculatedNearFar(*billboard_matrix,*drawable,true); float depth = distance(pos,modelview); /* if (_computeNearFar) diff --git a/src/osgUtil/IntersectVisitor.cpp b/src/osgUtil/IntersectVisitor.cpp index 391cbad62..ef4d87696 100644 --- a/src/osgUtil/IntersectVisitor.cpp +++ b/src/osgUtil/IntersectVisitor.cpp @@ -590,7 +590,7 @@ bool IntersectVisitor::intersect(Drawable& drawable) IntersectState* cis = _intersectStateStack.back().get(); - const BoundingBox& bb = drawable.getBound(); + const BoundingBox& bb = drawable.getBoundingBox(); for(IntersectState::LineSegmentList::iterator sitr=cis->_segList.begin(); sitr!=cis->_segList.end(); diff --git a/src/osgUtil/LineSegmentIntersector.cpp b/src/osgUtil/LineSegmentIntersector.cpp index d1b467370..230062b4c 100644 --- a/src/osgUtil/LineSegmentIntersector.cpp +++ b/src/osgUtil/LineSegmentIntersector.cpp @@ -312,7 +312,7 @@ void LineSegmentIntersector::intersect(osgUtil::IntersectionVisitor& iv, osg::Dr if (reachedLimit()) return; osg::Vec3d s(_start), e(_end); - if ( !intersectAndClip( s, e, drawable->getBound() ) ) return; + if ( !intersectAndClip( s, e, drawable->getBoundingBox() ) ) return; if (iv.getDoDummyTraversal()) return; diff --git a/src/osgUtil/Optimizer.cpp b/src/osgUtil/Optimizer.cpp index 61f2d76a8..c156ed27b 100644 --- a/src/osgUtil/Optimizer.cpp +++ b/src/osgUtil/Optimizer.cpp @@ -2876,7 +2876,7 @@ bool Optimizer::SpatializeGroupsVisitor::divide(osg::Geode* geode, unsigned int unsigned int i; for(i=0; igetNumDrawables(); ++i) { - bb.expandBy(geode->getDrawable(i)->getBound().center()); + bb.expandBy(geode->getDrawable(i)->getBoundingBox().center()); } float radius = bb.radius(); diff --git a/src/osgUtil/RayIntersector.cpp b/src/osgUtil/RayIntersector.cpp index 850e947ed..1642af280 100644 --- a/src/osgUtil/RayIntersector.cpp +++ b/src/osgUtil/RayIntersector.cpp @@ -108,7 +108,7 @@ void RayIntersector::intersect(IntersectionVisitor& iv, Drawable* drawable) // clip ray to finite line segment Vec3d s(_start), e; - if (!intersectAndClip(s, _direction, e, drawable->getBound())) return; + if (!intersectAndClip(s, _direction, e, drawable->getBoundingBox())) return; // dummy traversal if (iv.getDoDummyTraversal()) return; diff --git a/src/osgViewer/HelpHandler.cpp b/src/osgViewer/HelpHandler.cpp index 8e6f6ade2..22b002993 100644 --- a/src/osgViewer/HelpHandler.cpp +++ b/src/osgViewer/HelpHandler.cpp @@ -151,7 +151,7 @@ void HelpHandler::setUpScene(osgViewer::ViewerBase* viewer) label->setPosition(pos); label->setText(_applicationUsage->getDescription()); - pos.x() = label->getBound().xMax(); + pos.x() = label->getBoundingBox().xMax(); pos.y() -= characterSize*2.5f; } diff --git a/src/osgViewer/StatsHandler.cpp b/src/osgViewer/StatsHandler.cpp index 2e7466193..0abdc74de 100644 --- a/src/osgViewer/StatsHandler.cpp +++ b/src/osgViewer/StatsHandler.cpp @@ -1149,7 +1149,7 @@ void StatsHandler::setUpScene(osgViewer::ViewerBase* viewer) frameRateLabel->setPosition(pos); frameRateLabel->setText("Frame Rate: "); - pos.x() = frameRateLabel->getBound().xMax(); + pos.x() = frameRateLabel->getBoundingBox().xMax(); osg::ref_ptr frameRateValue = new osgText::Text; geode->addDrawable( frameRateValue.get() ); @@ -1347,7 +1347,7 @@ void StatsHandler::setUpScene(osgViewer::ViewerBase* viewer) averageLabel->setPosition(pos); averageLabel->setText("DatabasePager time to merge new tiles - average: "); - pos.x() = averageLabel->getBound().xMax(); + pos.x() = averageLabel->getBoundingBox().xMax(); osg::ref_ptr averageValue = new osgText::Text; _statsGeode->addDrawable( averageValue.get() ); @@ -1358,7 +1358,7 @@ void StatsHandler::setUpScene(osgViewer::ViewerBase* viewer) averageValue->setPosition(pos); averageValue->setText("1000"); - pos.x() = averageValue->getBound().xMax() + 2.0f*_characterSize; + pos.x() = averageValue->getBoundingBox().xMax() + 2.0f*_characterSize; osg::ref_ptr minLabel = new osgText::Text; @@ -1370,7 +1370,7 @@ void StatsHandler::setUpScene(osgViewer::ViewerBase* viewer) minLabel->setPosition(pos); minLabel->setText("min: "); - pos.x() = minLabel->getBound().xMax(); + pos.x() = minLabel->getBoundingBox().xMax(); osg::ref_ptr minValue = new osgText::Text; _statsGeode->addDrawable( minValue.get() ); @@ -1381,7 +1381,7 @@ void StatsHandler::setUpScene(osgViewer::ViewerBase* viewer) minValue->setPosition(pos); minValue->setText("1000"); - pos.x() = minValue->getBound().xMax() + 2.0f*_characterSize; + pos.x() = minValue->getBoundingBox().xMax() + 2.0f*_characterSize; osg::ref_ptr maxLabel = new osgText::Text; _statsGeode->addDrawable( maxLabel.get() ); @@ -1392,7 +1392,7 @@ void StatsHandler::setUpScene(osgViewer::ViewerBase* viewer) maxLabel->setPosition(pos); maxLabel->setText("max: "); - pos.x() = maxLabel->getBound().xMax(); + pos.x() = maxLabel->getBoundingBox().xMax(); osg::ref_ptr maxValue = new osgText::Text; _statsGeode->addDrawable( maxValue.get() ); @@ -1403,7 +1403,7 @@ void StatsHandler::setUpScene(osgViewer::ViewerBase* viewer) maxValue->setPosition(pos); maxValue->setText("1000"); - pos.x() = maxValue->getBound().xMax(); + pos.x() = maxValue->getBoundingBox().xMax(); osg::ref_ptr requestsLabel = new osgText::Text; _statsGeode->addDrawable( requestsLabel.get() ); @@ -1414,7 +1414,7 @@ void StatsHandler::setUpScene(osgViewer::ViewerBase* viewer) requestsLabel->setPosition(pos); requestsLabel->setText("requests: "); - pos.x() = requestsLabel->getBound().xMax(); + pos.x() = requestsLabel->getBoundingBox().xMax(); osg::ref_ptr requestList = new osgText::Text; _statsGeode->addDrawable( requestList.get() ); @@ -1425,7 +1425,7 @@ void StatsHandler::setUpScene(osgViewer::ViewerBase* viewer) requestList->setPosition(pos); requestList->setText("0"); - pos.x() = requestList->getBound().xMax() + 2.0f*_characterSize;; + pos.x() = requestList->getBoundingBox().xMax() + 2.0f*_characterSize;; osg::ref_ptr compileLabel = new osgText::Text; _statsGeode->addDrawable( compileLabel.get() ); @@ -1436,7 +1436,7 @@ void StatsHandler::setUpScene(osgViewer::ViewerBase* viewer) compileLabel->setPosition(pos); compileLabel->setText("tocompile: "); - pos.x() = compileLabel->getBound().xMax(); + pos.x() = compileLabel->getBoundingBox().xMax(); osg::ref_ptr compileList = new osgText::Text; _statsGeode->addDrawable( compileList.get() ); @@ -1447,7 +1447,7 @@ void StatsHandler::setUpScene(osgViewer::ViewerBase* viewer) compileList->setPosition(pos); compileList->setText("0"); - pos.x() = maxLabel->getBound().xMax(); + pos.x() = maxLabel->getBoundingBox().xMax(); _statsGeode->setCullCallback(new PagerCallback(dp, minValue.get(), maxValue.get(), averageValue.get(), requestList.get(), compileList.get(), 1000.0)); } @@ -1626,7 +1626,7 @@ void StatsHandler::createTimeStatsLine(const std::string& lineLabel, label->setPosition(pos); label->setText(lineLabel + ": "); - pos.x() = label->getBound().xMax(); + pos.x() = label->getBoundingBox().xMax(); osg::ref_ptr value = new osgText::Text; _statsGeode->addDrawable( value.get() ); diff --git a/src/osgWidget/Label.cpp b/src/osgWidget/Label.cpp index 37b462571..3731bca8c 100644 --- a/src/osgWidget/Label.cpp +++ b/src/osgWidget/Label.cpp @@ -141,7 +141,7 @@ void Label::setShadow(point_type offset) { } XYCoord Label::getTextSize() const { - osg::BoundingBox bb = _text->getBound(); + const osg::BoundingBox& bb = _text->getBoundingBox(); return XYCoord( osg::round(bb.xMax() - bb.xMin()),