collision_geometry_rotated_objects_test
AUTO-GENERATED FILE – DO NOT EDIT MANUALLY
Unit tests for CollisionGeometryUtils with rotated objects
PURPOSE: Isolate and test the root cause of indicator multiplication bug when objects are rotated.
CRITICAL BUG: When moving a rotated object, indicators are multiplied (26 → 52 → 78). Root cause hypothesis: Rotated shapes generate larger axis-aligned bounding boxes, causing more tiles to be detected than the actual shape occupies.
Test strategy:
- Test build_shape_transform() with rotation to verify transform composition
- Test that rotated shapes produce correct polygon representations
- Test that tile range calculation accounts for rotation correctly
- Test that overlap detection works correctly with rotated shapes
Source File: /addons/grid_building/test/utilities/collision/collision_geometry_rotated_objects_test.gd
Extends: GdUnitTestSuite
Constants
- Constant:
TILE_SIZE: Vector2 = Vector2(16, 16) - Constant:
SHAPE_SIZE: Vector2 = Vector2(32, 32) # 2x2 tiles when unrotated - Constant:
ROTATION_45_DEG: float = PI / 4.0 - Constant:
ROTATION_90_DEG: float = PI / 2.0 - Constant:
ORIGIN: Vector2 = Vector2.ZERO
Public Methods
test_build_shape_transform_no_rotation
| |
Test: build_shape_transform with no rotation produces identity + position Setup: Object at origin with no rotation, shape owner at origin Act: Build shape transform Assert: Transform has no rotation, origin at object’s global_position
test_build_shape_transform_90_degree_rotation
| |
Test: build_shape_transform with 90° rotation applies rotation correctly Setup: Object rotated 90° at origin, shape owner at origin Act: Build shape transform Assert: Transform has 90° rotation applied
test_build_shape_transform_45_degree_rotation
| |
Test: build_shape_transform with 45° rotation applies rotation correctly Setup: Object rotated 45° at origin, shape owner at origin Act: Build shape transform Assert: Transform has 45° rotation applied
test_build_shape_transform_with_shape_owner_offset_rotated
| |
Test: build_shape_transform with shape owner offset applies offset in rotated space Setup: Object rotated 90°, shape owner offset by (16, 0) local Act: Build shape transform Assert: Transform origin includes rotated offset (should be (100, 216) for 90° rotation)
test_rectangle_to_polygon_no_rotation
| |
Test: Rectangle shape converts to correct polygon when unrotated Setup: 32x32 rectangle at origin, no rotation Act: Convert to polygon Assert: Polygon has 4 vertices forming a 32x32 rectangle centered at origin
test_rectangle_to_polygon_45_degree_rotation
| |
Test: Rectangle shape converts to correct polygon when rotated 45° Setup: 32x32 rectangle at origin, rotated 45° Act: Convert to polygon Assert: Polygon has 4 vertices, bounding box is larger due to rotation (45.25x45.25)
test_rectangle_to_polygon_90_degree_rotation
| |
Test: Rectangle shape converts to correct polygon when rotated 90° Setup: 32x32 rectangle at origin, rotated 90° Act: Convert to polygon Assert: Polygon has 4 vertices, bounding box is still 32x32 (just rotated, no size change)
test_unrotated_rectangle_covers_4_tiles
| |
Test: CRITICAL - Unrotated 32x32 shape should cover exactly 2x2 = 4 tiles Setup: 32x32 rectangle at tile (0,0), 16x16 tiles, no rotation Act: Calculate which tiles the shape overlaps Expected: Exactly 4 tiles (2x2 grid)
This establishes the baseline: unrotated shape = 4 tiles
test_rotated_45_degree_rectangle_covers_similar_tiles
| |
Test: CRITICAL - Rotated 45° 32x32 shape should still cover approximately 4 tiles Setup: 32x32 rectangle at tile (0,0), 16x16 tiles, rotated 45° Act: Calculate which tiles the shape overlaps Expected: ~4-6 tiles (actual shape coverage, not bounding box)
BUG HYPOTHESIS: Current implementation uses axis-aligned bounding box which is 45x45, causing it to detect 3x3 = 9 tiles instead of the actual ~4-6 tiles the shape covers
test_rotated_90_degree_square_covers_4_tiles
| |
Test: CRITICAL - Rotated 90° 32x32 SQUARE should cover exactly 2x2 = 4 tiles Setup: 32x32 square at tile (0,0), 16x16 tiles, rotated 90° Act: Calculate which tiles the shape overlaps Expected: Exactly 4 tiles (rotation doesn’t change coverage for a square)
This verifies that 90° rotation of a SQUARE should produce identical tile coverage
Private Methods
_create_test_object
| |
Flags: private
_create_shape_owner
| |
Flags: private
_format_transform
| |
Flags: private
Helper: Format transform for debugging
_format_polygon_bounds
| |
Flags: private
Helper: Format polygon bounds for debugging
Grid Building v5.0.8 | Generated 24/05/2026