Polygon physic bug

When you add to the polygon of physics there is an error. When another object falls to the polygon, he falls through it.

Example:

display.setStatusBar(display.HiddenStatusBar) local physics = require("physics") physics.start() physics.setDrawMode("hybrid") vertices = {-100,-100,130,-10,150,-300,150,100} local polygon = display.newPolygon( 300, 280, vertices ) physics.addBody(polygon, "static", {density = 1,friction=0, bounce=0.4}) local rect = display.newRect( 395, 10, 40, 40) physics.addBody(rect, {density = 1,friction=1, bounce=0.1})

If you create a form of lines, all works.

Example:

display.setStatusBar(display.HiddenStatusBar) local physics = require("physics") physics.start() physics.setDrawMode("hybrid") vertices = {-100,-100,130,-10,150,-300,150,100} local polygon = display.newPolygon( 300, 280, vertices ) --physics.addBody(polygon, "static", {density = 1,friction=0, bounce=0.4}) local rect = display.newRect( 395, 10, 40, 40) physics.addBody(rect, {density = 1,friction=1, bounce=0.1}) local line = display.newLine( 175,280, 407,369 ) line:append( 425,82,425,482,175,280) physics.addBody(line, {friction=1, bounce=0.4}) line:setStrokeColor( 0, 0, 1 ) line.strokeWidth = 5

Physics shapes have to be convex shapes.  The diagram above is concave.  I also don’t know that you can change a polygon after you’re made a physics body out of it without removing/re-adding the physics body.

Rob

Draw a polygon shape by providing the outline (contour) of the shape. This includes convex or concave shapes. Self-intersecting shapes, however, are not supported and will result in undefined behavior.

Strange, because physics is created but buggy.

You can have concave polygons.  You cannot have concave physics shapes.  Display objects are things that exist in the drawing space.  Then there is the physics simulation which we tie together (as physics bodies move we move the display objects with them).  In other words its perfectly legal to have a concave display.newPolygon outside of the physics simulation.  But because Box2D has different requirements, you would have to build multiple physics shapes to do what you want.

Rob

Physics shapes have to be convex shapes.  The diagram above is concave.  I also don’t know that you can change a polygon after you’re made a physics body out of it without removing/re-adding the physics body.

Rob

Draw a polygon shape by providing the outline (contour) of the shape. This includes convex or concave shapes. Self-intersecting shapes, however, are not supported and will result in undefined behavior.

Strange, because physics is created but buggy.

You can have concave polygons.  You cannot have concave physics shapes.  Display objects are things that exist in the drawing space.  Then there is the physics simulation which we tie together (as physics bodies move we move the display objects with them).  In other words its perfectly legal to have a concave display.newPolygon outside of the physics simulation.  But because Box2D has different requirements, you would have to build multiple physics shapes to do what you want.

Rob