Hybrid hitboxes#382
Open
nickalreadyinuse wants to merge 4 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR implements a new “hybrid hitbox” system for multiplayer hit detection by replacing the legacy single AABB player hitbox with a split shape approach (lower capsule + upper tilted cylinder + head sphere), including lag-compensation-aware head tracking and optional debug rendering to visualize the resulting volumes.
Changes:
- Adds split hitbox intersection logic (capsule/cylinder/sphere) and installs a call-site hook to replace the legacy AABB intersection in the multiplayer entity collision path.
- Introduces a dedicated-server config toggle (
legacy_hitboxes) and propagates it via join-accept feature flags. - Adds debug rendering toggles to visualize the new hitboxes (and optionally collision spheres).
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| game_patch/rf/vmesh.h | Exposes vmesh_get_csphere_pos to fetch collision-sphere world positions. |
| game_patch/multi/server.h | Adds server_legacy_hitboxes() accessor. |
| game_patch/multi/server.cpp | Toggles a lag-comp flag around weapon-fire handling. |
| game_patch/multi/server_internal.h | Adds new server config fields (legacy_hitboxes, exclude_bots_from_player_count). |
| game_patch/multi/network.h | Adds legacy_hitboxes join-accept feature flag bit. |
| game_patch/multi/network.cpp | Sends/parses legacy_hitboxes in join accept extension. |
| game_patch/multi/multi.h | Publishes compute_tilt_axis() and set_lag_comp_flag() APIs + server info field. |
| game_patch/multi/multi.cpp | Implements the new hybrid hitbox intersection + head tracking + hook installation. |
| game_patch/multi/dedi_cfg.cpp | Parses/prints legacy_hitboxes and exclude_bots_from_player_count config keys. |
| game_patch/debug/debug.cpp | Renders the new hitboxes (and optional cspheres) when debug flag enabled. |
| game_patch/debug/debug_internal.h | Declares new debug globals. |
| game_patch/debug/debug_cmd.cpp | Adds debug hitbox flag (but currently misses wiring for csphere toggle). |
| docs/CHANGELOG.md | Documents the new hitbox system in the changelog. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+750
to
+755
| if (!(entity && upper_height > geo.radius)) { | ||
| geo.split = false; | ||
| geo.lower_bot = {cx, bbox_min.y, cz}; | ||
| geo.lower_top = {cx, bbox_max.y, cz}; | ||
| return geo; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces single rectangular player hitbox with three hitboxes:
Sphere - head
Cylinder - torso
Capsule - legs
Hitboxes shrink correctly when players crouch and the torso/head hitbox moves with the player's pitch. Playtested quite a bit over the past month or so with bots (and with a range of client latency), but needs some testing with humans. Makes the game somewhat more difficult as these conform much better to the mesh than the stock hitbox. Very noticeable difference when shooting someone in the side.