package collision
Functions
PointOutsideOfPlane
PointOutsideOfPlane returns true if the given point is outside of the plane
Types
AABB
struct
AABB is an axis-aligned bounding box
AABBFromMinMax
AABBFromMinMax creates an AABB from the minimum and maximum points
AABBFromWidth
AABBFromWidth creates an AABB from the center and half-width
AABBUnion
Union returns the union of two AABBs
AABB.AABBIntersect
AABBIntersect returns whether the AABB intersects another AABB
AABB.ClosestDistance
ClosestDistance returns the closest distance between two AABBs
AABB.Contains
Contains returns whether the AABB contains the point
AABB.ContainsAABB
ContainsAABB returns whether the AABB contains another AABB
AABB.FromTriangle
FromTriangle returns an AABB that contains the triangle
AABB.InFrustum
InFrustum returns whether the AABB is in the frustum
AABB.LongestAxis
LongestAxis returns the longest axis of the AABB (0 = X, 1 = Y, 2 = Z)
AABB.Max
Max returns the maximum point of the AABB
AABB.Min
Min returns the minimum point of the AABB
AABB.PlaneIntersect
PlaneIntersect returns whether the AABB intersects a plane
AABB.RayHit
RayHit returns the point of intersection and whether the ray hit the AABB
AABB.Size
Size returns the size of the AABB
AABB.TriangleIntersect
TriangleIntersect returns whether the AABB intersects a triangle
BVH
struct
type BVH struct {
Left *BVH
Right *BVH
Parent *BVH
Transform *matrix.Transform
Data HitObject
// Has unexported fields.
}
BVHBottomUp
BVHBottomUp constructs a BVH from a list of triangles
BVHInsert
BVHInsert inserts a new BVH into an existing BVH, returning the new root
NewBVH
BVH.Bounds
BVH.Duplicate
BVH.Insert
BVH.IsLeaf
IsLeaf returns whether or not the BVH is a leaf node
BVH.IsLeft
IsLeft returns whether or not the BVH is the left child of its parent
BVH.IsRight
IsRight returns whether or not the BVH is the right child of its parent
BVH.IsRoot
IsRoot returns whether or not the BVH is the root node
BVH.RayHit
RayHit returns the point of intersection and whether or not the ray hit the BVH. The point of intersection is the closest point of intersection along the ray.
BVH.RemoveNode
RemoveNode removes a node from the BVH and adjusts the tree accordingly. If the node is the root, nothing is done.
BVH.Root
DetailedTriangle
struct
type DetailedTriangle struct {
Points [3]matrix.Vec3
Normal matrix.Vec3
Centroid matrix.Vec3
Radius matrix.Float
}
DetailedTriangleFromPoints
DetailedTriangleFromPoints creates a detailed triangle from three points, a detailed triangle is different from a regular triangle in that it contains additional information such as the centroid and radius
DetailedTriangle.Bounds
DetailedTriangle.RayIntersect
Frustum
struct
HitObject
interface
OBB
struct
OBBFromAABB
OBB.ContainsPoint
OBB.Intersect
OBB.Overlaps
OBB.ProjectOntoAxis
Octree
struct
type Octree struct {
Center matrix.Vec3
HalfWidth matrix.Float
Children [8]*Octree
Objects []HitObject
}
NewOctree
OctreeForMesh
Octree.AsAABB
Octree.Insert
Plane
struct
PlaneCCW
PlaneCCW creates a plane from three points in counter clockwise order
Plane.ClosestPoint
ClosestPoint returns the closest point on the plane to the given point
Plane.Distance
Distance returns the distance from the plane to the given point
Plane.SetFloatValue
SetFloatValue sets the value of the plane at the given index (X, Y, Z, Dot)
Plane.ToArray
ToArray converts the plane to an array of 4 floats
Plane.ToVec4
ToVec4 converts the plane to a Vec4 (analogous to ToArray)
Ray
struct
Ray.PlaneHit
PlaneHit returns the point of intersection with the plane and true if the ray hits the plane
Ray.Point
Point returns the point at the given distance along the ray
Ray.SphereHit
SphereHit returns true if the ray hits the sphere
Ray.TriangleHit
TriangleHit returns true if the ray hits the triangle defined by the three points
Segment
struct
LineSegmentFromRay
LineSegmentFromRay creates a line segment from a ray
Segment.TriangleHit
TriangleHit returns true if the segment hits the triangle defined by the three points
Triangle
struct