Support physic on non-convex shape #3753
Replies: 3 comments
-
@4ian can we make a road map to improve collision polygon with this solution? decompose-polygon ts version |
Beta Was this translation helpful? Give feedback.
-
Check out the idea and we can start working from this line: https://github.com/4ian/GDevelop/blob/master/Extensions/Physics2Behavior/physics2runtimebehavior.ts#L473-L547 Just need to see how to change it: |
Beta Was this translation helpful? Give feedback.
-
@jjhesk Please rather discuss your ideas on the forum first - I know that you're doing a lot of research but you need to consolidate these and get ideas/feedbacks from other users before posting on GitHub (unfortunately posting multiple links is not super useful by itself - the research needs to be much more precise, or even prototyped if you can :)). |
Beta Was this translation helpful? Give feedback.
-
I have read about the content on wiki which talking about:
I think it is possible to calculate custom shape like the moon shape which can save tons of time in work-arounds done by hand.
Found some resources about this solution:
filling technique: https://tronche.com/gui/x/xlib/graphics/filling-areas/XFillPolygon.html
research
from godot documentation
from more discussions
Concave Polygons
Collisions uses the Separating Axis Theorem (SAT) for its narrow-phase collision tests. One caveat to SAT is that it only works properly on convex bodies. However, concave polygons can be "faked" by using a series of Lines. Keep in mind that a polygon drawn using Lines is "hollow".
Handling true concave polygons requires breaking them down into their component convex polygons (Convex Decomposition) and testing them for collisions individually. There are plans to integrate this functionality into the library in the future, but for now, check out poly-decomp.js.
Beta Was this translation helpful? Give feedback.
All reactions