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 AABBResult ¶
type AABBResult struct {
// contains filtered or unexported fields
}
AABBResult is the result of a basic ray trace collision with a bounding box.
func AABBIntercept ¶
AABBIntercept performs a ray trace and calculates the point on the AABB's edge nearest to the start position that the ray trace collided with. AABBIntercept returns a AABBResult with the colliding vector closest to the start position, if no colliding point was found, a zero AABBResult 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) AABB ¶
func (r BlockResult) AABB() physics.AABB
AABB returns the AABB 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) AABB ¶
func (r EntityResult) AABB() physics.AABB
AABB 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 { // AABB returns the bounding box collided with. AABB() physics.AABB // 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, aabb physics.AABB, 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.AABB that's passed is used for checking if any entity within the bounding box collided with the ray.