Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TraverseBlocks ¶
TraverseBlocks performs a ray trace between the start and end coordinates. A function 'f' is passed which is called for each voxel, if f returns false, the function will return. TraverseBlocks panics if the start and end positions are the same.
Types ¶
type BBoxResult ¶
type BBoxResult struct {
// contains filtered or unexported fields
}
BBoxResult is the result of a basic ray trace collision with a bounding box.
func BBoxIntercept ¶
BBoxIntercept performs a ray trace and calculates the point on the BBox's edge nearest to the start position that the ray trace collided with. BBoxIntercept returns a BBoxResult with the colliding vector closest to the start position, if no colliding point was found, a zero BBoxResult is returned and ok is false.
type BlockResult ¶
type BlockResult struct {
// contains filtered or unexported fields
}
BlockResult is the result of a ray trace collision with a block's model.
func BlockIntercept ¶
func BlockIntercept(pos cube.Pos, w *world.World, b world.Block, start, end mgl64.Vec3) (result BlockResult, ok bool)
BlockIntercept performs a ray trace and calculates the point on the block model's edge nearest to the start position that the ray collided with. BlockIntercept returns a BlockResult with the block collided with and with the colliding vector closest to the start position, if no colliding point was found, a zero BlockResult is returned and ok is false.
func (BlockResult) BBox ¶
func (r BlockResult) BBox() cube.BBox
BBox returns the BBox that was collided within the block's model.
func (BlockResult) BlockPosition ¶
func (r BlockResult) BlockPosition() cube.Pos
BlockPosition returns the block that was collided with.
type EntityResult ¶
type EntityResult struct {
// contains filtered or unexported fields
}
EntityResult is the result of a ray trace collision with an entities bounding box.
func EntityIntercept ¶
EntityIntercept performs a ray trace and calculates the point on the entities bounding box's edge nearest to the start position that the ray collided with. EntityIntercept returns an EntityResult with the entity collided with and with the colliding vector closest to the start position, if no colliding point was found, a zero BlockResult is returned ok is false.
func (EntityResult) BBox ¶
func (r EntityResult) BBox() cube.BBox
BBox returns the entities bounding box that was collided with.
func (EntityResult) Entity ¶
func (r EntityResult) Entity() world.Entity
Entity returns the entity that was collided with.
type Result ¶
type Result interface { // BBox returns the bounding box collided with. BBox() cube.BBox // Position returns where the ray first collided with the bounding box. Position() mgl64.Vec3 // Face returns the face of the bounding box that was collided on. Face() cube.Face }
Result represents the result of a ray trace collision with a bounding box.
func Perform ¶
func Perform(start, end mgl64.Vec3, w *world.World, box cube.BBox, ignored func(world.Entity) bool) (hit Result, ok bool)
Perform performs a ray trace between start and end, checking if any blocks or entities collided with the ray. The physics.BBox that's passed is used for checking if any entity within the bounding box collided with the ray.