physics

package
v0.0.0-...-5c722c9 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Body

type Body struct {
	Object interface{}

	Rotation gmath.Rad

	Pos gmath.Vec

	LayerMask uint16
	// contains filtered or unexported fields
}

func (*Body) BoundsRect

func (b *Body) BoundsRect() gmath.Rect

func (*Body) CircleRadius

func (b *Body) CircleRadius() float64

func (*Body) Dispose

func (b *Body) Dispose()

func (*Body) InitCircle

func (b *Body) InitCircle(o interface{}, radius float64)

func (*Body) InitRotatedRect

func (b *Body) InitRotatedRect(o interface{}, width, height float64)

func (*Body) InitStaticCircle

func (b *Body) InitStaticCircle(o interface{}, radius float64)

func (*Body) InitStaticRotatedRect

func (b *Body) InitStaticRotatedRect(o interface{}, width, height float64)

func (*Body) IsCircle

func (b *Body) IsCircle() bool

func (*Body) IsDisposed

func (b *Body) IsDisposed() bool

func (*Body) IsRotatedRect

func (b *Body) IsRotatedRect() bool

func (*Body) RotatedRectHeight

func (b *Body) RotatedRectHeight() float64

func (*Body) RotatedRectVertices

func (b *Body) RotatedRectVertices() RectVertices

func (*Body) RotatedRectWidth

func (b *Body) RotatedRectWidth() float64

func (Body) String

func (b Body) String() string

type Collision

type Collision struct {
	// Body is a body being collided.
	// To get a collision object, access `Collision.Body.Object`.
	Body *Body

	// LayerMask represents the layer masks intersection of the colliding objects.
	LayerMask uint16

	// Normal is a contacted surface collision normal vector.
	// Collision normal vector has unit length (it's normalized).
	//
	// Note: a normal is computed only when resolving with non-zero velocity.
	Normal gmath.Vec

	Depth float64
}

type CollisionConfig

type CollisionConfig struct {
	Offset gmath.Vec

	// If velocity magnitude is not 0, collisions are calculated
	// in the dynamics of the movement.
	Velocity gmath.Vec

	// If not 0, this mask will be used instead of the object own mask.
	// It can be used to both include or exclude some other objects from
	// the collisions calculation.
	LayerMask uint16

	Limit int
}

type CollisionEngine

type CollisionEngine struct {
	// contains filtered or unexported fields
}

func (*CollisionEngine) AddBody

func (e *CollisionEngine) AddBody(b *Body)

AddBody includes the given body into the collision space.

Note that it will not be ready to register or cause any collisions until the next frame.

func (*CollisionEngine) CalculateFrame

func (e *CollisionEngine) CalculateFrame()

CalculateFrame re-calculates layers and other things for the upcoming frame. This function is called from the framework itself in the beginning of each frame.

func (*CollisionEngine) GetCollisions

func (e *CollisionEngine) GetCollisions(b *Body, config CollisionConfig) []Collision

GetCollisions returns all colliders for the specified body. A config can affect the rules of this collision computation.

type RectVertices

type RectVertices [4]gmath.Vec

func (*RectVertices) LL

func (v *RectVertices) LL() gmath.Vec

func (*RectVertices) LR

func (v *RectVertices) LR() gmath.Vec

func (*RectVertices) UL

func (v *RectVertices) UL() gmath.Vec

func (*RectVertices) UR

func (v *RectVertices) UR() gmath.Vec

Jump to

Keyboard shortcuts

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