diff --git a/main.go b/main.go index c607895..3a261b1 100755 --- a/main.go +++ b/main.go @@ -36,7 +36,7 @@ func main() { sd := pgo.NewSceneDesc(ts) sd.SetGravity(pgo.NewVec3(0, -9.8, 0)) - sd.SetCpuDispatcher(pgo.DefaultCpuDispatcherCreate(2, 0).ToCpuDispatcher()) + sd.SetCpuDispatcher(pgo.DefaultCpuDispatcherCreate(2, nil).ToCpuDispatcher()) sd.SetOnContactCallback(contactHandler) scene := p.CreateScene(sd) diff --git a/pgo/libs/libphysx-c.a b/pgo/libs/libphysx-c.a index 15a092a..257a945 100755 Binary files a/pgo/libs/libphysx-c.a and b/pgo/libs/libphysx-c.a differ diff --git a/pgo/pgo.go b/pgo/pgo.go index 53a4f94..0d01896 100755 --- a/pgo/pgo.go +++ b/pgo/pgo.go @@ -362,9 +362,24 @@ func (d *DefaultCpuDispatcher) ToCpuDispatcher() *CpuDispatcher { return &CpuDispatcher{cCpuDisp: (*C.struct_CPxCpuDispatcher)(d.cDefCpuDisp)} } -func DefaultCpuDispatcherCreate(numThreads, affinityMasks uint32) *DefaultCpuDispatcher { +// DefaultCpuDispatcherCreate sets the number of threads used by physX. +// If affinityMasksPerThread is nil/zero then default masks are used, otherwise the size of the array +// must match the number of threads +func DefaultCpuDispatcherCreate(numThreads uint32, affinityMasksPerThread []uint32) *DefaultCpuDispatcher { + + if len(affinityMasksPerThread) == 0 { + return &DefaultCpuDispatcher{ + cDefCpuDisp: C.CPxDefaultCpuDispatcherCreate(C.uint(numThreads), nil), + } + } + + arr := make([]C.uint, len(affinityMasksPerThread)) + for i := 0; i < len(arr); i++ { + arr[i] = C.uint(affinityMasksPerThread[i]) + } + return &DefaultCpuDispatcher{ - cDefCpuDisp: C.CPxDefaultCpuDispatcherCreate(C.uint(numThreads), C.uint(affinityMasks)), + cDefCpuDisp: C.CPxDefaultCpuDispatcherCreate(C.uint(numThreads), &arr[0]), } } diff --git a/pgo/physx-c/CPxDefaultCpuDispatcher.h b/pgo/physx-c/CPxDefaultCpuDispatcher.h index 4a161e1..be7f913 100755 --- a/pgo/physx-c/CPxDefaultCpuDispatcher.h +++ b/pgo/physx-c/CPxDefaultCpuDispatcher.h @@ -11,7 +11,7 @@ extern "C" { void* obj; }; - CPxAPI CSTRUCT CPxDefaultCpuDispatcher* CPxDefaultCpuDispatcherCreate(CPxU32 numThreads, CPxU32 affinityMasks); + CPxAPI CSTRUCT CPxDefaultCpuDispatcher* CPxDefaultCpuDispatcherCreate(CPxU32 numThreads, CPxU32* affinityMasks); CPxAPI CSTRUCT CPxCpuDispatcher* CPxDefaultCpuDispatcher_toCPxCpuDispatcher(CSTRUCT CPxDefaultCpuDispatcher* cdcd); CPxAPI void CPxDefaultCpuDispatcher_release(CSTRUCT CPxDefaultCpuDispatcher* cdcd);