From e2f826b8fcfc49b9ce07577af15ad4a3fd2c158e Mon Sep 17 00:00:00 2001 From: Mathieu MARACHE Date: Tue, 29 Aug 2017 11:34:27 +0200 Subject: [PATCH 1/5] Under macOS the glValidateProgram reports too many false negatives (errors) about missing buffers, etc.. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From the internet https://stackoverflow.com/questions/15335510/opengl-glvalidateprogram-error-on-mac-os-x : « […] The purpose of glValidateProgram is not to use it as an added "check" step after linking the program, because the GL and application state is hardly ready for actually using that program at this point, probably it's even before we get around to initializing the default framebuffer (its bitdepth, its multisample buffers, etc), and that's what the error hints at. An appropriate place to call glValidateProgram would be right before you make a real render call. » --- src/osg/Program.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/osg/Program.cpp b/src/osg/Program.cpp index 7092a565a..85c49a37d 100644 --- a/src/osg/Program.cpp +++ b/src/osg/Program.cpp @@ -517,9 +517,10 @@ void Program::apply( osg::State& state ) const // for shader debugging: to minimize performance impact, // optionally validate based on notify level. // TODO: enable this using notify level, or perhaps its own getenv()? +#ifndef __APPLE__ if( osg::isNotifyEnabled(osg::INFO) ) pcp->validateProgram(); - +#endif pcp->useProgram(); state.setLastAppliedProgramObject(pcp); } From 4c4f760d4a337e92bf1f77cb63a32850dae6a38f Mon Sep 17 00:00:00 2001 From: Julien Valentin Date: Wed, 30 Aug 2017 23:15:01 +0200 Subject: [PATCH 2/5] fix a bug in how vertexattributes are filled --- src/osgAnimation/RigTransformHardware.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/osgAnimation/RigTransformHardware.cpp b/src/osgAnimation/RigTransformHardware.cpp index fbe4e9de1..651e48cf7 100644 --- a/src/osgAnimation/RigTransformHardware.cpp +++ b/src/osgAnimation/RigTransformHardware.cpp @@ -136,9 +136,6 @@ bool RigTransformHardware::createPalette(int nbVertexes, BoneMap boneMap, const OSG_INFO << "RigTransformHardware::createPalette will use " << boneNameCountMap.size() * 4 << " uniforms" << std::endl; - for (int i = 0 ; i < (int)vertexIndexWeight.size(); i++) - vertexIndexWeight[i].resize(maxBonePerVertex); - _nbVertexes = nbVertexes; _bonesPerVertex = maxBonePerVertex; _bonePalette = palette; @@ -181,7 +178,7 @@ RigTransformHardware::BoneWeightAttribList RigTransformHardware::createVertexAtt int boneIndexInVec4 = b*2; (*array)[j][0 + boneIndexInVec4] = 0; (*array)[j][1 + boneIndexInVec4] = 0; - if (boneIndexInList < getNumBonesPerVertex()) + if (boneIndexInList < _vertexIndexMatrixWeightList[j].size()) { float boneIndex = static_cast(_vertexIndexMatrixWeightList[j][boneIndexInList].getIndex()); float boneWeight = _vertexIndexMatrixWeightList[j][boneIndexInList].getWeight(); From 6048c1fbdc3432b137b30b6cbfe87e449b8fc4cf Mon Sep 17 00:00:00 2001 From: scrawl <720642+scrawl@users.noreply.github.com> Date: Sun, 3 Sep 2017 14:15:36 +0000 Subject: [PATCH 3/5] LineSegmentIntersector: respect the 'cullingActive' flag when testing drawable bounding box --- src/osgUtil/LineSegmentIntersector.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/osgUtil/LineSegmentIntersector.cpp b/src/osgUtil/LineSegmentIntersector.cpp index 63cb30366..5a6b69afe 100644 --- a/src/osgUtil/LineSegmentIntersector.cpp +++ b/src/osgUtil/LineSegmentIntersector.cpp @@ -500,7 +500,7 @@ void LineSegmentIntersector::intersect(osgUtil::IntersectionVisitor& iv, osg::Dr if (reachedLimit()) return; osg::Vec3d s(_start), e(_end); - if ( !intersectAndClip( s, e, drawable->getBoundingBox() ) ) return; + if ( drawable->isCullingActive() && !intersectAndClip( s, e, drawable->getBoundingBox() ) ) return; if (iv.getDoDummyTraversal()) return; From 3503a0fefb112436ccedd958af382f3076ee12b9 Mon Sep 17 00:00:00 2001 From: "Konstantin S. Matveyev" Date: Mon, 4 Sep 2017 11:29:50 +0300 Subject: [PATCH 4/5] Text3D dynamic changing fix --- src/osgText/Text3D.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/osgText/Text3D.cpp b/src/osgText/Text3D.cpp index 98056db58..ef9561422 100644 --- a/src/osgText/Text3D.cpp +++ b/src/osgText/Text3D.cpp @@ -438,9 +438,11 @@ void Text3D::computeGlyphRepresentation() { (*_coords)[i] += position; } + _coords->dirty(); // copy normals _normals->insert(_normals->end(), src_normals->begin(), src_normals->end()); + _normals->dirty(); copyAndOffsetPrimitiveSets(_frontPrimitiveSetList, it->_glyphGeometry->getFrontPrimitiveSetList(), base); copyAndOffsetPrimitiveSets(_wallPrimitiveSetList, it->_glyphGeometry->getWallPrimitiveSetList(), base); From ca42523cd0da3532309d8d6d948ff30969cb5154 Mon Sep 17 00:00:00 2001 From: "Konstantin S. Matveyev" Date: Mon, 4 Sep 2017 11:44:30 +0300 Subject: [PATCH 5/5] example_osgtext3d: more options for testing --- examples/osgtext3D/osgtext3D.cpp | 49 +++++++++++++++++++------------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/examples/osgtext3D/osgtext3D.cpp b/examples/osgtext3D/osgtext3D.cpp index 24178d039..62197139b 100644 --- a/examples/osgtext3D/osgtext3D.cpp +++ b/examples/osgtext3D/osgtext3D.cpp @@ -49,23 +49,34 @@ public: { if (ea.getKey() == osgGA::GUIEventAdapter::KEY_Up) { - m_Text3D->setCharacterSize(m_Text3D->getCharacterHeight() + 0.1); // failed - OSG_NOTICE<<"m_Text3D->getCharacterHeight()="<getCharacterHeight()<setCharacterSize(m_Text3D->getCharacterHeight() + 0.1); + OSG_NOTICE<<"m_Text3D->getCharacterHeight() = " << m_Text3D->getCharacterHeight() << std::endl; } else if (ea.getKey() == osgGA::GUIEventAdapter::KEY_Down) { - m_Text3D->setCharacterDepth(m_Text3D->getCharacterDepth() + 0.1); // ok - OSG_NOTICE<<"m_Text3D->getCharacterDepth()="<getCharacterDepth()<setCharacterDepth(m_Text3D->getCharacterDepth() + 0.1); + OSG_NOTICE<<"m_Text3D->getCharacterDepth() = " << m_Text3D->getCharacterDepth() << std::endl; } else if (ea.getKey() == osgGA::GUIEventAdapter::KEY_Left) { - m_Text3D->setText("setText\nworks!", osgText::String::ENCODING_UTF8); // ok - OSG_NOTICE<<"m_Text3D->getText()="<getText().size()<setText("Press arrow keys.", osgText::String::ENCODING_UTF8); + else if (counter%3 == 1) + m_Text3D->setText("setText\nworks!", osgText::String::ENCODING_UTF8); + else if (counter%3 == 2) + m_Text3D->setText("setText really works?", osgText::String::ENCODING_UTF8); + else if (counter%3 == 3) + m_Text3D->setText("setText works, really!", osgText::String::ENCODING_UTF8); + + ++counter; + + OSG_NOTICE<<"m_Text3D->getText().size() = " << m_Text3D->getText().size() << std::endl; } else if (ea.getKey() == osgGA::GUIEventAdapter::KEY_Right) { m_Text3D->setLineSpacing(m_Text3D->getLineSpacing() + 0.1); - OSG_NOTICE<<"m_Text3D->getLineSpacing()="<getLineSpacing()<getLineSpacing() = " << m_Text3D->getLineSpacing() << std::endl; } } @@ -90,7 +101,7 @@ int main(int argc, char** argv) if (!font) return 1; OSG_NOTICE<<"Read font "< style = new osgText::Style; @@ -238,18 +249,18 @@ int main(int argc, char** argv) geode->addDrawable( osg::createTexturedQuadGeometry(osg::Vec3(0.0f,characterSize*thickness,0.0f),osg::Vec3(characterSize,0.0,0.0),osg::Vec3(0.0f,0.0,characterSize), 0.0, 0.0, 1.0, 1.0) ); } - if (arguments.read("--add-axes")) - group->addChild(osgDB::readNodeFile("axes.osgt")); + if (arguments.read("--add-axes")) + group->addChild(osgDB::readNodeFile("axes.osgt")); - std::string mode; - if (arguments.read("--character-size-mode", mode)) - { - if (mode == "screen_coords") - { - text3D->setCharacterSizeMode(osgText::TextBase::SCREEN_COORDS); - text3D->setCharacterSize(1080/4); - } - } + std::string mode; + if (arguments.read("--character-size-mode", mode)) + { + if (mode == "screen_coords") + { + text3D->setCharacterSizeMode(osgText::TextBase::SCREEN_COORDS); + text3D->setCharacterSize(1080/4); + } + } viewer.addEventHandler(new Text3DAttributeHandler(text3D)); }