Outline bodies - User defined tables not possible?

Hi,

I have some concave objects and thought that I’d try using an “Outline body” as described here.

First I tried with the old shape functionality like this:

local w = display.contentWidth local h = display.contentHeight local physics = require("physics") physics.start() physics.setDrawMode("debug") shape1 = { -128,-128, 0,-128, 128,0, 128,128, -128,128 } local element = display.newRect(w/2, h/2, 256, 256) element.rotation = 90      physics.addBody(element, "static", { density=2.0, friction=0.9, bounce=0.0, shape=shape1}) 

And all is well. Using the physics engine in debug mode I can see that the shape looks good.

Then I tried to just change the last line to:

physics.addBody(element, "static", { density=2.0, friction=0.9, bounce=0.0, outline=shape1})

In other words; Using outline and set it to the shape array. This, apparently, does not work. Running the project in the emulator results in a square shape of the physics object. Isn’t the outline supposed to be an array just line shape?

I know that the graphics.newOutline() function is limited to the Pro versions of Corona, but I cannot se any mention that the usage of outline in addBody() has this limitation?

So what am I doing wrong?

Hi @runewinse,

I really encourage people to use “outline” with “newOutline()”, and not mix it with “shape” or try to manually construct/modify outline tables. Internally, the engineers have designed outlines to work in a certain way, and mixing them with “shape” and other such practices can’t be assured to work.

Best regards,

Brent

Thanks for the reply!

Ok, that was a bit surprising, because even in the docs you use a “handmade” table as an example:

 

outline (optional)

Array. Outline array containing the shape’s vertices: { x1,y1, x2,y2, …, xn,yn }. For example outline = { 0,-37, 37,-10, 23,34, -23,34, -37,-10 }.

 

Maybe you should formulate the docs slightly different? And add this is only available for Pro and Enterprise users (not for amateurs as me).

Hi @runewinse,

Thanks for the note… I will fix the documentation accordingly.

Brent

Hi @runewinse,

I really encourage people to use “outline” with “newOutline()”, and not mix it with “shape” or try to manually construct/modify outline tables. Internally, the engineers have designed outlines to work in a certain way, and mixing them with “shape” and other such practices can’t be assured to work.

Best regards,

Brent

Thanks for the reply!

Ok, that was a bit surprising, because even in the docs you use a “handmade” table as an example:

 

outline (optional)

Array. Outline array containing the shape’s vertices: { x1,y1, x2,y2, …, xn,yn }. For example outline = { 0,-37, 37,-10, 23,34, -23,34, -37,-10 }.

 

Maybe you should formulate the docs slightly different? And add this is only available for Pro and Enterprise users (not for amateurs as me).

Hi @runewinse,

Thanks for the note… I will fix the documentation accordingly.

Brent