Grid Placement

CollisionTestSetup

AUTO-GENERATED FILE — DO NOT EDIT MANUALLY

Source: placement/collsion_test/collision_test_setup.gd

Version: 5.0

class_name: CollisionTestSetup extends: RefCounted

Summary

CollisionTestSetup

Builds collision test parameters for a CollisionObject2D to enable placement indicators to perform accurate collision checks against object geometry.

[b]Purpose:[/b] Converts CollisionObject2D shapes into testable RectCollisionTestingSetup instances for collision validation during placement operations.

[b]Key Features:[/b] • Creates one RectCollisionTestingSetup per shape owner • Expands test areas using configurable shape_stretch_size • Supports CollisionShape2D and CollisionPolygon2D nodes • Comprehensive error reporting via issues array

[b]Quick Start:[/b] [codeblock] var test_setup = CollisionTestSetup.new(collision_object, Vector2(16, 16), owning_node) if test_setup.validate_setup():

Use test_setup.rect_collision_test_setups for collision testing

pass [/codeblock]

[b]Advanced Documentation:[/b] For detailed usage, API reference, and troubleshooting, see: https://gridbuilding.pages.dev/api/v5.0.0/CollisionTestSetup

[b]Dependencies:[/b] RectCollisionTestingSetup, GBGeometryUtils

Signals

(none)

Exports

(none)

Methods

  • _init()
    • Initializes collision test setup for the given CollisionObject2D.
  • add_issue()
    • Records an issue encountered during setup.
  • free_testing_nodes()
    • Frees all testing nodes created during setup. Call this when the setup is no longer needed to prevent memory leaks.
  • validate_setup()
    • Validates the collision test setup and reports any issues. Returns true if setup is valid and ready for use, false otherwise.
  • _create_rect_tests_for_collision_object()
    • Creates RectCollisionTestingSetup instances for each shape owner in the CollisionObject2D.
  • _get_testing_rect_for_owner()
    • Calculates the testing rectangle for a shape owner node. Supports CollisionShape2D and CollisionPolygon2D nodes.
  • _adjust_rect_to_testing_size()
    • Expands the rectangle by shape_stretch_size to ensure comprehensive tile coverage. Handles complex transforms by converting to squares when rotation/skew is present.