Box2D Forums

It is currently Sun May 19, 2013 9:32 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 65 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7  Next
Author Message
 Post subject: Re: 2.0 Progress Update
PostPosted: Fri Feb 01, 2008 3:15 pm 
Offline

Joined: Fri Jan 25, 2008 8:44 pm
Posts: 4
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?


Top
 Profile  
 
 Post subject: Re: 2.0 Progress Update
PostPosted: Fri Feb 01, 2008 9:31 pm 
Offline
Site Admin

Joined: Thu Sep 06, 2007 12:34 am
Posts: 2931
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.


Top
 Profile  
 
 Post subject: Re: 2.0 Progress Update
PostPosted: Fri Feb 01, 2008 10:44 pm 
Offline

Joined: Fri Jan 25, 2008 8:44 pm
Posts: 4
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:
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);
}


Top
 Profile  
 
 Post subject: Re: 2.0 Progress Update
PostPosted: Sat Feb 02, 2008 10:14 pm 
Offline

Joined: Fri Jan 25, 2008 8:44 pm
Posts: 4
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:
==== 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:
==== Collision/Shapes/b2PolygonShape.cpp ====
107,108c107
<       float32 length = ux.Normalize();
<       b2Assert(length > FLT_EPSILON);
---
>       b2Assert(ux.Normalize() > FLT_EPSILON);


Top
 Profile  
 
 Post subject: Re: 2.0 Progress Update
PostPosted: Sat Feb 02, 2008 11:43 pm 
Offline
Site Admin

Joined: Thu Sep 06, 2007 12:34 am
Posts: 2931
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.


Top
 Profile  
 
 Post subject: Re: 2.0 Progress Update
PostPosted: Sun Feb 03, 2008 7:04 am 
Offline

Joined: Wed Jan 23, 2008 9:36 am
Posts: 16
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.


Top
 Profile  
 
 Post subject: Re: 2.0 Progress Update
PostPosted: Wed Feb 06, 2008 1:24 am 
Offline
Site Admin

Joined: Thu Sep 06, 2007 12:34 am
Posts: 2931
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.


Top
 Profile  
 
 Post subject: Re: 2.0 Progress Update
PostPosted: Wed Feb 06, 2008 1:48 am 
Offline

Joined: Tue Sep 18, 2007 6:17 am
Posts: 155
Location: Western Cape, South Africa
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:


Top
 Profile  
 
 Post subject: Re: 2.0 Progress Update
PostPosted: Wed Feb 06, 2008 3:39 am 
Offline

Joined: Mon Dec 17, 2007 10:11 pm
Posts: 185
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...


Top
 Profile  
 
 Post subject: Re: 2.0 Progress Update
PostPosted: Wed Feb 06, 2008 6:17 am 
Offline

Joined: Tue Sep 18, 2007 6:17 am
Posts: 155
Location: Western Cape, South Africa
Static point grids...

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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 65 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7  Next

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group