GBGeometryMath
AUTO-GENERATED FILE – DO NOT EDIT MANUALLY
Geometry & collision math utilities for the grid building addon.
Source File: addons/grid_building/utils/gb_geometry_math.gd
Public Methods
polygon_intersection_area
Flags: static
Returns the intersection area between two polygons using Godot’s Geometry2D.
poly_a: PackedVector2Array - First polygon.
poly_b: PackedVector2Array - Second polygon.
Returns: float - Area of intersection (0.0 if no overlap).
get_tile_polygon
Flags: static
Returns the corners of a tile as a polygon for collision or geometry checks.
tile_top_left_pos: Vector2 - Top-left position of the tile in world space.
tile_size: Vector2 - Size of the tile (width, height).
tile_shape: TileSet.TileShape - Tile shape from TileSet (SQUARE, ISOMETRIC, HALF_OFFSET_SQUARE).
Returns: PackedVector2Array - Polygon corners in counterclockwise order.
intersection_area_with_tile
Flags: static
Returns the intersection area between a polygon and a tile polygon.
polygon: PackedVector2Array - The polygon to check.
tile_top_left_pos: Vector2 - Top-left position of the tile in world space (not center).
tile_size: Vector2 - Size of the tile (width, height).
tile_shape: TileSet.TileShape - Tile shape from TileSet (SQUARE, ISOMETRIC, etc.).
Returns: float - Area of intersection (0.0 if no overlap).
does_polygon_overlap_tile
Flags: static
Returns true if the intersection area between a polygon and a tile polygon exceeds epsilon.
polygon: PackedVector2Array - The polygon to check.
tile_top_left_pos: Vector2 - Top-left position of the tile in world space (not center).
tile_size: Vector2 - Size of the tile (width, height).
tile_shape: TileSet.TileShape - Tile shape from TileSet (SQUARE, ISOMETRIC, etc.).
epsilon: float - Minimum intersection area to count as covered.
Returns: bool - True if intersection area > epsilon.
does_shape_overlap_tile_optimized
Flags: static
Optimized collision detection using native Godot collision as primary method.
shape: Shape2D - The collision shape to test.
shape_transform: Transform2D - Transform of the shape.
tile_top_left_pos: Vector2 - Top-left position of the tile in world space (not center).
tile_size: Vector2 - Size of the tile.
tile_shape: TileSet.TileShape - Tile shape from TileSet (SQUARE, ISOMETRIC, HALF_OFFSET_SQUARE).
epsilon: float - Minimum overlap area (only used for polygon fallback).
Returns: bool - True if shape overlaps the tile.
does_polygon_overlap_tile_optimized
Flags: static
Optimized polygon overlap detection - uses native collision when possible.
polygon: PackedVector2Array - The polygon points to test.
tile_top_left_pos: Vector2 - Top-left position of the tile in world space (not center).
tile_size: Vector2 - Size of the tile.
tile_shape: TileSet.TileShape - Tile shape from TileSet (SQUARE, ISOMETRIC, HALF_OFFSET_SQUARE).
epsilon: float - Minimum intersection area threshold.
Returns: bool - True if polygon overlaps the tile significantly.
get_polygon_bounds
Flags: static
Returns the bounding rectangle of a polygon.
polygon: PackedVector2Array - The polygon points.
Returns: Rect2 - Bounding rectangle of the polygon.
convert_shape_to_polygon
Flags: static
Converts a Shape2D to a polygon for consistent processing.
shape: Shape2D - The shape to convert.
transform: Transform2D - Transform to apply to the shape.
Returns: PackedVector2Array - Polygon representation of the shape.
intersection_polygon_area
Flags: static
Calculates the area of a polygon defined by a PackedVector2Array. Used to determine the area of intersection between two polygons (e.g., tile and collision shape). Returns 0.0 if the input does not form a valid polygon (fewer than 3 points). This is used in overlap checks to ensure that only true area overlaps (not just edge or point contacts) are counted.
is_exact_polygon_match
Flags: static
Checks if two polygons are exactly the same (vertex by vertex)
exact_polygon_area
Flags: static
Returns area for exact polygon match
Private Methods
_is_axis_aligned_rectangle
Flags: static, private
Returns true if the polygon is an axis-aligned rectangle (all edges horizontal or vertical).
polygon: PackedVector2Array - Polygon to check.
Returns: bool - True if axis-aligned rectangle.