2.0 Progress Update

News about Box2D
Seligman
Posts: 4
Joined: Fri Jan 25, 2008 8:44 pm

Re: 2.0 Progress Update

Postby Seligman » Fri Feb 01, 2008 3:15 pm

Erin Catto wrote:That's a bug (obviously I haven't tested that function yet).

Try changing NULL to this.


Ahh, thanks. At this point would you appreciate bug reports around these untested functions, or would you rather we wait for some sort of RC version?

Erin Catto
Site Admin
Posts: 2948
Joined: Thu Sep 06, 2007 12:34 am

Re: 2.0 Progress Update

Postby Erin Catto » Fri Feb 01, 2008 9:31 pm

Bug reports are good. Also, this is a good thread for them. That way I know the bug is for the SVN version.

I'm almost feature complete for 2.0. Then only examples and documentation remains.

Seligman
Posts: 4
Joined: Fri Jan 25, 2008 8:44 pm

Re: 2.0 Progress Update

Postby Seligman » Fri Feb 01, 2008 10:44 pm

Attempting to remove a shape from a body that's resting against another body causes a NULL dereference attempt as the contacts are cleaned up: (this is against SVN revision 97)

Code: Select all

b2AABB aabb;
aabb.lowerBound.Set(-100, -100);
aabb.upperBound.Set(100, 100);
b2World w(aabb, b2Vec2(0, -10), true);

b2BodyDef bodydef;
bodydef.type = b2BodyDef::e_dynamicBody;
bodydef.position.Set(0, 0);
b2Body * body = w.Create(&bodydef);

b2PolygonDef boxdef;
boxdef.SetAsBox(1, 1, b2Vec2(0, 0), 0);
boxdef.density = 1;
body->Create(&boxdef);
boxdef.SetAsBox(1, 1, b2Vec2(1, 0), 0);
b2Shape * shape = body->Create(&boxdef);
body->SetMassFromShapes();

bodydef.type = b2BodyDef::e_staticBody;
bodydef.position.Set(0, -10);
b2Body * ground = w.Create(&bodydef);
boxdef.SetAsBox(100, 1, b2Vec2(0, 0), 0);
boxdef.density = 0;
ground->Create(&boxdef);
ground->SetMassFromShapes();

for (int i = 0; i < 500; i ++) {
    w.Step(0.3f, 100);

    if (i == 20) // b2ContactManager.cpp:189 can't derefence a NULL body1
        body->Destroy(shape); // boom
    TCHAR szDebug[100];
    _stprintf_s(szDebug, _T("%d %f %f\n"), i,
        body->GetWorldCenter().x, body->GetWorldCenter().y);
    OutputDebugString(szDebug);
}

Seligman
Posts: 4
Joined: Fri Jan 25, 2008 8:44 pm

Re: 2.0 Progress Update

Postby Seligman » Sat Feb 02, 2008 10:14 pm

It looks like simply moving the DestroyProxy call up to before the shape's data structures are cleared out fixes this. At least the bugs I'm finding now are all in my code :)

Code: Select all

==== Dynamics/b2Body.cpp ====
171c171,173
<       s->m_body = NULL;
---
>       s->DestroyProxy(m_world->m_broadPhase);
>
>     s->m_body = NULL;
195d196
<       s->DestroyProxy(m_world->m_broadPhase);


Also, this simple change will make VC happier in a release build:

Code: Select all

==== Collision/Shapes/b2PolygonShape.cpp ====
107,108c107
<       float32 length = ux.Normalize();
<       b2Assert(length > FLT_EPSILON);
---
>       b2Assert(ux.Normalize() > FLT_EPSILON);

Erin Catto
Site Admin
Posts: 2948
Joined: Thu Sep 06, 2007 12:34 am

Re: 2.0 Progress Update

Postby Erin Catto » Sat Feb 02, 2008 11:43 pm

Thanks for the crash report. I fixed the crash and added a shape editing test.

I've switched to using warning level 3 in release to avoid the warnings that occur when assertions are removed by the preprocessor.

mos
Posts: 16
Joined: Wed Jan 23, 2008 9:36 am

Re: 2.0 Progress Update

Postby mos » Sun Feb 03, 2008 7:04 am

Erin, you might want to take a look at this article on the proper way to write an assert macro. I know what you're probably thinking, "there's a proper way?" Actually, I was pretty surprised just how much better that assert is over the default.

The end result is that you'll be able to go back to w4.

Erin Catto
Site Admin
Posts: 2948
Joined: Thu Sep 06, 2007 12:34 am

Re: 2.0 Progress Update

Postby Erin Catto » Wed Feb 06, 2008 1:24 am

Thanks for the link. I'll look into it.

In other news, 2.0 is now feature complete! Continuous physics seems to be working well now and it finishes the time step so there is no visual lag. You can add/delete shapes from a body and you can use sensors for non-solid collision. Now I mainly have documentation work to complete.

Wahooney
Posts: 155
Joined: Tue Sep 18, 2007 6:17 am
Location: Western Cape, South Africa
Contact:

Re: 2.0 Progress Update

Postby Wahooney » Wed Feb 06, 2008 1:48 am

My hat and the top half of my head goes off to you, Erin, the amount of work you've put into Box2D is staggering to say the least.

Thanks for all the time and effort :mrgreen:

brainclog
Posts: 185
Joined: Mon Dec 17, 2007 10:11 pm
Contact:

Re: 2.0 Progress Update

Postby brainclog » Wed Feb 06, 2008 3:39 am

I am liking the sensor example :D There are so many amazing features in 2.0, I just hope I can keep up with finding ways to use them in my games! When I look at the planned features past 2.0...wow...spline joints, meshes, etc.. I don't even know what some of it is: tree constraints, static point-grids? :shock: I need to go look those up... Ok tree constraints appear to be some type of memory management thing, but it sounds cool!

If I am able to attain my crazy goal of making a living off of Flash games, I will owe you not only my deepest gratitude, but my job! :shock: (ok before anyone calls me crazy, the guys over at http://handdrawngames.com did it, and they didn't even have Box2D!) Of course if it doesn't work out I will be the most knowledgeable Box2D user living on the streets... Ok actually I will probably end up in a cubicle, but I'm not sure which is worse! Ah, such is the life of a recent CS college grad...

Wahooney
Posts: 155
Joined: Tue Sep 18, 2007 6:17 am
Location: Western Cape, South Africa
Contact:

Re: 2.0 Progress Update

Postby Wahooney » Wed Feb 06, 2008 6:17 am

Static point grids...

Erin, if I were to say Cortex Command, would I be thinking along the right track?


Return to “News”



Who is online

Users browsing this forum: No registered users and 2 guests