Complex Shapes "Layering" over the top of one another?

I’m having a Box2D issue with complex polys. I am dragging a non “body” object into my “world” and dropping it. Once it drops “onRelease” I am using addBody to insert it into the world. This works fine except for when using complex objects.

Here is the complex breakdown of my shape:

I am using a jsfl script to get my vertices, and it seems to work out ok:

[[[40, 40], [28.25, 11.7], [80, -40], [80, 40]], [[28.25, 11.7], [0, 0], [80, -40]], [[0, 0], [-28.3, 11.7], [-80, -40], [80, -40]], [[-28.3, 11.7], [-40, 40], [-80, 40], [-80, -40]]]

When I view this inside of Corona the hybrid version looks perfect:

But when I drag a few over the top of each other, they just “layer” whereas when I do this with a simple shape like a rectangle it will force the other bodies out of the way.

Any ideas?

Thank you so much in advance! [import]uid: 11554 topic_id: 3804 reply_id: 303804[/import]

upload your code …

will try have a look

but this works fine

[lua]physics = require(“physics”)
physics = require(“physics”)
gameUI = require(“gameUI”)
physics.start()
physics.setDrawMode(“hybrid”)

local function dragBody( event )
gameUI.dragBody( event )
end

local floor = display.newRect(0,430,320,50)
floor:setFillColor(0,255,0)
physics.addBody(floor,“static”, {density=1})

local defs =
{

{shape={40, 40, 28.25, 11.7, 80, -40, 80, 40}},
{shape={28.25, 11.7, 0, 0, 80, -40}},
{shape={0, 0, -28.3, 11.7, -80, -40, 80, -40}},
{shape={-28.3, 11.7, -40, 40, -80, 40, -80, -40}}

}

function dropBlock()

– create dummy display object
local obj = display.newRect(0,0,150,70)
obj:setFillColor(255,0,0)
obj.alpha=0.2
obj.x=50+math.random()*200
physics.addBody(obj, “dynamic”,unpack(defs))

obj:addEventListener(“touch”,dragBody)

end

local t = timer.performWithDelay(0,dropBlock,-1)
t._delay=1000[/lua]

note i’ve put a rectangle behind the shape but this doesnt affect the physics… ie the archway will still let other objects inside it [import]uid: 6645 topic_id: 3804 reply_id: 11635[/import]

ah there is a problem in my case if two objects spawn inside each other
[import]uid: 6645 topic_id: 3804 reply_id: 11637[/import]

Yes that is the same problem I am having. I am dragging an object over the “world” then onRelease I am creating a body and inserting it into the world at that x/y. So if you overlap them they layer instead of pushing each other out of the way like the simpler bodies do.

I am running around right now but once I get back home I will post my code. It is essentially very similar to what you have though.

Thank you for any assistance you can provide.

[import]uid: 11554 topic_id: 3804 reply_id: 11639[/import]

posted bug report
http://developer.anscamobile.com/forum/2010/11/20/complex-bodies-get-stuck-inside-each-other
[import]uid: 6645 topic_id: 3804 reply_id: 11640[/import]

Great thank you! [import]uid: 11554 topic_id: 3804 reply_id: 11649[/import]

One last thought…

Do you think i could temporarily solve this issue by using 4 separate shapes, each connected by a weld joint? Or is this essentially the same thing we are accomplishing by feeding the poly tables to a single complex body?

Just looking for temporary solutions.

Thank you! [import]uid: 11554 topic_id: 3804 reply_id: 11678[/import]

don’t know sorry. need a reply from ansca really [import]uid: 6645 topic_id: 3804 reply_id: 11680[/import]

Just out of curiosity I decided to try out the weld joints with much simpler geometry and they still are layering. Please see attachment. I’m out of ideas hopefully we will hear something from Ansca soon.

[import]uid: 11554 topic_id: 3804 reply_id: 11735[/import]