Skip to content

Commit 28d8cf0

Browse files
committed
fix gpu contact query with 0 contacts
1 parent 4700df3 commit 28d8cf0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/physx/physx_system.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,9 +540,11 @@ void PhysxSystemGpu::gpuQueryContactPairImpulses(PhysxGpuContactPairImpulseQuery
540540

541541
copyContactData();
542542

543-
handle_contacts((PxGpuContactPair *)mCudaContactBuffer.ptr, mContactCount,
543+
if (mContactCount) {
544+
handle_contacts((PxGpuContactPair *)mCudaContactBuffer.ptr, mContactCount,
544545
(ActorPairQuery *)query.query.ptr, query.query.shape.at(0),
545546
(Vec3 *)query.buffer.ptr, mCudaStream);
547+
}
546548
cudaStreamSynchronize(mCudaStream);
547549
}
548550

@@ -555,9 +557,11 @@ void PhysxSystemGpu::gpuQueryContactBodyImpulses(PhysxGpuContactBodyImpulseQuery
555557

556558
copyContactData();
557559

558-
handle_net_contact_force((PxGpuContactPair *)mCudaContactBuffer.ptr, mContactCount,
560+
if (mContactCount) {
561+
handle_net_contact_force((PxGpuContactPair *)mCudaContactBuffer.ptr, mContactCount,
559562
(ActorQuery *)query.query.ptr, query.query.shape.at(0),
560563
(Vec3 *)query.buffer.ptr, mCudaStream);
564+
}
561565
cudaStreamSynchronize(mCudaStream);
562566
}
563567

0 commit comments

Comments
 (0)