Strange chipmunk performance with 3.0 OS!!

Official forum for the Chipmunk2D Physics Library.
Johanovski
Posts: 24
Joined: Thu Apr 29, 2010 5:07 am
Contact:

Re: Strange chipmunk performance with 3.0 OS!!

Post by Johanovski »

Hi slembcke!

Thanks for your replies! The game now runs "nearly" always as I expected... However sometimes (rarely, but existing) in the 1G iPhone physics still have some bugs. The problem is that I don't know how can I get my last used system to work, because my timer variables give me really high values, and I don't know how to make a relationship between them and the physics interval... Here is my code:

Code: Select all

float newTime = CFAbsoluteTimeGetCurrent();
		float deltaTime = newTime - currentTime;
		currentTime = newTime;

		accumulator += deltaTime;
		
		int count = 0;
		int maxCount = 10;
		
		if (accumulator < intervalFisica) {
			accumulator = intervalFisica;
		}
		
		while ( (accumulator >= intervalFisica) && (count < maxCount) ) {
			cpSpaceStep(space, intervalFisica);
			
			accumulator -= intervalFisica;
			
			count++;
		}	

		cpSpaceHashEach(space->activeShapes, &eachShape, nil);
		cpSpaceHashEach(space->staticShapes, &eachShape, nil);
		
		[self updateScene:delta];
Sometimes the "deltaTime" interval is lesser than the "intervalFisica" time (which is 1.0f/60.0f), so I've forced to do at least a loop in the spaceStep (this happens in the simulator), and sometimes the value if higher than 30 (yes, I've said 30 and not 0.30) so I don't let it loop more than 10 times (this happens in the 1G iPhone). However game performance really decreases this way... maybe physics are better processed and never fail, but with the 1G iPhone each loop does 10 spaceSteps so game is unplayable...

My time getter functions (CFAbsoluteTimeGetCurrent) give me values like "295193824.000000", which I think are really higher than those I need. is there any way to get just a seconds or milliseconds precision? Though the game runs well relating the delta time (as I exposed in my last post) sometimes it fails in the 1G so, if I can solve it, I want to...

Thanks for your help! :)
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Strange chipmunk performance with 3.0 OS!!

Post by slembcke »

You have to realize that part of your problem isn't that you aren't using the right performance algorithms, but that the code simply runs too slowly to work properly on the older hardware. Optimize all you want and turn down shader quality, but you will never get an Xbox game to run on a Commodore 64. The 1st gen iPhone/iTouch hardware is considerably slower than the newer hardware. If you want to target both, you have to first make a game that runs well on the 1st gen hardware, then figure out what effects you can add to make it look better on the newer hardware.

Have you looked at all into profiling your app with Shark? Have you tried using larger timesteps (like 1/30) or fewer solver iterations?
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Johanovski
Posts: 24
Joined: Thu Apr 29, 2010 5:07 am
Contact:

Re: Strange chipmunk performance with 3.0 OS!!

Post by Johanovski »

Hi slembcke!

You're right, maybe I'm trying to fit an app designed by the 3GS in a 1G which is, as you've said, not possible without some performance or gameplay decreasing... Well in fact what I did made the game at least playable with the 1G (when it used to be simply unplayable because nearly each time the game were run it showed an issue or another, so I think it's a really positive change! Maybe sometimes the game will show a strange effect with the 1G? Well, life isn't fair, we all know...

Thanks for your help, I've really understood much about Chipmunk that I completely ignore till I faced this and, as I've said, you helped me a lot making the game at least playable in the 1G! Thank you very much! :)

PS: Now, battling with the other post about the shapes XD! ;)
Post Reply

Who is online

Users browsing this forum: No registered users and 39 guests