How come Line shapes collide in RUBE ?

General discussion about the R.U.B.E editor
Post Reply
devel
Posts: 4
Joined: Fri Apr 21, 2017 12:58 am

How come Line shapes collide in RUBE ?

Post by devel » Fri Apr 21, 2017 1:14 am

Hi, does anyone know why Line shapes collide in RUBE ?
I've been trying to do the same with JBox2D but the engine does not support collisions of two objects with zero volume. Adding radius to one if the lines seems have no effect (to obtain volume)
Example can be found in fixtureTypes.rube sample scene, where fixtures hit the ground.

iforce2d
Site Admin
Posts: 860
Joined: Sat Dec 22, 2012 7:20 pm

Re: How come Line shapes collide in RUBE ?

Post by iforce2d » Fri Apr 21, 2017 3:13 am

b2Edge/b2Chain shapes don't collide with other like shapes in Box2D, this is not really RUBE thing. Additionally because edge/chain shapes have no volume, they have no defined center of mass or rotational inertia. So they are only of practical use on static or kinematic bodies. If you try make a dynamic body with only line fixtures, Box2D will set a default mass of 1 and infinite rotational inertia, which is why you see those bodies fall down but not rotate in the fixtureTypes sample. That sample is only meant to show how the different fixture types turn out, not really as a usable physics scene.

devel
Posts: 4
Joined: Fri Apr 21, 2017 12:58 am

Re: How come Line shapes collide in RUBE ?

Post by devel » Fri Apr 21, 2017 2:22 pm

I was probably not clear.
I meant to say that in fixture types.rube Line fixture with id=11 successfully collides with the ground Line fixture id=1.
Whereas in JBox2d one Chain shape falls through another Edge shape, and no collision happens.
Even if I add radius to Edge/Chain shapes it has no effect.

iforce2d
Site Admin
Posts: 860
Joined: Sat Dec 22, 2012 7:20 pm

Re: How come Line shapes collide in RUBE ?

Post by iforce2d » Fri Apr 21, 2017 5:24 pm

circlesAndPolygons.jpg
circlesAndPolygons.jpg (21.17 KiB) Viewed 11378 times
This one? Those are circles and polygons.

Box2D only has circle, polygon and edge shapes (a b2Chain shape internally manages multiple b2Edge shapes). http://box2d.org/manual.pdf
The "fat lines" you see in RUBE are circles and rectangles generated by RUBE to fit the line. It's not a standard Box2D feature. When exporting to .json, RUBE calculates these and also does some other processing (eg. making sure polygons are convex and only have maximum of 8 vertices etc).

Search the built-in help for "Fixture types" to see some more info about this.
See also the "Difference between saving and exporting" topic under "Exporting scenes".

devel
Posts: 4
Joined: Fri Apr 21, 2017 12:58 am

Re: How come Line shapes collide in RUBE ?

Post by devel » Fri Apr 21, 2017 6:16 pm

That makes sense now, thanks a lot !
Am I right thinking that if Line RUBE fixture has zero radius - then it will be exported as a standard edge/chain b2 shape ?

iforce2d
Site Admin
Posts: 860
Joined: Sat Dec 22, 2012 7:20 pm

Re: How come Line shapes collide in RUBE ?

Post by iforce2d » Sat Apr 22, 2017 12:15 am

Yes, that's correct.

Post Reply