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

Introduce `IDisposableShape` #295

Closed Saalvage closed 8 months ago

Saalvage commented 8 months ago

Allows for properly disposing of a shape, given only an IShape without having to do various type checks.

An alternative approach would be introducing something like IBufferPoolDisposable and tagging everything in the library that supports disposing via a buffer pool. Potential use cases for that would be tracking everything that needs disposing for a BufferPool instance or something along those lines? If that seems like a more appropriate approach I can adjust the PR, but I personally feel like this is probably sufficient for now.

RossNordby commented 8 months ago

I'm on the fence about this a little bit, but it's a small change with nonzero use and effectively zero possible downside other than a tiny amount of refactoring effort later.

It'd be nice to have the more general version, but off the top of my head, it'd probably get blocked by subtle variations in the dispose signature (e.g. different parameters) and would give a false sense of universality, so a more focused option for a dedicated use case seems reasonable.

Thanks!