mirror of
https://github.com/bloeys/physx-go.git
synced 2025-12-29 07:58:20 +00:00
Receive onContact callbacks
This commit is contained in:
10
pgo/ccallbacks.go
Executable file
10
pgo/ccallbacks.go
Executable file
@ -0,0 +1,10 @@
|
||||
package pgo
|
||||
|
||||
/*
|
||||
void goOnContactCallback_cgo(void* pairHeader)
|
||||
{
|
||||
void goOnContactCallback(void*);
|
||||
goOnContactCallback(pairHeader);
|
||||
}
|
||||
*/
|
||||
import "C"
|
||||
Binary file not shown.
18
pgo/pgo.go
18
pgo/pgo.go
@ -6,8 +6,12 @@ package pgo
|
||||
|
||||
#include <wrap.c>
|
||||
#include <stdlib.h> //Needed for C.free
|
||||
|
||||
//simulation event callbacks forward declarations. Actual definitions MUST be in a go different file
|
||||
void goOnContactCallback_cgo(void* pairHeader);
|
||||
*/
|
||||
import "C"
|
||||
import "unsafe"
|
||||
|
||||
type PvdInstrumentationFlag uint32
|
||||
|
||||
@ -99,8 +103,6 @@ func (s *Scene) Simulate(elapsedTime float32) {
|
||||
C.CPxScene_simulate(s.cS, C.float(elapsedTime))
|
||||
}
|
||||
|
||||
// void CPxScene_advance(CSTRUCT CPxScene*);
|
||||
|
||||
func (s *Scene) Collide(elapsedTime float32) {
|
||||
C.CPxScene_collide(s.cS, C.float(elapsedTime))
|
||||
}
|
||||
@ -203,9 +205,6 @@ func (s *Shape) SetSimulationFilterData(fd *FilterData) {
|
||||
C.CPxShape_setSimulationFilterData(&s.cShape, &fd.cFilterData)
|
||||
}
|
||||
|
||||
// CPxAPI CSTRUCT CPxFilterData CPxShape_getSimulationFilterData(CSTRUCT CPxShape* cs);
|
||||
// CPxAPI void CPxShape_setSimulationFilterData(CSTRUCT CPxShape* cs, CSTRUCT CPxFilterData cfd);
|
||||
|
||||
func CreateExclusiveShape(rigidActor RigidActor, geom *Geometry, mat *Material, shapeFlags ShapeFlags) Shape {
|
||||
return Shape{
|
||||
cShape: C.createExclusiveShape(rigidActor.cRa, geom.cG, mat.cM, uint32(shapeFlags)),
|
||||
@ -264,6 +263,15 @@ func (sd *SceneDesc) SetCpuDispatcher(cd *CpuDispatcher) {
|
||||
C.CPxSceneDesc_set_cpuDispatcher(sd.cSD, cd.cCpuDisp)
|
||||
}
|
||||
|
||||
//export goOnContactCallback
|
||||
func goOnContactCallback(p unsafe.Pointer) {
|
||||
println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
|
||||
}
|
||||
|
||||
func (sd *SceneDesc) SetOnContactCallback() {
|
||||
C.CPxSceneDesc_set_onContactCallback(sd.cSD, (C.CPxonContactCallback)(unsafe.Pointer(C.goOnContactCallback_cgo)))
|
||||
}
|
||||
|
||||
func NewSceneDesc(ts *TolerancesScale) *SceneDesc {
|
||||
return &SceneDesc{
|
||||
cSD: C.NewCPxSceneDesc(ts.cTolScale),
|
||||
|
||||
@ -13,14 +13,17 @@ extern "C" {
|
||||
void* obj;
|
||||
};
|
||||
|
||||
typedef void (*CPxonContactCallback)(void* pairHeader);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a SceneDesc with a custom filterShader that uses word0/word1 as groups shapes belong to, and word2/word3 as mask on the groups.
|
||||
/// Creates a SceneDesc with a custom filterShader that uses word0/word1 as groups shapes can belong to, word2 as a mask on word0, and word3 as a mask on word1.
|
||||
/// </summary>
|
||||
/// <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_onContactCallback(CSTRUCT CPxSceneDesc*, CPxonContactCallback cb);
|
||||
CPxAPI void FreeCPxSceneDesc(CSTRUCT CPxSceneDesc*);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
Reference in New Issue
Block a user