Update sceneDesc to non-pointer

This commit is contained in:
bloeys
2022-02-19 07:11:06 +04:00
parent fa291d4e4c
commit 1b0d545d82
3 changed files with 14 additions and 7 deletions

View File

@ -99,7 +99,7 @@ func main() {
s.AddActor(dynCapsule.ToActor()) s.AddActor(dynCapsule.ToActor())
//Add compound shape //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) 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)

View File

@ -241,7 +241,7 @@ type Physics struct {
func (p *Physics) CreateScene(sd *SceneDesc) *Scene { func (p *Physics) CreateScene(sd *SceneDesc) *Scene {
return &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 { type SceneDesc struct {
cSD *C.struct_CPxSceneDesc cSD C.struct_CPxSceneDesc
} }
func (sd *SceneDesc) SetGravity(v *Vec3) { 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) { 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. //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. //Setting a contact callback handler overrides the previous one. Only the most recent one gets called.
func (sd *SceneDesc) SetOnContactCallback(cb func(ContactPairHeader)) { func (sd *SceneDesc) SetOnContactCallback(cb func(ContactPairHeader)) {
contactCallback = cb 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 { func NewSceneDesc(ts *TolerancesScale) *SceneDesc {

View File

@ -20,9 +20,16 @@ extern "C" {
/// </summary> /// </summary>
/// <param name="CPxTolerancesScale"></param> /// <param name="CPxTolerancesScale"></param>
/// <returns></returns> /// <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_gravity(CSTRUCT CPxSceneDesc*, CSTRUCT CPxVec3);
CPxAPI void CPxSceneDesc_set_cpuDispatcher(CSTRUCT CPxSceneDesc*, CSTRUCT CPxCpuDispatcher*); 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 CPxSceneDesc_set_onContactCallback(CSTRUCT CPxSceneDesc*, CPxonContactCallback cb);
CPxAPI void FreeCPxSceneDesc(CSTRUCT CPxSceneDesc*); CPxAPI void FreeCPxSceneDesc(CSTRUCT CPxSceneDesc*);