From c3c74b46a4d10982c54fbdb093f3c9a6d24b5304 Mon Sep 17 00:00:00 2001 From: bloeys Date: Mon, 17 Jan 2022 19:37:00 +0400 Subject: [PATCH] PvdSceneClient --- main.go | 7 +++++++ pgo/libs/libphysx-c.a | Bin 6430 -> 8944 bytes pgo/pgo.go | 27 +++++++++++++++++++++++++- pgo/physx-c/CPxActor.h | 19 ++++++++++++++++++ pgo/physx-c/CPxMaterial.h | 19 ++++++++++++++++++ pgo/physx-c/CPxPhysics.h | 2 ++ pgo/physx-c/CPxPlane.h | 20 +++++++++++++++++++ pgo/physx-c/CPxPvdSceneClient.h | 33 ++++++++++++++++++++++++++++++++ pgo/physx-c/CPxRigidStatic.h | 25 ++++++++++++++++++++++++ pgo/physx-c/CPxScene.h | 6 ++++++ pgo/wrap.cxx | 4 ++++ 11 files changed, 161 insertions(+), 1 deletion(-) create mode 100755 pgo/physx-c/CPxActor.h create mode 100755 pgo/physx-c/CPxMaterial.h create mode 100755 pgo/physx-c/CPxPlane.h create mode 100755 pgo/physx-c/CPxPvdSceneClient.h create mode 100755 pgo/physx-c/CPxRigidStatic.h diff --git a/main.go b/main.go index 14f919f..7819393 100755 --- a/main.go +++ b/main.go @@ -26,6 +26,13 @@ func main() { s := p.CreateScene(sd) println("Scene:", s) + scenePvdClient := s.GetScenePvdClient() + println("ScenePvdClient:", scenePvdClient) + + scenePvdClient.SetScenePvdFlag(pgo.PvdSceneFlag_eTRANSMIT_CONSTRAINTS, true) + scenePvdClient.SetScenePvdFlag(pgo.PvdSceneFlag_eTRANSMIT_CONTACTS, true) + scenePvdClient.SetScenePvdFlag(pgo.PvdSceneFlag_eTRANSMIT_SCENEQUERIES, true) + for { } diff --git a/pgo/libs/libphysx-c.a b/pgo/libs/libphysx-c.a index b42540ab3e191cbbc3ca065e5a0317f76a68342b..cac0d89ef1fbacd6987439e31fe469097bb2becd 100755 GIT binary patch literal 8944 zcmcIpYiv|S6h19bpnxqceNkGr1wlm0t6OMd$d(oY0ZP*rC1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ax5@!N4xOZO?R*xsFOr2gEQlc(2Z*LU^y GlKdO>JK~%G diff --git a/pgo/pgo.go b/pgo/pgo.go index ed7d090..0ed7e1e 100755 --- a/pgo/pgo.go +++ b/pgo/pgo.go @@ -24,6 +24,10 @@ struct CPxPhysics* CPxCreatePhysics(struct CPxFoundation* cfoundation, struct CP struct CPxScene* CPxPhysics_createScene(struct CPxPhysics*, struct CPxSceneDesc*); void CPxPhysics_release(struct CPxPhysics*); +struct CPxPvdSceneClient* CPxScene_getScenePvdClient(struct CPxScene*); + +void CPxPvdSceneClient_setScenePvdFlag(struct CPxPvdSceneClient* c, enum CPxPvdSceneFlag flag, bool value); + struct CPxVec3 NewCPxVec3(float x, float y, float z); struct CPxDefaultCpuDispatcher* CPxDefaultCpuDispatcherCreate(CPxU32 numThreads, CPxU32 affinityMasks); @@ -111,11 +115,16 @@ type Scene struct { cS *C.struct_CPxScene } +func (s *Scene) GetScenePvdClient() *PvdSceneClient { + return &PvdSceneClient{ + cPvdSceneClient: C.CPxScene_getScenePvdClient(s.cS), + } +} + type Physics struct { cPhysics *C.struct_CPxPhysics } -// struct CPxScene* CPxPhysics_createScene(struct CPxPhysics*, struct CPxSceneDesc*); func (p *Physics) CreateScene(sd *SceneDesc) *Scene { return &Scene{ cS: C.CPxPhysics_createScene(p.cPhysics, sd.cSD), @@ -181,3 +190,19 @@ func NewSceneDesc(ts *TolerancesScale) *SceneDesc { cSD: C.NewCPxSceneDesc(ts.cTolScale), } } + +type PvdSceneFlag uint32 + +const ( + PvdSceneFlag_eTRANSMIT_CONTACTS PvdSceneFlag = (1 << 0) //Transmits contact stream to PVD. + PvdSceneFlag_eTRANSMIT_SCENEQUERIES PvdSceneFlag = (1 << 1) //Transmits scene query stream to PVD. + PvdSceneFlag_eTRANSMIT_CONSTRAINTS PvdSceneFlag = (1 << 2) //Transmits constraints visualize stream to PVD. +) + +type PvdSceneClient struct { + cPvdSceneClient *C.struct_CPxPvdSceneClient +} + +func (p *PvdSceneClient) SetScenePvdFlag(flag PvdSceneFlag, value bool) { + C.CPxPvdSceneClient_setScenePvdFlag(p.cPvdSceneClient, uint32(flag), C._Bool(value)) +} diff --git a/pgo/physx-c/CPxActor.h b/pgo/physx-c/CPxActor.h new file mode 100755 index 0000000..e3afb09 --- /dev/null +++ b/pgo/physx-c/CPxActor.h @@ -0,0 +1,19 @@ +#ifndef CPxActor_H +#define CPxActor_H + +#ifdef __cplusplus +extern "C" { +#endif + + struct CPxActor + { + void* obj; + }; + + CPxAPI void CPxActor_release(CSTRUCT CPxActor*); + +#ifdef __cplusplus +} +#endif + +#endif // !CPxActor_H diff --git a/pgo/physx-c/CPxMaterial.h b/pgo/physx-c/CPxMaterial.h new file mode 100755 index 0000000..8c4ef56 --- /dev/null +++ b/pgo/physx-c/CPxMaterial.h @@ -0,0 +1,19 @@ +#ifndef CPxMaterial_H +#define CPxMaterial_H + +#ifdef __cplusplus +extern "C" { +#endif + + struct CPxMaterial + { + void* obj; + }; + + CPxAPI void CPxMaterial_release(CSTRUCT CPxMaterial*); + +#ifdef __cplusplus +} +#endif + +#endif // !CPxMaterial_H diff --git a/pgo/physx-c/CPxPhysics.h b/pgo/physx-c/CPxPhysics.h index 8eeb427..d2c4b80 100755 --- a/pgo/physx-c/CPxPhysics.h +++ b/pgo/physx-c/CPxPhysics.h @@ -5,6 +5,7 @@ #include "CPxFoundation.h" #include "CPxScene.h" #include "CPxSceneDesc.h" +#include "CPxMaterial.h" #include "CPxTolerancesScale.h" #ifdef __cplusplus @@ -17,6 +18,7 @@ extern "C" { 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 void CPxPhysics_release(CSTRUCT CPxPhysics*); #ifdef __cplusplus diff --git a/pgo/physx-c/CPxPlane.h b/pgo/physx-c/CPxPlane.h new file mode 100755 index 0000000..19382e2 --- /dev/null +++ b/pgo/physx-c/CPxPlane.h @@ -0,0 +1,20 @@ +#ifndef CPxPlane_H +#define CPxPlane_H + +#ifdef __cplusplus +extern "C" { +#endif + + struct CPxPlane + { + void* obj; + }; + + CPxAPI CSTRUCT CPxPlane* NewCPxPlane(float nx, float ny, float nz, float distance); + CPxAPI void CPxPlane_release(CSTRUCT CPxPlane*); + +#ifdef __cplusplus +} +#endif + +#endif // !CPxPlane_H diff --git a/pgo/physx-c/CPxPvdSceneClient.h b/pgo/physx-c/CPxPvdSceneClient.h new file mode 100755 index 0000000..5a65296 --- /dev/null +++ b/pgo/physx-c/CPxPvdSceneClient.h @@ -0,0 +1,33 @@ +#ifndef CPxPvdSceneClient_H +#define CPxPvdSceneClient_H + +#ifdef __cplusplus +extern "C" { +#endif + + enum CPxPvdSceneFlag + { + CPxPvdSceneFlag_eTRANSMIT_CONTACTS = (1 << 0), //Transmits contact stream to PVD. + CPxPvdSceneFlag_eTRANSMIT_SCENEQUERIES = (1 << 1), //Transmits scene query stream to PVD. + CPxPvdSceneFlag_eTRANSMIT_CONSTRAINTS = (1 << 2) //Transmits constraints visualize stream to PVD. + }; + + struct CPxPvdSceneClient + { + 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*); + +#ifdef __cplusplus +} +#endif + +#endif // !CPxPvdSceneClient_H diff --git a/pgo/physx-c/CPxRigidStatic.h b/pgo/physx-c/CPxRigidStatic.h new file mode 100755 index 0000000..6fd37d9 --- /dev/null +++ b/pgo/physx-c/CPxRigidStatic.h @@ -0,0 +1,25 @@ +#ifndef CPxRigidStatic_H +#define CPxRigidStatic_H + +#include "CPxPhysics.h" +#include "CPxPlane.h" +#include "CPxMaterial.h" +#include "CPxActor.h" + +#ifdef __cplusplus +extern "C" { +#endif + + struct CPxRigidStatic + { + void* obj; + }; + + CPxAPI CSTRUCT CPxRigidStatic* CPxCreatePlane(CSTRUCT CPxPhysics* sdk, CSTRUCT CPxPlane* plane, CSTRUCT CPxMaterial* material); + CPxAPI CSTRUCT CPxActor* CPxRigidStatic_toCPxActor(CSTRUCT CPxRigidStatic*); + +#ifdef __cplusplus +} +#endif + +#endif // !CPxRigidStatic_H diff --git a/pgo/physx-c/CPxScene.h b/pgo/physx-c/CPxScene.h index deea264..d441619 100755 --- a/pgo/physx-c/CPxScene.h +++ b/pgo/physx-c/CPxScene.h @@ -1,6 +1,9 @@ #ifndef CPxScene_H #define CPxScene_H +#include "CPxPvdSceneClient.h" +#include "CPxActor.h" + #ifdef __cplusplus extern "C" { #endif @@ -10,6 +13,9 @@ extern "C" { void* obj; }; + CPxAPI CSTRUCT CPxPvdSceneClient* CPxScene_getScenePvdClient(CSTRUCT CPxScene*); + CPxAPI void CPxScene_addActor(CSTRUCT CPxScene*, CSTRUCT CPxActor* actor); + CPxAPI void CPxScene_release(CSTRUCT CPxScene*); #ifdef __cplusplus diff --git a/pgo/wrap.cxx b/pgo/wrap.cxx index 36265ec..ebf42a9 100755 --- a/pgo/wrap.cxx +++ b/pgo/wrap.cxx @@ -16,3 +16,7 @@ #include #include #include +#include +#include +#include +#include