Skip to content

feat: allow to create mesh colliders without mesh components#460

Merged
ripel2 merged 7 commits into
mainfrom
create-mesh-colliders-without-mesh
Jan 31, 2026
Merged

feat: allow to create mesh colliders without mesh components#460
ripel2 merged 7 commits into
mainfrom
create-mesh-colliders-without-mesh

Conversation

@ripel2

@ripel2 ripel2 commented Jan 31, 2026

Copy link
Copy Markdown
Contributor

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

    • Colliders can embed mesh data directly for more flexible configuration.
  • Improvements

    • Shape creation now prefers embedded mesh then falls back to an entity mesh, with clearer warnings when no mesh is available.
    • Component docs and constructors clarified for more predictable behavior and handling of interior points.

✏️ Tip: You can customize this high-level summary in your review settings.

@ripel2 ripel2 self-assigned this Jan 31, 2026
@coderabbitai

coderabbitai Bot commented Jan 31, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Adds optional embedded mesh storage to MeshCollider and ConvexHullMeshCollider; updates RigidBodySystem to prefer embedded mesh, fall back to entity Object::Mesh, and pass the resolved mesh into mesh-shape creation, with clearer warnings when mesh data is missing.

Changes

Cohort / File(s) Summary
Collider component changes
src/plugin/physics/src/component/ConvexHullMeshCollider.hpp, src/plugin/physics/src/component/MeshCollider.hpp
Introduce std::optional<Object::Component::Mesh> mesh to allow embedding mesh data; add Mesh.hpp and <optional> includes; clarify docs; add explicit constructors for ConvexHullMeshCollider.
Shape creation logic
src/plugin/physics/src/system/RigidBodySystem.cpp
Resolve a single mesh source per collider (prefer embedded mesh, else use entity Object::Mesh); update warnings for missing mesh; propagate resolved mesh into CreateMeshShapeFromMesh to avoid repeated lookups.
Minor signature/docs
.../RigidBodySystem.cpp
Added NOSONAR comments to function parameters (signature annotation change only).

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

enhancement

Suggested reviewers

  • Divengerss

Poem

🐰
I hid a mesh within my fur so light,
Vertices tucked away from plain sight,
No need to fetch across the night,
Shapes form quick and hop just right—
Physics hums beneath the moonlight.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: allowing mesh colliders to be created without requiring separate mesh components by embedding mesh data directly.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch create-mesh-colliders-without-mesh

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ripel2 ripel2 requested a review from a team January 31, 2026 15:12
@ripel2 ripel2 merged commit fe237a0 into main Jan 31, 2026
5 checks passed
@ripel2 ripel2 deleted the create-mesh-colliders-without-mesh branch January 31, 2026 20:36
@Miou-zora Miou-zora restored the create-mesh-colliders-without-mesh branch January 31, 2026 20:36
@sonarqubecloud

Copy link
Copy Markdown

@Miou-zora Miou-zora deleted the create-mesh-colliders-without-mesh branch March 23, 2026 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants