Bullets and thin walls

Discuss issues specific the Java port of Box2D
Alexin
Posts: 10
Joined: Fri Sep 04, 2009 1:17 am

Bullets and thin walls

Postby Alexin » Mon Sep 07, 2009 2:37 am

Hi,

The following screenshot shows several dynamic bodies (balls) falling on static ones (walls).

jbox2D-incorrent_collision_detection.png
jbox2D-incorrent_collision_detection.png (10.75 KiB) Viewed 4941 times


Except for the for one, all of the balls penetrate into the walls. My first attempt was to set the balls as bullets (Body.setBullet(true)). The second one was to enable continuous physics (World.setContinuousPhysics(true)). None of the attempts solve the problem.
I did it based on the documentation, wiki and this thread.

I should say the walls are made by combining several shapes. The wall that isn't penetrated is made of "large" squares, while the others are made of small and thin rectangles and L shapes. It seems that the thin bodies are at fault, but the wall labeled A is larger and is penetrated (but still made of thin shapes).

I'd appreciate any clarification/solution. Just ask if you need more information.
Thank you.

Michiel
Posts: 34
Joined: Sat May 02, 2009 6:07 am

Re: Bullets and thin walls

Postby Michiel » Mon Sep 07, 2009 3:20 pm

You seem very thorough so I hate to ask but do you specify shapes in a counter clockwise direction?

Alexin
Posts: 10
Joined: Fri Sep 04, 2009 1:17 am

Re: Bullets and thin walls

Postby Alexin » Mon Sep 07, 2009 4:55 pm

The single shapes alone are specified in clockwise direction.

Michiel
Posts: 34
Joined: Sat May 02, 2009 6:07 am

Re: Bullets and thin walls

Postby Michiel » Mon Sep 07, 2009 10:45 pm

Okay, because if I specify them clockwise things go through as well.

EDIT: This makes sense if you use setAsBox() on the large square.

toucansam
Posts: 356
Joined: Mon Jun 08, 2009 12:21 pm
Contact:

Re: Bullets and thin walls

Postby toucansam » Tue Sep 08, 2009 4:38 am

is this solved? counter-clockwise works?

Alexin
Posts: 10
Joined: Fri Sep 04, 2009 1:17 am

Re: Bullets and thin walls

Postby Alexin » Thu Sep 10, 2009 2:30 am

Sorry for the late response.

I altered the thickness of the walls and the order the points are defined. Here are the results:

  • Thickness = 0.2, CW -> FAIL (original test case I posted above)
  • Thickness = 0.2, CCW -> FAIL
  • Thickness = 0.4, CCW -> SUCCESS
  • Thickness = 0.3, CCW -> SUCCESS
  • Thickness = 0.2, CCW -> SUCCESS
  • Thickness = 0.2, CW -> SUCCESS

Note: thickness is relative to the shape's dimensions and ranges from 0.0 to 1.0 (think of textures coordinates). It isn't a measure of world or pixel units.

As you can see, I ended up with the original test case, but this time it works and there's no need to set the balls as bullets or enable continuous physics. The first platform (A) still has a problem, though - only the inner points are combined and it still can be penetrated.

I'll investigate more on this and post if necessary.

Michiel
Posts: 34
Joined: Sat May 02, 2009 6:07 am

Re: Bullets and thin walls

Postby Michiel » Thu Sep 10, 2009 2:58 am

Glad to see you are making progress. Truthfully, I can't really comprehend what you are up to. Does this have to do with an editor?

Alexin
Posts: 10
Joined: Fri Sep 04, 2009 1:17 am

Re: Bullets and thin walls

Postby Alexin » Thu Sep 10, 2009 7:36 am

Strange. Now, only shapes declared in CCW order works fine. Well, as long as it works correctly...

Michiel wrote:Truthfully, I can't really comprehend what you are up to. Does this have to do with an editor?

I'm sorry but, unfortunately, I'm not allowed to tell more about it.


Return to “Java”



Who is online

Users browsing this forum: No registered users and 1 guest