physics

package
v0.0.0-...-8e5a076 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2024 License: GPL-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BoxShape      = ShapeType(1)
	SphereShape   = ShapeType(2)
	CylinderShape = ShapeType(3)
	CapsuleShape  = ShapeType(4)
	MeshShape     = ShapeType(5)
	CompoundShape = ShapeType(6)
)
View Source
const All = Mask(0xFFFFFFFF)
View Source
const None = Mask(0)

Variables

This section is empty.

Functions

func CollisionMesh

func CollisionMesh(mesh vertex.Mesh) vertex.Mesh

func GoDrawLineCallback

func GoDrawLineCallback(handle C.goDynamicsWorldHandle, start_x, start_y, start_z, end_x, end_y, end_z, color_r, color_g, color_b C.float)

Types

type Box

type Box struct {
	*Collider

	Extents object.Property[vec3.T]
	// contains filtered or unexported fields
}

func NewBox

func NewBox(pool object.Pool, size vec3.T) *Box

func (*Box) Name

func (b *Box) Name() string

func (*Box) String

func (b *Box) String() string

type Capsule

type Capsule struct {
	*Collider

	Radius object.Property[float32]
	Height object.Property[float32]
	// contains filtered or unexported fields
}

func NewCapsule

func NewCapsule(pool object.Pool, height, radius float32) *Capsule

func (*Capsule) Name

func (c *Capsule) Name() string

func (*Capsule) String

func (c *Capsule) String() string

type Character

type Character struct {
	object.Component
	// contains filtered or unexported fields
}

func NewCharacter

func NewCharacter(pool object.Pool, height, radius, stepHeight float32) *Character

func (*Character) Grounded

func (c *Character) Grounded() bool

Grounded returns true if the character is in contact with ground.

func (*Character) Jump

func (c *Character) Jump()

Jump applies a jumping force to the character todo: configurable?

func (*Character) Move

func (c *Character) Move(dir vec3.T)

Move the character controller. Called every frame to apply movement.

func (*Character) OnDisable

func (c *Character) OnDisable()

func (*Character) OnEnable

func (c *Character) OnEnable()

type Collider

type Collider struct {
	object.Component
	// contains filtered or unexported fields
}

func (*Collider) OnChange

func (c *Collider) OnChange() *events.Event[Shape]

func (*Collider) OnDisable

func (c *Collider) OnDisable()

func (*Collider) OnEnable

func (c *Collider) OnEnable()

type Compound

type Compound struct {
	*Collider
	// contains filtered or unexported fields
}

func NewCompound

func NewCompound(pool object.Pool) *Compound

func (*Compound) Name

func (c *Compound) Name() string

func (*Compound) OnDisable

func (c *Compound) OnDisable()

func (*Compound) OnEnable

func (c *Compound) OnEnable()

type Mask

type Mask uint32

func Layers

func Layers(layers ...Mask) Mask

type Mesh

type Mesh struct {
	*Collider

	Mesh object.Property[assets.Mesh]
	// contains filtered or unexported fields
}

func NewMesh

func NewMesh(pool object.Pool) *Mesh

func (*Mesh) EditorUpdate

func (m *Mesh) EditorUpdate(scene object.Component, dt float32)

func (*Mesh) Name

func (m *Mesh) Name() string

func (*Mesh) OnDisable

func (m *Mesh) OnDisable()

func (*Mesh) OnEnable

func (m *Mesh) OnEnable()

func (*Mesh) Update

func (m *Mesh) Update(scene object.Component, dt float32)

type Object

type Object interface {
	// contains filtered or unexported methods
}

type RaycastHit

type RaycastHit struct {
	Shape  Shape
	Point  vec3.T
	Normal vec3.T
}

type RigidBody

type RigidBody struct {
	object.Component

	Mass  object.Property[float32]
	Layer object.Property[Mask]
	Mask  object.Property[Mask]
	// contains filtered or unexported fields
}

func NewRigidBody

func NewRigidBody(pool object.Pool, mass float32) *RigidBody

func (*RigidBody) Kinematic

func (b *RigidBody) Kinematic() bool

func (*RigidBody) OnDisable

func (b *RigidBody) OnDisable()

func (*RigidBody) OnEnable

func (b *RigidBody) OnEnable()

type Shape

type Shape interface {
	object.Component

	OnChange() *events.Event[Shape]
	// contains filtered or unexported methods
}

func Shapes

func Shapes(cmp object.Component) []Shape

type ShapeType

type ShapeType int

type Sphere

type Sphere struct {
	*Collider

	Radius object.Property[float32]
	// contains filtered or unexported fields
}

func NewSphere

func NewSphere(pool object.Pool, radius float32) *Sphere

type Vertex

type Vertex struct {
	vec3.T `vtx:"position,float,3"`
}

Vertex format used by physics meshes

func (Vertex) Position

func (v Vertex) Position() vec3.T

type World

type World struct {
	object.Component
	// contains filtered or unexported fields
}

func NewWorld

func NewWorld(pool object.Pool) *World

func (*World) AddCharacter

func (w *World) AddCharacter(character *Character)

func (*World) Debug

func (w *World) Debug(enabled bool)

func (*World) DebugDraw

func (w *World) DebugDraw()

func (*World) OnEnable

func (w *World) OnEnable()

func (*World) Raycast

func (w *World) Raycast(from, to vec3.T, mask Mask) (hit RaycastHit, exists bool)

func (*World) RemoveCharacter

func (w *World) RemoveCharacter(character *Character)

func (*World) SetGravity

func (w *World) SetGravity(gravity vec3.T)

func (*World) Update

func (w *World) Update(scene object.Component, dt float32)

Jump to

Keyboard shortcuts

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