GBCachedShapeCast2D

AUTO-GENERATED FILE – DO NOT EDIT MANUALLY

Base ShapeCast2D providing thread-safe, immediate collision caching.

Source File: /addons/grid_building/base/gb_cached_shape_cast_2d.gd

Extends: ShapeCast2D

Under threaded physics (physics/2d/run_on_separate_thread = true), calling Godot’s built-in collision methods outside _physics_process can cause thread safety issues or return stale data. This base class manages a thread-safe cache populated safely during the physics process frame.

Properties

  • Property: cached_is_colliding: bool - Checks if the cache is stale, refreshes it if in a safe physics tick context, and returns the cached collision status.
  • Property: cached_colliders: Array[Node] - Checks if the cache is stale, refreshes it if in a safe physics tick context, and returns the cached colliding nodes.
  • Property: cached_global_transform: Transform2D - Tracks the global transform at which the collision cache was last updated.

Public Methods

force_shapecast_update

1
force_shapecast_update() -> void

Override force_shapecast_update to capture cached collision values in safe environments. With physics/2d/run_on_separate_thread = true, we restrict updates to _physics_process or general physics frame execution to avoid thread-safety violations. Outside those, we fall back to the last cached state.


is_cache_stale

1
is_cache_stale() -> bool

Checks if the current cache is stale based on position/rotation changes since the last update.


Private Methods

_update_collision_cache

1
_update_collision_cache() -> void

Flags: private

Safely updates the cached collision state from the current ShapeCast2D state.


_check_and_refresh_cache_if_stale

1
_check_and_refresh_cache_if_stale() -> void

Flags: private

Transparently checks if the cache is stale and triggers an update if in a safe physics tick context.


_physics_process_update

1
_physics_process_update() -> void

Flags: private

Abstract method to be overridden by child classes for their frame update logic.


Grid Building v5.0.8 | Generated 01/06/2026