BallSystem: use OBB circle test for weapon melee detection #79

Merged
cammymoop merged 1 commit from feature/ball-system-weapon-obb into master 2026-03-05 14:45:09 -06:00
Collaborator

Summary

  • Replaces the circular approximation for weapon hit detection with an exact circle-vs-OBB intersection test.
  • Ball center is transformed into the rectangle local frame (using weapon_area.global_rotation), closest point on the AABB is found via clamp, squared distance compared against ball radius.
  • Weapon shape parameters: RectangleShape2D size=(110,38) → half_extents=(55,19). Exposed as @export var weapon_half_extents on BallSystem.
  • Cheap broadphase circle (diagonal of half-extents) still guards the per-ball OBB call to skip clearly-out-of-range balls.

Test plan

  • Headless run exits clean
  • Melee hits fire when the weapon arc physically overlaps a ball, not just the weapon center proximity circle
## Summary - Replaces the circular approximation for weapon hit detection with an exact circle-vs-OBB intersection test. - Ball center is transformed into the rectangle local frame (using `weapon_area.global_rotation`), closest point on the AABB is found via clamp, squared distance compared against ball radius. - Weapon shape parameters: `RectangleShape2D size=(110,38)` → `half_extents=(55,19)`. Exposed as `@export var weapon_half_extents` on BallSystem. - Cheap broadphase circle (diagonal of half-extents) still guards the per-ball OBB call to skip clearly-out-of-range balls. ## Test plan - [x] Headless run exits clean - [ ] Melee hits fire when the weapon arc physically overlaps a ball, not just the weapon center proximity circle
Replaces the circular approximation (distance to weapon_area center)
with an exact circle-vs-OBB intersection: the ball center is
transformed into the weapon rectangle's local frame, the closest
point on the AABB is found via clamp, and the squared distance is
compared against ball_radius². A cheap broadphase circle (diagonal of
the rectangle's half-extents) still guards the per-ball OBB call.

Weapon shape: RectangleShape2D size=(110,38), half-extents=(55,19),
from player.tscn. weapon_half_extents is an @export on BallSystem so
it can be updated if the weapon shape changes without touching code.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
cammymoop merged commit 27390e1c03 into master 2026-03-05 14:45:09 -06:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cammymoop/semi-vibed-game!79
No description provided.