Skip to content

Add rotateable hitbox support for collision detection#7

Closed
Copilot wants to merge 4 commits into
masterfrom
copilot/add-rotatable-hitboxes
Closed

Add rotateable hitbox support for collision detection#7
Copilot wants to merge 4 commits into
masterfrom
copilot/add-rotatable-hitboxes

Conversation

Copilot AI commented Nov 29, 2025

Copy link
Copy Markdown

Adds rotated rectangle collision detection using Separating Axis Theorem (SAT), enabling mechanics like swimming, rope swinging, and rotating platforms.

Changes

New RotatedRectf class (src/math/rotated_rectf.hpp/.cpp)

  • Rectangle represented by center, half-extents, and rotation angle
  • SAT-based overlaps() for rotated-vs-rotated and rotated-vs-AABB collision
  • Helper methods: get_corners(), get_axes(), get_aabb(), contains()

CollisionObject rotation support

  • Added m_rotation_angle member with accessors
  • get_rotated_bbox() returns SAT-compatible representation
  • has_rotation() for fast path when angle is zero

CollisionSystem integration

  • collision_object() and touchable collision checks use SAT when either object has rotation
  • Debug drawing renders rotated hitboxes as outlines with rotation indicator

Scripting API

  • MovingObject::get_hitbox_rotation() / set_hitbox_rotation(angle) exposed to Squirrel

Usage

// C++
m_col.set_rotation_angle(M_PI / 4.0f);

// Squirrel
obj.set_hitbox_rotation(0.785398);

Tests

Added RotatedRectfTest covering construction, point containment, corner calculation, AABB computation, and overlap detection.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Something that would be really benefitial is having rotateable hitboxes (for mechanics like swimming, swinging on ropes, rotating platforms etc.).


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI self-assigned this Nov 29, 2025
Copilot AI and others added 3 commits November 30, 2025 00:01
Co-authored-by: tobbi <583169+tobbi@users.noreply.github.com>
…x constant

Co-authored-by: tobbi <583169+tobbi@users.noreply.github.com>
Co-authored-by: tobbi <583169+tobbi@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for rotatable hitboxes Add rotateable hitbox support for collision detection Nov 30, 2025
Copilot AI requested a review from tobbi November 30, 2025 00:14
@tobbi tobbi closed this Jan 24, 2026
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