Documentation ¶
Overview ¶
Package collision implements collision related algorithms and data structures. WARNING: Parts of this package are experimental and incomplete!
Index ¶
- func CheckConvex(g1, g2 *geometry.Geometry) bool
- type Contact
- type Intersect
- type Matrix
- type Raycaster
- func (rc *Raycaster) IntersectObject(inode core.INode, recursive bool) []Intersect
- func (rc *Raycaster) IntersectObjects(inodes []core.INode, recursive bool) []Intersect
- func (rc *Raycaster) RaycastLineStrip(l *graphic.LineStrip, intersects *[]Intersect)
- func (rc *Raycaster) RaycastLines(l *graphic.Lines, intersects *[]Intersect)
- func (rc *Raycaster) RaycastMesh(m *graphic.Mesh, intersects *[]Intersect)
- func (rc *Raycaster) RaycastPoints(p *graphic.Points, intersects *[]Intersect)
- func (rc *Raycaster) RaycastSprite(s *graphic.Sprite, intersects *[]Intersect)
- func (rc *Raycaster) SetFromCamera(cam *camera.Camera, sx, sy float32) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckConvex ¶
Types ¶
type Intersect ¶ added in v0.3.2
type Intersect struct { // Distance between the origin of the ray and the intersect Distance float32 // Point of intersection in world coordinates Point math32.Vector3 // Intersected node Object core.INode // If the geometry has indices, this field is the // index in the Indices buffer of the vertex intersected // or the first vertex of the intersected face. // If the geometry doesn't have indices, this field is the // index in the positions buffer of the vertex intersected // or the first vertex of the insersected face. Index uint32 }
Intersect describes the intersection between a ray and an object
type Matrix ¶
type Matrix [][]bool
Matrix is a triangular collision matrix indicating which pairs of bodies are colliding.
type Raycaster ¶ added in v0.3.2
type Raycaster struct { // The distance from the ray origin to the intersected points // must be greater than the value of this field to be considered. // The defaul value is 0.0 Near float32 // The distance from the ray origin to the intersected points // must be less than the value of this field to be considered. // The defaul value is +Infinity. Far float32 // Minimum distance in world coordinates between the ray and // a line segment when checking intersects with lines. // The default value is 0.1 LinePrecision float32 // Minimum distance in world coordinates between the ray and // a point when checking intersects with points. // The default value is 0.1 PointPrecision float32 // This field must be set with the camera view matrix used // when checking for sprite intersections. // It is set automatically when using camera.SetRaycaster ViewMatrix math32.Matrix4 // Embedded ray math32.Ray }
Raycaster represents an empty object that can cast rays and check for ray intersections.
func NewRaycaster ¶ added in v0.3.2
NewRaycaster creates and returns a pointer to a new raycaster object with the specified origin and direction.
func (*Raycaster) IntersectObject ¶ added in v0.3.2
IntersectObject checks intersections between this raycaster and and the specified node. If recursive is true, it also checks the intersection with the node's children. Intersections are returned sorted by distance, closest first.
func (*Raycaster) IntersectObjects ¶ added in v0.3.2
IntersectObjects checks intersections between this raycaster and the specified array of scene nodes. If recursive is true, it also checks the intersection with each nodes' children. Intersections are returned sorted by distance, closest first.
func (*Raycaster) RaycastLineStrip ¶ added in v0.3.2
RaycastLineStrip
func (*Raycaster) RaycastLines ¶ added in v0.3.2
RaycastLines
func (*Raycaster) RaycastMesh ¶ added in v0.3.2
RaycastMesh
func (*Raycaster) RaycastPoints ¶ added in v0.3.2
RaycastPoints
func (*Raycaster) RaycastSprite ¶ added in v0.3.2
RaycastSprite checks intersections between the raycaster and the specified sprite and if any found appends it to the specified intersects array.
func (*Raycaster) SetFromCamera ¶ added in v0.3.2
SetRaycaster sets the specified raycaster with this camera position in world coordinates pointing to the direction defined by the specified coordinates unprojected using this camera.