RobotLocomotion / drake

Model-based design and verification for robotics.
https://drake.mit.edu
Other
3.35k stars 1.27k forks source link

[multibody] Remove dynamic_cast from snake_case inline functions #22205

Closed jwnimmer-tri closed 4 days ago

jwnimmer-tri commented 5 days ago

Using dynamic_cast in an inline function is verboten per our style guide. This commit replaces it with a static_cast. This change is tangentially inspired by #22204.

We could move the existing implementation to the cc file instead, but fixing the cast seems to me like the better approach.


This change is Reviewable

jwnimmer-tri commented 5 days ago

+@sherm1 for a first look of this new pattern, please. If you like it, I'll replicate the same pattern to all of the joint types.

CC @rpoyner-tri FYI

jwnimmer-tri commented 5 days ago

Right, I don't know if there is a performance benefit either. The question is do we want inline static_cast in the header, or stick with dynamic_cast and move the function bodies to the cc file instead? Either way resolves the styleguide violation. If we think these have no reason to be inline, then I'm happy to just move them to the cc file as-is (possibly still de-duplicating a bit).

jwnimmer-tri commented 5 days ago

Okay, I've pushed the same approach to all joints now.