module Rosegold::Raytrace

Defined in:

rosegold/control/raytrace.cr

Constant Summary

EDGE_EPSILON = 1e-4

A ray aimed at a block's closest point lands on an edge/corner of its hitbox, and look quantization can put the hit a hair outside the face. Tolerate that so grazing hits register instead of being dropped (mirrors vanilla's inflated clip); far smaller than the 1/16 gap between blocks, so it can't hit a neighbor.

MOVE_EPSILON = 1e-7

Movement collision uses the opposite tolerance from block-aiming: the entity box is shrunk inward by 1e-7 on the perpendicular axes (matching vanilla VoxelShape.collideX), so a surface the entity merely touches — e.g. the floor it stands flush on, or the next floor block coplanar with its feet — does not impede perpendicular motion. Without this the bot wall-sticks on the top face it stands on (top slabs, full-block floors).

Class Method Summary

Class Method Detail

def self.raytrace(start : Vec3d, delta : Vec3d, boxes : Array(AABBd), strict : Bool = false) : Result | Nil #

strict selects movement-collision tolerance (touching != colliding); leave false for block-aiming, which wants the grazing tolerance.


[View source]
def self.raytrace(ray : Ray, boxes : Array(AABBd), strict : Bool = false) : Result | Nil #

[View source]