Box2DFlash 2.1a RELEASE!

Discuss issues specific to the Flash/AS3 port of Box2D
patadox
Posts: 57
Joined: Mon Nov 16, 2009 11:34 am

Re: Box2DFlash 2.1a RELEASE!

Postby patadox » Tue Feb 02, 2010 8:41 am

I spent a night porting my 2.02 code to 2.1 - I tore 2.02 up turning all the static bodies into kinematic bodies for my purposes, and I was happy to update to a version that actually supported what I wanted to do. Looking at the code, it seemed a lot cleaner too.

Sadly, I'm still stuck with 2.02 for now. After a night of porting, I finally got the game to compile and noticed severe slow down when I flooded the stage with some 100 to 150 circular dynamic bodies - way slower than 2.02. I thought it might be my contact listeners, but taking them out, the slow down remained.

2.1 is awash with great features, and I'm very happy to see raycast and buoyancy especially. But it seems like the math of 2.1 is less efficient that 2.02 under high stress.

I'm not familiar with Erin's work on the original, or the Alchemy port - is this slowdown specific to Flash, specific to AS3, or just a general 2.1 problem? Has anyone done any benchmarking?

BorisTheBrave
Posts: 1911
Joined: Mon Jan 07, 2008 10:51 am
Contact:

Re: Box2DFlash 2.1a RELEASE!

Postby BorisTheBrave » Tue Feb 02, 2010 1:19 pm

Hmm. This is an alpha, so I am expecting things to be slower. I'd be very interested if you could try the following things for me, and see which ones help, as I don't have time for benchmarking myself:

1) Try using the Flash 9 (Arrays) release. Vectors haven't shown the improvement as I'd have thought, for some reason.

2) Disable continuous physics, if you have it on. These code paths are VERY unoptimized compared with the normal case, at the moment.

3) Use the old broadphase. I.e. call myWorld.SetBroadphase(new b2Broadphase(aabb)).

You can also try the Alchemy port. It is faster.

sketchbookgames
Posts: 564
Joined: Tue Feb 24, 2009 4:10 pm
Location: Michigan
Contact:

Re: Box2DFlash 2.1a RELEASE!

Postby sketchbookgames » Fri Feb 05, 2010 10:13 am

BorisTheBrave,

your new site:
http://box2dflash.boristhebrave.com/

Box2D - C++ links to box2d.com instead of box2d.org
which seems to be a dog pet care wordpress...

sHTiF
Posts: 1
Joined: Fri Feb 05, 2010 8:48 pm

Re: Box2DFlash 2.1a RELEASE!

Postby sHTiF » Fri Feb 05, 2010 8:54 pm

Boris great work, i already posted on your blog about the TOI issue for the bullet simulation its nice to see that you solved it. I did a couple of tests and works fine now :)

About the slowdown comparing to 2.02 that i mentioned its not so apparent when using the Flash9 version so it seems that indeed the vectors are the issue. Spammed 120 balls in my breakout test game where all of them are bullet bodies and no slowdown at all with the F9 version :D

cjcat2266
Posts: 2
Joined: Sat Feb 06, 2010 7:08 am
Location: Taipei, Taiwan
Contact:

Re: Box2DFlash 2.1a RELEASE!

Postby cjcat2266 » Sat Feb 06, 2010 7:11 am

Hey, thanks for the port. It all looks fantastic! I'm trying to integrate it with a minimalistic game engine already.

Just one quick thought. Are you going to release two versions, one for Flash Player 9, and one for 10? Because in some cases people might want to develop under Flash CS3. I notice that you've used the new Vector class in the 2.1a port, which will be a problem with people sticking to Flash CS3.

Thanks again for all your effort on the port!

flashisland
Posts: 4
Joined: Sat Feb 06, 2010 10:04 am

Re: Box2DFlash 2.1a RELEASE!

Postby flashisland » Sat Feb 06, 2010 11:14 am

I'm having a lot of issues with bullet objects going right through walls. I know this has been mentioned before but I thought it had been corrected. Can anyone else verify that this is still an issue?

Edit: This occurs with both the Flash 9 & 10 versions.

sketchbookgames
Posts: 564
Joined: Tue Feb 24, 2009 4:10 pm
Location: Michigan
Contact:

Re: Box2DFlash 2.1a RELEASE!

Postby sketchbookgames » Sun Feb 07, 2010 6:24 am

@cjcat2266

i think BorisTheBrave was planning on dropping vectors because they didn't improve performance as much as he had hoped.
(i think he mentioned this in a discussion with mayobutter on this thread or one similar viewtopic.php?f=8&t=4345

flashisland
Posts: 4
Joined: Sat Feb 06, 2010 10:04 am

Re: Box2DFlash 2.1a RELEASE!

Postby flashisland » Sun Feb 07, 2010 8:54 pm

I've been testing the 2.1a release more and my dynamic objects keep moving through static objects. I've attached a screenshot illustrating a dynamic ball set as bullet moving through a static polygon. Usually the ball will be inside the polygon for one frame until the engine corrects for it. Sometimes the ball is able to move completely through the polygon completely within one frame. This appears to be a major bug in this release.
Attachments
ball-and-wall.jpg
ball-and-wall.jpg (3.05 KiB) Viewed 1762 times

cjcat2266
Posts: 2
Joined: Sat Feb 06, 2010 7:08 am
Location: Taipei, Taiwan
Contact:

Re: Box2DFlash 2.1a RELEASE!

Postby cjcat2266 » Sat Feb 13, 2010 12:41 am

I'm not sure if this is a bug. But the restitution value of a fixture with a circle shape seems to act pretty differently from fixtures with other shapes.

Supposedly, when two fixtures with zero restitution values collide, they do not "bounce off" in the normal direction. However, I found that if one of the fixture has a circle shape, even with zero restitution value, the two fixtures would bounce off against each other.

I have tried many times, and this phenomenon keeps occurring. Simply by swapping the circle shape with any other types of shape immediately eliminates this problem.

Any suggestion or solution?

BorisTheBrave
Posts: 1911
Joined: Mon Jan 07, 2008 10:51 am
Contact:

Re: Box2DFlash 2.1a RELEASE!

Postby BorisTheBrave » Sat Feb 13, 2010 3:56 am

flashisland: Please submit a testcase. I've not been able to reproduce for myself, but I've seen other reports.

cjcat2266: Testcase it. Should be fairly straightforward.

I cannot stress how useful it is to me to get bugreports, and reproducible test cases. I've spent days trying to track down some possible problem with the CCD, to no avail. Bugs frequently occur in very exact conditions, and you have to get lucky to be able to find one. I recently solved a bug when an unrelated testcase started demonstrating it, but in general I'm relying on everyone's luck to find them.

Here's my ideal testcase:
  • Modifies the prexisting testbed.
  • Doesn't include many unnecessary elements.
  • Demonstrates the problem within a few seconds of running without user intervention.
But anything is better than nothing.


Return to “Flash”



Who is online

Users browsing this forum: Bing [Bot], Yahoo [Bot] and 3 guests