mirror of
https://github.com/bulletphysics/bullet3
synced 2025-01-18 21:10:05 +00:00
don't crash if the maximum number of pairs is exceeded, but report an error using b3Error
This commit is contained in:
parent
f73d11d896
commit
31282ab85e
@ -397,7 +397,7 @@ void ParticleDemo::clientMoveAndDisplay()
|
||||
cl_mem pairsGPU = 0;
|
||||
|
||||
{
|
||||
m_data->m_broadphaseGPU->calculateOverlappingPairs();
|
||||
m_data->m_broadphaseGPU->calculateOverlappingPairs(64*numParticles);
|
||||
pairsGPU = m_data->m_broadphaseGPU->getOverlappingPairBuffer();
|
||||
numPairsGPU = m_data->m_broadphaseGPU->getNumOverlap();
|
||||
}
|
||||
|
@ -308,7 +308,7 @@ void PairBench::clientMoveAndDisplay()
|
||||
}
|
||||
{
|
||||
B3_PROFILE("calculateOverlappingPairs");
|
||||
m_data->m_broadphaseGPU->calculateOverlappingPairs();
|
||||
m_data->m_broadphaseGPU->calculateOverlappingPairs(64*numObjects);
|
||||
//int numPairs = m_data->m_broadphaseGPU->getNumOverlap();
|
||||
//printf("numPairs = %d\n", numPairs);
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ void b3GpuSapBroadphase::calculateOverlappingPairsHostIncremental3Sap()
|
||||
|
||||
}
|
||||
|
||||
void b3GpuSapBroadphase::calculateOverlappingPairsHost()
|
||||
void b3GpuSapBroadphase::calculateOverlappingPairsHost(int maxPairs)
|
||||
{
|
||||
//test
|
||||
//if (m_currentBuffer>=0)
|
||||
@ -236,6 +236,10 @@ void b3GpuSapBroadphase::calculateOverlappingPairsHost()
|
||||
}
|
||||
}
|
||||
|
||||
if (hostPairs.size() > maxPairs)
|
||||
{
|
||||
hostPairs.resize(maxPairs);
|
||||
}
|
||||
|
||||
if (hostPairs.size())
|
||||
{
|
||||
@ -262,7 +266,7 @@ void b3GpuSapBroadphase::reset()
|
||||
}
|
||||
|
||||
|
||||
void b3GpuSapBroadphase::calculateOverlappingPairs()
|
||||
void b3GpuSapBroadphase::calculateOverlappingPairs(int maxPairs)
|
||||
{
|
||||
int axis = 0;//todo on GPU for now hardcode
|
||||
|
||||
@ -398,8 +402,6 @@ void b3GpuSapBroadphase::calculateOverlappingPairs()
|
||||
}
|
||||
|
||||
|
||||
int maxPairsPerBody = 64;
|
||||
int maxPairs = maxPairsPerBody * numSmallAabbs;//todo
|
||||
m_overlappingPairs.resize(maxPairs);
|
||||
|
||||
b3OpenCLArray<int> pairCount(m_context, m_queue);
|
||||
@ -423,8 +425,10 @@ void b3GpuSapBroadphase::calculateOverlappingPairs()
|
||||
|
||||
numPairs = pairCount.at(0);
|
||||
if (numPairs >maxPairs)
|
||||
{
|
||||
b3Error("Error running out of pairs: numPairs = %d, maxPairs = %d.\n", numPairs, maxPairs);
|
||||
numPairs =maxPairs;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
if (m_gpuSmallSortedAabbs.size())
|
||||
@ -467,7 +471,10 @@ void b3GpuSapBroadphase::calculateOverlappingPairs()
|
||||
|
||||
numPairs = pairCount.at(0);
|
||||
if (numPairs>maxPairs)
|
||||
{
|
||||
b3Error("Error running out of pairs: numPairs = %d, maxPairs = %d.\n", numPairs, maxPairs);
|
||||
numPairs = maxPairs;
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
@ -49,8 +49,8 @@ class b3GpuSapBroadphase
|
||||
b3GpuSapBroadphase(cl_context ctx,cl_device_id device, cl_command_queue q );
|
||||
virtual ~b3GpuSapBroadphase();
|
||||
|
||||
void calculateOverlappingPairs();
|
||||
void calculateOverlappingPairsHost();
|
||||
void calculateOverlappingPairs(int maxPairs);
|
||||
void calculateOverlappingPairsHost(int maxPairs);
|
||||
|
||||
void reset();
|
||||
|
||||
|
@ -144,7 +144,7 @@ void b3GpuRigidBodyPipeline::stepSimulation(float deltaTime)
|
||||
numPairs = m_data->m_broadphaseDbvt->getOverlappingPairCache()->getNumOverlappingPairs();
|
||||
} else
|
||||
{
|
||||
m_data->m_broadphaseSap->calculateOverlappingPairs();
|
||||
m_data->m_broadphaseSap->calculateOverlappingPairs(m_data->m_config.m_maxBroadphasePairs);
|
||||
numPairs = m_data->m_broadphaseSap->getNumOverlap();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user