PocketMine-MP 5.15.1 git-fb9a74e8799c71ed8292cfa53abe7a4c9204629d
pocketmine\math\VoxelRayTrace Class Reference
+ Collaboration diagram for pocketmine\math\VoxelRayTrace:

Static Public Member Functions

static betweenPoints (Vector3 $start, Vector3 $end)
 
static inDirection (Vector3 $start, Vector3 $directionVector, float $maxDistance)
 

Detailed Description

Definition at line 29 of file VoxelRayTrace.php.

Member Function Documentation

◆ betweenPoints()

static pocketmine\math\VoxelRayTrace::betweenPoints ( Vector3  $start,
Vector3  $end 
)
static

Performs a ray trace between the start and end coordinates. This returns a Generator which yields Vector3s containing the coordinates of voxels it passes through.

The first Vector3 is $start->floor(). Every subsequent Vector3 has a taxicab distance of exactly 1 from the previous Vector3; if the ray crosses the intersection of multiple axis boundaries directly, the algorithm prefers crossing the boundaries in the order Z -> Y -> X.

If $end is on an axis boundary, the final Vector3 may or may not cross that boundary. Otherwise, the final Vector3 is equal to $end->floor().

This is an implementation of the algorithm described in the link below. |Vector3[] -return <int, Vector3, void, void> if $start and $end have zero distance.

Definition at line 67 of file VoxelRayTrace.php.

◆ inDirection()

static pocketmine\math\VoxelRayTrace::inDirection ( Vector3  $start,
Vector3  $directionVector,
float  $maxDistance 
)
static

Performs a ray trace from the start position in the given direction, for a distance of $maxDistance. This returns a Generator which yields Vector3s containing the coordinates of voxels it passes through.

See also
VoxelRayTrace::betweenPoints for precise semantics
Returns
\Generator|Vector3[] @phpstan-return \Generator<int, Vector3, void, void>

Definition at line 43 of file VoxelRayTrace.php.


The documentation for this class was generated from the following file: