Documentation
¶
Index ¶
- func CheckIntersectionBoxWithMesh(box Box, mesh Mesh, flipped bool, resultSet IntersectionCollection)
- func CheckIntersectionLineWithMesh(line Line, mesh Mesh, flipped bool, resultSet IntersectionCollection)
- func CheckIntersectionLineWithTriangle(line Line, triangle Triangle, flipped bool, resultSet IntersectionCollection)
- func CheckIntersectionSetWithSet(first, second Set, resultSet IntersectionCollection)
- func CheckIntersectionSphereWithBox(sphere Sphere, box Box, flipped bool, resultSet IntersectionCollection)
- func CheckIntersectionSphereWithMesh(sphere Sphere, mesh Mesh, flipped bool, resultSet IntersectionCollection)
- func CheckIntersectionSphereWithSphere(first, second Sphere, flipped bool, resultSet IntersectionCollection)
- func CheckIntersectionSphereWithTriangle(sphere Sphere, triangle Triangle, flipped bool, ...)
- func IsSphereWithSphereIntersecting(bs1, bs2 Sphere) bool
- func LineWithSphereIntersectionPoints(line Line, sphere Sphere) (dprec.Vec3, dprec.Vec3, bool)
- func LineWithSurfaceIntersectionPoint(line Line, point, normal dprec.Vec3) (dprec.Vec3, bool)
- type BestIntersection
- type Box
- func (b *Box) BoundingSphere() Sphere
- func (b *Box) HalfHeight() float64
- func (b *Box) HalfLength() float64
- func (b *Box) HalfWidth() float64
- func (b *Box) Height() float64
- func (b *Box) Length() float64
- func (b *Box) Position() dprec.Vec3
- func (b *Box) Replace(template Box, transform Transform)
- func (b *Box) Rotation() dprec.Quat
- func (b *Box) Size() dprec.Vec3
- func (b *Box) Width() float64
- type Intersection
- type IntersectionBucket
- type IntersectionCollection
- type LastIntersection
- type Line
- type Mesh
- type Set
- type SetOption
- type Sphere
- type Transform
- type Triangle
- func (t *Triangle) A() dprec.Vec3
- func (t *Triangle) Area() float64
- func (t *Triangle) B() dprec.Vec3
- func (t *Triangle) BoundingSphere() Sphere
- func (t *Triangle) C() dprec.Vec3
- func (t *Triangle) Center() dprec.Vec3
- func (t *Triangle) ContainsPoint(point dprec.Vec3) bool
- func (t *Triangle) IsLookingTowards(direction dprec.Vec3) bool
- func (t *Triangle) Normal() dprec.Vec3
- func (t *Triangle) Replace(template Triangle, transform Transform)
- type WorstIntersection
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckIntersectionBoxWithMesh ¶
func CheckIntersectionBoxWithMesh(box Box, mesh Mesh, flipped bool, resultSet IntersectionCollection)
CheckIntersectionBoxWithMesh checks if a Box shape intersects with a Mesh shape.
func CheckIntersectionLineWithMesh ¶
func CheckIntersectionLineWithMesh(line Line, mesh Mesh, flipped bool, resultSet IntersectionCollection)
CheckIntersectionLineWithMesh checks if a Line shape intersects with a Mesh shape.
func CheckIntersectionLineWithTriangle ¶
func CheckIntersectionLineWithTriangle(line Line, triangle Triangle, flipped bool, resultSet IntersectionCollection)
CheckIntersectionLineWithTriangle checks if a Line shape intersects with a Triangle shape.
func CheckIntersectionSetWithSet ¶
func CheckIntersectionSetWithSet(first, second Set, resultSet IntersectionCollection)
CheckIntersectionSetWithSet checks for any intersections between the two collision Sets.
func CheckIntersectionSphereWithBox ¶
func CheckIntersectionSphereWithBox(sphere Sphere, box Box, flipped bool, resultSet IntersectionCollection)
CheckIntersectionSphereWithBox checks if a Sphere shape intersects with a Box shape.
func CheckIntersectionSphereWithMesh ¶
func CheckIntersectionSphereWithMesh(sphere Sphere, mesh Mesh, flipped bool, resultSet IntersectionCollection)
CheckIntersectionSphereWithMesh checks if a Sphere shape intersects with a Mesh shape.
func CheckIntersectionSphereWithSphere ¶
func CheckIntersectionSphereWithSphere(first, second Sphere, flipped bool, resultSet IntersectionCollection)
CheckIntersectionSphereWithSphere checks if a Sphere shape intersects with another Sphere shape.
func CheckIntersectionSphereWithTriangle ¶
func CheckIntersectionSphereWithTriangle(sphere Sphere, triangle Triangle, flipped bool, resultSet IntersectionCollection)
CheckIntersectionSphereWithTriangle checks if a Sphere shape intersects with a Triangle shape.
func IsSphereWithSphereIntersecting ¶
IsSphereWithSphereIntersecting is a quick check to determine if two spheres are intersecting.
func LineWithSphereIntersectionPoints ¶
LineWithSphereIntersectionPoints returns the two intersection points of a line with a sphere, if there are such.
Types ¶
type BestIntersection ¶
type BestIntersection struct {
// contains filtered or unexported fields
}
BestIntersection is an implementation of IntersectionCollection that keeps track of the best (smallest depth) observed intersection.
func (*BestIntersection) AddIntersection ¶
func (i *BestIntersection) AddIntersection(intersection Intersection)
AddIntersection tracks the specified intersection.
func (*BestIntersection) Intersection ¶
func (i *BestIntersection) Intersection() (Intersection, bool)
Intersection returns the best observed intersection and a flag whether there was actually any intersection observed.
func (*BestIntersection) Reset ¶
func (i *BestIntersection) Reset()
Reset clears any observed intersection.
type Box ¶
type Box struct {
// contains filtered or unexported fields
}
Box represents a 3D box shape.
func (*Box) BoundingSphere ¶
BoundingSphere returns a sphere that encompases this box.
func (*Box) HalfHeight ¶
HalfHeight returns half of the height of this box.
func (*Box) HalfLength ¶
HalfLength returns half of the length of this box.
func (*Box) Replace ¶
Replace replaces this shape with the template one after the specified transformation has been applied to it.
type Intersection ¶
type Intersection struct {
// Depth returns the amount of penetration between the two shapes.
Depth float64
// FirstContact returns the point of contact on the first shape.
FirstContact dprec.Vec3
// FirstDisplaceNormal returns the normal along which the second shape
// needs to be moved in order to separate the two shapes the fastest.
FirstDisplaceNormal dprec.Vec3
// SecondContact returns the point of contact on the second shape.
SecondContact dprec.Vec3
// SecondDisplaceNormal returns the normal along which the first shape
// needs to be moved in order to separate the two shapes the fastest.
SecondDisplaceNormal dprec.Vec3
}
Intersection represents the collision between two shapes.
func (*Intersection) Flipped ¶
func (i *Intersection) Flipped() Intersection
Flipped returns a new Intersection where the first and second shapes have their places swapped within the structure.
type IntersectionBucket ¶
type IntersectionBucket struct {
// contains filtered or unexported fields
}
IntersectionBucket is a structure that can be used to collect the result of an intersection test.
func NewIntersectionBucket ¶
func NewIntersectionBucket(initialCapacity int) *IntersectionBucket
NewIntersectionBucket creates a new IntersectionBucket instance with the specified initial capacity.
func (*IntersectionBucket) AddIntersection ¶
func (b *IntersectionBucket) AddIntersection(intersection Intersection)
Add adds a new Intersection to this set.
func (*IntersectionBucket) Intersections ¶
func (s *IntersectionBucket) Intersections() []Intersection
Intersections returns a slice of all intersections that have been observed.
NOTE: The slice must not be modified or cached as it will be reused.
func (*IntersectionBucket) IsEmpty ¶
func (b *IntersectionBucket) IsEmpty() bool
IsEmpty returns whether no intersections were found.
func (*IntersectionBucket) Reset ¶
func (b *IntersectionBucket) Reset()
Reset clears the buffer of this result set so that it can be reused.
type IntersectionCollection ¶
type IntersectionCollection interface {
AddIntersection(intersection Intersection)
}
IntersectionCollection represents a data structure that can hold intersections.
type LastIntersection ¶
type LastIntersection struct {
// contains filtered or unexported fields
}
LastIntersection is an implementation of IntersectionCollection that keeps track of the last observed intersection.
func (*LastIntersection) AddIntersection ¶
func (i *LastIntersection) AddIntersection(intersection Intersection)
AddIntersection tracks the specified intersection.
func (*LastIntersection) Intersection ¶
func (i *LastIntersection) Intersection() (Intersection, bool)
Intersection returns the last observed intersection and a flag whether there was actually any intersection observed.
func (*LastIntersection) Reset ¶
func (i *LastIntersection) Reset()
Reset clears any observed intersection.
type Line ¶
type Line struct {
// contains filtered or unexported fields
}
Line represents a line segment between two 3D points.
type Mesh ¶
type Mesh struct {
// contains filtered or unexported fields
}
Mesh represents a collection of triangles.
func NewMesh ¶
NewMesh creates a new Mesh from the specified list of triangles.
NOTE: The Mesh becomes the owner of the slice so callers should not keep a reference to it afterwards or modify the contents in any way.
func (*Mesh) BoundingSphere ¶
BoundingSphere returns a Sphere that encompases this mesh.
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
Set represents a collection of collision shapes.
func (*Set) BoundingSphere ¶
BoundingSphere returns a sphere that encompases this set.
func (*Set) Boxes ¶
Boxes returns all boxes contained in this set.
NOTE: This returns the internal slice which should not be modified in any way.
func (*Set) Meshes ¶
Meshes returns all meshes contained in this set.
NOTE: This returns the internal slice which should not be modified in any way.
type SetOption ¶
type SetOption func(s *Set)
SetOption represents a configuration option for a Set object.
func WithMeshes ¶
WithMeshes specifies the mesh shapes contained by the set.
func WithSpheres ¶
WithSpheres specifies the sphere shapes contained by the set.
type Sphere ¶
type Sphere struct {
// contains filtered or unexported fields
}
Sphere represents a 3D sphere shape.
type Transform ¶
Transform represents a shape transformation.
func ChainedTransform ¶
ChainedTransform returns the Transform that is the result of combining two Transforms together.
func IdentityTransform ¶
func IdentityTransform() Transform
IdentityTransform returns a new Transform that represents the origin.
func RotationTransform ¶
RotationTransform returns a new Transform that represents a rotation.
func TRTransform ¶
TRTransform returns a new Transform that represents both a translation and a rotation.
func TranslationTransform ¶
TranslationTransform returns a new Transform that represents a translation.
type Triangle ¶
type Triangle struct {
// contains filtered or unexported fields
}
Triangle represents a tringle in 3D space.
func NewTriangle ¶
NewTriangle creates a new Triangle shape.
func (*Triangle) BoundingSphere ¶
BoundingSphere returns a Sphere shape that encompases this triangle.
func (*Triangle) ContainsPoint ¶
ContainsPoint checks whether the specified Point is inside the triangle.
Beware, currently this method assumes that the point lies somewhere on the surface plane of the triangle.
func (*Triangle) IsLookingTowards ¶
IsLookingTowards checks whether the orientation of the triangle looks towards the same hemisphere as the provided direction.
type WorstIntersection ¶
type WorstIntersection struct {
// contains filtered or unexported fields
}
WorstIntersection is an implementation of IntersectionCollection that keeps track of the worst (largest depth) observed intersection.
func (*WorstIntersection) AddIntersection ¶
func (i *WorstIntersection) AddIntersection(intersection Intersection)
AddIntersection tracks the specified intersection.
func (*WorstIntersection) Intersection ¶
func (i *WorstIntersection) Intersection() (Intersection, bool)
Intersection returns the worst observed intersection and a flag whether there was actually any intersection observed.
func (*WorstIntersection) Reset ¶
func (i *WorstIntersection) Reset()
Reset clears any observed intersection.