feat: allow to create mesh colliders without mesh components#460
Conversation
📝 WalkthroughWalkthroughAdds optional embedded mesh storage to MeshCollider and ConvexHullMeshCollider; updates RigidBodySystem to prefer embedded mesh, fall back to entity Changes
Sequence Diagram(s)sequenceDiagram
participant RigidBodySystem as RigidBodySystem
participant Collider as Collider(Component)
participant Registry as Registry/Object
participant ShapeFactory as ShapeCreator
RigidBodySystem->>Collider: Inspect collider (ConvexHull/MeshCollider)
alt collider has embedded mesh
Collider-->>RigidBodySystem: return embedded Mesh
else no embedded mesh
RigidBodySystem->>Registry: get Object::Mesh component
alt Object::Mesh present
Registry-->>RigidBodySystem: return Mesh
else missing mesh
Registry-->>RigidBodySystem: none (log warning)
RigidBodySystem-->>RigidBodySystem: abort shape creation
end
end
RigidBodySystem->>ShapeFactory: CreateMeshShapeFromMesh(resolved Mesh)
ShapeFactory-->>RigidBodySystem: collision shape
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|



Not related to any issues.
Allow to create mesh colliders (and convex hull mesh colliders) by passing them a mesh instead of adding it as a component.
For physics this can be useful to create an invisible terrain collider
Sonar wants us to "reduce the complexity" of the function to create a shape but it's useless, splitting into two functions would create spaghetti code
Summary by CodeRabbit
New Features
Improvements
✏️ Tip: You can customize this high-level summary in your review settings.