Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Intersecting shapes in multi-element bodies
Started by ldurniat May 30 2018 12:45 PM

13 replies to this topic
multi-element bodies intersect polygon shape
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

ldurniat

[GLOBAL: userInfoPane.html]
ldurniat
  • Contributor

  • 361 posts
  • Corona SDK

Hi,

 

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

 

ldurniat



[TOPIC: post.html]
#2

sporkfin

[GLOBAL: userInfoPane.html]
sporkfin
  • Contributor

  • 415 posts
  • Corona SDK

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?



[TOPIC: post.html]
#3

davebollinger

[GLOBAL: userInfoPane.html]
davebollinger
  • Corona Geek

  • 1,203 posts
  • Enterprise

"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)



[TOPIC: post.html]
#4

sporkfin

[GLOBAL: userInfoPane.html]
sporkfin
  • Contributor

  • 415 posts
  • Corona SDK

@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.



[TOPIC: post.html]
#5

ldurniat

[GLOBAL: userInfoPane.html]
ldurniat
  • Contributor

  • 361 posts
  • Corona SDK

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?

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 :(

 

I444Cy1.png



[TOPIC: post.html]
#6

sporkfin

[GLOBAL: userInfoPane.html]
sporkfin
  • Contributor

  • 415 posts
  • Corona SDK

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.



[TOPIC: post.html]
#7

ldurniat

[GLOBAL: userInfoPane.html]
ldurniat
  • Contributor

  • 361 posts
  • Corona SDK

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.



[TOPIC: post.html]
#8

zombiexp2010

[GLOBAL: userInfoPane.html]
zombiexp2010
  • Enthusiast

  • 55 posts
  • Corona SDK

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

Attached Files


  • ldurniat and mmihajlovic like this

[TOPIC: post.html]
#9

ldurniat

[GLOBAL: userInfoPane.html]
ldurniat
  • Contributor

  • 361 posts
  • Corona SDK

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:)



[TOPIC: post.html]
#10

zombiexp2010

[GLOBAL: userInfoPane.html]
zombiexp2010
  • Enthusiast

  • 55 posts
  • Corona SDK

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 )) 


  • ldurniat and sporkfin like this

[TOPIC: post.html]
#11

sporkfin

[GLOBAL: userInfoPane.html]
sporkfin
  • Contributor

  • 415 posts
  • Corona SDK

@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?



[TOPIC: post.html]
#12

zombiexp2010

[GLOBAL: userInfoPane.html]
zombiexp2010
  • Enthusiast

  • 55 posts
  • Corona SDK

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 

and  sphere without 

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 (((



[TOPIC: post.html]
#13

zombiexp2010

[GLOBAL: userInfoPane.html]
zombiexp2010
  • Enthusiast

  • 55 posts
  • Corona SDK

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

2. Fast moving without collision bugs

3. Without holes between tiles like in ponywolf loader

Attached Files



[TOPIC: post.html]
#14

sporkfin

[GLOBAL: userInfoPane.html]
sporkfin
  • Contributor

  • 415 posts
  • Corona SDK

@zombiexp2010

 

Cool, I'll take a look, thanks!




[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: multi-element, bodies, intersect, polygon, shape