-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Curved slopes #52
Comments
Now that I think about it, tiles 1 and 2 are concave and hence not amenable to collision detection by SAT. Also, tiles 3 and 4, albeit convex, consist of many segmented sides constituting the curve, which would give the SAT solver a lot more to do. |
Yes, this wouldn't use proper SAT, but there is a solution for it. http://www.metanetsoftware.com/technique/tutorialA.html#section2 See the "round shapes" subheading. I didn't dive into this for the plugin because I didn't feel I was ready to at the time. Hopefully this is something I could look into in the future, because then this would be the complete alternative solution to the deprecated Ninja Physics system. |
The method described in that tutorial is quite interesting. I was surprised how it worked with the convex curve as well. It seems to be a hybrid that applies SAT on the horizontal and vertical axes but computes a an overlap projection along the normal to the curve in a different way. Perhaps it's because a circular arc has certain properties. I don't know if the same assumptions can be applied to a polynomial curve as in my tiles above. Anyhow, keep up the good work! This is really a great plugin! |
Thank you! I look forward to getting more time for it next year. |
I'd like to suggest the introduction of additional curved slopes like the ones below:
I understand that collision bodies for the sloped tiles are generated from polygons which are made of straight edges, but I think with some interpolation, curved slopes can also be generated programmatically.
The formula for the curved part of the 4 tiles above are:
where c(x) = x^2 / 4w
and w is the width of the tile (e.g. 16, 32, 64, 128 etc.)
Note: I'm assuming that the Y axis points downwards, as per normal display convention.
When generating the curved slope, x would be sweeped from 0 to w by a step of 1 and y would be computed accordingly. For practical purposes, x can be incremented by a larger step, e.g. by w / 4 to reduce the number of sides.
An additional point for tile 1 and 4, or two points for 2 and 3, would need to be generated for the lower corner(s).
I can give you the formulas for the 4 tiles going down right, but as you might imagine, they are simple variants of tiles 1 to 4.
Notice how 2 and 3 have 45 degree slopes at one end, which makes it possible to combine them with straight 45 degree slopes.
Flatter versions (1/2 height) can be generated for transitioning on to straight 22.5 degree slopes as well, since their edge would end at halfway up the second tile with a tangent corresponding to the 22.5 slopes, so the second 22.5 straight slope can be placed next to it for a smooth transition.
These could be also extended to curved ceiling tiles, but they're not really that useful.
I could try extending your library myself, but I'm not sure I understand the rest of your code!
What are your thoughts on this?
The text was updated successfully, but these errors were encountered: