When running a small test with 100 colliding circles, the performance is extremely slow.
Profiling shows that 99% of the cpu time is consumed by the FindAvailableManifoldIndex() function.
It seems that this function returns the first available manifold id.
But it only used from the PhysicsStep function,
and that function first deletes all manifolds.
So would the first available manifold id not just be the number of manifolds + 1 ?
like so:
// Finds a valid index for a new manifold initialization
static int FindAvailableManifoldIndex()
{
const int id = physicsManifoldsCount + 1;
if (id >= PHYSAC_MAX_MANIFOLDS)
return -1;
return id;
}
my test program (cpp)
SetPhysicsGravity(0, 0);
// Create obstacle circle physics body
Vector2 position = { 0, 0 };
for (float i = 0; i < 100; i++)
{
CreatePhysicsBodyCircle({i,i}, 5, 10);
};
PhysicsBody floor = CreatePhysicsBodyRectangle({0,-100}, 500, 5, 10);
floor->enabled = false; // Disable body state to convert it to static (no dynamics, but collisions)
for (int i = 0; i < 5; i++)
{
PhysicsStep();
std::cout << i << std::endl;
}
When running a small test with 100 colliding circles, the performance is extremely slow. Profiling shows that 99% of the cpu time is consumed by the FindAvailableManifoldIndex() function.
It seems that this function returns the first available manifold id. But it only used from the PhysicsStep function, and that function first deletes all manifolds.
So would the first available manifold id not just be the number of manifolds + 1 ?
like so:
my test program (cpp)