Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/j-bbr/PolygonColliderSimplification
A set of scripts to reduce the complexity of Polygon2D and Edge Colliders in Unity
https://github.com/j-bbr/PolygonColliderSimplification
Last synced: 2 months ago
JSON representation
A set of scripts to reduce the complexity of Polygon2D and Edge Colliders in Unity
- Host: GitHub
- URL: https://github.com/j-bbr/PolygonColliderSimplification
- Owner: j-bbr
- License: mit
- Created: 2017-05-25T17:25:11.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-06-09T10:09:41.000Z (over 7 years ago)
- Last Synced: 2024-08-03T19:09:58.286Z (6 months ago)
- Language: C#
- Size: 31.3 KB
- Stars: 137
- Watchers: 6
- Forks: 28
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: license.txt
Awesome Lists containing this project
- awesome-unity-open-source-on-github - PolygonColliderSimplification - A set of scripts to reduce the complexity of Polygon2D and Edge Colliders (Optimization)
README
# Polygon Collider Simplification
A couple of scripts for creating efficient non primitive 2d colliders in Unity(Edge Collider 2D and Polygon Collider 2D).
You can adjust and see the results of the optimization in the Editor without entering playmode.## Polygon Collider
![Polygon Collider Optimization](https://img.itch.zone/aW1hZ2UvNjgxOTcvMzEwMTcyLmdpZg==/original/iZAynj.gif)
## Edge Collider
![Edge Collider Optimization](https://img.itch.zone/aW1hZ2UvNjgxOTcvMzEwMTcxLmdpZg==/original/VjvR9G.gif)
## How it works
Both scripts remove points from the collision shape with a given reduction tolerance using the Ramer-Douglas-Peucker Algorithm. The Edge Collider Optimizer works in conjunction with a polygon collider by casting down a lot of rays from the upper edge of the bounds of the polygon and creating an edge out of the intersection points.
That edge is then optimized with the given tolerance. After your satisfied with the result you can remove the polygon collider (and the optimization scripts as well, they are only thought for the Editor).
Because the rays are cast down this doesn’t deal with overhanging sprite geometry, but still gives you a better starting point to manually adjust the edge than the default line with 2 points.Link to the original c# implementation of the Ramer-Douglas-Peucker Algorithm (modified slightly for Unity):
http://www.codeproject.com/Articles/18936/A-Csharp-Implementation-of-Douglas-Peucker-Line-Ap## License
MIT