Hi,
i’m developing an application with many objects (1000) with chipmunk on iOs devices the performance is good (iPad2 35fps, iPodTouch 4.gen 15fps). But on android Galaxy S2 it gets only up to 10 fps with only 500 objects with 1000 it doesn’t work. Are there any compile params i can use to get much better performance? How can the code optimized to get a good performance on android?
setup physics:
m_pSpace->gravity = cpv(0, 100); m_pSpace->sleepTimeThreshold = 0.5f; cpSpaceSetIterations(m_pSpace,10); cpSpaceUseSpatialHash(m_pSpace, 14.0, 10000);
generating the objects in a for loop:
float mass = 1.0 + static_cast <float> (rand()) /( static_cast <float> (RAND_MAX/(3.0-1.0))); float radius = 4.0f + mass; cpBody *ballBody = cpBodyNew(mass, cpMomentForCircle(mass, radius, radius, cpvzero)); cpBodySetVelLimit(ballBody, 150.0f); cpBodySetPos(ballBody, cpv(pos.x, pos.y)); cpSpaceAddBody(m_pSpace, ballBody); cpShape *ballShape = cpCircleShapeNew(ballBody, radius, cpvzero); ballShape->e = 0.0; ballShape->u = 0.0; cpSpaceAddShape(m_pSpace, ballShape);
Best regards,
Christian