u3d-community / U3D

Open-source, cross-platform 2D and 3D game engine built in C++
https://u3d.io
MIT License
160 stars 26 forks source link

CollisionShape::UpdateShape() is private #40

Open SirNate0 opened 1 year ago

SirNate0 commented 1 year ago

CollisionShape supports being overloaded to allow users to wrap additional btCollisionShapes through UpdateDerivedShape. In working on a MultiSphereHullShape (for btMultiSphereShape), I realized the API could be improved - the UpdateShape function that is called that actually updates the shape_ member is private. This can be worked around by calling SetShapeType twice, but that updates the shape twice rather than once. Instead, I think we should just make UpdateShape protected. Possibly also MarkShapeDirty.


I intend to share the MultiSphereHullShape code as well, so remind me if I forget. Using some geometry nodes with modern Blender, I have a fairly decent workflow for creating them using an edge to mark the position and diameter of each sphere that make up the hull. They have proven fairly useful in generating complex close-fitting collision shapes to detect damage to my game's creatures, while in theory (I have not tested much) remaining more performant than mesh-based alternatives.