Kevin McGowan
Kevin McGowan

Reputation: 463

Why is having multiple objects with 3D rotation causing a dramatic performance loss

At the moment I am working on a prototype racing game, with an aim to get as close to 3D graphics, without having to use Flash Player 11 and/or DirectX. For this, I opted to use RotationX, RotationY and RotationZ to give me the desired effects. In order to make buildings become 3D, I created four instances of the same object and rotate/index them appropriately.

This works great, until there comes a point where there are a lot of these rotation objects on stage - Then the issues start with performance. Namely, there is none.

An example is here: http://www.hosted101.net/car/Racing3D.html

If you follow the track around you will see that performance becomes progressively worse the more that is on stage.

Stages that I have taken to try and rectify this include:

1) Disabling Z sorting - This gave no increase in performance (to my surprise)

2) Disabling object RotationZ to follow the camera - Again, no increase in performance

3) Swapping Vector graphics for Bitmap graphics - Sadly again, no increase in performance

What exactly is causing these dramatic performance hits?

Is it just that having this many objects with 3D rotation on the stage?

Example of massive FPS loss

Upvotes: 1

Views: 330

Answers (2)

Kevin McGowan
Kevin McGowan

Reputation: 463

To answer my own question here, in case somebody ever gets into a similar pickle:

The problem was directed related to the FPS of the game. Having it set to (originally) 120 wasn't possible for lower-end machines to match, as such different results were being seen. When dropped to 60, it was still too high and as such when multiple rotated objects were onstage the FPS dropped too low, giving the choppy effect.

Having set the FPS maximum to 24 and doubled the maximum speed/turn, the game is now working as it should.

Moral: Lower FPS is better, if you're aiming for lower-spec machines.

Upvotes: 1

Barış Uşaklı
Barış Uşaklı

Reputation: 13532

The link you posted ran for me at a constant 60 FPS.

Your performance bottleneck might be somewhere else if none of those changes helped, try to profile using something like TheMiner.

You can also try setting wmode to "direct" or "gpu" I noticed you are using "window".

Since you don't need any mouse events on any of these buildings and trees make sure you set mouseEnabled mouseChildren to false on all these sprites.

Those are the things that come to my mind hope that helps.

Upvotes: 0

Related Questions