Box2D Forums

It is currently Thu May 23, 2013 5:35 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Sat Oct 08, 2011 7:30 pm 
Offline

Joined: Sat Oct 08, 2011 7:21 pm
Posts: 4
I'm attempting to create a class based dynamic object creation system and I've encountered an issue compiling. I'm only partly sure that it was caused by making b2World World a static class entity, but I'm not really sure(my debugger is pretty lousy).

First, it spits this out:
Code:
Assertion failed: area > 1.19209290e-7F, file D:\Source\Packages\Box2D_v2.1.2\Box2D\Box2D\Collision\
Shapes\b2PolygonShape.cpp, line 428

Afterwards, it stalls, it attempts to resolve itself for a while, and then returns 3 when I tell it to terminate.

Here's the source code


Top
 Profile  
 
PostPosted: Sun Oct 09, 2011 12:47 am 
Offline

Joined: Tue Jun 24, 2008 8:25 pm
Posts: 1517
Location: Tokyo
That one is usually caused by specifying a polygon that has the vertex winding backwards, or is not a convex polygon.


Top
 Profile  
 
PostPosted: Sun Oct 09, 2011 8:58 pm 
Offline

Joined: Sat Oct 08, 2011 7:21 pm
Posts: 4
How exactly would I fix that? I'm working with boxes, so it can't be a concave polygon issue, and I'm not sure if I've done anything wrong as far as vertex winding goes. If I messed up, can you tell me where?


Top
 Profile  
 
PostPosted: Sun Oct 09, 2011 11:41 pm 
Offline
Site Admin

Joined: Thu Sep 06, 2007 12:34 am
Posts: 2931
Code:
Box(int x, int y = 0);


The default height is zero --> zero area box.

BTW, this is one reason why I don't like default argument values. They hide bugs.


Top
 Profile  
 
PostPosted: Mon Oct 10, 2011 7:24 pm 
Offline

Joined: Sat Oct 08, 2011 7:21 pm
Posts: 4
I've since changed my code quite a bit (Still dealing with a similar issue though), but in the above source, it has an if statement that changes y to x to form a square if y = 0. Shouldn't that prevent any issues?


Top
 Profile  
 
PostPosted: Tue Oct 11, 2011 1:04 pm 
Offline

Joined: Sat Oct 08, 2011 7:21 pm
Posts: 4
Aha! I'm surprised neither of you caught this. It was my if statement, which instead of doing 'width == 0' did 'if (width = 0)'. Thanks for your help(?), guys! :D


Top
 Profile  
 
PostPosted: Tue Oct 11, 2011 1:54 pm 
Offline
Site Admin

Joined: Thu Sep 06, 2007 12:34 am
Posts: 2931
I recommend not using such convoluted logic. Make your APIs simple and direct without weird side effects.

Also, when you have a problem in your code you should step through line-by-line using the debugger. You would have easily caught this problem that way.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


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