Class CollisionTestSetup
- Namespace
- GridPlacement.GDScript
- Assembly
- MoonBark.GridPlacement.GDScript.dll
CollisionTestSetup\n\nBuilds collision test parameters for a CollisionObject2D to enable placement indicators to perform accurate collision checks against object geometry.\n\n[b]Purpose:[/b] Converts CollisionObject2D shapes into testable RectCollisionTestingSetup instances for collision validation during placement operations.\n\n[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\n\n[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]\n\n[b]Advanced Documentation:[/b] For detailed usage, API reference, and troubleshooting, see: https://gridbuilding.pages.dev/api/v5.0.0/CollisionTestSetup\n\n[b]Dependencies:[/b] RectCollisionTestingSetup, GBGeometryUtils
class CollisionTestSetup extends RefCounted
Properties
collision_object
The CollisionObject2D being analyzed for collision testing.
var collision_object: CollisionObject2D :
owning_node
The owning Node2D that contains this collision object (e.g., the test object or scene node). This provides context about which object this collision setup belongs to.
var owning_node: Node2D
shape_stretch_size
Size to stretch collision shapes for comprehensive tile coverage. Recommended: Use your tile size (e.g., Vector2(16, 16) for 16x16 tiles). See advanced documentation for detailed sizing guidance.
var shape_stretch_size: Vector2
rect_collision_test_setups
Array of RectCollisionTestingSetup instances, one per shape owner. Use these setups to perform collision tests for placement indicators.
var rect_collision_test_setups: Array[RectCollisionTestingSetup]
issues
Issues discovered during collision test setup. Check this array after initialization to identify configuration problems.
var issues: Array[String] = []
no_issues
var no_issues = true
owner_test_params_set
var owner_test_params_set: Array[RectCollisionTestingSetup] = []
shape_owner_ids
var shape_owner_ids = p_collision_object.get_shape_owners()
shape_owner_node
var shape_owner_node = p_collision_object.shape_owner_get_owner(shape_owner_id)
owner_shape_count
var owner_shape_count = p_collision_object.shape_owner_get_shape_count(shape_owner_id)
owned_shapes
var owned_shapes: Array[Shape2D] = []
found_shape
var found_shape = p_collision_object.shape_owner_get_shape(shape_owner_id, shape_index)
owner_testing_rect
var owner_testing_rect = _get_testing_rect_for_owner(shape_owner_node)
rect_test_parameters
var rect_test_parameters = RectCollisionTestingSetup.new(
shape
var shape = p_shape_owner.shape
shape_rect
var shape_rect = p_shape_owner.shape.get_rect()
adjusted_rect
var adjusted_rect = p_base_rect
polygon
var polygon: PackedVector2Array = p_shape_owner.polygon
polygon_rect
var polygon_rect: Rect2 = GBGeometryUtils.points_array_to_rect_2d(polygon, p_shape_owner.position)
adjusted_rect
var adjusted_rect = p_base_rect
origin
var origin = p_shape_owner_global_transform.get_origin()
adjusted_rect
var adjusted_rect = p_base_rect
Methods
add_issue
func add_issue(p_issue: String) -> void:
Parameters
p_issue
Returns
free_testing_nodes
func free_testing_nodes() -> void:
Returns
validate_setup
func validate_setup() -> bool: