diff --git a/main.go b/main.go
index 0a855ed..439de67 100755
--- a/main.go
+++ b/main.go
@@ -99,7 +99,7 @@ func main() {
s.AddActor(dynCapsule.ToActor())
//Add compound shape
- dynComp := p.CreateRigidDynamic(pgo.NewTransform(pgo.NewVec3(0, 35, 0), qID))
+ dynComp := p.CreateRigidDynamic(pgo.NewTransform(pgo.NewVec3(2.5, 35, 0), qID))
pgo.CreateExclusiveShape(dynComp.ToRigidActor(), pgo.NewBoxGeometry(10, 0.1, 0.1).ToGeometry(), pMat, pgo.ShapeFlags_eSCENE_QUERY_SHAPE|pgo.ShapeFlags_eSIMULATION_SHAPE|pgo.ShapeFlags_eVISUALIZATION)
diff --git a/pgo/pgo.go b/pgo/pgo.go
index e03f80b..c892f76 100755
--- a/pgo/pgo.go
+++ b/pgo/pgo.go
@@ -241,7 +241,7 @@ type Physics struct {
func (p *Physics) CreateScene(sd *SceneDesc) *Scene {
return &Scene{
- cS: C.CPxPhysics_createScene(p.cPhysics, sd.cSD),
+ cS: C.CPxPhysics_createScene(p.cPhysics, &sd.cSD),
}
}
@@ -365,22 +365,22 @@ func DefaultCpuDispatcherCreate(numThreads, affinityMasks uint32) *DefaultCpuDis
}
type SceneDesc struct {
- cSD *C.struct_CPxSceneDesc
+ cSD C.struct_CPxSceneDesc
}
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)
+ 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 {
diff --git a/pgo/physx-c/CPxSceneDesc.h b/pgo/physx-c/CPxSceneDesc.h
index 221aed4..3f65633 100755
--- a/pgo/physx-c/CPxSceneDesc.h
+++ b/pgo/physx-c/CPxSceneDesc.h
@@ -20,9 +20,16 @@ extern "C" {
///
///
///
- CPxAPI CSTRUCT CPxSceneDesc* NewCPxSceneDesc(CSTRUCT CPxTolerancesScale);
+ CPxAPI CSTRUCT CPxSceneDesc NewCPxSceneDesc(CSTRUCT CPxTolerancesScale);
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.
+ //The callback is sent an object of type 'CPxContactPairHeader*'. This object is only valid for the duration of the callback handler.
+ //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*);