Edge Shape (Chain) Body Questions

Hello, I have 3 questions regarding edge/chain shapes.

  1. The documentation states “Up to 32 vertices can be declared” for edge shape (chain) bodies. If I understand correctly, this means that the “chain” table should include up to 64 arguments (not 32) since each vertex relates to two indices within the table, correct?

  2. What is expected to happen if I add more than the maximum number of vertices? I’ve tested this in the Simulator using 40+ vertices and the chain still continued. How is this possible if the function expects a maximum or 32 vertices. If this is expected to work, then why does the documentation say that 32 vertices is the maximum and what is the true maximum?

  3. Does collision handling work with edge shapes? For example, should a second physics object crossing the edge shape trigger a collision?

Thank you!

@jhow, interesting you should bring this up because I implemented edge chain physics in the Level Director libraries and was concerned that only 32 vertices were allowed, but even when creating complex Bezier curves with physics, Level Director generates way more than 32 and seems to work fine.

Collision handling should also work fine, and if you want an example download the free version of Level Director X and try the ‘Joint’ demo, the car rolls smoothly along a Bezier curve which is using edge chain physics.

Thanks @retrofitProductions.

I’m hoping that somebody from Corona will clarify if there is truly a maximum number of chains or not. If not, that’s wonderful. If so, what’s the maximum so I know not to go over it?

Hi guys,

The engineers looked into this further. It seems that there is not a limit of 32 vertices, so the docs were incorrect. I’ll fix it shortly.

Of course, as with everything in Corona physics, you really need to maintain some reasonable level in your code. If you construct a chain shape of 2000+ vertices, I fully expect you’ll blow out the memory and crash your app.

Another thing which you should be aware of (and I’m adding this to the docs as well) is to not build a chain shape with self-intersecting segments. In other words, don’t construct your vertices so that segments are crossing over other segments. That will very likely break the expected collision detection, according to Box2Ds documentation.

Brent

Thank you

Glad the docs are going to be updated.  I found out the 32 wasn’t a limit a while ago and never knew if there was a limit or if it would all the sudden be enforced.

@jhow, interesting you should bring this up because I implemented edge chain physics in the Level Director libraries and was concerned that only 32 vertices were allowed, but even when creating complex Bezier curves with physics, Level Director generates way more than 32 and seems to work fine.

Collision handling should also work fine, and if you want an example download the free version of Level Director X and try the ‘Joint’ demo, the car rolls smoothly along a Bezier curve which is using edge chain physics.

Thanks @retrofitProductions.

I’m hoping that somebody from Corona will clarify if there is truly a maximum number of chains or not. If not, that’s wonderful. If so, what’s the maximum so I know not to go over it?

Hi guys,

The engineers looked into this further. It seems that there is not a limit of 32 vertices, so the docs were incorrect. I’ll fix it shortly.

Of course, as with everything in Corona physics, you really need to maintain some reasonable level in your code. If you construct a chain shape of 2000+ vertices, I fully expect you’ll blow out the memory and crash your app.

Another thing which you should be aware of (and I’m adding this to the docs as well) is to not build a chain shape with self-intersecting segments. In other words, don’t construct your vertices so that segments are crossing over other segments. That will very likely break the expected collision detection, according to Box2Ds documentation.

Brent

Thank you

Glad the docs are going to be updated.  I found out the 32 wasn’t a limit a while ago and never knew if there was a limit or if it would all the sudden be enforced.