Open bdumesnil opened 7 years ago
Could you provide a repro for the geometry that causes this assert to fire?
Are you making use of features like holes in the heightfield?
It would be useful to know exactly what the issue is. There are several games that have successfully used unified heightfields over the past few years as it generally produces better behaviour than the legacy heightfield implementation.
I get the exact same assert as the OP does using unified heightfields, we had to revert back to using the legacy heightfields
Hi,
When passing from legacy heightfields to unified heightfields we stumbled on the assert
PX_ASSERT(inds[0] == vertIndices[a] || inds[1] == vertIndices[a] || inds[2] == vertIndices[a]);
inPCMHeightfieldContactGenerationCallback::onEvent
Here is the call stack :Our investigation lead us to functions
Gu::HeightField::getTriangleVertexIndices
andGu::HeightField::getTriangleAdjacencyIndices
. There seems to be a confusion between vertexIds, cellIds and trianglesIds.Let's say for a ( nbRow*nbColumn ) heightfield there is :
But in
getTriangleAdjacencyIndices
adjacent triangles are calculated by adding/subtracting VerticesPerRow instead of CellsPerRow, making one of the adjacent index wrong by one. For example :adjacencyIndex2 = ((cell + mData.columns ) * 2) + 1;
Instead ofadjacencyIndex2 = ((cell + ( mData.columns - 1 ) ) * 2) + 1;
Similarly in
getTriangleVertexIndices
it is assumed thatcellId == VertexId of first vertex in cell
for instance :Instead it should be :
because there is one more vertex per row than there is cells.
There is a few other places I have seen similar errors, you'll find an attached file containing a patch of some of the errors I found ( I only fixed those who triggered when testing there are probably others ).
0001-Heightfield-fixes.zip
It seems that unified heightfields are not safe to use yet, or maybe we missed something in our calculations.