simvx.core.physics._raycasting

Persistent raycast query nodes: RayCast2D and RayCast3D.

Private leaf module: import via the simvx.core.physics facade.

Module Contents

Classes

RayCast3D

Persistent ray query node for 3D physics.

RayCast2D

Persistent ray query node for 2D physics.

Data

API

simvx.core.physics._raycasting.__all__

[‘RayCast2D’, ‘RayCast3D’]

class simvx.core.physics._raycasting.RayCast3D(target_position=None, collision_mask: int = 4294967295, enabled: bool = True, **kwargs)[source]

Bases: simvx.core.nodes_3d.node3d.Node3D

Persistent ray query node for 3D physics.

Casts a ray from the node’s global position towards target_position (in local space) each physics frame and caches the result. Useful for ground detection, line-of-sight checks, lasers, etc.

Example: ray = RayCast3D(target_position=Vec3(0, -2, 0)) player.add_child(ray) # Later, in physics_process: if ray.is_colliding(): print(“Hit:”, ray.collider, “at”, ray.collision_point)

Initialization

target_position

‘Property(…)’

collision_mask

‘Bitmask(…)’

enabled

‘Property(…)’

gizmo_colour

‘Property(…)’

get_gizmo_lines() list[tuple[simvx.core.math.types.Vec3, simvx.core.math.types.Vec3]][source]

Return ray line with arrowhead from position to target in world space.

on_physics_process(dt: float) None[source]
is_colliding() bool[source]

True if the ray hit something on the last physics frame.

property collider: simvx.core.nodes_3d.node3d.Node3D | None[source]

The first body hit, or None.

property collision_point: simvx.core.math.types.Vec3[source]

World-space collision point of the first hit.

property collision_normal: simvx.core.math.types.Vec3[source]

Outward surface normal at the first hit (zero vector if no hit).

property all_hits: list[simvx.core.collision.RayHit][source]

All hits from the last cast, sorted by distance.

position

‘_SpatialVecProperty(…)’

rotation

‘Property(…)’

scale

‘_SpatialVecProperty(…)’

render_layer

‘Property(…)’

property rotation_degrees: simvx.core.math.types.Vec3
property world_position: simvx.core.math.types.Vec3
property world_rotation: simvx.core.math.types.Quat
property world_scale: simvx.core.math.types.Vec3
property forward: simvx.core.math.types.Vec3
property right: simvx.core.math.types.Vec3
property up: simvx.core.math.types.Vec3
translate(offset: tuple[float, float, float] | numpy.ndarray)
translate_global(offset: tuple[float, float, float] | numpy.ndarray)
rotate(axis: tuple[float, float, float] | numpy.ndarray, angle: float)
rotate_x(angle: float)
rotate_y(angle: float)
rotate_z(angle: float)
look_at(target: tuple[float, float, float] | numpy.ndarray, up=None)
face_along(forward: tuple[float, float, float] | numpy.ndarray, up: tuple[float, float, float] | numpy.ndarray | None = None) None
set_render_layer(index: int, enabled: bool = True) None
is_on_render_layer(index: int) bool
wrap_bounds(bounds: tuple[float, float, float] | numpy.ndarray, margin: float = 1.0)
strict_errors: ClassVar[bool]

True

script_error_raised

‘Signal(…)’

classmethod __init_subclass__(**kwargs)
property name: str
property process_mode: simvx.core.descriptors.ProcessMode
property visible: bool
reset_error() None
add_child(node: simvx.core.node.Node) simvx.core.node.Node
remove_child(node: simvx.core.node.Node)
reparent(new_parent: simvx.core.node.Node)
get_node(path: str) simvx.core.node.Node
find_child(name: str, recursive: bool = False) simvx.core.node.Node | None
find(target: type | str, recursive: bool = True) simvx.core.node.Node | None
find_all(node_type: type, recursive: bool = True) list
walk(*, include_self: bool = True) collections.abc.Iterator[simvx.core.node.Node]
property path: str
add_to_group(group: str)
remove_from_group(group: str)
is_in_group(group: str) bool
on_ready() None
on_enter_tree() None
on_exit_tree() None
on_process(dt: float) None
on_draw(renderer) None
on_picked(event: simvx.core.events.InputEvent) None
on_unhandled_input(event: simvx.core.events.TreeInputEvent) None
start_coroutine(gen: simvx.core.descriptors.Coroutine) simvx.core.descriptors.CoroutineHandle
stop_coroutine(gen_or_handle)
clear_children()
destroy()
property app
property tree: simvx.core.scene_tree.SceneTree
__getitem__(key: str)
classmethod get_properties() dict[str, simvx.core.descriptors.Property]
__repr__()
class simvx.core.physics._raycasting.RayCast2D(target_position=None, collision_mask: int = 4294967295, enabled: bool = True, **kwargs)[source]

Bases: simvx.core.nodes_2d.node2d.Node2D

Persistent ray query node for 2D physics.

Casts a ray from the node’s global position towards target_position (in local space) each physics frame and caches the result.

Example: ray = RayCast2D(target_position=Vec2(0, 100)) player.add_child(ray) if ray.is_colliding(): print(“Hit:”, ray.collider)

Initialization

target_position

‘Property(…)’

collision_mask

‘Bitmask(…)’

enabled

‘Property(…)’

gizmo_colour

‘Property(…)’

get_gizmo_lines() list[tuple[simvx.core.math.types.Vec2, simvx.core.math.types.Vec2]][source]

Return ray line with arrowhead from position to target in world space.

on_physics_process(dt: float) None[source]
is_colliding() bool[source]

True if the ray hit something on the last physics frame.

property collider: simvx.core.nodes_2d.node2d.Node2D | None[source]

The first body hit, or None.

property collision_point: simvx.core.math.types.Vec2[source]

World-space collision point of the first hit.

property collision_normal: simvx.core.math.types.Vec2[source]

Outward surface normal at the first hit (zero vector if no hit).

property all_hits: list[simvx.core.collision.RayHit][source]

All hits from the last cast, sorted by distance.

position

‘_SpatialVecProperty(…)’

rotation

‘Property(…)’

scale

‘_SpatialVecProperty(…)’

z_index

‘Property(…)’

z_as_relative

‘Property(…)’

render_layer

‘Property(…)’

set_render_layer(index: int, enabled: bool = True) None
is_on_render_layer(index: int) bool
property absolute_z_index: int
property rotation_degrees: float
property world_position: simvx.core.math.types.Vec2
property world_rotation: float
property world_scale: simvx.core.math.types.Vec2
property world_transform: tuple[simvx.core.math.types.Vec2, simvx.core.math.types.Vec2, float]
property forward: simvx.core.math.types.Vec2
property right: simvx.core.math.types.Vec2
translate(offset: tuple[float, float] | numpy.ndarray)
rotate(radians: float)
rotate_deg(degrees: float)
look_at(target: tuple[float, float] | numpy.ndarray)
transform_points(points: list[simvx.core.math.types.Vec2]) list[simvx.core.math.types.Vec2]
draw_polygon(renderer, points: list[simvx.core.math.types.Vec2], closed=True, colour=None)
wrap_screen(margin: float = 20)
strict_errors: ClassVar[bool]

True

script_error_raised

‘Signal(…)’

classmethod __init_subclass__(**kwargs)
property name: str
property process_mode: simvx.core.descriptors.ProcessMode
property visible: bool
reset_error() None
add_child(node: simvx.core.node.Node) simvx.core.node.Node
remove_child(node: simvx.core.node.Node)
reparent(new_parent: simvx.core.node.Node)
get_node(path: str) simvx.core.node.Node
find_child(name: str, recursive: bool = False) simvx.core.node.Node | None
find(target: type | str, recursive: bool = True) simvx.core.node.Node | None
find_all(node_type: type, recursive: bool = True) list
walk(*, include_self: bool = True) collections.abc.Iterator[simvx.core.node.Node]
property path: str
add_to_group(group: str)
remove_from_group(group: str)
is_in_group(group: str) bool
on_ready() None
on_enter_tree() None
on_exit_tree() None
on_process(dt: float) None
on_draw(renderer) None
on_picked(event: simvx.core.events.InputEvent) None
on_unhandled_input(event: simvx.core.events.TreeInputEvent) None
start_coroutine(gen: simvx.core.descriptors.Coroutine) simvx.core.descriptors.CoroutineHandle
stop_coroutine(gen_or_handle)
clear_children()
destroy()
property app
property tree: simvx.core.scene_tree.SceneTree
__getitem__(key: str)
classmethod get_properties() dict[str, simvx.core.descriptors.Property]
__repr__()