-
Notifications
You must be signed in to change notification settings - Fork 285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix refresh of LineSegmentShapeNode #1381
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1381 +/- ##
=======================================
Coverage 56.97% 56.97%
=======================================
Files 366 366
Lines 27460 27460
=======================================
Hits 15646 15646
Misses 11814 11814 |
::osg::ref_ptr<::osg::DrawElementsUInt> elements | ||
= new ::osg::DrawElementsUInt(::osg::PrimitiveSet::LINES); | ||
elements->reserve(2 * connections.size()); | ||
mElements->resize(2 * connections.size()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we want to use resize(~)
alongside push_back(~)
, because that means we're going to make mElements
the size 2 * connections.size()
and then later push back an additional 2 * connections.size()
number of new elements.
I would recommend using reserve(2 * connections.size()
and then clear()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively resize(~)
and then [2*i] =
and [2*i+1] =
would also work, but that feels more risky to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching this out. Let me fix this as suggested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! Thanks for correcting my flub 😅
It was an easy fix! Thanks for the review. |
LineSegmentShapeNode
keeps adding new line segments instead of refreshing with new line. See the details in #1380 and this post.Resolves #1380.
Before creating a pull request
clang-format
Before merging a pull request
CHANGELOG.md