This project has moved and is read-only. For the latest updates, please go here.

Perfect Circles - Performance Question

Sep 16, 2010 at 9:24 PM

Hi everyone.

First of all let me say, that I absolutely love FPE! Since this is the very first time I post a question on theese discussions boards, I felt the need to express me appreciation for this project, and give credit to thoose of you who have spent your time making this engine. You are truly awesome! Allright, on to my question :)

My current project / experiment, is a fast-paced 2D space shooter game. I'm using FPE 3.0 for physics on my game objects, including projectiles from weapons. In my game I expect a lot of projectiles to flying around at any given time.

Currently the projectiles are created using perfect circles as fixtures. My understanding would be, that using perfect circles would perform better than using polygons. However how much perfomance increase am I getting from this, if any, considering the amount of active bodies? Also I use CCD for my projectiles, which I'm guessing is heavy on performance as well?

Which would be the most optimized solution for this? Or should I consider taking the projectiles entirely out of the physics engine, and go for a different approach?

I apologize if my question is somewhat abstract, but I could use some advice before getting too far in the development process.

Thanks in advance :)

- Cheers, Carsten



Sep 16, 2010 at 9:31 PM

Thanks for the kind words. Most of the thanks goes to Box2D for supplying us with a good foundation and the Box2D.XNA team for porting it to .NET. We added a great deal of tools and made the engine faster and easier to use. FPE is the best of all worlds.

Circles are faster to check than polygons - You will have to profile it to find out how much.

CCD uses a good amount of CPU time, so limit the number of CCD enabled bodies in the world. If you use the DebugView class, you can see how much time is spend on solving the CCD bodies.

You should be able to create hundreds of bodies, if performance begin to suffer, then you find a way of minimizing the number of active bodies.

Sep 16, 2010 at 9:59 PM

Thank you, for that extremely rapid reply :)

I've had a quick look a the debug data - In an emtpy scene with projectiles exclusively, the engine only spends around 5-6% of total update time doing CCD, when 350 or so projectiles bodies are active. This is around where my computer starts falling behind on FPS.

However I don't know about Xbox performance, because I currently don't have the possibilities to run my project on one. I've read somewhere, though, that Xbox performance is not as good as Windows performance for FPE. Is the diffrence big? Again, apologies for the abstract question :)

Sep 16, 2010 at 10:04 PM

If all the projectiles can collide with each other or collides with something at the same time, then it slow down a lot. Most of the time in the engine is used on solving the contact positions. We perform to the best of our abilities on Xbox360, however, we are limited by the less (compiler) optimized code and the hardware.

Sep 16, 2010 at 10:24 PM

Ah, thanks for elaborating.

Projectiles in my game cannot, by default, collide with eachother. And as for hardware, the Xbox is way supperior hardware-wise to my PC - So I guess I don't have to worry too much about performance yet, if badly optimized compiler code is "all" that stands in the way. But better off doing some research, before getting too far in development :)

But thank you very much for your replies. I'll back to coding now - my coffee's getting cold :)

- Cheers!




Sep 19, 2010 at 2:57 AM
Edited Sep 19, 2010 at 3:11 AM

I run my game on an i5 processor 2.66 ghz on a single thread. And my game can handle up to 600 geometries. (So to be safe, there's only ever 400 enemies).

On the Xbox, the same game can only handle 150 geoms and about 5 collisions per second will lag it down to  20 fps and below. The Xbox is about 1/4th the power of a standard computer or LESS.

Have not tried the new farseer engine (3.0) as I wasn't going to make any drastic changes before a contest submission, but I may have to because of how poorly the game is running =/. I may also have to look into multi-threading. If you're curious about what optimizations I've done so far- I use SAT collision handling, and I have temporary collision disabling amongst similar enemies upon contact. Also, I don't use DrawingHelper to draw Rectangles anymore, it is extremely inefficient :(.


Farseer runs super great on PC though! Loads of fun, great engine overall- at the moment though, it's my bottleneck.

here, have a video:

I really have lots of enemies and stuff as well.