Intersecting shapes in multi-element bodies

Hi,

Should I need worry about using intersecting polygonal shapes in multi-element bodies?

ldurniat

Have you made these bodies already or are they theoretical?  Can you post a physics image in “hybrid” mode for us to take a look at?

“worry”?  no

“consider”?  sure

iow, maybe you WANT the overlap, maybe you DON’T.  one issue might be the extra mass, but also collision testing happens between the individual fixtures of different bodies, not directly on the implied “body-as-a-sum-of-its-fixtures”.  sometimes a bit of strategic overlap at well-determined angles can help avoid certain types of nuisance penetrations between fixtures (that occur mainly when strong joints are involved, along a perfectly coincident shared edge, can often be mitigated by intentionally causing minor overlap)

@davebollinger - “nuisance penetrations between fixtures” is a beautifully worded explanation for exactly where I have had problems in the past.  I have resolved these problems by using circles as physics bodies stand-ins when possible. 

My trouble wasn’t that the multi-element bodies had problems internally, it was that they caused problems with interacting with other multi-element physics bodies.  For example, the horn of one object gets stuck between elements of another object and they remain stuck or, worse, pry each other’s joints apart and crash the physics engine.  *This happened rarely, like one in 2,000 collisions but if you have enough collisions it will happen sooner or later.  After I started using circles as the physics bodies for the horns, it stopped the penetration.

I splitted polygon (image on right) into several smaller ones (image on left) since Corona require that polygon have at most 8 vertices. 

I figure out now that polygon on right in not entirely convex. I have forgotten about this :frowning:

I444Cy1.png

Those look like good physics bodies to me!  I wouldn’t worry about the overlap.  If they were super-complicated or there were hollow spaces or deep divots, then I’d worry.

Ok:) Thanks.

Corona require that polygon have at most 8

Why don’t you using chain body? I have tested chain body from hundreds (more than 600) vertices and this worked fine.


You need to break this type of body only if you need to simulate legs and arms apart from body i.e. make them moving but keep them physics applied


In attachment body 720 vertices

I have never use multi-element bodies before so I thought this is the only way.  What is difference between multi-element body and chain body?

Thanks for your time to prepare simple project for me:)

There is difference. You can make concave chain body hollow inside. Polygon body, as I remember, must be 8 vertices max, convex and you cannot use inner space.

Maybe polygon bodies are faster, because there is no additional load on engine to count inner space and concave spaces. But really, if you have few bodies with only ten/twenty/thirty vertices running on phones better than i.e. Samsung Galaxy S1 this is irrelevant.

Depends on situation. If you need ease of use + possibility to create convex bodies/spline bodies/arcs/extremely complicated bodies assembled from array of lines with possibility to change it’s shape + extremely perverted inconceivable modifications  -> body created using chains is your choice. But if you need to create simplest convex body that maybe will be cloned in amount of thousands on worst 2000’s device -> use simple shape forms.

Other example: I need to create thousand different body shapes from pictures where shapes will surely have more than 8 vertices, will be maybe convex and maube concave and maybe with usefull inner space. Because I’m beginner with Lua, I will open new project in MS Visual Basic and will write program (.NET version can open png with alpha channel) to easily get array of bits of image, loop through it’s mask to identify key points (future vertices) and to output generated Lua-style or json code for an array of shape vertices that is ready to use in Corona. Last thing is to drop all these thousand images on this programm to get thousand ready to use shapes.


Thanks for your time to prepare simple project for me:)

Offtopic: Corona is ONE and ONLY tool that is working from box without additional dancing with drum. It’s simply working and have many examples. 

Gideros doesn’t compile programs and after two hours of anguish I couldn’t get it to work

LOVE is something strange and not working properly from box and not so simple as it wants to look like.

UNITY is very simple only on first look of youtube overviewers but too hard to make something if you are lower grade than highly-trained professional, realy, you will loose yourself in two lines of code.

That’s why we are looking walkarounds instead of simply changing tool )) 

@zombiexp2010  I like your method for getting an array of vertices.  

I use chain bodies for landscapes and large physics bodies but I’ve never used them for small bodies like balls or characters.  Have you used them for small physics bodies and, if so, have you encountered any collision detection problems when they are moving fast?

Have you used them for small physics bodies and, if so, have you encountered any collision detection problems when they are moving fast?

Yes, sometimes. Solution is to add one more shape to the body with +1 pixel larger. It’s looks like you are extruding shape from inner to outer by +1 pixel.

Also, I haven’t encountered performance issues because, as I said, if you want to create thousands of extra fast bodies you need to use another type of shape, so for few bodies with resulting count (with « extruded shell») about 30 vertices per body this is not important. Much more important sometimes is ease of use with another programs that give you only points so if you want to use combined bodies you need to do a lot of work (break polygons, create clockwise trajectory for points and so on…)

Hmmm, but I have encountered this bug even with simple polygons:

rect+poly with bug https://www.youtube.com/watch?v=1JKBJJx8wLE

and  sphere without https://www.youtube.com/watch?v=KtzlqIoqpT4

so…

As you see, I don’t want to use object:applyLinearImpulse because when char will climb on a hill he will lose in speed. Only direct x-coordinate handling (((

Oh, if you are searching good shape for use with character and to have proper physics, look:

1.Proper rotation angle while standing on the ground - one of chalenges for proper shape

  1. Fast moving without collision bugs

  2. Without holes between tiles like in ponywolf loader

@zombiexp2010

Cool, I’ll take a look, thanks!

Have you made these bodies already or are they theoretical?  Can you post a physics image in “hybrid” mode for us to take a look at?

“worry”?  no

“consider”?  sure

iow, maybe you WANT the overlap, maybe you DON’T.  one issue might be the extra mass, but also collision testing happens between the individual fixtures of different bodies, not directly on the implied “body-as-a-sum-of-its-fixtures”.  sometimes a bit of strategic overlap at well-determined angles can help avoid certain types of nuisance penetrations between fixtures (that occur mainly when strong joints are involved, along a perfectly coincident shared edge, can often be mitigated by intentionally causing minor overlap)

@davebollinger - “nuisance penetrations between fixtures” is a beautifully worded explanation for exactly where I have had problems in the past.  I have resolved these problems by using circles as physics bodies stand-ins when possible. 

My trouble wasn’t that the multi-element bodies had problems internally, it was that they caused problems with interacting with other multi-element physics bodies.  For example, the horn of one object gets stuck between elements of another object and they remain stuck or, worse, pry each other’s joints apart and crash the physics engine.  *This happened rarely, like one in 2,000 collisions but if you have enough collisions it will happen sooner or later.  After I started using circles as the physics bodies for the horns, it stopped the penetration.

I splitted polygon (image on right) into several smaller ones (image on left) since Corona require that polygon have at most 8 vertices. 

I figure out now that polygon on right in not entirely convex. I have forgotten about this :frowning:

I444Cy1.png

Those look like good physics bodies to me!  I wouldn’t worry about the overlap.  If they were super-complicated or there were hollow spaces or deep divots, then I’d worry.

Ok:) Thanks.