Skip to content
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

Merged
merged 3 commits into from
Jul 31, 2019
Merged

Conversation

jslee02
Copy link
Member

@jslee02 jslee02 commented Jul 30, 2019

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

  • Document new methods and classes
  • Format new code files using clang-format

Before merging a pull request

  • Set version target by selecting a milestone on the right side
  • Summarize this change in CHANGELOG.md
  • Add unit test(s) for this change (N/A)

@jslee02 jslee02 requested a review from mxgrey July 30, 2019 16:51
@codecov
Copy link

codecov bot commented Jul 30, 2019

Codecov Report

Merging #1381 into master will not change coverage.
The diff coverage is n/a.

@@           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());
Copy link
Member

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().

Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

@mxgrey mxgrey left a 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 😅

@jslee02
Copy link
Member Author

jslee02 commented Jul 31, 2019

It was an easy fix! Thanks for the review.

@jslee02 jslee02 merged commit 74317c5 into master Jul 31, 2019
@jslee02 jslee02 deleted the bugfix/line_segment_shape branch July 31, 2019 05:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Setting DataVariance=DYNAMIC causes simulation to slow and then stop
2 participants