Box2D Forums

It is currently Thu May 23, 2013 2:15 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Sat Oct 29, 2011 11:58 am 
Offline

Joined: Sat Oct 29, 2011 11:19 am
Posts: 4
Hello everyone,

Sorry for the haste in making the topic, but i will just copy my question from stackexchange, because im in a hurry at this time and i really need help :)

I have a Box2D simulation going on and a system that loads the bodies and its' shapes from a text file definition.

I create a new physics world, i load bodies into it, from one of these files. Everything seems to work fine, collisions included.

Then, i attempt to create a really simple one-shaped body from code, just like the most basic tutorials. Lets say a circle.

The circle appears fine, starts falling with gravity, and as soon as it hits a static body, both the circle and that body disapear. As simple as that. The body the circle is colliding with is in this case a ground static rectangle.. Pretty straightforward!

I think im setting everything just the regular way, but i can edit this question with more information if pertinent. Sorry for the lack of detail.

EDIT: For some reason, seems to work in Debug builds, but no in Release.

So, anyone knows any circumstances that could cause such an event?

Thanks in advance!


Top
 Profile  
 
PostPosted: Sat Oct 29, 2011 12:51 pm 
Offline

Joined: Tue Jun 24, 2008 8:25 pm
Posts: 1517
Location: Tokyo
It disappears why? Does it fly away into space or is it not in the world at all? Is it being destroyed - what's going on in BeginContact?


Top
 Profile  
 
PostPosted: Sat Oct 29, 2011 1:34 pm 
Offline

Joined: Sat Oct 29, 2011 11:19 am
Posts: 4
They just disappear, but there is something wrong with my system, i will keep fixing things in it until it solves itself. Something is bugging Box2D in it.


Top
 Profile  
 
PostPosted: Sat Oct 29, 2011 4:16 pm 
Offline

Joined: Sat Oct 29, 2011 11:19 am
Posts: 4
So, really weird, i made a really simple function like:

Code:
void KinesisWorld::CreateQuickCircle(int x, int y, int r){
      b2BodyDef def;
      def.position = b2Vec2(ToMeters(x),ToMeters(y));
      def.type = b2_dynamicBody;

      b2CircleShape circle;
      circle.m_radius = ToMeters(r);
      circle.m_p = b2Vec2(0, 0);      

      b2Body *body = CreateBody(&def);

      b2FixtureDef fixDef;
      fixDef.shape = &circle;
      fixDef.density = 1.0f;
      fixDef.friction = 0.5f;
      fixDef.restitution = 0.5f;

      body->CreateFixture(&fixDef);
   };


Then i mapped a key to it. Just to note that the world starts with a ground shape(static) and one circle(dynamic) before any key is pressed.

Funny thing is, besides the two bodies previously created, i get to create exactly six more. Only six more. If there are 8 objects in the world, its just fine, if i press the key one time more, the bug mentioned early happens. Weird.

Sample of this bug: http://www.mediafire.com/?p9ct4sa8ycpqp39

EDIT: After testing some more, i concluded this bug is happening only when there are b2PolygonShape objects in the world. With circles it runs fine, release or debug. With boxes the bug happens, and its exactly at the count of 8 like i said, giving the following assert failure in debug mode:

Code:
Assertion failed:area > 1.192092896e-07F, ..\..\Box2D\Collision\Shapes\b2PolygonShape.cpp, line 352


Top
 Profile  
 
PostPosted: Sat Oct 29, 2011 5:43 pm 
Offline

Joined: Sat Oct 29, 2011 11:19 am
Posts: 4
i think i found the problem. What a silly thing. The size for the shapes was being generated randomly, and the randomizer is the most simplistic possible, therefore it was giving me a value of 0 at exactly the same time, which i set to my box dimensions, giving that assert a valid meaning :)


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

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 2 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