From e145f27b3b689a3b48a3df06596671930a119950 Mon Sep 17 00:00:00 2001 From: Jeongseok Lee Date: Tue, 30 Jul 2019 08:16:34 -0700 Subject: [PATCH 1/3] Fix refresh of LineSegmentShapeNode --- dart/gui/osg/render/LineSegmentShapeNode.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/dart/gui/osg/render/LineSegmentShapeNode.cpp b/dart/gui/osg/render/LineSegmentShapeNode.cpp index 3daf6f578a3db..8b9bb0117c3c8 100644 --- a/dart/gui/osg/render/LineSegmentShapeNode.cpp +++ b/dart/gui/osg/render/LineSegmentShapeNode.cpp @@ -84,6 +84,7 @@ class LineSegmentShapeDrawable : public ::osg::Geometry ::osg::ref_ptr<::osg::Vec3Array> mVertices; ::osg::ref_ptr<::osg::Vec4Array> mColors; + ::osg::ref_ptr<::osg::DrawElementsUInt> mElements; }; //============================================================================== @@ -187,8 +188,10 @@ LineSegmentShapeDrawable::LineSegmentShapeDrawable( : mLineSegmentShape(shape), mVisualAspect(visualAspect), mVertices(new ::osg::Vec3Array), - mColors(new ::osg::Vec4Array) + mColors(new ::osg::Vec4Array), + mElements(new ::osg::DrawElementsUInt(::osg::PrimitiveSet::LINES)) { + addPrimitiveSet(mElements); refresh(true); } @@ -207,18 +210,16 @@ void LineSegmentShapeDrawable::refresh(bool firstTime) const common::aligned_vector& connections = mLineSegmentShape->getConnections(); - ::osg::ref_ptr<::osg::DrawElementsUInt> elements - = new ::osg::DrawElementsUInt(::osg::PrimitiveSet::LINES); - elements->reserve(2 * connections.size()); + mElements->resize(2 * connections.size()); for (std::size_t i = 0; i < connections.size(); ++i) { const Eigen::Vector2i& c = connections[i]; - elements->push_back(c[0]); - elements->push_back(c[1]); + mElements->push_back(static_cast(c[0])); + mElements->push_back(static_cast(c[1])); } - addPrimitiveSet(elements); + setPrimitiveSet(0, mElements); } if (mLineSegmentShape->checkDataVariance( From 3fa3ace0634aac4eecc9c9fe7e79770ebc6a4d64 Mon Sep 17 00:00:00 2001 From: Jeongseok Lee Date: Tue, 30 Jul 2019 08:20:55 -0700 Subject: [PATCH 2/3] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 70c86299da8ce..1b67bf2d89fab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ * Fixed memory leaks from dart::gui::osg::Viewer: [#1349](https://github.com/dartsim/dart/pull/1349) * Added point rendering mode to PointCloudShape: [#1351](https://github.com/dartsim/dart/pull/1351), [#1355](https://github.com/dartsim/dart/pull/1355) * Updated ImGui to 1.71: [#1362](https://github.com/dartsim/dart/pull/1362) + * Fixed refresh of LineSegmentShapeNode: [#1381](https://github.com/dartsim/dart/pull/1381) * dartpy From 77469a7c03262b7c26ccf4eb6a39dc44243c7fb6 Mon Sep 17 00:00:00 2001 From: Jeongseok Lee Date: Tue, 30 Jul 2019 18:29:08 -0700 Subject: [PATCH 3/3] Fix element vector update --- dart/gui/osg/render/LineSegmentShapeNode.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dart/gui/osg/render/LineSegmentShapeNode.cpp b/dart/gui/osg/render/LineSegmentShapeNode.cpp index 8b9bb0117c3c8..63dd2d181f64a 100644 --- a/dart/gui/osg/render/LineSegmentShapeNode.cpp +++ b/dart/gui/osg/render/LineSegmentShapeNode.cpp @@ -210,7 +210,8 @@ void LineSegmentShapeDrawable::refresh(bool firstTime) const common::aligned_vector& connections = mLineSegmentShape->getConnections(); - mElements->resize(2 * connections.size()); + mElements->clear(); + mElements->reserve(2 * connections.size()); for (std::size_t i = 0; i < connections.size(); ++i) {