8 Commits

Author SHA1 Message Date
a01e4b6bbd Switch to mostly returning objects instead of pointers since
almost all objects contain only one pointer inside, making them
very small, so no point paying (de)allocation costs.

This has also been done to physx-c
2022-12-19 00:43:04 +04:00
96c55ad30d Add flag to say if pvd is supported 2022-12-07 06:38:33 +04:00
dd5a42c760 Support both checked and release modes 2022-12-07 06:34:13 +04:00
ceabe5d59b Flag to disable pvd 2022-12-07 06:06:49 +04:00
7e63090cb1 Move to go 1.18 2022-12-07 03:24:25 +04:00
8e358fb31f Correct DefaultCpuDispatcherCreate 2022-12-07 01:45:28 +04:00
6880bac72a Add PvdSceneClient.Release 2022-12-07 00:53:27 +04:00
66d8f247f1 Support pvd being null in CreatePhysics 2022-12-07 00:01:42 +04:00
28 changed files with 291 additions and 201 deletions

4
go.mod
View File

@ -1,5 +1,5 @@
module github.com/bloeys/physx-go
go 1.17
go 1.18
require github.com/bloeys/gglm v0.3.1
require github.com/bloeys/gglm v0.43.0

2
go.sum
View File

@ -1,2 +1,4 @@
github.com/bloeys/gglm v0.3.1 h1:Sy9upW7SBsBfDXrSmEhid3aQ+7J7itej+upwcxOnPMQ=
github.com/bloeys/gglm v0.3.1/go.mod h1:qwJQ0WzV191wAMwlGicbfbChbKoSedMk7gFFX6GnyOk=
github.com/bloeys/gglm v0.43.0 h1:ZpOghR3PHfpkigTDh+FqxLsF0gN8CD6s/bWoei6LyxI=
github.com/bloeys/gglm v0.43.0/go.mod h1:qwJQ0WzV191wAMwlGicbfbChbKoSedMk7gFFX6GnyOk=

82
main.go
View File

@ -14,45 +14,53 @@ func contactHandler(cph pgo.ContactPairHeader) {
// points := pairs[i].GetContactPoints()
// for j := 0; j < pairs[i].GetContactPointCount(); j++ {
// pos := points[j].GetPos()
// println("Contact at pos:", pos.String())
// fmt.Println("Contact at pos:", pos.String())
// }
// }
}
func main() {
f := pgo.CreateFoundation()
println("foundation:", f)
fmt.Println("foundation:", f)
pvdTr := pgo.DefaultPvdSocketTransportCreate("127.0.0.1", 5425, 100000)
println("Pvd transport:", pvdTr)
var pvd *pgo.Pvd
if pgo.PvdSupported {
pvdTr := pgo.DefaultPvdSocketTransportCreate("127.0.0.1", 5425, 100000)
fmt.Println("Pvd transport:", pvdTr)
pvd := pgo.CreatePvd(f)
println("Pvd:", pvd)
println("connected to PVD:", pvd.Connect(pvdTr, pgo.PvdInstrumentationFlag_eALL))
pvd = pgo.CreatePvd(f)
fmt.Println("Pvd:", pvd)
fmt.Println("connected to PVD:", pvd.Connect(pvdTr, pgo.PvdInstrumentationFlag_eALL))
}
ts := pgo.NewTolerancesScale(1, 9.81)
p := pgo.CreatePhysics(f, ts, false, pvd)
println("Physics:", p)
fmt.Println("Physics:", p)
sd := pgo.NewSceneDesc(ts)
sd.SetGravity(pgo.NewVec3(0, -9.8, 0))
sd.SetCpuDispatcher(pgo.DefaultCpuDispatcherCreate(2, 0).ToCpuDispatcher())
defaultCpuDispatcher := pgo.DefaultCpuDispatcherCreate(2, nil)
sd.SetCpuDispatcher(defaultCpuDispatcher.ToCpuDispatcher())
sd.SetOnContactCallback(contactHandler)
s := p.CreateScene(sd)
println("Scene:", s)
scene := p.CreateScene(sd)
fmt.Println("Scene:", scene)
scenePvdClient := s.GetScenePvdClient()
println("ScenePvdClient:", scenePvdClient)
if pgo.PvdSupported {
scenePvdClient := scene.GetScenePvdClient()
fmt.Println("ScenePvdClient:", scenePvdClient)
scenePvdClient.SetScenePvdFlag(pgo.PvdSceneFlag_eTRANSMIT_CONSTRAINTS, true)
scenePvdClient.SetScenePvdFlag(pgo.PvdSceneFlag_eTRANSMIT_CONTACTS, true)
scenePvdClient.SetScenePvdFlag(pgo.PvdSceneFlag_eTRANSMIT_SCENEQUERIES, true)
scenePvdClient.SetScenePvdFlag(pgo.PvdSceneFlag_eTRANSMIT_CONSTRAINTS, true)
scenePvdClient.SetScenePvdFlag(pgo.PvdSceneFlag_eTRANSMIT_CONTACTS, true)
scenePvdClient.SetScenePvdFlag(pgo.PvdSceneFlag_eTRANSMIT_SCENEQUERIES, true)
}
//Add plane
pMat := p.CreateMaterial(0.5, 0.5, 0.6)
groundPlane := pgo.CreatePlane(p, pgo.NewPlane(0, 1, 0, 0), pMat)
s.AddActor(groundPlane.ToActor())
scene.AddActor(groundPlane.ToActor())
//W0/W1 are filter groups the shape belongs to, and W2/W3 are a filter group mask
fd := pgo.NewFilterData(1, 1, 1, 1)
@ -70,7 +78,7 @@ func main() {
ra := dynBox.ToRigidActor()
ra.SetSimFilterData(&fd)
s.AddActor(dynBox.ToActor())
scene.AddActor(dynBox.ToActor())
//Add box2
v = pgo.NewVec3(0.5, 12, 0)
@ -79,7 +87,7 @@ func main() {
ra = dynBox2.ToRigidActor()
ra.SetSimFilterData(&fd)
s.AddActor(dynBox2.ToActor())
scene.AddActor(dynBox2.ToActor())
//Add sphere
v = pgo.NewVec3(0, 16, 0)
@ -88,7 +96,7 @@ func main() {
ra = dynSphere.ToRigidActor()
ra.SetSimFilterData(&fd)
s.AddActor(dynSphere.ToActor())
scene.AddActor(dynSphere.ToActor())
//Add capsule
v = pgo.NewVec3(0, 20, 0)
@ -96,7 +104,7 @@ func main() {
dynCapsule := pgo.CreateDynamic(p, tr4, pgo.NewCapsuleGeometry(0.25, 0.5).ToGeometry(), pMat, 1, shapeOffset)
ra = dynCapsule.ToRigidActor()
ra.SetSimFilterData(&fd)
s.AddActor(dynCapsule.ToActor())
scene.AddActor(dynCapsule.ToActor())
//Add compound shape
dynComp := p.CreateRigidDynamic(pgo.NewTransform(pgo.NewVec3(2.5, 35, 0), qID))
@ -111,33 +119,33 @@ func main() {
ra = dynComp.ToRigidActor()
ra.SetSimFilterData(&fd)
s.AddActor(dynComp.ToActor())
scene.AddActor(dynComp.ToActor())
//Make some changes and print info
dynSphere.SetMass(1)
dynCapsule.SetMass(1)
println("Box 1 mass:", dynBox.GetMass())
println("Box 2 mass:", dynBox2.GetMass())
println("Sphere mass:", dynSphere.GetMass())
println("Capsule mass:", dynCapsule.GetMass())
fmt.Println("Box 1 mass:", dynBox.GetMass())
fmt.Println("Box 2 mass:", dynBox2.GetMass())
fmt.Println("Sphere mass:", dynSphere.GetMass())
fmt.Println("Capsule mass:", dynCapsule.GetMass())
println("Capsule linear damping A:", dynCapsule.GetLinearDamping())
fmt.Println("Capsule linear damping A:", dynCapsule.GetLinearDamping())
dynCapsule.SetLinearDamping(0.05)
println("Capsule linear damping B:", dynCapsule.GetLinearDamping())
fmt.Println("Capsule linear damping B:", dynCapsule.GetLinearDamping())
//Run simulation
// r := bufio.NewReader(os.Stdin)
raycastBuffer := pgo.NewRaycastBuffer(1)
defer raycastBuffer.Release()
s.SetScratchBuffer(4)
scene.SetScratchBuffer(4)
for {
s.Collide(1 / 50.0)
s.FetchCollision(true)
s.Advance()
s.FetchResults(true)
scene.Collide(1 / 50.0)
scene.FetchCollision(true)
scene.Advance()
scene.FetchResults(true)
s.RaycastWithHitBuffer(pgo.NewVec3(0, 0, 0), pgo.NewVec3(0, 1, 0), 9, raycastBuffer, 1)
scene.RaycastWithHitBuffer(pgo.NewVec3(0, 0, 0), pgo.NewVec3(0, 1, 0), 9, raycastBuffer, 1)
if raycastBuffer.HasBlock() {
block := raycastBuffer.GetBlock()
d := block.GetDistance()
@ -145,11 +153,7 @@ func main() {
fmt.Printf("Raycast hit at dist (%v) and post %v\n", d, pos.String())
}
// fmt.Printf("\nRaycast hit: %v\n", rHit)
// println("Press enter...")
// fmt.Println("Press enter...")
// r.ReadBytes('\n')
}
// p.Release()
// pvd.Release()
// pvdTr.Release()
}

5
pgo/consts_checked.go Executable file
View File

@ -0,0 +1,5 @@
//go:build !physx_release
package pgo
const PvdSupported = true

5
pgo/consts_release.go Executable file
View File

@ -0,0 +1,5 @@
//go:build physx_release
package pgo
const PvdSupported = false

Binary file not shown.

View File

@ -2,7 +2,11 @@ package pgo
/*
#cgo CFLAGS: -I physx-c
#cgo LDFLAGS: -L ./libs -l physx-c
#cgo LDFLAGS: -L ./libs
// NOTE: If you change this update rigiddynamic.go as well
#cgo windows,amd64 LDFLAGS: -l physxc_checked_windows_amd64
#cgo windows,amd64,physx_release LDFLAGS: -l physxc_release_windows_amd64
#include <wrap.c>
#include <stdlib.h> //Needed for C.free
@ -22,26 +26,26 @@ var (
)
type Foundation struct {
cFoundation *C.struct_CPxFoundation
cFoundation C.struct_CPxFoundation
}
func (f *Foundation) Release() {
C.CPxFoundation_release(f.cFoundation)
}
func CreateFoundation() *Foundation {
func CreateFoundation() Foundation {
f := &Foundation{}
f := Foundation{}
f.cFoundation = C.CPxCreateFoundation()
return f
}
type Pvd struct {
cPvd *C.struct_CPxPvd
cPvd C.struct_CPxPvd
}
func (p *Pvd) Connect(pvdTr *PvdTransport, instFlag PvdInstrumentationFlag) bool {
func (p *Pvd) Connect(pvdTr PvdTransport, instFlag PvdInstrumentationFlag) bool {
return bool(C.CPxPvd_connect(p.cPvd, pvdTr.cPvdTr, uint32(instFlag)))
}
@ -49,7 +53,7 @@ func (p *Pvd) Release() {
C.CPxPvd_release(p.cPvd)
}
func CreatePvd(f *Foundation) *Pvd {
func CreatePvd(f Foundation) *Pvd {
p := &Pvd{}
p.cPvd = C.CPxCreatePvd(f.cFoundation)
@ -58,17 +62,13 @@ func CreatePvd(f *Foundation) *Pvd {
}
type PvdTransport struct {
cPvdTr *C.struct_CPxPvdTransport
cPvdTr C.struct_CPxPvdTransport
}
func (p *PvdTransport) Release() {
C.CPxPvdTransport_release(p.cPvdTr)
}
func DefaultPvdSocketTransportCreate(host string, port, timeoutMillis int) *PvdTransport {
func DefaultPvdSocketTransportCreate(host string, port, timeoutMillis int) PvdTransport {
//This CString should NOT be freed because its stored internally. If this is freed connection to PVD will fail
p := &PvdTransport{}
p := PvdTransport{}
p.cPvdTr = C.CPxDefaultPvdSocketTransportCreate(C.CString(host), C.int(port), C.int(timeoutMillis))
return p
}
@ -77,8 +77,8 @@ type TolerancesScale struct {
cTolScale C.struct_CPxTolerancesScale
}
func NewTolerancesScale(length, speed float32) *TolerancesScale {
return &TolerancesScale{
func NewTolerancesScale(length, speed float32) TolerancesScale {
return TolerancesScale{
cTolScale: C.struct_CPxTolerancesScale{
length: C.float(length),
speed: C.float(speed),
@ -87,11 +87,11 @@ func NewTolerancesScale(length, speed float32) *TolerancesScale {
}
type Scene struct {
cS *C.struct_CPxScene
cS C.struct_CPxScene
}
func (s *Scene) GetScenePvdClient() *PvdSceneClient {
return &PvdSceneClient{
func (s *Scene) GetScenePvdClient() PvdSceneClient {
return PvdSceneClient{
cPvdSceneClient: C.CPxScene_getScenePvdClient(s.cS),
}
}
@ -135,7 +135,7 @@ func (s *Scene) Raycast(origin, unitDir *Vec3, distance float32) (bool, RaycastB
return bool(ret), rb
}
func (s *Scene) RaycastWithHitBuffer(origin, unitDir *Vec3, distance float32, rb *RaycastBuffer, touchesToRead uint) bool {
func (s *Scene) RaycastWithHitBuffer(origin, unitDir *Vec3, distance float32, rb RaycastBuffer, touchesToRead uint) bool {
ret := C.CPxScene_raycastWithHitBuffer(s.cS, &origin.cV, &unitDir.cV, C.float(distance), rb.cRb, C.uint(touchesToRead))
return bool(ret)
@ -174,9 +174,9 @@ func (rb *RaycastBuffer) Release() {
C.CPxRaycastBuffer_release(rb.cRb)
}
func NewRaycastBuffer(maxTouches uint32) *RaycastBuffer {
func NewRaycastBuffer(maxTouches uint32) RaycastBuffer {
rb := &RaycastBuffer{
rb := RaycastBuffer{
cRb: C.NewCPxRaycastBufferWithAlloc(C.uint(maxTouches)),
}
@ -236,29 +236,29 @@ func (rh *RaycastHit) GetUV() (float32, float32) {
}
type Physics struct {
cPhysics *C.struct_CPxPhysics
cPhysics C.struct_CPxPhysics
}
func (p *Physics) CreateScene(sd *SceneDesc) *Scene {
return &Scene{
cS: C.CPxPhysics_createScene(p.cPhysics, &sd.cSD),
func (p *Physics) CreateScene(sd SceneDesc) Scene {
return Scene{
cS: C.CPxPhysics_createScene(p.cPhysics, sd.cSD),
}
}
func (p *Physics) CreateMaterial(staticFriction, dynamicFriction, restitution float32) *Material {
return &Material{
func (p *Physics) CreateMaterial(staticFriction, dynamicFriction, restitution float32) Material {
return Material{
cM: C.CPxPhysics_createMaterial(p.cPhysics, C.float(staticFriction), C.float(dynamicFriction), C.float(restitution)),
}
}
func (p *Physics) CreateRigidDynamic(tr *Transform) *RigidDynamic {
return &RigidDynamic{
func (p *Physics) CreateRigidDynamic(tr *Transform) RigidDynamic {
return RigidDynamic{
cRd: C.CPxPhysics_createRigidDynamic(p.cPhysics, &tr.cT),
}
}
func (p *Physics) CreateRigidStatic(tr *Transform) *RigidStatic {
return &RigidStatic{
func (p *Physics) CreateRigidStatic(tr *Transform) RigidStatic {
return RigidStatic{
cRs: C.CPxPhysics_createRigidStatic(p.cPhysics, &tr.cT),
}
}
@ -267,10 +267,14 @@ func (p *Physics) Release() {
C.CPxPhysics_release(p.cPhysics)
}
func CreatePhysics(f *Foundation, ts *TolerancesScale, trackOutstandingAllocations bool, pvd *Pvd) *Physics {
func CreatePhysics(f Foundation, ts TolerancesScale, trackOutstandingAllocations bool, pvd *Pvd) Physics {
p := &Physics{}
p.cPhysics = C.CPxCreatePhysics(f.cFoundation, ts.cTolScale, C._Bool(trackOutstandingAllocations), pvd.cPvd)
p := Physics{}
if pvd != nil {
p.cPhysics = C.CPxCreatePhysics(f.cFoundation, ts.cTolScale, C._Bool(trackOutstandingAllocations), &pvd.cPvd)
} else {
p.cPhysics = C.CPxCreatePhysics(f.cFoundation, ts.cTolScale, C._Bool(trackOutstandingAllocations), nil)
}
return p
}
@ -296,25 +300,25 @@ type Shape struct {
func (s *Shape) GetLocalPose() *Transform {
return &Transform{
cT: C.CPxShape_getLocalPose(&s.cShape),
cT: C.CPxShape_getLocalPose(s.cShape),
}
}
func (s *Shape) SetLocalPose(tr *Transform) {
C.CPxShape_setLocalPose(&s.cShape, &tr.cT)
C.CPxShape_setLocalPose(s.cShape, &tr.cT)
}
func (s *Shape) GetSimulationFilterData() FilterData {
return FilterData{
cFilterData: C.CPxShape_getSimulationFilterData(&s.cShape),
cFilterData: C.CPxShape_getSimulationFilterData(s.cShape),
}
}
func (s *Shape) SetSimulationFilterData(fd *FilterData) {
C.CPxShape_setSimulationFilterData(&s.cShape, &fd.cFilterData)
C.CPxShape_setSimulationFilterData(s.cShape, &fd.cFilterData)
}
func CreateExclusiveShape(rigidActor RigidActor, geom *Geometry, mat *Material, shapeFlags ShapeFlags) Shape {
func CreateExclusiveShape(rigidActor RigidActor, geom Geometry, mat Material, shapeFlags ShapeFlags) Shape {
return Shape{
cShape: C.createExclusiveShape(rigidActor.cRa, geom.cG, mat.cM, uint32(shapeFlags)),
}
@ -347,20 +351,35 @@ func NewVec3(x, y, z float32) *Vec3 {
}
type CpuDispatcher struct {
cCpuDisp *C.struct_CPxCpuDispatcher
cCpuDisp C.struct_CPxCpuDispatcher
}
type DefaultCpuDispatcher struct {
cDefCpuDisp *C.struct_CPxDefaultCpuDispatcher
cDefCpuDisp C.struct_CPxDefaultCpuDispatcher
}
func (d *DefaultCpuDispatcher) ToCpuDispatcher() *CpuDispatcher {
return &CpuDispatcher{cCpuDisp: (*C.struct_CPxCpuDispatcher)(d.cDefCpuDisp)}
func (d *DefaultCpuDispatcher) ToCpuDispatcher() CpuDispatcher {
return CpuDispatcher{cCpuDisp: C.CPxDefaultCpuDispatcher_toCPxCpuDispatcher(d.cDefCpuDisp)}
}
func DefaultCpuDispatcherCreate(numThreads, affinityMasks uint32) *DefaultCpuDispatcher {
return &DefaultCpuDispatcher{
cDefCpuDisp: C.CPxDefaultCpuDispatcherCreate(C.uint(numThreads), C.uint(affinityMasks)),
// DefaultCpuDispatcherCreate sets the number of threads used by physX.
// If affinityMasksPerThread is nil/zero then default masks are used, otherwise the size of the array
// must match the number of threads
func DefaultCpuDispatcherCreate(numThreads uint32, affinityMasksPerThread []uint32) DefaultCpuDispatcher {
if len(affinityMasksPerThread) == 0 {
return DefaultCpuDispatcher{
cDefCpuDisp: C.CPxDefaultCpuDispatcherCreate(C.uint(numThreads), nil),
}
}
arr := make([]C.uint, len(affinityMasksPerThread))
for i := 0; i < len(arr); i++ {
arr[i] = C.uint(affinityMasksPerThread[i])
}
return DefaultCpuDispatcher{
cDefCpuDisp: C.CPxDefaultCpuDispatcherCreate(C.uint(numThreads), &arr[0]),
}
}
@ -369,22 +388,22 @@ type SceneDesc struct {
}
func (sd *SceneDesc) SetGravity(v *Vec3) {
C.CPxSceneDesc_set_gravity(&sd.cSD, v.cV)
C.CPxSceneDesc_set_gravity(sd.cSD, v.cV)
}
func (sd *SceneDesc) SetCpuDispatcher(cd *CpuDispatcher) {
C.CPxSceneDesc_set_cpuDispatcher(&sd.cSD, cd.cCpuDisp)
func (sd *SceneDesc) SetCpuDispatcher(cd CpuDispatcher) {
C.CPxSceneDesc_set_cpuDispatcher(sd.cSD, cd.cCpuDisp)
}
//SetOnContactCallback sets the GLOBAL contact callback handler. Physx-c currently only supports 1 contact callback handler.
//Setting a contact callback handler overrides the previous one. Only the most recent one gets called.
// SetOnContactCallback sets the GLOBAL contact callback handler. Physx-c currently only supports 1 contact callback handler.
// Setting a contact callback handler overrides the previous one. Only the most recent one gets called.
func (sd *SceneDesc) SetOnContactCallback(cb func(ContactPairHeader)) {
contactCallback = cb
C.CPxSceneDesc_set_onContactCallback(&sd.cSD, (C.CPxonContactCallback)(unsafe.Pointer(C.goOnContactCallback_cgo)))
C.CPxSceneDesc_set_onContactCallback(sd.cSD, (C.CPxonContactCallback)(unsafe.Pointer(C.goOnContactCallback_cgo)))
}
func NewSceneDesc(ts *TolerancesScale) *SceneDesc {
return &SceneDesc{
func NewSceneDesc(ts TolerancesScale) SceneDesc {
return SceneDesc{
cSD: C.NewCPxSceneDesc(ts.cTolScale),
}
}
@ -499,7 +518,7 @@ const (
)
type PvdSceneClient struct {
cPvdSceneClient *C.struct_CPxPvdSceneClient
cPvdSceneClient C.struct_CPxPvdSceneClient
}
func (p *PvdSceneClient) SetScenePvdFlag(flag PvdSceneFlag, value bool) {
@ -507,7 +526,7 @@ func (p *PvdSceneClient) SetScenePvdFlag(flag PvdSceneFlag, value bool) {
}
type Material struct {
cM *C.struct_CPxMaterial
cM C.struct_CPxMaterial
}
type Plane struct {
@ -551,16 +570,24 @@ type SphereGeometry struct {
cSg C.struct_CPxSphereGeometry
}
func (sg *SphereGeometry) GetRadius() float32 {
return float32(sg.cSg.radius)
}
func (sg *SphereGeometry) SetRadius(r float32) {
sg.cSg.radius = C.float(r)
}
// struct CPxGeometry CPxSphereGeometry_toCPxGeometry(struct CPxSphereGeometry*);
func (sg *SphereGeometry) ToGeometry() *Geometry {
return &Geometry{
func (sg SphereGeometry) ToGeometry() Geometry {
return Geometry{
cG: C.CPxSphereGeometry_toCPxGeometry(&sg.cSg),
}
}
// struct CPxSphereGeometry NewCPxSphereGeometry(CPxReal radius);
func NewSphereGeometry(radius float32) *SphereGeometry {
return &SphereGeometry{
func NewSphereGeometry(radius float32) SphereGeometry {
return SphereGeometry{
cSg: C.struct_CPxSphereGeometry{
radius: C.float(radius),
},
@ -571,14 +598,28 @@ type BoxGeometry struct {
cBg C.struct_CPxBoxGeometry
}
func (bg *BoxGeometry) ToGeometry() *Geometry {
return &Geometry{
// GetExtents returns the extents of each dimension of the box.
// An extent is half the length total length.
//
// For example, a cube of size 1x1x1 would have an extent of 0.5 on each side
func (bg *BoxGeometry) GetExtents() (ex, ey, ez float32) {
return float32(bg.cBg.hx), float32(bg.cBg.hy), float32(bg.cBg.hz)
}
func (bg *BoxGeometry) SetExtents(ex, ey, ez float32) {
bg.cBg.hx = C.float(ex)
bg.cBg.hy = C.float(ey)
bg.cBg.hz = C.float(ez)
}
func (bg BoxGeometry) ToGeometry() Geometry {
return Geometry{
cG: C.CPxBoxGeometry_toCPxGeometry(&bg.cBg),
}
}
func NewBoxGeometry(hx, hy, hz float32) *BoxGeometry {
return &BoxGeometry{
func NewBoxGeometry(hx, hy, hz float32) BoxGeometry {
return BoxGeometry{
cBg: C.struct_CPxBoxGeometry{
hx: C.float(hx),
hy: C.float(hy),
@ -591,14 +632,23 @@ type CapsuleGeometry struct {
cCg C.struct_CPxCapsuleGeometry
}
func (bg *CapsuleGeometry) ToGeometry() *Geometry {
return &Geometry{
func (bg *CapsuleGeometry) GetParams() (radius, extent float32) {
return float32(bg.cCg.radius), float32(bg.cCg.halfHeight)
}
func (bg *CapsuleGeometry) SetParams(radius, extent float32) {
bg.cCg.radius = C.float(radius)
bg.cCg.halfHeight = C.float(extent)
}
func (bg CapsuleGeometry) ToGeometry() Geometry {
return Geometry{
cG: C.CPxCapsuleGeometry_toCPxGeometry(&bg.cCg),
}
}
func NewCapsuleGeometry(radius, halfHeight float32) *CapsuleGeometry {
return &CapsuleGeometry{
func NewCapsuleGeometry(radius, halfHeight float32) CapsuleGeometry {
return CapsuleGeometry{
cCg: C.struct_CPxCapsuleGeometry{
radius: C.float(radius),
halfHeight: C.float(halfHeight),
@ -615,13 +665,13 @@ type RigidActor struct {
}
func (ra *RigidActor) SetSimFilterData(fd *FilterData) {
C.CPxRigidActor_setSimFilterData(&ra.cRa, &fd.cFilterData)
C.CPxRigidActor_setSimFilterData(ra.cRa, fd.cFilterData)
}
// CPxAPI void CPxRigidActor_setSimFilterData(CSTRUCT CPxRigidActor* cra, CSTRUCT CPxFilterData* cfd);
type RigidStatic struct {
cRs *C.struct_CPxRigidStatic
cRs C.struct_CPxRigidStatic
}
func (rs *RigidStatic) ToActor() Actor {
@ -636,8 +686,8 @@ func (rs *RigidStatic) ToRigidActor() RigidActor {
}
}
func CreatePlane(p *Physics, plane *Plane, mat *Material) *RigidStatic {
return &RigidStatic{
func CreatePlane(p Physics, plane *Plane, mat Material) RigidStatic {
return RigidStatic{
cRs: C.CPxCreatePlane(p.cPhysics, &plane.cP, mat.cM),
}
}

View File

@ -10,7 +10,7 @@
extern "C" {
#endif
CPxAPI CSTRUCT CPxRigidDynamic* CPxCreateDynamic(CSTRUCT CPxPhysics* sdk, CSTRUCT CPxTransform* transform, CSTRUCT CPxGeometry geometry, CSTRUCT CPxMaterial* material, CPxReal density, CSTRUCT CPxTransform* shapeOffset);
CPxAPI CSTRUCT CPxRigidDynamic CPxCreateDynamic(CSTRUCT CPxPhysics sdk, CSTRUCT CPxTransform* transform, CSTRUCT CPxGeometry geometry, CSTRUCT CPxMaterial material, CPxReal density, CSTRUCT CPxTransform* shapeOffset);
#ifdef __cplusplus
}

View File

@ -10,7 +10,7 @@ extern "C" {
void* obj;
};
CPxAPI void CPxActor_release(CSTRUCT CPxActor*);
CPxAPI void CPxActor_release(CSTRUCT CPxActor);
#ifdef __cplusplus
}

View File

@ -10,14 +10,6 @@ extern "C" {
void* obj;
};
/// <summary>
/// This only frees C representation of the base class (the CPxCpuDispatcher struct). obj is NOT freed.
/// To release the PhysX resources release must be called on the actual C implementation (e.g. CPxDefaultCpuDispatcher_release)
/// </summary>
/// <param name="CPxCpuDispatcher"></param>
/// <returns></returns>
CPxAPI void CPxCpuDispatcher_release(CSTRUCT CPxCpuDispatcher*);
#ifdef __cplusplus
}
#endif

View File

@ -11,9 +11,9 @@ extern "C" {
void* obj;
};
CPxAPI CSTRUCT CPxDefaultCpuDispatcher* CPxDefaultCpuDispatcherCreate(CPxU32 numThreads, CPxU32 affinityMasks);
CPxAPI CSTRUCT CPxCpuDispatcher* CPxDefaultCpuDispatcher_toCPxCpuDispatcher(CSTRUCT CPxDefaultCpuDispatcher* cdcd);
CPxAPI void CPxDefaultCpuDispatcher_release(CSTRUCT CPxDefaultCpuDispatcher* cdcd);
CPxAPI CSTRUCT CPxDefaultCpuDispatcher CPxDefaultCpuDispatcherCreate(CPxU32 numThreads, CPxU32* affinityMasks);
CPxAPI CSTRUCT CPxCpuDispatcher CPxDefaultCpuDispatcher_toCPxCpuDispatcher(CSTRUCT CPxDefaultCpuDispatcher cdcd);
CPxAPI void CPxDefaultCpuDispatcher_release(CSTRUCT CPxDefaultCpuDispatcher cdcd);
#ifdef __cplusplus
}

View File

@ -9,8 +9,8 @@ extern "C" {
void* obj;
};
CPxAPI CSTRUCT CPxFoundation* CPxCreateFoundation();
CPxAPI void CPxFoundation_release(CSTRUCT CPxFoundation* cpf);
CPxAPI CSTRUCT CPxFoundation CPxCreateFoundation();
CPxAPI void CPxFoundation_release(CSTRUCT CPxFoundation cpf);
#ifdef __cplusplus
}
#endif

View File

@ -10,8 +10,6 @@ extern "C" {
void* obj;
};
CPxAPI void CPxMaterial_release(CSTRUCT CPxMaterial*);
#ifdef __cplusplus
}
#endif

View File

@ -19,13 +19,13 @@ extern "C" {
void* obj;
};
CPxAPI CSTRUCT CPxPhysics* CPxCreatePhysics(CSTRUCT CPxFoundation* cfoundation, CSTRUCT CPxTolerancesScale cscale, bool trackOutstandingAllocations, CSTRUCT CPxPvd* cpvd);
CPxAPI CSTRUCT CPxScene* CPxPhysics_createScene(CSTRUCT CPxPhysics*, CSTRUCT CPxSceneDesc*);
CPxAPI CSTRUCT CPxMaterial* CPxPhysics_createMaterial(CSTRUCT CPxPhysics*, CPxReal staticFriction, CPxReal dynamicFriction, CPxReal restitution);
CPxAPI CSTRUCT CPxRigidDynamic* CPxPhysics_createRigidDynamic(CSTRUCT CPxPhysics* cp, CSTRUCT CPxTransform* ctr);
CPxAPI CSTRUCT CPxRigidStatic* CPxPhysics_createRigidStatic(CSTRUCT CPxPhysics* cp, CSTRUCT CPxTransform* ctr);
CPxAPI CSTRUCT CPxPhysics CPxCreatePhysics(CSTRUCT CPxFoundation cfoundation, CSTRUCT CPxTolerancesScale cscale, bool trackOutstandingAllocations, CSTRUCT CPxPvd* cpvd);
CPxAPI CSTRUCT CPxScene CPxPhysics_createScene(CSTRUCT CPxPhysics, CSTRUCT CPxSceneDesc);
CPxAPI CSTRUCT CPxMaterial CPxPhysics_createMaterial(CSTRUCT CPxPhysics, CPxReal staticFriction, CPxReal dynamicFriction, CPxReal restitution);
CPxAPI CSTRUCT CPxRigidDynamic CPxPhysics_createRigidDynamic(CSTRUCT CPxPhysics cp, CSTRUCT CPxTransform* ctr);
CPxAPI CSTRUCT CPxRigidStatic CPxPhysics_createRigidStatic(CSTRUCT CPxPhysics cp, CSTRUCT CPxTransform* ctr);
CPxAPI void CPxPhysics_release(CSTRUCT CPxPhysics*);
CPxAPI void CPxPhysics_release(CSTRUCT CPxPhysics);
#ifdef __cplusplus
}

View File

@ -62,9 +62,9 @@ extern "C" {
void* obj;
};
CPxAPI CSTRUCT CPxPvd* CPxCreatePvd(CSTRUCT CPxFoundation*);
CPxAPI bool CPxPvd_connect(CSTRUCT CPxPvd*, CSTRUCT CPxPvdTransport*, CENUM CPxPvdInstrumentationFlag);
CPxAPI void CPxPvd_release(CSTRUCT CPxPvd* cpp);
CPxAPI CSTRUCT CPxPvd CPxCreatePvd(CSTRUCT CPxFoundation);
CPxAPI bool CPxPvd_connect(CSTRUCT CPxPvd, CSTRUCT CPxPvdTransport, CENUM CPxPvdInstrumentationFlag);
CPxAPI void CPxPvd_release(CSTRUCT CPxPvd cpp);
#ifdef __cplusplus
}
#endif

View File

@ -17,14 +17,7 @@ extern "C" {
void* obj;
};
CPxAPI void CPxPvdSceneClient_setScenePvdFlag(CSTRUCT CPxPvdSceneClient* c, CENUM CPxPvdSceneFlag flag, bool value);
/// <summary>
/// This only releases the C struct
/// </summary>
/// <param name=""></param>
/// <returns></returns>
CPxAPI void CPxPvdSceneClient_release(CSTRUCT CPxPvdSceneClient*);
CPxAPI void CPxPvdSceneClient_setScenePvdFlag(CSTRUCT CPxPvdSceneClient c, CENUM CPxPvdSceneFlag flag, bool value);
#ifdef __cplusplus
}

View File

@ -9,8 +9,7 @@ extern "C" {
void* obj;
};
CPxAPI CSTRUCT CPxPvdTransport* CPxDefaultPvdSocketTransportCreate(const char* address, int port, int timeoutMillis);
CPxAPI void CPxPvdTransport_release(CSTRUCT CPxPvdTransport* cppt);
CPxAPI CSTRUCT CPxPvdTransport CPxDefaultPvdSocketTransportCreate(const char* address, int port, int timeoutMillis);
#ifdef __cplusplus
}
#endif

View File

@ -13,7 +13,7 @@ extern "C" {
};
//Sets the CPxFilterData on all the shapes of the actor.
CPxAPI void CPxRigidActor_setSimFilterData(CSTRUCT CPxRigidActor* cra, CSTRUCT CPxFilterData* cfd);
CPxAPI void CPxRigidActor_setSimFilterData(CSTRUCT CPxRigidActor cra, CSTRUCT CPxFilterData cfd);
#ifdef __cplusplus
}

View File

@ -11,7 +11,7 @@
extern "C" {
#endif
CPxAPI CSTRUCT CPxShape createExclusiveShape(CSTRUCT CPxRigidActor actor, CSTRUCT CPxGeometry geometry, CSTRUCT CPxMaterial* material, CENUM CPxShapeFlags shapeFlags);
CPxAPI CSTRUCT CPxShape createExclusiveShape(CSTRUCT CPxRigidActor actor, CSTRUCT CPxGeometry geometry, CSTRUCT CPxMaterial material, CENUM CPxShapeFlags shapeFlags);
#ifdef __cplusplus
}

View File

@ -18,37 +18,37 @@ extern "C" {
void* obj;
};
CPxAPI CSTRUCT CPxActor CPxRigidDynamic_toCPxActor(CSTRUCT CPxRigidDynamic*);
CPxAPI CSTRUCT CPxRigidActor CPxRigidDynamic_toCPxRigidActor(CSTRUCT CPxRigidDynamic*);
CPxAPI CSTRUCT CPxActor CPxRigidDynamic_toCPxActor(CSTRUCT CPxRigidDynamic);
CPxAPI CSTRUCT CPxRigidActor CPxRigidDynamic_toCPxRigidActor(CSTRUCT CPxRigidDynamic);
CPxAPI void CPxRigidDynamic_addForce(CSTRUCT CPxRigidDynamic* crd, CSTRUCT CPxVec3* force, CENUM CPxForceMode fmode, bool autoAwake);
CPxAPI void CPxRigidDynamic_addTorque(CSTRUCT CPxRigidDynamic* crd, CSTRUCT CPxVec3* torque, CENUM CPxForceMode fmode, bool autoAwake);
CPxAPI void CPxRigidDynamic_addForce(CSTRUCT CPxRigidDynamic crd, CSTRUCT CPxVec3* force, CENUM CPxForceMode fmode, bool autoAwake);
CPxAPI void CPxRigidDynamic_addTorque(CSTRUCT CPxRigidDynamic crd, CSTRUCT CPxVec3* torque, CENUM CPxForceMode fmode, bool autoAwake);
CPxAPI void CPxRigidDynamic_setLinearDamping(CSTRUCT CPxRigidDynamic* crd, CPxReal damping);
CPxAPI void CPxRigidDynamic_setAngularDamping(CSTRUCT CPxRigidDynamic* crd, CPxReal damping);
CPxAPI CPxReal CPxRigidDynamic_getLinearDamping(CSTRUCT CPxRigidDynamic* crd);
CPxAPI CPxReal CPxRigidDynamic_getAngularDamping(CSTRUCT CPxRigidDynamic* crd);
CPxAPI void CPxRigidDynamic_setLinearDamping(CSTRUCT CPxRigidDynamic crd, CPxReal damping);
CPxAPI void CPxRigidDynamic_setAngularDamping(CSTRUCT CPxRigidDynamic crd, CPxReal damping);
CPxAPI CPxReal CPxRigidDynamic_getLinearDamping(CSTRUCT CPxRigidDynamic crd);
CPxAPI CPxReal CPxRigidDynamic_getAngularDamping(CSTRUCT CPxRigidDynamic crd);
CPxAPI CSTRUCT CPxVec3 CPxRigidDynamic_getLinearVelocity(CSTRUCT CPxRigidDynamic* crd);
CPxAPI CSTRUCT CPxVec3 CPxRigidDynamic_getAngularVelocity(CSTRUCT CPxRigidDynamic* crd);
CPxAPI CSTRUCT CPxVec3 CPxRigidDynamic_getLinearVelocity(CSTRUCT CPxRigidDynamic crd);
CPxAPI CSTRUCT CPxVec3 CPxRigidDynamic_getAngularVelocity(CSTRUCT CPxRigidDynamic crd);
CPxAPI void CPxRigidDynamic_setMass(CSTRUCT CPxRigidDynamic* crd, CPxReal mass);
CPxAPI CPxReal CPxRigidDynamic_getMass(CSTRUCT CPxRigidDynamic* crd);
CPxAPI void CPxRigidDynamic_setMass(CSTRUCT CPxRigidDynamic crd, CPxReal mass);
CPxAPI CPxReal CPxRigidDynamic_getMass(CSTRUCT CPxRigidDynamic crd);
CPxAPI void CPxRigidDynamic_setRigidBodyFlag(CSTRUCT CPxRigidDynamic* crd, CENUM CPxRigidBodyFlag flag, bool value);
CPxAPI void CPxRigidDynamic_setRigidBodyFlags(CSTRUCT CPxRigidDynamic* crd, CENUM CPxRigidBodyFlag flags);
CPxAPI CENUM CPxRigidBodyFlag CPxRigidDynamic_getRigidBodyFlags(CSTRUCT CPxRigidDynamic* crd);
CPxAPI void CPxRigidDynamic_setRigidBodyFlag(CSTRUCT CPxRigidDynamic crd, CENUM CPxRigidBodyFlag flag, bool value);
CPxAPI void CPxRigidDynamic_setRigidBodyFlags(CSTRUCT CPxRigidDynamic crd, CENUM CPxRigidBodyFlag flags);
CPxAPI CENUM CPxRigidBodyFlag CPxRigidDynamic_getRigidBodyFlags(CSTRUCT CPxRigidDynamic crd);
CPxAPI void CPxRigidDynamic_setRigidDynamicLockFlag(CSTRUCT CPxRigidDynamic* crd, CENUM CPxRigidDynamicLockFlag flag, bool value);
CPxAPI void CPxRigidDynamic_setRigidDynamicLockFlags(CSTRUCT CPxRigidDynamic* crd, CENUM CPxRigidDynamicLockFlag flags);
CPxAPI CENUM CPxRigidDynamicLockFlag CPxRigidDynamic_getRigidDynamicLockFlags(CSTRUCT CPxRigidDynamic* crd);
CPxAPI void CPxRigidDynamic_setRigidDynamicLockFlag(CSTRUCT CPxRigidDynamic crd, CENUM CPxRigidDynamicLockFlag flag, bool value);
CPxAPI void CPxRigidDynamic_setRigidDynamicLockFlags(CSTRUCT CPxRigidDynamic crd, CENUM CPxRigidDynamicLockFlag flags);
CPxAPI CENUM CPxRigidDynamicLockFlag CPxRigidDynamic_getRigidDynamicLockFlags(CSTRUCT CPxRigidDynamic crd);
CPxAPI void CPxRigidDynamic_putToSleep(CSTRUCT CPxRigidDynamic* crd);
CPxAPI CSTRUCT CPxTransform CPxRigidDynamic_getGlobalPose(CSTRUCT CPxRigidDynamic* crd);
CPxAPI void CPxRigidDynamic_setGlobalPose(CSTRUCT CPxRigidDynamic* crd, CSTRUCT CPxTransform* tr, bool autoAwake);
CPxAPI void CPxRigidDynamic_putToSleep(CSTRUCT CPxRigidDynamic crd);
CPxAPI CSTRUCT CPxTransform CPxRigidDynamic_getGlobalPose(CSTRUCT CPxRigidDynamic crd);
CPxAPI void CPxRigidDynamic_setGlobalPose(CSTRUCT CPxRigidDynamic crd, CSTRUCT CPxTransform* tr, bool autoAwake);
CPxAPI CSTRUCT CPxTransform CPxRigidDynamic_getCMassLocalPose(CSTRUCT CPxRigidDynamic* crd);
CPxAPI void CPxRigidDynamic_setCMassLocalPose(CSTRUCT CPxRigidDynamic* crd, CSTRUCT CPxTransform* tr);
CPxAPI CSTRUCT CPxTransform CPxRigidDynamic_getCMassLocalPose(CSTRUCT CPxRigidDynamic crd);
CPxAPI void CPxRigidDynamic_setCMassLocalPose(CSTRUCT CPxRigidDynamic crd, CSTRUCT CPxTransform* tr);
#ifdef __cplusplus
}

View File

@ -13,8 +13,8 @@ extern "C" {
void* obj;
};
CPxAPI CSTRUCT CPxActor CPxRigidStatic_toCPxActor(CSTRUCT CPxRigidStatic*);
CPxAPI CSTRUCT CPxRigidActor CPxRigidStatic_toCPxRigidActor(CSTRUCT CPxRigidStatic*);
CPxAPI CSTRUCT CPxActor CPxRigidStatic_toCPxActor(CSTRUCT CPxRigidStatic);
CPxAPI CSTRUCT CPxRigidActor CPxRigidStatic_toCPxRigidActor(CSTRUCT CPxRigidStatic);
#ifdef __cplusplus
}

View File

@ -19,20 +19,20 @@ extern "C" {
CPxU32 scratchBufferSize;
};
CPxAPI CSTRUCT CPxPvdSceneClient* CPxScene_getScenePvdClient(CSTRUCT CPxScene*);
CPxAPI void CPxScene_addActor(CSTRUCT CPxScene*, CSTRUCT CPxActor actor);
CPxAPI void CPxScene_simulate(CSTRUCT CPxScene*, CPxReal elapsedTime);
CPxAPI void CPxScene_collide(CSTRUCT CPxScene*, CPxReal elapsedTime);
CPxAPI bool CPxScene_fetchCollision(CSTRUCT CPxScene*, bool block);
CPxAPI void CPxScene_advance(CSTRUCT CPxScene*);
CPxAPI bool CPxScene_fetchResults(CSTRUCT CPxScene*, bool block, CPxU32* errorState);
CPxAPI CSTRUCT CPxPvdSceneClient CPxScene_getScenePvdClient(CSTRUCT CPxScene);
CPxAPI void CPxScene_addActor(CSTRUCT CPxScene, CSTRUCT CPxActor actor);
CPxAPI void CPxScene_simulate(CSTRUCT CPxScene, CPxReal elapsedTime);
CPxAPI void CPxScene_collide(CSTRUCT CPxScene, CPxReal elapsedTime);
CPxAPI bool CPxScene_fetchCollision(CSTRUCT CPxScene, bool block);
CPxAPI void CPxScene_advance(CSTRUCT CPxScene);
CPxAPI bool CPxScene_fetchResults(CSTRUCT CPxScene, bool block, CPxU32* errorState);
//Does a scene raycast. Allocates memory for hitRet and then reads data into it. It is the callers responsibility to free.
CPxAPI bool CPxScene_raycast(CSTRUCT CPxScene* cs, CSTRUCT CPxVec3* origin, CSTRUCT CPxVec3* unitDir, CPxReal distance, CSTRUCT CPxRaycastBuffer** hitRet);
CPxAPI bool CPxScene_raycast(CSTRUCT CPxScene cs, CSTRUCT CPxVec3* origin, CSTRUCT CPxVec3* unitDir, CPxReal distance, CSTRUCT CPxRaycastBuffer** hitRet);
//Does a scene raycast. 'hit' must be pre-allocated as NO new allocation will happen in the function.
//hit->touches will be filled up to 'touchesToRead' and must also be pre-allocated. If the hit produces more touches than 'touchesToRead' then the additional touches will be ignored.
CPxAPI bool CPxScene_raycastWithHitBuffer(CSTRUCT CPxScene* cs, CSTRUCT CPxVec3* origin, CSTRUCT CPxVec3* unitDir, CPxReal distance, CSTRUCT CPxRaycastBuffer* hit, CPxU32 touchesToRead);
CPxAPI bool CPxScene_raycastWithHitBuffer(CSTRUCT CPxScene cs, CSTRUCT CPxVec3* origin, CSTRUCT CPxVec3* unitDir, CPxReal distance, CSTRUCT CPxRaycastBuffer* hit, CPxU32 touchesToRead);
/// <summary>
/// Creates a scratch buffer thats a multiple of 16K to be used by the scene when running CPxScene_simulate.
@ -40,9 +40,9 @@ extern "C" {
/// If multiples passed are zero then any existing buffers are cleared
/// </summary>
/// <returns></returns>
CPxAPI void CPxScene_setScratchBuffer(CSTRUCT CPxScene*, CPxU32 multiplesOf16k);
CPxAPI void CPxScene_setScratchBuffer(CSTRUCT CPxScene, CPxU32 multiplesOf16k);
CPxAPI void CPxScene_release(CSTRUCT CPxScene*);
CPxAPI void CPxScene_release(CSTRUCT CPxScene);
#ifdef __cplusplus
}

View File

@ -21,8 +21,8 @@ extern "C" {
/// <param name="CPxTolerancesScale"></param>
/// <returns></returns>
CPxAPI CSTRUCT CPxSceneDesc NewCPxSceneDesc(CSTRUCT CPxTolerancesScale);
CPxAPI void CPxSceneDesc_set_gravity(CSTRUCT CPxSceneDesc*, CSTRUCT CPxVec3);
CPxAPI void CPxSceneDesc_set_cpuDispatcher(CSTRUCT CPxSceneDesc*, CSTRUCT CPxCpuDispatcher*);
CPxAPI void CPxSceneDesc_set_gravity(CSTRUCT CPxSceneDesc, CSTRUCT CPxVec3);
CPxAPI void CPxSceneDesc_set_cpuDispatcher(CSTRUCT CPxSceneDesc, CSTRUCT CPxCpuDispatcher);
//CPxSceneDesc_set_onContactCallback sets the contact callback handler of the given scene descriptor.
@ -30,8 +30,8 @@ extern "C" {
//Therefore, the callback handler MUST copy data it wishes to keep for longer than the lifetime of the callback handler, as the memory it was handed might be reused/freed.
//
//NOTE: This function assumes you are using the default physx-c callback handler. Do NOT use this function if you set 'sceneDesc->simulationEventCallback' with your own custom implementation.
CPxAPI void CPxSceneDesc_set_onContactCallback(CSTRUCT CPxSceneDesc*, CPxonContactCallback cb);
CPxAPI void FreeCPxSceneDesc(CSTRUCT CPxSceneDesc*);
CPxAPI void CPxSceneDesc_set_onContactCallback(CSTRUCT CPxSceneDesc, CPxonContactCallback cb);
CPxAPI void FreeCPxSceneDesc(CSTRUCT CPxSceneDesc);
#ifdef __cplusplus
}

View File

@ -13,10 +13,10 @@ extern "C" {
void* obj;
};
CPxAPI void CPxShape_setLocalPose(CSTRUCT CPxShape* cs, CSTRUCT CPxTransform* tr);
CPxAPI CSTRUCT CPxTransform CPxShape_getLocalPose(CSTRUCT CPxShape* cs);
CPxAPI CSTRUCT CPxFilterData CPxShape_getSimulationFilterData(CSTRUCT CPxShape* cs);
CPxAPI void CPxShape_setSimulationFilterData(CSTRUCT CPxShape* cs, CSTRUCT CPxFilterData* cfd);
CPxAPI void CPxShape_setLocalPose(CSTRUCT CPxShape cs, CSTRUCT CPxTransform* tr);
CPxAPI CSTRUCT CPxTransform CPxShape_getLocalPose(CSTRUCT CPxShape cs);
CPxAPI CSTRUCT CPxFilterData CPxShape_getSimulationFilterData(CSTRUCT CPxShape cs);
CPxAPI void CPxShape_setSimulationFilterData(CSTRUCT CPxShape cs, CSTRUCT CPxFilterData* cfd);
#ifdef __cplusplus
}

View File

@ -10,7 +10,7 @@
extern "C" {
#endif
CPxAPI CSTRUCT CPxRigidStatic* CPxCreatePlane(CSTRUCT CPxPhysics* sdk, CSTRUCT CPxPlane* plane, CSTRUCT CPxMaterial* material);
CPxAPI CSTRUCT CPxRigidStatic CPxCreatePlane(CSTRUCT CPxPhysics sdk, CSTRUCT CPxPlane* plane, CSTRUCT CPxMaterial material);
#ifdef __cplusplus
}

View File

@ -2,7 +2,11 @@ package pgo
/*
#cgo CFLAGS: -I physx-c
#cgo LDFLAGS: -L ./libs -l physx-c
#cgo LDFLAGS: -L ./libs
// NOTE: If you change this update pgo.go as well
#cgo windows,amd64 LDFLAGS: -l physxc_checked_windows_amd64
#cgo windows,amd64,physx_release LDFLAGS: -l physxc_release_windows_amd64
#include <wrap.c>
#include <stdlib.h> //Needed for C.free
@ -10,7 +14,7 @@ package pgo
import "C"
type RigidDynamic struct {
cRd *C.struct_CPxRigidDynamic
cRd C.struct_CPxRigidDynamic
}
func (rd *RigidDynamic) AddForce(force *Vec3, fmode ForceMode, autoAwake bool) {
@ -117,8 +121,8 @@ func (rd *RigidDynamic) ToRigidActor() RigidActor {
}
}
func CreateDynamic(p *Physics, t *Transform, g *Geometry, m *Material, density float32, shapeOffset *Transform) *RigidDynamic {
return &RigidDynamic{
func CreateDynamic(p Physics, t *Transform, g Geometry, m Material, density float32, shapeOffset *Transform) RigidDynamic {
return RigidDynamic{
cRd: C.CPxCreateDynamic(p.cPhysics, &t.cT, g.cG, m.cM, C.float(density), &shapeOffset.cT),
}
}

38
switch-physx-mode.sh Executable file
View File

@ -0,0 +1,38 @@
#!/bin/bash
set -e
if [[ $# -ne 1 ]]; then
echo -e "1) Checked mode\n2) Release mode"
exit 0
fi
mode=$1
physxBinDir="../physx/physx/bin/win.x86_64.vc142.mt"
physxCBinDir="../physx-c/x64"
if [[ $mode -eq 1 ]]; then
physxCheckedBinDir="$physxBinDir/checked"
cp "$physxCheckedBinDir/PhysX_64.dll" "$physxCheckedBinDir/PhysXCommon_64.dll" "$physxCheckedBinDir/PhysXFoundation_64.dll" .
physxCCheckedBinDir="$physxCBinDir/Checked"
cp "$physxCCheckedBinDir/physx-c.dll" .
echo "Switched PhysX to Checked mode"
elif [[ $mode -eq 2 ]]; then
physxReleaseBinDir="$physxBinDir/release"
cp "$physxReleaseBinDir/PhysX_64.dll" "$physxReleaseBinDir/PhysXCommon_64.dll" "$physxReleaseBinDir/PhysXFoundation_64.dll" .
physxCReleaseBinDir="$physxCBinDir/Release"
cp "$physxCReleaseBinDir/physx-c.dll" .
echo "Switched PhysX to Release mode"
else
echo "Unknown mode. Please select 1 or 2"
exit 1
fi