From a01e4b6bbd2e0577ab86ae7b57fcd6bf8dab4fb9 Mon Sep 17 00:00:00 2001 From: bloeys Date: Mon, 19 Dec 2022 00:43:04 +0400 Subject: [PATCH] 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 --- main.go | 35 +++--- pgo/pgo.go | 171 +++++++++++++++----------- pgo/physx-c/CExtSimpleFactory.h | 2 +- pgo/physx-c/CPxActor.h | 2 +- pgo/physx-c/CPxCpuDispatcher.h | 8 -- pgo/physx-c/CPxDefaultCpuDispatcher.h | 6 +- pgo/physx-c/CPxFoundation.h | 4 +- pgo/physx-c/CPxMaterial.h | 2 - pgo/physx-c/CPxPhysics.h | 12 +- pgo/physx-c/CPxPvd.h | 6 +- pgo/physx-c/CPxPvdSceneClient.h | 9 +- pgo/physx-c/CPxPvdTransport.h | 3 +- pgo/physx-c/CPxRigidActor.h | 2 +- pgo/physx-c/CPxRigidActorExt.h | 2 +- pgo/physx-c/CPxRigidDynamic.h | 46 +++---- pgo/physx-c/CPxRigidStatic.h | 4 +- pgo/physx-c/CPxScene.h | 22 ++-- pgo/physx-c/CPxSceneDesc.h | 8 +- pgo/physx-c/CPxShape.h | 8 +- pgo/physx-c/CPxSimpleFactory.h | 2 +- pgo/rigiddynamic.go | 6 +- switch-physx-mode.sh | 38 ++++++ 22 files changed, 221 insertions(+), 177 deletions(-) create mode 100755 switch-physx-mode.sh diff --git a/main.go b/main.go index 8ddb951..e5a8d24 100755 --- a/main.go +++ b/main.go @@ -14,7 +14,7 @@ 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()) // } // } } @@ -22,38 +22,39 @@ func contactHandler(cph pgo.ContactPairHeader) { func main() { f := pgo.CreateFoundation() - println("foundation:", f) + fmt.Println("foundation:", f) var pvd *pgo.Pvd if pgo.PvdSupported { pvdTr := pgo.DefaultPvdSocketTransportCreate("127.0.0.1", 5425, 100000) - println("Pvd transport:", pvdTr) + fmt.Println("Pvd transport:", pvdTr) pvd = pgo.CreatePvd(f) - println("Pvd:", pvd) - println("connected to PVD:", pvd.Connect(pvdTr, pgo.PvdInstrumentationFlag_eALL)) + 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, nil).ToCpuDispatcher()) + + defaultCpuDispatcher := pgo.DefaultCpuDispatcherCreate(2, nil) + sd.SetCpuDispatcher(defaultCpuDispatcher.ToCpuDispatcher()) sd.SetOnContactCallback(contactHandler) scene := p.CreateScene(sd) - println("Scene:", scene) + fmt.Println("Scene:", scene) if pgo.PvdSupported { scenePvdClient := scene.GetScenePvdClient() - println("ScenePvdClient:", scenePvdClient) + 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.Release() } //Add plane @@ -123,14 +124,14 @@ func main() { //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) @@ -152,7 +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') } } diff --git a/pgo/pgo.go b/pgo/pgo.go index 0de8641..89de82d 100755 --- a/pgo/pgo.go +++ b/pgo/pgo.go @@ -26,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))) } @@ -53,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) @@ -62,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 } @@ -81,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), @@ -91,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), } } @@ -139,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) @@ -178,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)), } @@ -240,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), } } @@ -271,11 +267,11 @@ 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 := Physics{} if pvd != nil { - p.cPhysics = C.CPxCreatePhysics(f.cFoundation, ts.cTolScale, C._Bool(trackOutstandingAllocations), pvd.cPvd) + 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) } @@ -304,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)), } @@ -355,24 +351,24 @@ 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)} } // 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 { +func DefaultCpuDispatcherCreate(numThreads uint32, affinityMasksPerThread []uint32) DefaultCpuDispatcher { if len(affinityMasksPerThread) == 0 { - return &DefaultCpuDispatcher{ + return DefaultCpuDispatcher{ cDefCpuDisp: C.CPxDefaultCpuDispatcherCreate(C.uint(numThreads), nil), } } @@ -382,7 +378,7 @@ func DefaultCpuDispatcherCreate(numThreads uint32, affinityMasksPerThread []uint arr[i] = C.uint(affinityMasksPerThread[i]) } - return &DefaultCpuDispatcher{ + return DefaultCpuDispatcher{ cDefCpuDisp: C.CPxDefaultCpuDispatcherCreate(C.uint(numThreads), &arr[0]), } } @@ -392,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. 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), } } @@ -522,19 +518,15 @@ const ( ) type PvdSceneClient struct { - cPvdSceneClient *C.struct_CPxPvdSceneClient + cPvdSceneClient C.struct_CPxPvdSceneClient } func (p *PvdSceneClient) SetScenePvdFlag(flag PvdSceneFlag, value bool) { C.CPxPvdSceneClient_setScenePvdFlag(p.cPvdSceneClient, uint32(flag), C._Bool(value)) } -func (p *PvdSceneClient) Release() { - C.CPxPvdSceneClient_release(p.cPvdSceneClient) -} - type Material struct { - cM *C.struct_CPxMaterial + cM C.struct_CPxMaterial } type Plane struct { @@ -578,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), }, @@ -598,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), @@ -618,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), @@ -642,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 { @@ -663,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), } } diff --git a/pgo/physx-c/CExtSimpleFactory.h b/pgo/physx-c/CExtSimpleFactory.h index 7fc668b..f2849e0 100755 --- a/pgo/physx-c/CExtSimpleFactory.h +++ b/pgo/physx-c/CExtSimpleFactory.h @@ -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 } diff --git a/pgo/physx-c/CPxActor.h b/pgo/physx-c/CPxActor.h index e3afb09..509ea2f 100755 --- a/pgo/physx-c/CPxActor.h +++ b/pgo/physx-c/CPxActor.h @@ -10,7 +10,7 @@ extern "C" { void* obj; }; - CPxAPI void CPxActor_release(CSTRUCT CPxActor*); + CPxAPI void CPxActor_release(CSTRUCT CPxActor); #ifdef __cplusplus } diff --git a/pgo/physx-c/CPxCpuDispatcher.h b/pgo/physx-c/CPxCpuDispatcher.h index bde6a4a..999fee9 100755 --- a/pgo/physx-c/CPxCpuDispatcher.h +++ b/pgo/physx-c/CPxCpuDispatcher.h @@ -10,14 +10,6 @@ extern "C" { void* obj; }; - /// - /// 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) - /// - /// - /// - CPxAPI void CPxCpuDispatcher_release(CSTRUCT CPxCpuDispatcher*); - #ifdef __cplusplus } #endif diff --git a/pgo/physx-c/CPxDefaultCpuDispatcher.h b/pgo/physx-c/CPxDefaultCpuDispatcher.h index be7f913..411ece6 100755 --- a/pgo/physx-c/CPxDefaultCpuDispatcher.h +++ b/pgo/physx-c/CPxDefaultCpuDispatcher.h @@ -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 } diff --git a/pgo/physx-c/CPxFoundation.h b/pgo/physx-c/CPxFoundation.h index 7e40b98..1dd2302 100755 --- a/pgo/physx-c/CPxFoundation.h +++ b/pgo/physx-c/CPxFoundation.h @@ -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 diff --git a/pgo/physx-c/CPxMaterial.h b/pgo/physx-c/CPxMaterial.h index 8c4ef56..df405df 100755 --- a/pgo/physx-c/CPxMaterial.h +++ b/pgo/physx-c/CPxMaterial.h @@ -10,8 +10,6 @@ extern "C" { void* obj; }; - CPxAPI void CPxMaterial_release(CSTRUCT CPxMaterial*); - #ifdef __cplusplus } #endif diff --git a/pgo/physx-c/CPxPhysics.h b/pgo/physx-c/CPxPhysics.h index 38dc155..1640723 100755 --- a/pgo/physx-c/CPxPhysics.h +++ b/pgo/physx-c/CPxPhysics.h @@ -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 } diff --git a/pgo/physx-c/CPxPvd.h b/pgo/physx-c/CPxPvd.h index 2fb3cb7..de7f16c 100755 --- a/pgo/physx-c/CPxPvd.h +++ b/pgo/physx-c/CPxPvd.h @@ -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 diff --git a/pgo/physx-c/CPxPvdSceneClient.h b/pgo/physx-c/CPxPvdSceneClient.h index 5a65296..693f442 100755 --- a/pgo/physx-c/CPxPvdSceneClient.h +++ b/pgo/physx-c/CPxPvdSceneClient.h @@ -17,14 +17,7 @@ extern "C" { void* obj; }; - CPxAPI void CPxPvdSceneClient_setScenePvdFlag(CSTRUCT CPxPvdSceneClient* c, CENUM CPxPvdSceneFlag flag, bool value); - - /// - /// This only releases the C struct - /// - /// - /// - CPxAPI void CPxPvdSceneClient_release(CSTRUCT CPxPvdSceneClient*); + CPxAPI void CPxPvdSceneClient_setScenePvdFlag(CSTRUCT CPxPvdSceneClient c, CENUM CPxPvdSceneFlag flag, bool value); #ifdef __cplusplus } diff --git a/pgo/physx-c/CPxPvdTransport.h b/pgo/physx-c/CPxPvdTransport.h index 4c077a2..8ecfe9b 100755 --- a/pgo/physx-c/CPxPvdTransport.h +++ b/pgo/physx-c/CPxPvdTransport.h @@ -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 diff --git a/pgo/physx-c/CPxRigidActor.h b/pgo/physx-c/CPxRigidActor.h index 4386b1b..c7bb1bd 100755 --- a/pgo/physx-c/CPxRigidActor.h +++ b/pgo/physx-c/CPxRigidActor.h @@ -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 } diff --git a/pgo/physx-c/CPxRigidActorExt.h b/pgo/physx-c/CPxRigidActorExt.h index ac61a6b..fd58ba8 100755 --- a/pgo/physx-c/CPxRigidActorExt.h +++ b/pgo/physx-c/CPxRigidActorExt.h @@ -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 } diff --git a/pgo/physx-c/CPxRigidDynamic.h b/pgo/physx-c/CPxRigidDynamic.h index 23b8013..dc9719c 100755 --- a/pgo/physx-c/CPxRigidDynamic.h +++ b/pgo/physx-c/CPxRigidDynamic.h @@ -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 } diff --git a/pgo/physx-c/CPxRigidStatic.h b/pgo/physx-c/CPxRigidStatic.h index b3d594b..b57bc65 100755 --- a/pgo/physx-c/CPxRigidStatic.h +++ b/pgo/physx-c/CPxRigidStatic.h @@ -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 } diff --git a/pgo/physx-c/CPxScene.h b/pgo/physx-c/CPxScene.h index 64a0340..15e4b2a 100755 --- a/pgo/physx-c/CPxScene.h +++ b/pgo/physx-c/CPxScene.h @@ -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); /// /// 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 /// /// - 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 } diff --git a/pgo/physx-c/CPxSceneDesc.h b/pgo/physx-c/CPxSceneDesc.h index 3f65633..edbbcb8 100755 --- a/pgo/physx-c/CPxSceneDesc.h +++ b/pgo/physx-c/CPxSceneDesc.h @@ -21,8 +21,8 @@ extern "C" { /// /// 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 } diff --git a/pgo/physx-c/CPxShape.h b/pgo/physx-c/CPxShape.h index 48ac2a4..1a730e0 100755 --- a/pgo/physx-c/CPxShape.h +++ b/pgo/physx-c/CPxShape.h @@ -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 } diff --git a/pgo/physx-c/CPxSimpleFactory.h b/pgo/physx-c/CPxSimpleFactory.h index 3efd88b..925fefe 100755 --- a/pgo/physx-c/CPxSimpleFactory.h +++ b/pgo/physx-c/CPxSimpleFactory.h @@ -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 } diff --git a/pgo/rigiddynamic.go b/pgo/rigiddynamic.go index e095306..ceaf84b 100755 --- a/pgo/rigiddynamic.go +++ b/pgo/rigiddynamic.go @@ -14,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) { @@ -121,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), } } diff --git a/switch-physx-mode.sh b/switch-physx-mode.sh new file mode 100755 index 0000000..2784688 --- /dev/null +++ b/switch-physx-mode.sh @@ -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