trace

package
v0.5.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 23, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TraverseBlocks

func TraverseBlocks(start, end mgl64.Vec3, f func(pos cube.Pos) (con bool))

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

func AABBIntercept(bb physics.AABB, start, end mgl64.Vec3) (result AABBResult, ok bool)

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.

func (AABBResult) AABB

func (r AABBResult) AABB() physics.AABB

AABB ...

func (AABBResult) Face

func (r AABBResult) Face() cube.Face

Face ...

func (AABBResult) Position

func (r AABBResult) Position() mgl64.Vec3

Position ...

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.

func (BlockResult) Face

func (r BlockResult) Face() cube.Face

Face returns the hit block face.

func (BlockResult) Position

func (r BlockResult) Position() mgl64.Vec3

Position ...

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

func EntityIntercept(e world.Entity, start, end mgl64.Vec3) (result EntityResult, ok bool)

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.

func (EntityResult) Face

func (r EntityResult) Face() cube.Face

Face ...

func (EntityResult) Position

func (r EntityResult) Position() mgl64.Vec3

Position ...

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL