complex bodies get stuck inside each other

we’re having trouble with complex bodies getting stuck inside each other when spawning in a similar position, or being dragged over each other
http://developer.anscamobile.com/forum/2010/11/19/complex-shapes-layering-over-top-one-another

this may relate to the topics here… although i see no specific solutions. setting a groupIndex collision filter doesnt seem to help
http://www.box2d.org/forum/viewtopic.php?f=8&t=47
http://www.box2d.org/forum/viewtopic.php?f=3&t=1054&start=0

[import]uid: 6645 topic_id: 3826 reply_id: 303826[/import]

In an effort to try and find a temporary workaround I’ve also tried overlapping the polys a bit to see if this helps, unfortunately this provided to help. The complex objects still layer. [import]uid: 11554 topic_id: 3826 reply_id: 11733[/import]

Here is a great example (borrowing jmp909’s code) of these items layering. Please note I’ve simplified the shapes for this example:

[lua]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={-120, -60, -80, -60, -80, 60, -120, 60}},
{shape={-80, -60, 80, -60, 80, -20, -80, -20}},
{shape={80, -60, 120, -60, 120, 60, 80, 60}}

}

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
obj.y=math.random()*480
physics.addBody(obj, “dynamic”,unpack(defs))

obj:addEventListener(“touch”,dragBody)

end

local t = timer.performWithDelay(0,dropBlock,-1)
t._delay=1000[/lua] [import]uid: 11554 topic_id: 3826 reply_id: 11734[/import]

Your “unpacks(defs)” will add multiple “shape=” elements when only one is expected. Have you tried it by only defining one shape?

-Tom [import]uid: 7559 topic_id: 3826 reply_id: 11789[/import]

I wasn’t aware that you could define a complex shape using one one definition. Could you provide an example of how this is done? [import]uid: 11554 topic_id: 3826 reply_id: 11803[/import]

Here is an example of how I am doing this within my application currently:

[lua]shape = {
{-80, 40, -80, -40, -28.25, 11.75, -40, 40},
{-80, -40, 80, -40, 0, 0, -28.25, 11.75},
{0, 0, 80, -40, 28.25, 11.75},
{28.25, 11.75, 80, -40, 80, 40, 40, 40}
}

local blockMaterial = {}

for i = 1, #shapes do

local currShape = shapes[i]

blockMaterial[i] = {
density = 1.0,
friction = 1.0,
bounce = 0.0,
shape = currShape
}
end

local block = display.newImage ( path, 0, 0, true )

physicsRef.addBody (block, unpack (blockMaterial))[/lua]

Is this not correct? [import]uid: 11554 topic_id: 3826 reply_id: 11804[/import]

Any updates??? [import]uid: 11554 topic_id: 3826 reply_id: 11977[/import]

Problem is still active? Any solutions? [import]uid: 76117 topic_id: 3826 reply_id: 47160[/import]