jrouwe / JoltPhysics

A multi core friendly rigid body physics and collision detection library. Written in C++. Suitable for games and VR applications. Used by Horizon Forbidden West.
MIT License
6k stars 374 forks source link

NonCopyable is missing move operations #1144

Closed Evangel63 closed 3 weeks ago

Evangel63 commented 4 weeks ago

JPH::NonCopyable (and derived classes) are missing the move operations (move construction/assignment). Is there any reason for them to be non-moveable?

jrouwe commented 4 weeks ago

I only marked classes NonCopyable where I thought it would not make sense to copy/move them or where it is even dangerous to do so (e.g. because of internal pointers). Which class would you like to move?

Evangel63 commented 4 weeks ago

JPH::DebugRenderer, it's only got JPH::Ref and UnorderedMap members, but the documentation for NonCopyable didn't say anything about moving, so I thought it was a mistake.

jrouwe commented 4 weeks ago

JPH::DebugRenderer is a singleton that you allocate once and then keep until you're done simulating. In its constructor it sets the DebugRenderer::sInstance member (= pointer to the instance). I don't really see a reason for ever wanting to move this class to a new location, so I marked it as NonCopyable.