Low fps with Chipmunk
-
- Posts: 24
- Joined: Wed Jul 15, 2009 2:15 am
- Contact:
Re: Low fps with Chipmunk
hey So I appologise but im kind of new to this for the compiler flags do i just put those in "other C flags"?
Thanks
-Lars
Thanks
-Lars
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: Low fps with Chipmunk
If you look under the build options, there is a "Code generation settings" section. That's where you'll find the checkbox for compile for thumb and the optimization settings. Make sure you are editing the release configuration and not your debug one. -ffast-math would go in a space separated list under OTHER_CFLAGS. That should help your performance a bit.
You should also profile your application with Shark to get a line by line performance analysis of your application. Invaluable.
You should also profile your application with Shark to get a line by line performance analysis of your application. Invaluable.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
-
- Posts: 1
- Joined: Fri Jul 31, 2009 7:26 pm
- Contact:
Re: Low fps with Chipmunk
Hello, I was having a similar problem.
maybe this thread will help:
http://www.cocos2d-iphone.org/forum/topic/1244
maybe this thread will help:
http://www.cocos2d-iphone.org/forum/topic/1244
-
- Posts: 24
- Joined: Wed Jul 15, 2009 2:15 am
- Contact:
Re: Low fps with Chipmunk
Hey penguins,
I actually saw that post first and used it but it didnt change anything.
And as for the tags there was no difference in performance. I am still wondering about the dim as well. You said its a lot of guess and check but how can you make a decent guess on the size? if i have a body that has a radius of 25 what should i set my size at?
Thanks
-Lars
I actually saw that post first and used it but it didnt change anything.
And as for the tags there was no difference in performance. I am still wondering about the dim as well. You said its a lot of guess and check but how can you make a decent guess on the size? if i have a body that has a radius of 25 what should i set my size at?
Thanks
-Lars
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: Low fps with Chipmunk
From the docs:
So if your radius is 25, 25 would be a good starting size for your dim.Setting dim to half the average collision shape size is likely to give the best performance.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
-
- Posts: 24
- Joined: Wed Jul 15, 2009 2:15 am
- Contact:
Re: Low fps with Chipmunk
Ok, So I have done everything i can think of and have not seen a performance change. I looked at the Grabbed app and that uses chipmunk and i put it on my phone with 26 circles(about what i have total). and it also only runs at 30fps. is this a limitation of chipmunk?
Thanks
-Lars
Thanks
-Lars
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: Low fps with Chipmunk
Have you not profiled yet? I can't really offer you any more help if you don't know exactly what is slowing you down.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
-
- Posts: 4
- Joined: Thu Aug 20, 2009 2:18 am
- Contact:
Re: Low fps with Chipmunk
recently, i was trying to optimize the iphone app i'm working on.
the first thing to do is indeed set some compiler flags as -ffast-math as mentioned by slembcke.
another thing i found very usefull, is to decouple the chipmunk-loop and the graphics rendering.
right now i have the chipmunk step-interval at 240/s - while the graphics run very smooth at their own 60fps
(although i choose to cap that at 30 to leave headroom for audio processing)
also i found great improvement when calling cpSpaceHashEach() only once every 8 times i call cpSpaceStep().
not sure what side-effects that has, but for me it works great.
the first thing to do is indeed set some compiler flags as -ffast-math as mentioned by slembcke.
another thing i found very usefull, is to decouple the chipmunk-loop and the graphics rendering.
right now i have the chipmunk step-interval at 240/s - while the graphics run very smooth at their own 60fps
(although i choose to cap that at 30 to leave headroom for audio processing)
also i found great improvement when calling cpSpaceHashEach() only once every 8 times i call cpSpaceStep().
not sure what side-effects that has, but for me it works great.
-
- Posts: 1
- Joined: Tue Aug 25, 2009 4:37 am
- Contact:
Re: Low fps with Chipmunk
Heya i had the same problem with my projectiles on i-phone so i started to store my projectiles off screen all lined up in a kind of array, here is the code i used for my projectiles that leave the screen.
It just stacks all your projectiles in a row till it gets to 60 (or what ever you set it to) then starts over again.
Some one also gave me this code which helped also.
And put this function outside of your @implementation declare, but in the same file
Hope this helps, it did for me, my fps went from about 15 to a solid 60.
Code: Select all
-(void) updateBullets {
int i =0;
for(Bullet *b in bulletarray)
{
if(b.position.y > 500)
{
i++;
[b stopAllActions];
b.position = cpv(-42*i,-50); //change 42 to the width you need
[b setCanFire: YES];
}
else
{
i++;
}
if(i == 60) //same as number of projectiles to be stored
{
i = 0;
}
}
}
Some one also gave me this code which helped also.
Code: Select all
-(void)setupChipmunk {
...........
cpSpaceAddCollisionPairFunction(space, 1, 1, &cancelCollision, nil); //Instead of the 1, put your shape collision type number for your projectiles
................
}
Code: Select all
static int cancelCollision (cpShape *a, cpShape *b, cpContact *contacts,
int numContacts, cpFloat normal_coef, void *data) {
//Do Nothing
return 0;
}
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: Low fps with Chipmunk
Oi oi oi. You guys aren't listening.
The expensive part is that you should be removing your inactive shapes from the space, then they don't use any CPU at all. What you just said has two problems in general. Moving them all near each other makes it likely to be getting collisions between them, and by setting a collision function that does nothing makes it so that it will almost completely process a collision before discarding it. The only thing it doesn't do is process the collision in the impulse solver.
The expensive part is that you should be removing your inactive shapes from the space, then they don't use any CPU at all. What you just said has two problems in general. Moving them all near each other makes it likely to be getting collisions between them, and by setting a collision function that does nothing makes it so that it will almost completely process a collision before discarding it. The only thing it doesn't do is process the collision in the impulse solver.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Who is online
Users browsing this forum: No registered users and 41 guests