Skip to content

Class

GridCellRaycaster3D

Generated GDScript class reference for GridPlacement.GridCellRaycaster3D.

Status
Draft
Version
v6.0
Updated
Development docs generated from GDScript source

This is unreleased documentation in active development. APIs, class names, and behavior may change before the final release.

Camera ray-cast helper behind [GridPositioner3D]: resolves the GridMap cell (or a solid hit) under a screen-space cursor position. Given a Camera3D, a GridMap, and a screen position, it builds the ray from [method Camera3D.project_ray_origin] / [method Camera3D.project_ray_normal], checks physics solids, placed volumes, and the configured ground plane, and returns the nearest cell, or [member MISS] when nothing is hit. It is a stand-alone Node3D helper, not a positioner: mode gating, input, and lifecycle live in [GridPositioner3D]. (Named GridPositioner3DSpike before 6.2.)

Source: addons/grid_placement/systems/grid_targeting/grid_positioner/3d/grid_cell_raycaster_3d.gd

Syntax

class GridCellRaycaster3D extends RefCounted

Members

NameKindSummary
cameraPropertyThe camera to ray-cast through. Set it at _ready(); it is not auto-discovered.
gridPropertyThe grid cells are resolved on. Same pattern as `camera`.
ground_plane_yPropertyThe y-coordinate (in grid-local space) of the ground plane the ray intersects. Default 0.0 = top face of the cell layer at y=0.
cursor_collision_maskPropertyPhysics layers the cursor ray stops at before the volume/ground tiers. When the ray strikes a fitted solid (wall/door/floor collision) the cursor resolves from that hit, so aiming at an object targets the object instead of the floor behind it. Empty openings (window/doorway voids carry no collision) pass through to the tiers below — correct. Ghost previews carry no collision (the 3D service neuters them), so the ray never stops at its own preview. 0 disables the tier (volume/ground cascade only).
MISSFieldSentinel returned when the ray misses the grid. The test asserts on `== MISS` rather than `== null` to make the contract explicit and to avoid Godot's null-Variant ambiguity.
cellPropertyWhere a ray first crosses the ground: the cell and the world distance along the ray, or [constant MISS] and INF.
tProperty
last_ray_originPropertyWorld-space ray of the most recent screen-to-cell call. The positioner mirrors it to the targeting state so hover identity resolves the record the ray hit, not the oldest record overlapping the cell column.
last_ray_dirProperty
has_last_hitPropertyWinning hit of the most recent [method cell_from_ray]: one ray, one hit. Socket picks (wall edge/corner/top) resolve from the SAME hit the cell came from instead of firing an independent ground-plane ray that ignores physics and volumes. Physics wins record the exact hit + face normal; volume wins the box entry + entry-face normal; ground wins the crossing with an up normal. Cleared on miss (no stale socket input).
last_hit_positionProperty
last_hit_normalProperty
last_hit_cellProperty
last_hit_colliderPropertyThe collider behind a physics-tier win ([code]null[/code] for volume and ground wins, which have no physics body). Socket consumers reject a hit whose collider is not placement-relevant (set dressing, player) instead of resolving a socket from it.
placement_relevance_filterPropertyOptional placement-relevance predicate for physics candidates: called with each candidate [CollisionObject3D], must return [bool]. An invalid callable accepts every candidate (legacy). The positioner wires this to its registry/grid check so rocks, dressing, and other unregistered bodies can never win the socket ray.
surface_height_sourcePropertySurface-height source for cursor ground hits: a Callable taking a Vector3i column cell (x, 0, z) and returning the world-space surface height as a float, or a non-finite value (such as [constant ObjectPlacementGeometry3D.NO_GROUND]) when the column has no ground. When valid, ground hits march the ray against these heights instead of the flat [member ground_plane_y] seed plane; when invalid the legacy plane math runs exactly as before. The 3D positioner wires the live placement support surface so the cursor and commits agree on "the ground".
SURFACE_MARCH_MAX_STEPSFieldHard cap on marched columns per ground hit (failsafe; horizon-grazing rays over empty columns would otherwise march to the far plane).
IRRELEVANT_SKIP_MAXFieldHard cap on placement-irrelevant bodies skipped per physics pick (failsafe; a dense rock pile in front of the aim must not re-query unboundedly — past the cap the volume/ground tiers take over).
SURFACE_CELL_EPSILONFieldA surface caps the cell below it: crossings are mapped a hair under the surface so row-boundary tops (cube faces) resolve the item underneath instead of the empty row above, regardless of float noise.
VOLUME_CORE_EPSFieldStep past the shrunk-box entry when mapping a volume hit to its cell (then clamped back inside, so oblique rays cannot punch through a thin box into the far neighbor).
VOLUME_SHRINK_MIN_SIZEFieldVolumes thinner than this after shrinking keep the legacy entry+nudge reading: there is no core to re-enter.
ray_from_screen_to_cellMethod
ray_from_screen_to_cell_occludedMethod
ray_originProperty
ray_normalProperty
cell_from_rayMethod
dirProperty
world_to_gridProperty
solid_tProperty
solid_cellProperty
solid_hitProperty
best_volume_tProperty
best_volume_cellProperty
best_volume_entryProperty
best_volumeProperty
volumeProperty
entryProperty
tProperty
ownerProperty
grid_originProperty
grid_normalProperty
groundProperty
ground_cellProperty
ground_tProperty
tProperty
candidateProperty
world_hitProperty
cell_sizeProperty
posProperty
dProperty
xiProperty
ziProperty
step_xProperty
step_zProperty
t_delta_xProperty
t_delta_zProperty
frac_xProperty
frac_zProperty
t_max_xProperty
t_max_zProperty
tProperty
stepsProperty
saw_heightProperty
t_nextProperty
y_enterProperty
y_exitProperty
h_worldProperty
h_localProperty
d_enterProperty
d_exitProperty
tcProperty
local_hitProperty
map_hitProperty
candidateProperty
world_hitProperty
world_tProperty
ray_intersection_pointMethod
ray_ground_tracking_pointMethod
cell_from_hit_pointMethod