GBGeometryUtils
AUTO-GENERATED FILE – DO NOT EDIT MANUALLY
Utility functions for geometry calculations and shape operations.
Source File: addons/grid_building/utils/gb_geometry_utils.gd
Public Methods
points_array_to_rect_2d
Flags: static
Converts an array of Vector2 points to a bounding Rect2. Returns a Rect2 that bounds all points in the given PackedVector2Array, with the origin at p_rect_position.
get_collision_object_shapes
Flags: static
Returns all Shape2D instances owned by a CollisionObject2D.
p_collision_object: CollisionObject2D - Collision object to extract shapes from
get_all_collision_shapes_by_owner
Flags: static
Returns a dictionary mapping each collidable node (CollisionObject2D or CollisionPolygon2D) to its array of Shape2D objects. This allows you to check collision layers/masks and know which shapes belong to which node. Supports both standard collision objects and polygon-defined collision shapes. Recursively returns a dictionary mapping each collidable node (CollisionObject2D or CollisionPolygon2D) to its array of Shape2D objects. Includes root and all children. Useful for mapping collision owners to their shapes for collision checks.
get_shapes_from_owner
Flags: static
Helper to get all shape 2Ds that a owner Node2D has. Returns all Shape2D objects owned by a Node2D (CollisionObject2D or CollisionPolygon2D). Converts polygons to ConvexPolygonShape2D if possible.
p_owner: Node2D - Node to extract shapes from (CollisionObject2D or CollisionPolygon2D)
grow_rect2_to_increment
Flags: static
Grows a rect2 by the given increment values Returns a Rect2 grown by the given increment vector, handling negative sizes correctly. Useful for expanding bounding boxes or shapes by a margin.
grow_rect2_to_square
Flags: static
Returns a square Rect2 that fully contains the input Rect2, rounding up to the largest dimension. Useful for fitting non-square shapes into square tiles or grids.
get_rect2_position_offset
Flags: static
Gets the direction difference between center to position and center to end
Returns the difference vector with magnitude and direction of the further point between position and end Returns the offset vector from the center to the position of a Rect2. Useful for calculating position differences or alignment offsets.
get_overlapped_tiles_for_rect
Flags: static
Returns all tile positions overlapped by a rectangle, with a small buffer (epsilon) to avoid counting adjacent tiles for exact fits. Useful for mapping which tiles are covered by a rectangular shape in a TileMapLayer.
is_tile_covered_by_collision_shape
Flags: static
Checks if a tile is covered by a CollisionShape2D (using Geometry2D intersection) Returns true if a tile is covered by a CollisionShape2D, using intersection area (with epsilon threshold). Useful for strict collision checks between tiles and collision shapes. tile_type: TileSet.TileShape (required) epsilon: minimum intersection area to count as covered (default 0.01)
is_tile_covered_by_collision_polygon
Flags: static
Checks if a tile is covered by a CollisionPolygon2D (using Geometry2D intersection) Returns true if a tile is covered by a CollisionPolygon2D, using intersection area (with epsilon threshold). Useful for strict collision checks between tiles and collision polygons. tile_type: TileSet.TileShape (required) epsilon: minimum intersection area to count as covered (default 0.01)