mirror of
https://github.com/bloeys/physx-go.git
synced 2025-12-29 07:58:20 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8e358fb31f | |||
| 6880bac72a |
3
main.go
3
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)
|
||||
@ -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.
23
pgo/pgo.go
23
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]),
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user