physics

package
v0.0.0-...-124f97e Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2023 License: GPL-2.0 Imports: 15 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 DeserializeBox

func DeserializeBox(dec object.Decoder) (object.Component, error)

func DeserializeCapsule

func DeserializeCapsule(dec object.Decoder) (object.Component, error)

func DeserializeMesh

func DeserializeMesh(dec object.Decoder) (object.Component, error)

func DeserializeRigidBody

func DeserializeRigidBody(dec object.Decoder) (object.Component, error)

func DeserializeSphere

func DeserializeSphere(dec object.Decoder) (object.Component, error)

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(size vec3.T) *Box

func (*Box) Name

func (b *Box) Name() string

func (*Box) Serialize

func (s *Box) Serialize(enc object.Encoder) error

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(height, radius float32) *Capsule

func (*Capsule) Name

func (c *Capsule) Name() string

func (*Capsule) Serialize

func (s *Capsule) Serialize(enc object.Encoder) error

func (*Capsule) String

func (c *Capsule) String() string

type Character

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

func NewCharacter

func NewCharacter(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() *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[vertex.Mesh]
	// contains filtered or unexported fields
}

func NewMesh

func NewMesh() *Mesh

func (*Mesh) Name

func (m *Mesh) Name() string

func (*Mesh) OnDisable

func (m *Mesh) OnDisable()

func (*Mesh) OnEnable

func (m *Mesh) OnEnable()

func (*Mesh) Serialize

func (m *Mesh) Serialize(enc object.Encoder) error

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(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()

func (*RigidBody) Serialize

func (b *RigidBody) Serialize(enc object.Encoder) error

type RigidbodyState

type RigidbodyState struct {
	Mass  float32
	Layer Mask
	Mask  Mask
}

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(radius float32) *Sphere

func (*Sphere) Serialize

func (s *Sphere) Serialize(enc object.Encoder) error

type World

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

func NewWorld

func NewWorld() *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