From 2648e5743ea8217b92eea32773b4d70606e557c5 Mon Sep 17 00:00:00 2001 From: bloeys Date: Fri, 28 Jan 2022 02:01:08 +0400 Subject: [PATCH] Capsule geometry --- main.go | 17 ++++++++++++++--- pgo/libs/libphysx-c.a | Bin 11670 -> 12552 bytes pgo/pgo.go | 16 ++++++++++++++++ pgo/physx-c/CPxCapsuleGeometry.h | 19 +++++++++++++++++++ pgo/physx-c/CPxGeometry.h | 7 +++++-- pgo/wrap.c | 3 ++- 6 files changed, 56 insertions(+), 6 deletions(-) create mode 100755 pgo/physx-c/CPxCapsuleGeometry.h diff --git a/main.go b/main.go index d4e1b12..85a9d89 100755 --- a/main.go +++ b/main.go @@ -13,7 +13,7 @@ func main() { pvd := pgo.CreatePvd(f) println("Pvd:", pvd) - println("connect:", pvd.Connect(pvdTr, pgo.PvdInstrumentationFlag_eALL)) + println("connected to PVD:", pvd.Connect(pvdTr, pgo.PvdInstrumentationFlag_eALL)) ts := pgo.NewTolerancesScale(1, 9.81) p := pgo.CreatePhysics(f, ts, false, pvd) @@ -55,10 +55,21 @@ func main() { dynBox2 := pgo.CreateDynamic(p, tr2, box.ToGeometry(), pMat, 10, shapeOffset) s.AddActor(dynBox2.ToActor()) + //Add sphere + v = pgo.NewVec3(0, 16, 0) + tr3 := pgo.NewTransform(v, qID) + dynSphere := pgo.CreateDynamic(p, tr3, pgo.NewSphereGeometry(3).ToGeometry(), pMat, 10, shapeOffset) + s.AddActor(dynSphere.ToActor()) + + //Add capsule + v = pgo.NewVec3(0, 20, 0) + tr4 := pgo.NewTransform(v, qID) + dynCapsule := pgo.CreateDynamic(p, tr4, pgo.NewCapsuleGeometry(0.25, 0.5).ToGeometry(), pMat, 10, shapeOffset) + s.AddActor(dynCapsule.ToActor()) + for { s.Simulate(1 / 60.0) - a, b := s.FetchResults(true) - println("a:", a, "; b:", b) + s.FetchResults(true) } p.Release() diff --git a/pgo/libs/libphysx-c.a b/pgo/libs/libphysx-c.a index 9a89d38d59ef67c07fa80e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X=knCIzJj1xNN9P@208p zm}Y3wy(~9khkM_tHC%YFV93D`xD}cz0ZFqduB2P651=XEn{4| zTw9!MNpB@{P)i>KtEtJW)2dRFi*j{~bUF+ccE-fa{n!#0HmtNa*dgvLwvJ0dZQRq- zq{t-^ii-{YlN0=EP)3PRQheTbc~oAjovwyMzXkBo_GpvnU;Fzge;rUx7r6J;*Xm(@e(=)+l?m;cndw<6YCs?b{*@Rms<`}VbxACQfIj;14DGEDj~-1?D|tC4b$x^>))^9W_|zw diff --git a/pgo/pgo.go b/pgo/pgo.go index 74fb315..ff29f8b 100755 --- a/pgo/pgo.go +++ b/pgo/pgo.go @@ -272,6 +272,22 @@ func NewBoxGeometry(hx, hy, hz float32) *BoxGeometry { } } +type CapsuleGeometry struct { + cCg C.struct_CPxCapsuleGeometry +} + +func (bg *CapsuleGeometry) ToGeometry() *Geometry { + return &Geometry{ + cG: C.CPxCapsuleGeometry_toCPxGeometry(&bg.cCg), + } +} + +func NewCapsuleGeometry(radius, halfHeight float32) *CapsuleGeometry { + return &CapsuleGeometry{ + cCg: C.NewCPxCapsuleGeometry(C.float(radius), C.float(halfHeight)), + } +} + type Actor struct { cA C.struct_CPxActor } diff --git a/pgo/physx-c/CPxCapsuleGeometry.h b/pgo/physx-c/CPxCapsuleGeometry.h new file mode 100755 index 0000000..9f59419 --- /dev/null +++ b/pgo/physx-c/CPxCapsuleGeometry.h @@ -0,0 +1,19 @@ +#ifndef CPxCapsuleGeometry_H +#define CPxCapsuleGeometry_H + +#ifdef __cplusplus +extern "C" { +#endif + + struct CPxCapsuleGeometry + { + CPxReal radius, halfHeight; + }; + + CPxAPI CPxInline CSTRUCT CPxCapsuleGeometry NewCPxCapsuleGeometry(CPxReal radius, CPxReal halfHeight); + +#ifdef __cplusplus +} +#endif + +#endif // !CPxCapsuleGeometry_H diff --git a/pgo/physx-c/CPxGeometry.h b/pgo/physx-c/CPxGeometry.h index 56726a4..24400ce 100755 --- a/pgo/physx-c/CPxGeometry.h +++ b/pgo/physx-c/CPxGeometry.h @@ -3,6 +3,7 @@ #include "CPxBoxGeometry.h" #include "CPxSphereGeometry.h" +#include "CPxCapsuleGeometry.h" #ifdef __cplusplus extern "C" { @@ -27,12 +28,14 @@ extern "C" { CENUM CPxGeometryType type; }; - CPxAPI CPxInline CSTRUCT CPxSphereGeometry CPxGeometry_toCPxSphere(CSTRUCT CPxGeometry); + CPxAPI CPxInline CSTRUCT CPxSphereGeometry CPxGeometry_toCPxSphereGeometry(CSTRUCT CPxGeometry); CPxAPI CPxInline CSTRUCT CPxGeometry CPxSphereGeometry_toCPxGeometry(CSTRUCT CPxSphereGeometry*); - CPxAPI CPxInline CSTRUCT CPxBoxGeometry CPxGeometry_toCPxBox(CSTRUCT CPxGeometry); + CPxAPI CPxInline CSTRUCT CPxBoxGeometry CPxGeometry_toCPxBoxGeometry(CSTRUCT CPxGeometry); CPxAPI CPxInline CSTRUCT CPxGeometry CPxBoxGeometry_toCPxGeometry(CSTRUCT CPxBoxGeometry*); + CPxAPI CPxInline CSTRUCT CPxCapsuleGeometry CPxGeometry_toCPxCapsuleGeometry(CSTRUCT CPxGeometry); + CPxAPI CPxInline CSTRUCT CPxGeometry CPxCapsuleGeometry_toCPxGeometry(CSTRUCT CPxCapsuleGeometry*); #ifdef __cplusplus } diff --git a/pgo/wrap.c b/pgo/wrap.c index 6904302..143a2ce 100755 --- a/pgo/wrap.c +++ b/pgo/wrap.c @@ -25,4 +25,5 @@ #include #include #include -#include \ No newline at end of file +#include +#include \ No newline at end of file