[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4762: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4764: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4765: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4766: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
Chipmunk Physics • View topic - Low fps with Chipmunk

Low fps with Chipmunk

Official forum for the .

Low fps with Chipmunk

Postby korki696 » Mon Aug 10, 2009 1:25 pm

Hey all,
So i got my game working pretty well on the simulator so i decided to pay the $99 and i put it on my iphone and i noticed during gameplay i only get 30fps and i narrowed it down to being chipmunk thats causing it. What i have right now are 6 larger active shapes that are players, 3 larger static shapes that are objects and 30 total projectiles. i never add more i only remove players when they die.

My first question is does chipmunk slow down if bodies are touching eventhough there is no collision callback on them? for example my projectiles are al in the same place. could this slow down my game?

Second is the cpSpaceResizeActiveHash and StaticHash. I understand that dim should be 1/2 the size of the average size? my question is how do i find the size? and the count i understand.

Is there anything else i could change?
Thanks
-Lars
korki696
 
Posts: 24
Joined: Wed Jul 15, 2009 2:15 am

Re: Low fps with Chipmunk

Postby slembcke » Mon Aug 10, 2009 3:13 pm

First, you should read the draft of the new wiki page I wrote, it might answer some questions: http://code.google.com/p/chipmunk-physi ... nDetection

You don't really find the size, you just estimate what you think it will be on average. It's not going to be that sensitive exactly.

The most expensive part in Chipmunk is processing touching objects, so that should answer your other question. ;) Have you tried using fewer solver iterations? (space->iterations)
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: Low fps with Chipmunk

Postby korki696 » Mon Aug 10, 2009 3:38 pm

Hey,
So having touching objects be the most memory expensive makes sense but i am doing it slightly different. what i do is move my sprites and then update the bodies to the position of the sprite. This allows me to use the moveTo function of cocos2d and use the physics engine of chipmunk to see if two touch and all of my collision callbacks return 0 because i just move them off of the screen. and either remove them or reset them. would the way i move my bodies cause a slow down?

And also i guess i wasnt really asking how to get the size but more of what does 100 mean? w*h? or what?

Thanks
-Lars
korki696
 
Posts: 24
Joined: Wed Jul 15, 2009 2:15 am

Re: Low fps with Chipmunk

Postby slembcke » Mon Aug 10, 2009 4:06 pm

So you are just using Chipmunk for the collision detection and moving all of your "dead" objects to the same place instead of removing them from the space? That would also be bad because it would force Chipmunk to check a ton of collisions between objects that you don't even care about. Every object would have to be checked against every other object in that area.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: Low fps with Chipmunk

Postby korki696 » Mon Aug 10, 2009 4:15 pm

WHat im doing is in the collision callback if there health is 0 then move them out of the screen and change their state to dead and then in my main loop after i step chipmunk it checks if any are dead and if so it deletes them. when i move them i also give them a random number to add to it so they dont touch. but i do have my projectiles that get created in the same location but i have no colision call back on them does chipmunk stll do math for those?

Thanks
-Lars
korki696
 
Posts: 24
Joined: Wed Jul 15, 2009 2:15 am

Re: Low fps with Chipmunk

Postby slembcke » Mon Aug 10, 2009 5:01 pm

Still not quite sure what you mean exactly, but the answer is likely yes.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: Low fps with Chipmunk

Postby korki696 » Mon Aug 10, 2009 5:51 pm

Ok what im doing is creating 15 projectiles all with the same collision_type on the same location lets say -100, -100. there is no collision function for them hitting each other only other objects such as enemies but does chipmunk still do calculations for those? If so how can i make it so it doesnt?
Thanks
-Lars
korki696
 
Posts: 24
Joined: Wed Jul 15, 2009 2:15 am

Re: Low fps with Chipmunk

Postby maximile » Tue Aug 11, 2009 4:27 am

I don't think Chipmunk checks whether the collision function is NULL before it does the costly stuff. Putting the projectiles into a group would sort it out.
maximile
 
Posts: 157
Joined: Mon Aug 20, 2007 12:53 pm
Location: London, UK

Re: Low fps with Chipmunk

Postby korki696 » Tue Aug 11, 2009 3:30 pm

Ok, so i played around with my code a lot and ended up making all of my shapes into circles, which if i remember right are the fastest. which gave me a boost of about .5fps. i then decided to see if its my projectiles so i went from making 20 total to just 2 and it runs at 60 fps. so then i went to 10 total and it drops to 40fps. the projectiles are all in a group and they are just circles with a radius of 6. so they are quite small. how could they be slowing down the game so much?
Thanks
-Lars
korki696
 
Posts: 24
Joined: Wed Jul 15, 2009 2:15 am

Re: Low fps with Chipmunk

Postby slembcke » Tue Aug 11, 2009 6:44 pm

Have you tried profiling and what compiler flags are you using? Disable thumb compilation, and use -O3 and -ffast-math for Chipmunk. That should make a pretty big difference.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Next

Return to Chipmunk2D Physics

Who is online

Users browsing this forum: No registered users and 1 guest

cron