mirror of
https://github.com/bloeys/physx-go.git
synced 2025-12-29 07:58:20 +00:00
Update sceneDesc to non-pointer
This commit is contained in:
10
pgo/pgo.go
10
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 {
|
||||
|
||||
@ -20,9 +20,16 @@ extern "C" {
|
||||
/// </summary>
|
||||
/// <param name="CPxTolerancesScale"></param>
|
||||
/// <returns></returns>
|
||||
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*);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user