Concave Collision Shapes

Rainbros

  • Posts: 175
I am trying to generate random polygonal collision shapes for an actor at runtime, but I would like the shapes to be concave, so I was just wondering...

Why is it that concave terrain is automatically decomposed into multiple convex shapes, but the same isn't true for actor collision shapes? It seems like it could work the same way.

Rimrook

  • Posts: 251
Modern physics are based on things not crossing lines. If each segment of a shape is extended infinitely to create these lines, you would get a very defined shape still in the center of the lines if the shape is convex.

If the segments were strings laid in the floor and you were told not to cross any of them, you easily could remain inside the shape made without doing so. Now if the shape was concave, a part of the shape would be inaccessible to you even though it's within the perceived shape. A line would cut you off from a section. A computer also would not be able to tell which side of the line you would be on in this section. Whether your on the inside of a line or outside it, the computer needs to know this in order to calculate a collision. Like if you were on the inside of all of the lines at the same time, you are definitely inside the shape.

Concaves get redrawn and  broken apart to maintain the shape while obeying this law. Like you would be able to be inside shape A, if not, check shape B, either result would satisfy the 'within' property and return a physical response. You don't see this with actors because I believe it does break them apart but stencyl doesn't draw the sections to make the concave satisfy the convex law. Simply the debugger draws the main segments that define a shape and the cross-sections are just hidden.

Hope this helps with understanding.

Hectate

  • *
  • Posts: 4645
I definitely had trouble with concave terrain once upon a time, but that was (literally) years ago (Dreaming Big). It's safest to just use multiple convex shapes to generate your own concave shape as a result. That's what I did and it solved my collision issues.
:
:
Patience is a Virtue,
But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

Daniel Bell

  • Posts: 11
thanks, i too was looking a way for concave collision shapes  :)