bepu / bepuphysics2

Pure C# 3D real time physics simulation library, now with a higher version number.
Apache License 2.0
2.25k stars 261 forks source link

Utilize static virtual members #287

Closed Saalvage closed 10 months ago

Saalvage commented 10 months ago

Inspired by the TODO on IShape.

Primarily intended to eliminate the following two antipatterns:

This PR could be both overzealous (taking away the ability to vary behavior by instance) and non-exhaustive at the same time. I addressed the above mentioned antipatterns, then skimmed over all interfaces and how they are used, trying to get a rough idea of whether making them static appears sensible. A deeper understanding of the engine might allow better judgement on some of these calls.

I've also taken the liberty of fixing a typo here and there and removing a redundant unsafe when it was next to the code I was modifying.

I understand that this PR is quite large (although it contains no functional changes!) If desired I could split it up into a part solely addressing the "safe" fixes to the antipatterns above and then see where it's going from there.

P.S.: Thank you for this awesome lib!

RossNordby commented 10 months ago

Thanks! I'm out of town for a little bit, but at a glance this looks fine; should be able to get to it in a few days.

RossNordby commented 10 months ago

Looks good, merged and thanks!