2 Commits

Author SHA1 Message Date
8e358fb31f Correct DefaultCpuDispatcherCreate 2022-12-07 01:45:28 +04:00
6880bac72a Add PvdSceneClient.Release 2022-12-07 00:53:27 +04:00
4 changed files with 24 additions and 4 deletions

View File

@ -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)
@ -48,6 +48,7 @@ func main() {
scenePvdClient.SetScenePvdFlag(pgo.PvdSceneFlag_eTRANSMIT_CONSTRAINTS, true)
scenePvdClient.SetScenePvdFlag(pgo.PvdSceneFlag_eTRANSMIT_CONTACTS, true)
scenePvdClient.SetScenePvdFlag(pgo.PvdSceneFlag_eTRANSMIT_SCENEQUERIES, true)
scenePvdClient.Release()
//Add plane
pMat := p.CreateMaterial(0.5, 0.5, 0.6)

Binary file not shown.

View File

@ -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]),
}
}
@ -510,6 +525,10 @@ func (p *PvdSceneClient) SetScenePvdFlag(flag PvdSceneFlag, value bool) {
C.CPxPvdSceneClient_setScenePvdFlag(p.cPvdSceneClient, uint32(flag), C._Bool(value))
}
func (p *PvdSceneClient) Release() {
C.CPxPvdSceneClient_release(p.cPvdSceneClient)
}
type Material struct {
cM *C.struct_CPxMaterial
}

View File

@ -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);