From 09ba86ea360286f35c6757c176a1184d78d4fa92 Mon Sep 17 00:00:00 2001 From: erwin coumans Date: Tue, 17 Dec 2013 19:25:53 -0800 Subject: [PATCH] fix cpu version of findCompoundPairs, in order to fix Mac OSX OpenCL compound issues --- .../b3ConvexHullContact.cpp | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/Bullet3OpenCL/NarrowphaseCollision/b3ConvexHullContact.cpp b/src/Bullet3OpenCL/NarrowphaseCollision/b3ConvexHullContact.cpp index c37a78245..55061af57 100644 --- a/src/Bullet3OpenCL/NarrowphaseCollision/b3ConvexHullContact.cpp +++ b/src/Bullet3OpenCL/NarrowphaseCollision/b3ConvexHullContact.cpp @@ -3340,7 +3340,6 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( b3OpenCLArray* b3AlignedObjectArray hostBodyBuf; bodyBuf->copyToHost(hostBodyBuf); - int numCompoundPairsOut=0; b3AlignedObjectArray cpuCompoundPairsOut; cpuCompoundPairsOut.resize(compoundPairCapacity); @@ -3366,7 +3365,8 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( b3OpenCLArray* int bodyIndexB = hostPairs[pairIndex].y; int collidableIndexA = hostBodyBuf[bodyIndexA].m_collidableIdx; int collidableIndexB = hostBodyBuf[bodyIndexB].m_collidableIdx; - + if (cpuChildShapes.size()) + { findCompoundPairsKernel( pairIndex, bodyIndexA, @@ -3381,19 +3381,30 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( b3OpenCLArray* hostAabbsLocalSpace, &cpuChildShapes[0], &cpuCompoundPairsOut[0], - &numCompoundPairsOut, + &numCompoundPairs, compoundPairCapacity, treeNodesCPU, subTreesCPU, bvhInfoCPU ); - } - if (numCompoundPairsOut) - { -// printf("numCompoundPairsOut=%d\n",numCompoundPairsOut); + } } + + m_numCompoundPairsOut.copyFromHostPointer(&numCompoundPairs,1,0,true); + if (numCompoundPairs) + { + b3CompoundOverlappingPair* ptr = (b3CompoundOverlappingPair*)&cpuCompoundPairsOut[0]; + m_gpuCompoundPairs.copyFromHostPointer(ptr,numCompoundPairs,0,true); + } + //cpuCompoundPairsOut + } + if (numCompoundPairs) + { + printf("numCompoundPairs=%d\n",numCompoundPairs); + } + if (numCompoundPairs > compoundPairCapacity) { b3Error("Exceeded compound pair capacity (%d/%d)\n", numCompoundPairs, compoundPairCapacity);