mirror of
https://github.com/bloeys/physx-go.git
synced 2025-12-29 07:58:20 +00:00
Correct DefaultCpuDispatcherCreate
This commit is contained in:
2
main.go
2
main.go
@ -36,7 +36,7 @@ func main() {
|
|||||||
|
|
||||||
sd := pgo.NewSceneDesc(ts)
|
sd := pgo.NewSceneDesc(ts)
|
||||||
sd.SetGravity(pgo.NewVec3(0, -9.8, 0))
|
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)
|
sd.SetOnContactCallback(contactHandler)
|
||||||
|
|
||||||
scene := p.CreateScene(sd)
|
scene := p.CreateScene(sd)
|
||||||
|
|||||||
Binary file not shown.
19
pgo/pgo.go
19
pgo/pgo.go
@ -362,9 +362,24 @@ func (d *DefaultCpuDispatcher) ToCpuDispatcher() *CpuDispatcher {
|
|||||||
return &CpuDispatcher{cCpuDisp: (*C.struct_CPxCpuDispatcher)(d.cDefCpuDisp)}
|
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{
|
return &DefaultCpuDispatcher{
|
||||||
cDefCpuDisp: C.CPxDefaultCpuDispatcherCreate(C.uint(numThreads), C.uint(affinityMasks)),
|
cDefCpuDisp: C.CPxDefaultCpuDispatcherCreate(C.uint(numThreads), &arr[0]),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -11,7 +11,7 @@ extern "C" {
|
|||||||
void* obj;
|
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 CSTRUCT CPxCpuDispatcher* CPxDefaultCpuDispatcher_toCPxCpuDispatcher(CSTRUCT CPxDefaultCpuDispatcher* cdcd);
|
||||||
CPxAPI void CPxDefaultCpuDispatcher_release(CSTRUCT CPxDefaultCpuDispatcher* cdcd);
|
CPxAPI void CPxDefaultCpuDispatcher_release(CSTRUCT CPxDefaultCpuDispatcher* cdcd);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user