Documentation
¶
Index ¶
- type AABB
- type BodyType
- type Box
- func (b *Box) CollideWithPlane(planeNormal mgl64.Vec3, planeDistance float64, myTransform Transform) (bool, PlaneContact)
- func (b *Box) ComputeAABB(transform Transform)
- func (b *Box) ComputeInertia(mass float64) mgl64.Mat3
- func (b *Box) ComputeMass(density float64) float64
- func (b *Box) GetAABB() AABB
- func (b *Box) GetContactFeature(direction mgl64.Vec3, output *[8]mgl64.Vec3, count *int)
- func (b *Box) Support(direction mgl64.Vec3) mgl64.Vec3
- type ContactPoint
- type Material
- type Plane
- func (p *Plane) CollideWithPlane(planeNormal mgl64.Vec3, planeDistance float64, myTransform Transform) (bool, PlaneContact)
- func (p *Plane) ComputeAABB(transform Transform)
- func (p *Plane) ComputeInertia(mass float64) mgl64.Mat3
- func (p *Plane) ComputeMass(density float64) float64
- func (p *Plane) GetAABB() AABB
- func (p *Plane) GetContactFeature(direction mgl64.Vec3, output *[8]mgl64.Vec3, count *int)
- func (p *Plane) Support(direction mgl64.Vec3) mgl64.Vec3
- type PlaneContact
- type RigidBody
- func (rb *RigidBody) AddForce(force mgl64.Vec3)
- func (rb *RigidBody) AddTorque(torque mgl64.Vec3)
- func (rb *RigidBody) ClearForces()
- func (rb *RigidBody) GetInertiaWorld() mgl64.Mat3
- func (rb *RigidBody) GetInverseInertiaWorld() mgl64.Mat3
- func (rb *RigidBody) Integrate(dt float64, gravity mgl64.Vec3)
- func (rb *RigidBody) Sleep()
- func (rb *RigidBody) SupportWorld(direction mgl64.Vec3) mgl64.Vec3
- func (rb *RigidBody) TrySleep(dt float64, timethreshold float64, velocityThreshold float64) uint8
- func (rb *RigidBody) Update(dt float64)
- func (rb *RigidBody) WakeUp()
- type ShapeInterface
- type ShapeType
- type Sphere
- func (s *Sphere) CollideWithPlane(planeNormal mgl64.Vec3, planeDistance float64, myTransform Transform) (bool, PlaneContact)
- func (s *Sphere) ComputeAABB(transform Transform)
- func (s *Sphere) ComputeInertia(mass float64) mgl64.Mat3
- func (s *Sphere) ComputeMass(density float64) float64
- func (s *Sphere) GetAABB() AABB
- func (s *Sphere) GetContactFeature(direction mgl64.Vec3, output *[8]mgl64.Vec3, count *int)
- func (s *Sphere) Support(direction mgl64.Vec3) mgl64.Vec3
- type Transform
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AABB ¶
AABB represents an axis-aligned bounding box
func (AABB) ContainsPoint ¶
ContainsPoint checks if a point is inside the AABB
type BodyType ¶
type BodyType int
BodyType represents the type of rigid body
const ( // BodyTypeDynamic bodies are affected by forces, gravity, and collisions // They have finite mass and can move freely BodyTypeDynamic BodyType = iota // BodyTypeStatic bodies are immovable and have infinite mass // They are not affected by forces or gravity (e.g., ground, walls) BodyTypeStatic )
type Box ¶
Box represents an oriented box collision shape The box is defined by its half-extents (half-width, half-height, half-depth)
func (*Box) CollideWithPlane ¶
func (b *Box) CollideWithPlane(planeNormal mgl64.Vec3, planeDistance float64, myTransform Transform) (bool, PlaneContact)
CollideWithPlane - Collision Box/Plane
func (*Box) ComputeAABB ¶
func (*Box) ComputeMass ¶
ComputeMass calculates mass data for the box
func (*Box) GetContactFeature ¶
type ContactPoint ¶
type Material ¶
type Plane ¶
type Plane struct {
Normal mgl64.Vec3 // Plane normal (must be normalized)
Distance float64 // Plane constant (signed distance from origin)
// contains filtered or unexported fields
}
Plane represents an infinite plane collision shape The plane is defined by the equation: Normal · p + Distance = 0 where Normal is the plane's normal vector (must be normalized) and Distance is the signed distance from the origin along the normal
func (*Plane) CollideWithPlane ¶
func (p *Plane) CollideWithPlane(planeNormal mgl64.Vec3, planeDistance float64, myTransform Transform) (bool, PlaneContact)
CollideWithPlane - Plane/Plane collision (not supported)
func (*Plane) ComputeAABB ¶
This method is bypassed, because planes are automatically included from the broad phase to the narrow phase We use specific functions for plane / convex shapes collision
func (*Plane) ComputeMass ¶
ComputeMass calculates mass data for the plane Planes are always static with infinite mass
func (*Plane) GetContactFeature ¶
The narrow phase has specific code path for planes, this should not be called
type PlaneContact ¶
type PlaneContact []ContactPoint
type RigidBody ¶
type RigidBody struct {
// Useful to map to user data (e.g. entity id)
Id any
// Spatial properties
PreviousTransform Transform
Transform Transform
// Linear motion
PresolveVelocity mgl64.Vec3
Velocity mgl64.Vec3 // Linear velocity (m/s)
// Angular motion (NOUVEAU)
PresolveAngularVelocity mgl64.Vec3
AngularVelocity mgl64.Vec3 // Vitesse de rotation (rad/s)
// Inertia (NOUVEAU)
InertiaLocal mgl64.Mat3 // Tenseur d'inertie en espace local
InverseInertiaLocal mgl64.Mat3
IsTrigger bool
IsSleeping bool
SleepTimer float64
// Physical properties
Material Material
BodyType BodyType // Dynamic or Static
// Collision shape
Shape ShapeInterface // The collision shape
Mutex sync.Mutex
// contains filtered or unexported fields
}
RigidBody represents a rigid body in the physics simulation
func NewRigidBody ¶
func NewRigidBody(transform Transform, shape ShapeInterface, bodyType BodyType, density float64) *RigidBody
NewRigidBody creates a new rigid body with the given properties density is used to calculate mass for dynamic bodies (ignored for static)
func (*RigidBody) GetInertiaWorld ¶
Inertie en espace monde
func (*RigidBody) GetInverseInertiaWorld ¶
Inverse de l'inertie en espace monde
type ShapeInterface ¶
type ShapeInterface interface {
// ComputeAABB calculates the axis-aligned bounding box for the shape
// at the given transform
ComputeAABB(transform Transform)
GetAABB() AABB
// ComputeMass calculates mass data for the shape given a density
ComputeMass(density float64) float64
ComputeInertia(mass float64) mgl64.Mat3
Support(direction mgl64.Vec3) mgl64.Vec3
GetContactFeature(direction mgl64.Vec3, output *[8]mgl64.Vec3, count *int)
CollideWithPlane(planeNormal mgl64.Vec3, planeDistance float64, myTransform Transform) (bool, PlaneContact)
}
ShapeInterface is the interface that all collision shapes must implement
type Sphere ¶
type Sphere struct {
Radius float64
// contains filtered or unexported fields
}
Sphere represents a spherical collision shape
func (*Sphere) CollideWithPlane ¶
func (*Sphere) ComputeAABB ¶
ComputeAABB calculates the axis-aligned bounding box for the sphere
func (*Sphere) ComputeMass ¶
ComputeMass calculates mass data for the sphere