Huge Slowdown

Jun 30, 2009 at 3:16 PM

Hi, I created a rope with several rectangles (10 or 15), linked together with a LinearSpring and a SlideJoint each.

It works perfectly but sometimes, after I shoot the rope (kind of grappling hook) vertically, when all the links fall down and concentrate in a small area (some are over others, I modified their OnCollision method to avoid collision between links), the fps falls down to 10 or 4. In the debug view, I see a big increase on the Narrow Phase Collision value (over 10 and even over 20) when this happens. The strangest thing is that this doesn't happen every time. Any idea? Cheers!

Jun 30, 2009 at 3:54 PM

I'm not sure why it might be happenning, but it's probably a better approach to put all link geoms into the same collision group, that way the Arbiters should avoid getting to the narrow phase at all.

Jun 30, 2009 at 4:27 PM

Thanks Roonda, I tried it but the problem is still happening :(

Tried also with collisioncategories (instead of collisiongroup), and the geometry's collideswith value I specified to collide with everything but its category (CollidesWith = CollisionCategory.All & ~CollisionCategory.Cat1), and the problem is still there.

Jun 30, 2009 at 4:55 PM

OK, I discovered something... It woks better using CollisionCategories, but it still keeps to collect garbage or something... slower than before (a lot slower), but the Narrow Phase Collision Value keeps increasing its value as I shoot continusly the rope (and let it drop to the floor). The rope loads always the same links (they are stored in a pool, so thay are not reloaded each time I shoot the rope), and at the beginning the Narrow Phase Collision Value is between 0 and 0.2, but after 5 minutes shooting the rope, it gets between 6 and 7, under the same initial conditions.

Jun 30, 2009 at 6:04 PM

Hi Pnikosis,

I am doing something similar - but I tried a different route that avoided the problem - I'm using pin-joint connecting bodies only - no geoms, so there no collision checks.  I was using geoms at first, but I liked it better when my grapple rope could swing through things after it's connected. 

~Alex

Jun 30, 2009 at 6:21 PM

Thanks Alexna!

I'll try your solution. Maybe it looks even better without coliding with other objects :)

I guess that for drawing the rope you are using a similar method used for the Linebrush in the examples.

Coordinator
Jun 30, 2009 at 9:15 PM

Something is very wrong if the narrow phase time builds up over time. The narrow phase should only be active when things actually collide. I would like to know if this is an issue with Farseer or your game. I've not seen similar issues reported before so I'm inclined to think the latter.

I would like to take a look at it. It would be great if you could send me your code or a demo. If you contact me using codeplex I will reply back with my email. Hope that we can get this issue resolved.

Jul 1, 2009 at 9:52 AM

Thanks genbox, I'll contact you after I clean up a little the code :)

Cheers!