-
Notifications
You must be signed in to change notification settings - Fork 92
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
get rid of dynamic_cast #143
Conversation
src/body_operations.cpp
Outdated
@@ -160,9 +160,11 @@ void bodies::computeBoundingSphere(const std::vector<const bodies::Body*>& bodie | |||
unsigned int vertex_count = 0; | |||
for (auto body : bodies) | |||
{ | |||
const bodies::ConvexMesh* conv = dynamic_cast<const bodies::ConvexMesh*>(body); | |||
if (!conv) | |||
if (body->type != MESH) |
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.
First test if body != nullptr
. The old check would rule such cases out, whether the suggested change would segfault.
2fceb43
to
4dedda8
Compare
First test if `body != nullptr`.
The old check would rule such cases out, whether the suggested change would segfault.
True, I updated the patch.
I'm not perfectly happy with silently skipping nullptr's in the list,
but the patch was not meant to change behavior.
|
@v4hn, have you seen that your code is broken? For example, you need to use |
This library does not need RTTI as all bodies & shapes are marked with `type`. The EXPECT_TRUE in the test degenerates to true for all minimally-optimizing compilers. Replaced it with something meaningful.
4dedda8
to
25d35aa
Compare
@v4hn, have you seen that your code is broken? For example, you need to use `type_` instead of `type`.
Actually, CI was partially just broken for this test for network issues. But yes, there was still one more namespace mistake I just fixed.
|
Codecov Report
@@ Coverage Diff @@
## noetic-devel #143 +/- ##
================================================
+ Coverage 48.01% 55.60% +7.59%
================================================
Files 11 11
Lines 1689 1721 +32
================================================
+ Hits 811 957 +146
+ Misses 878 764 -114
Continue to review full report at Codecov.
|
This library does not need RTTI as all bodies & shapes are marked with a `type`.
This library does not need RTTI as all bodies & shapes are marked with
type
.The EXPECT_TRUE in the test degenerates to true for all minimally-optimizing compilers.
Replaced it with something meaningful.
should be backported to melodic.