physac

package
v0.0.0-...-dca22cd Latest Latest
Warning

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

Go to latest
Published: May 17, 2021 License: Zlib Imports: 5 Imported by: 0

Documentation

Overview

Package physac provides Go bindings for Physac.

Index

Constants

View Source
const (
	// PHYSAC_STANDALONE as defined in go-raylib/<predefine>:24
	PHYSAC_STANDALONE = 1
	// PHYSAC_MAX_BODIES as defined in src/physac.h:102
	PHYSAC_MAX_BODIES = 64
	// PHYSAC_MAX_MANIFOLDS as defined in src/physac.h:103
	PHYSAC_MAX_MANIFOLDS = 4096
	// PHYSAC_MAX_VERTICES as defined in src/physac.h:104
	PHYSAC_MAX_VERTICES = 24
	// PHYSAC_CIRCLE_VERTICES as defined in src/physac.h:105
	PHYSAC_CIRCLE_VERTICES = 24
	// PHYSAC_COLLISION_ITERATIONS as defined in src/physac.h:107
	PHYSAC_COLLISION_ITERATIONS = 100
	// PHYSAC_PENETRATION_ALLOWANCE as defined in src/physac.h:108
	PHYSAC_PENETRATION_ALLOWANCE = 0.05
	// PHYSAC_PENETRATION_CORRECTION as defined in src/physac.h:109
	PHYSAC_PENETRATION_CORRECTION = 0.4
	// PHYSAC_PI as defined in src/physac.h:111
	PHYSAC_PI = 3.14159265358979323846
	// PHYSAC_DEG2RAD as defined in src/physac.h:112
	PHYSAC_DEG2RAD = (PHYSAC_PI / 180.0)
	// PHYSAC_FLT_MAX as defined in src/physac.h:285
	PHYSAC_FLT_MAX = 3.402823466e+38
	// PHYSAC_EPSILON as defined in src/physac.h:286
	PHYSAC_EPSILON = 0.000001
	// PHYSAC_K as defined in src/physac.h:287
	PHYSAC_K = 1.0 / 3.0
)

Variables

This section is empty.

Functions

func BiasGreaterThan

func BiasGreaterThan(valueA float32, valueB float32) bool

BiasGreaterThan function as declared in src/physac.h:398

func Clip

func Clip(normal Vector2, clip float32, faceA *Vector2, faceB *Vector2) int32

Clip function as declared in src/physac.h:397

func ClosePhysics

func ClosePhysics()

ClosePhysics function as declared in src/physac.h:225

func CorrectPhysicsPositions

func CorrectPhysicsPositions(manifold *PhysicsManifoldData)

CorrectPhysicsPositions function as declared in src/physac.h:394

func DestroyPhysicsBody

func DestroyPhysicsBody(body *PhysicsBodyData)

DestroyPhysicsBody function as declared in src/physac.h:223

func DestroyPhysicsManifold

func DestroyPhysicsManifold(manifold *PhysicsManifoldData)

DestroyPhysicsManifold function as declared in src/physac.h:384

func DistSqr

func DistSqr(v1 Vector2, v2 Vector2) float32

DistSqr function as declared in src/physac.h:410

func FindAvailableBodyIndex

func FindAvailableBodyIndex() int32

FindAvailableBodyIndex function as declared in src/physac.h:377

func FindAvailableManifoldIndex

func FindAvailableManifoldIndex() int32

FindAvailableManifoldIndex function as declared in src/physac.h:382

func FindAxisLeastPenetration

func FindAxisLeastPenetration(faceIndex *int32, shapeA PhysicsShape, shapeB PhysicsShape) float32

FindAxisLeastPenetration function as declared in src/physac.h:395

func FindIncidentFace

func FindIncidentFace(v0 *Vector2, v1 *Vector2, ref PhysicsShape, inc PhysicsShape, index int32)

FindIncidentFace function as declared in src/physac.h:396

func GetCurrentTime

func GetCurrentTime() float64

GetCurrentTime function as declared in src/physac.h:403

func GetPhysicsBodiesCount

func GetPhysicsBodiesCount() int32

GetPhysicsBodiesCount function as declared in src/physac.h:217

func GetPhysicsShapeType

func GetPhysicsShapeType(index int32) int32

GetPhysicsShapeType function as declared in src/physac.h:219

func GetPhysicsShapeVerticesCount

func GetPhysicsShapeVerticesCount(index int32) int32

GetPhysicsShapeVerticesCount function as declared in src/physac.h:220

func GetTimeCount

func GetTimeCount() uint64

GetTimeCount function as declared in src/physac.h:402

func InitPhysics

func InitPhysics()

InitPhysics function as declared in src/physac.h:206

func InitTimer

func InitTimer()

InitTimer function as declared in src/physac.h:401

func InitializePhysicsManifolds

func InitializePhysicsManifolds(manifold *PhysicsManifoldData)

InitializePhysicsManifolds function as declared in src/physac.h:391

func IntegratePhysicsForces

func IntegratePhysicsForces(body *PhysicsBodyData)

IntegratePhysicsForces function as declared in src/physac.h:390

func IntegratePhysicsImpulses

func IntegratePhysicsImpulses(manifold *PhysicsManifoldData)

IntegratePhysicsImpulses function as declared in src/physac.h:392

func IntegratePhysicsVelocity

func IntegratePhysicsVelocity(body *PhysicsBodyData)

IntegratePhysicsVelocity function as declared in src/physac.h:393

func IsPhysicsEnabled

func IsPhysicsEnabled() bool

IsPhysicsEnabled function as declared in src/physac.h:209

func Mat2Set

func Mat2Set(matrix *Matrix2x2, radians float32)

Mat2Set function as declared in src/physac.h:418

func MathCrossVector2

func MathCrossVector2(v1 Vector2, v2 Vector2) float32

MathCrossVector2 function as declared in src/physac.h:407

func MathDot

func MathDot(v1 Vector2, v2 Vector2) float32

MathDot function as declared in src/physac.h:409

func MathLenSqr

func MathLenSqr(vector Vector2) float32

MathLenSqr function as declared in src/physac.h:408

func MathNormalize

func MathNormalize(vector *Vector2)

MathNormalize function as declared in src/physac.h:411

func PhysicsAddForce

func PhysicsAddForce(body *PhysicsBodyData, force Vector2)

PhysicsAddForce function as declared in src/physac.h:214

func PhysicsAddTorque

func PhysicsAddTorque(body *PhysicsBodyData, amount float32)

PhysicsAddTorque function as declared in src/physac.h:215

func PhysicsLoop

func PhysicsLoop(arg unsafe.Pointer) unsafe.Pointer

PhysicsLoop function as declared in src/physac.h:380

func PhysicsShatter

func PhysicsShatter(body *PhysicsBodyData, position Vector2, force float32)

PhysicsShatter function as declared in src/physac.h:216

func PhysicsStep

func PhysicsStep()

PhysicsStep function as declared in src/physac.h:381

func ResetPhysics

func ResetPhysics()

ResetPhysics function as declared in src/physac.h:224

func RunPhysicsStep

func RunPhysicsStep()

RunPhysicsStep function as declared in src/physac.h:207

func SetPhysicsBodyRotation

func SetPhysicsBodyRotation(body *PhysicsBodyData, radians float32)

SetPhysicsBodyRotation function as declared in src/physac.h:222

func SetPhysicsGravity

func SetPhysicsGravity(x float32, y float32)

SetPhysicsGravity function as declared in src/physac.h:210

func SetPhysicsTimeStep

func SetPhysicsTimeStep(delta float64)

SetPhysicsTimeStep function as declared in src/physac.h:208

func SolveCircleToCircle

func SolveCircleToCircle(manifold *PhysicsManifoldData)

SolveCircleToCircle function as declared in src/physac.h:386

func SolveCircleToPolygon

func SolveCircleToPolygon(manifold *PhysicsManifoldData)

SolveCircleToPolygon function as declared in src/physac.h:387

func SolvePhysicsManifold

func SolvePhysicsManifold(manifold *PhysicsManifoldData)

SolvePhysicsManifold function as declared in src/physac.h:385

func SolvePolygonToCircle

func SolvePolygonToCircle(manifold *PhysicsManifoldData)

SolvePolygonToCircle function as declared in src/physac.h:388

func SolvePolygonToPolygon

func SolvePolygonToPolygon(manifold *PhysicsManifoldData)

SolvePolygonToPolygon function as declared in src/physac.h:389

Types

type Matrix2x2

type Matrix2x2 struct {
	M00 float32
	M01 float32
	M10 float32
	M11 float32
}

func AllocMatrix2x2

func AllocMatrix2x2(cM00 float32, cM01 float32, cM10 float32, cM11 float32) (*Matrix2x2, *cgoAllocMap)

AllocMatrix2x2 new Go object and Mapping to C object.

func Mat2Radians

func Mat2Radians(radians float32) Matrix2x2

Mat2Radians function as declared in src/physac.h:417

func Mat2Transpose

func Mat2Transpose(matrix Matrix2x2) Matrix2x2

Mat2Transpose function as declared in src/physac.h:419

func NewMatrix2x2

func NewMatrix2x2(cM00 float32, cM01 float32, cM10 float32, cM11 float32) Matrix2x2

NewMatrix2x2 new Go object and Mapping to C object.

func (*Matrix2x2) GC

func (x *Matrix2x2) GC(a *cgoAllocMap, args ...*cgoAllocMap)

GC is register for garbage collection.

func (*Matrix2x2) Index

func (x *Matrix2x2) Index(index int32) *Matrix2x2

Index reads Go data structure out from plain C format.

type PhysicsBodyData

type PhysicsBodyData struct {
	Id              uint32
	Enabled         bool
	Position        Vector2
	Velocity        Vector2
	Force           Vector2
	AngularVelocity float32
	Torque          float32
	Orient          float32
	Inertia         float32
	InverseInertia  float32
	Mass            float32
	InverseMass     float32
	StaticFriction  float32
	DynamicFriction float32
	Restitution     float32
	UseGravity      bool
	IsGrounded      bool
	FreezeOrient    bool
	Shape           PhysicsShape
}

func AllocPhysicsBodyData

func AllocPhysicsBodyData(cId uint32, cEnabled bool, cPosition Vector2, cVelocity Vector2, cForce Vector2, cAngularVelocity float32, cTorque float32, cOrient float32, cInertia float32, cInverseInertia float32, cMass float32, cInverseMass float32, cStaticFriction float32, cDynamicFriction float32, cRestitution float32, cUseGravity bool, cIsGrounded bool, cFreezeOrient bool, cShape PhysicsShape) (*PhysicsBodyData, *cgoAllocMap)

AllocPhysicsBodyData new Go object and Mapping to C object.

func CreatePhysicsBodyCircle

func CreatePhysicsBodyCircle(pos Vector2, radius float32, density float32) *PhysicsBodyData

CreatePhysicsBodyCircle function as declared in src/physac.h:211

func CreatePhysicsBodyPolygon

func CreatePhysicsBodyPolygon(pos Vector2, radius float32, sides int32, density float32) *PhysicsBodyData

CreatePhysicsBodyPolygon function as declared in src/physac.h:213

func CreatePhysicsBodyRectangle

func CreatePhysicsBodyRectangle(pos Vector2, width float32, height float32, density float32) *PhysicsBodyData

CreatePhysicsBodyRectangle function as declared in src/physac.h:212

func GetPhysicsBody

func GetPhysicsBody(index int32) *PhysicsBodyData

GetPhysicsBody function as declared in src/physac.h:218

func NewPhysicsBodyData

func NewPhysicsBodyData(cId uint32, cEnabled bool, cPosition Vector2, cVelocity Vector2, cForce Vector2, cAngularVelocity float32, cTorque float32, cOrient float32, cInertia float32, cInverseInertia float32, cMass float32, cInverseMass float32, cStaticFriction float32, cDynamicFriction float32, cRestitution float32, cUseGravity bool, cIsGrounded bool, cFreezeOrient bool, cShape PhysicsShape) PhysicsBodyData

NewPhysicsBodyData new Go object and Mapping to C object.

func (*PhysicsBodyData) GC

func (x *PhysicsBodyData) GC(a *cgoAllocMap, args ...*cgoAllocMap)

GC is register for garbage collection.

func (*PhysicsBodyData) Index

func (x *PhysicsBodyData) Index(index int32) *PhysicsBodyData

Index reads Go data structure out from plain C format.

type PhysicsManifoldData

type PhysicsManifoldData struct {
	Id              uint32
	BodyA           *PhysicsBodyData
	BodyB           *PhysicsBodyData
	Penetration     float32
	Normal          Vector2
	Contacts        [2]Vector2
	ContactsCount   uint32
	Restitution     float32
	DynamicFriction float32
	StaticFriction  float32
}

func AllocPhysicsManifoldData

func AllocPhysicsManifoldData(cId uint32, cBodyA []PhysicsBodyData, cBodyB []PhysicsBodyData, cPenetration float32, cNormal Vector2, cContacts [2]Vector2, cContactsCount uint32, cRestitution float32, cDynamicFriction float32, cStaticFriction float32) (*PhysicsManifoldData, *cgoAllocMap)

AllocPhysicsManifoldData new Go object and Mapping to C object.

func CreatePhysicsManifold

func CreatePhysicsManifold(a *PhysicsBodyData, b *PhysicsBodyData) *PhysicsManifoldData

CreatePhysicsManifold function as declared in src/physac.h:383

func NewPhysicsManifoldData

func NewPhysicsManifoldData(cId uint32, cBodyA []PhysicsBodyData, cBodyB []PhysicsBodyData, cPenetration float32, cNormal Vector2, cContacts [2]Vector2, cContactsCount uint32, cRestitution float32, cDynamicFriction float32, cStaticFriction float32) PhysicsManifoldData

NewPhysicsManifoldData new Go object and Mapping to C object.

func (*PhysicsManifoldData) BodyAer

func (x *PhysicsManifoldData) BodyAer(index int32) *PhysicsBodyData

BodyA returns a reference to C object within a struct

func (*PhysicsManifoldData) BodyBer

func (x *PhysicsManifoldData) BodyBer(index int32) *PhysicsBodyData

BodyB returns a reference to C object within a struct

func (*PhysicsManifoldData) Contactser

func (x *PhysicsManifoldData) Contactser(index int32) *Vector2

Contacts returns a reference to C object within a struct

func (*PhysicsManifoldData) GC

func (x *PhysicsManifoldData) GC(a *cgoAllocMap, args ...*cgoAllocMap)

GC is register for garbage collection.

func (*PhysicsManifoldData) Index

Index reads Go data structure out from plain C format.

type PhysicsShape

type PhysicsShape struct {
	Type       PhysicsShapeType
	Body       *PhysicsBodyData
	Radius     float32
	Transform  Matrix2x2
	VertexData PolygonData
}

func AllocPhysicsShape

func AllocPhysicsShape(cType PhysicsShapeType, cBody []PhysicsBodyData, cRadius float32, cTransform Matrix2x2, cVertexData PolygonData) (*PhysicsShape, *cgoAllocMap)

AllocPhysicsShape new Go object and Mapping to C object.

func NewPhysicsShape

func NewPhysicsShape(cType PhysicsShapeType, cBody []PhysicsBodyData, cRadius float32, cTransform Matrix2x2, cVertexData PolygonData) PhysicsShape

NewPhysicsShape new Go object and Mapping to C object.

func (*PhysicsShape) Bodyer

func (x *PhysicsShape) Bodyer(index int32) *PhysicsBodyData

Body returns a reference to C object within a struct

func (*PhysicsShape) GC

func (x *PhysicsShape) GC(a *cgoAllocMap, args ...*cgoAllocMap)

GC is register for garbage collection.

func (*PhysicsShape) Index

func (x *PhysicsShape) Index(index int32) *PhysicsShape

Index reads Go data structure out from plain C format.

type PhysicsShapeType

type PhysicsShapeType int32

PhysicsShapeType as declared in src/physac.h:133

const (
	PHYSICS_CIRCLE  PhysicsShapeType = iota
	PHYSICS_POLYGON PhysicsShapeType = 1
)

PhysicsShapeType enumeration from src/physac.h:133

type PolygonData

type PolygonData struct {
	VertexCount uint32
	Positions   [24]Vector2
	Normals     [24]Vector2
}

func AllocPolygonData

func AllocPolygonData(cVertexCount uint32, cPositions [24]Vector2, cNormals [24]Vector2) (*PolygonData, *cgoAllocMap)

AllocPolygonData new Go object and Mapping to C object.

func CreateRandomPolygon

func CreateRandomPolygon(radius float32, sides int32) PolygonData

CreateRandomPolygon function as declared in src/physac.h:378

func CreateRectanglePolygon

func CreateRectanglePolygon(pos Vector2, size Vector2) PolygonData

CreateRectanglePolygon function as declared in src/physac.h:379

func NewPolygonData

func NewPolygonData(cVertexCount uint32, cPositions [24]Vector2, cNormals [24]Vector2) PolygonData

NewPolygonData new Go object and Mapping to C object.

func (*PolygonData) GC

func (x *PolygonData) GC(a *cgoAllocMap, args ...*cgoAllocMap)

GC is register for garbage collection.

func (*PolygonData) Index

func (x *PolygonData) Index(index int32) *PolygonData

Index reads Go data structure out from plain C format.

func (*PolygonData) Normalser

func (x *PolygonData) Normalser(index int32) *Vector2

Normals returns a reference to C object within a struct

func (*PolygonData) Positionser

func (x *PolygonData) Positionser(index int32) *Vector2

Positions returns a reference to C object within a struct

type Vector2

type Vector2 struct {
	X float32
	Y float32
}

func AllocVector2

func AllocVector2(cX float32, cY float32) (*Vector2, *cgoAllocMap)

AllocVector2 new Go object and Mapping to C object.

func GetPhysicsShapeVertex

func GetPhysicsShapeVertex(body *PhysicsBodyData, vertex int32) Vector2

GetPhysicsShapeVertex function as declared in src/physac.h:221

func Mat2MultiplyVector2

func Mat2MultiplyVector2(matrix Matrix2x2, vector Vector2) Vector2

Mat2MultiplyVector2 function as declared in src/physac.h:420

func MathCross

func MathCross(value float32, vector Vector2) Vector2

MathCross function as declared in src/physac.h:406

func NewVector2

func NewVector2(cX float32, cY float32) Vector2

NewVector2 new Go object and Mapping to C object.

func TriangleBarycenter

func TriangleBarycenter(v1 Vector2, v2 Vector2, v3 Vector2) Vector2

TriangleBarycenter function as declared in src/physac.h:399

func (*Vector2) GC

func (x *Vector2) GC(a *cgoAllocMap, args ...*cgoAllocMap)

GC is register for garbage collection.

func (*Vector2) Index

func (x *Vector2) Index(index int32) *Vector2

Index reads Go data structure out from plain C format.

Jump to

Keyboard shortcuts

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