with intersecting AABBs to each btFluidSph. If internalClearRigidContacts() is called, it will also clear
those AABBs so that there is no input to the narrowphase.
Try replacing:
m_fluidSph->internalClearRigidContacts();
with:
m_fluidSph->internalGetRigidContacts().clear();
As a more efficient alternative, I've also added a mid-tick callback.
The 'invalid type conversion' error is due to the fact that btFluidSph::getSolverData() returns const void*
and the static_cast cannot remove const; add const to the pointer types to fix it.
Each particle has a neighbor table, so the loop would access solverData->m_neighborTable.
getNeighborIndex() is called on each entry in the neighbor table( btFluidSphNeighbors::size() ),
so a different index(not i) would be used to loop through it. In the example and also in much of
the BulletFluids code, i and n are used as indices for fluid particles.
If the 'distance-vector' to other particles is needed, it would need to be recalculated. Additionally,
the performance benefit over using surface tension would be much less. Currently, the surface tension
increases the time for each frame by a factor of ~1.5x on the CPU. Using a cheaper method might increase
the frame time by ~1.1-1.2x.
Code: Select all
btFluidSphSolverDefault::SphParticles* solverData = static_cast<btFluidSphSolverDefault::SphParticles*>(m_fluidSph->getSolverData()); //add const to pointers
btAlignedObjectArray<int> numParticlesInSphRadius; //1 entry per particle
for(each particle) //index i
{
const btFluidSphNeighbors& table = solverData->m_neighborTable[i];
for(each entry in neighbor table) //index j
{
int n = table.getNeighborIndex(j);
//Each entry in the neighbor table contains a pair of particles
//(for neighbor table of particle i, index i is implicit)
numParticlesInSphRadius[i] += 1;
numParticlesInSphRadius[n] += 1;
}
}