Skip to content

feat: add bullet3 collision system - #24

Merged
LoayAhmed304 merged 15 commits into
mainfrom
feat/initial-collision
Apr 17, 2026
Merged

feat: add bullet3 collision system#24
LoayAhmed304 merged 15 commits into
mainfrom
feat/initial-collision

Conversation

@LoayAhmed304

@LoayAhmed304 LoayAhmed304 commented Apr 13, 2026

Copy link
Copy Markdown
Collaborator

Most important things to notice

  • Implement support for Sphere and Capsule shapes. The next commit is to have for Box shape too
  • Expose raycast() function that takes target type and max distance and returns the first entity it hits of the specified type. This may be used in shooting to get the shot enemy entity (call raycast on left mouse click)

@LoayAhmed304
LoayAhmed304 force-pushed the feat/initial-collision branch from 59fe0c8 to 71fbd3a Compare April 13, 2026 18:32
Comment thread src/states/play-state.hpp Outdated
Comment thread src/game/systems/collision-system.cpp
Comment thread src/game/systems/collision-system.cpp Outdated
Comment thread src/game/systems/collision-system.cpp Outdated
Comment thread src/game/systems/collision-system.cpp
Comment thread src/game/systems/collision-system.cpp
Comment thread src/states/play-state.hpp Outdated
Comment thread src/game/systems/collision-system.cpp

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Integrates a Bullet3-backed collision system into the game loop, adding collider layers and exposing query helpers (raycast/overlap) for gameplay usage.

Changes:

  • Add CollisionSystem (Bullet collision world integration) with per-frame collision events + basic pushback.
  • Extend ColliderComponent with CollisionLayer and layer parsing from JSON.
  • Wire collision system lifecycle into Playstate and add a sample collision-focused scene config.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/states/play-state.hpp Initializes, updates, and destroys the new collision system as part of the play loop.
src/game/systems/collision-system.hpp Declares collision system API (update, raycast, overlapSphere) and event/result structs.
src/game/systems/collision-system.cpp Implements Bullet world sync, contact extraction, pushback, raycast, and overlapSphere.
src/game/components/collider.hpp Adds bitmask-based collision layers and updates ColliderComponent to use them.
src/game/components/collider.cpp Adds JSON string → CollisionLayer parsing.
config/json-configs/collision.jsonc Adds a sample scene demonstrating capsule/sphere colliders and layers.
CMakeLists.txt Adds the collision system source to the build.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/game/systems/collision-system.cpp
Comment thread src/game/systems/collision-system.hpp Outdated
Comment thread src/game/systems/collision-system.cpp Outdated
Comment thread src/game/systems/collision-system.cpp Outdated
Comment thread src/game/systems/collision-system.cpp Outdated
Comment thread src/game/systems/collision-system.hpp
Comment thread src/game/systems/collision-system.cpp Outdated
@AhmedSobhy01

Copy link
Copy Markdown
Collaborator
image

With this config:

"world": [
            {
                "position": [0, 1.7, 6],
                "components": [
                    { "type": "Camera" },
                    { "type": "Free Camera Controller" }
                ]
            },
            {
                "name": "Haha",
                "scale": [2, 2, 2],
                "position": [0, 1, 0],
                "children": [
                    {
                        "components": [
                            { "type": "Mesh Renderer", "mesh": "sphere", "material": "moon" },
                            { "type": "Collider", "shape": "Sphere", "radius": 1, "layer": "enemy" }
                        ]
                    }
                ]
            },
            {
                "name": "Hehe",
                "position": [1.5, 1, 0],
                "components": [
                    { "type": "Mesh Renderer", "mesh": "sphere", "material": "metal" },
                    { "type": "Collider", "shape": "Sphere", "radius": 1, "layer": "environment" }
                ]
            }
        ]

They get separated by the wrong amount relative to the overlap, probably because the child collider only uses local scale when created, and the pushback is calculated with the wrong inverse.

Comment thread src/game/systems/collision-system.cpp
AhmedSobhy01
AhmedSobhy01 previously approved these changes Apr 17, 2026

@AhmedSobhy01 AhmedSobhy01 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you sir, great addition!

Let's close this, but keep in mind we still have issues with changing scaling during runtime and also with parent scaling.

@AhmedAmrNabil AhmedAmrNabil left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but check comments

Comment thread src/game/systems/collision-system.cpp
Comment thread src/game/systems/collision-system.cpp

@AhmedAmrNabil AhmedAmrNabil left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@AhmedSobhy01 AhmedSobhy01 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@LoayAhmed304 LoayAhmed304 reopened this Apr 17, 2026
@LoayAhmed304 LoayAhmed304 changed the title feat: integrate bullet3 collision system feat: add bullet3 collision system Apr 17, 2026
@LoayAhmed304
LoayAhmed304 merged commit 489029d into main Apr 17, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants