trace

package
v0.9.19 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 License: MIT Imports: 4 Imported by: 4

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 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

func BBoxIntercept(bb cube.BBox, start, end mgl64.Vec3) (result BBoxResult, ok bool)

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.

func (BBoxResult) BBox

func (r BBoxResult) BBox() cube.BBox

BBox ...

func (BBoxResult) Face

func (r BBoxResult) Face() cube.Face

Face ...

func (BBoxResult) Position

func (r BBoxResult) 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) 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.

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) 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.

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 {
	// 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.

Jump to

Keyboard shortcuts

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