-
-
Notifications
You must be signed in to change notification settings - Fork 97
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
Add support for defining holes in polygons #9127
Comments
I think it related to godotengine/godot#41447 |
looking on https://www.cs.cmu.edu/~quake/triangle.demo.html from https://github.com/libigl/triangle |
We already have Delaunay triangulation support in Godot. Also, the code you linked isn't under an open source license as its license forbids commercial use. |
Agreed, don't have other suggestions :( In the example(https://www.cs.cmu.edu/~quake/triangle.defs.html#pslg) they had an symbol "A" example called PSLG which have a hole, Thought this is what godot needed for "holed polygons" |
The navigation mesh baking can already do all that. If it is too slow it is a matter of not feeding too much source geometry data to the baking process. Recent prs like godotengine/godot#87961 help with baking chunk navigation meshes to partion too large game worlds that can not be updated in one piece at runtime without frame drops. Most of the time it is not really the baking responsible for the frame drop but a too large navigation map or scenetree that requires too much time to be parsed or synced with the update. Or too many agents that all burst forward requesting a path update on a map change at the same time. Creating a navigation mesh manually would do nothing for those performance problems. A polygon with hole does not exist. Anything with a hole are always 2+ polygons arranged around empty space. The |
thank you for good recommendations my game is 2.5d technically it has a 2d logic but represented in 3d space so NavigationPolygon won't work, it needs NavigationMesh, which I'm producing as 2d polygon and adding third dimension as 0.0. |
There is a 3D version with pr godotengine/godot#87378 that works the same as the 2D version except for having slightly different property names (AABB / Rect2). |
@smix8 thank you for useful feature, is it part of any godot releases like godot 4.3-dev3? |
The PR was merged just after 4.3.dev3 was tagged, so it'll be available in 4.3.dev4 or 4.3.beta1. |
I suspect the reason for the performance drop with the "normal" navigation mesh bake is that CSG meshes are slow to parse and stall the RenderingServer. CSG and rendering meshes are ok-ish for baking in the editor but not really functional in terms of performance to be parsed at runtime. Try to use and parse (physics) collision shapes instaed. They are a lot faster because they are ready-available on the CPU. |
@smix8 |
@Necronomicron I think means on your image you can see multiple triangles without holes connected to form plane with a hole. |
@smix8 Found my problem, just not switched In a mean time ability to set navigation mesh with holes for avoidance is a great option, because baking not always provides perfect results. BTW: let me ask side question about navigation baking. If my nav_mesh should be not in XZ plane but vertical, for instance XY, can I change baking settings to make UP direction Vector3(0, 0, 1)? |
The problem with any visual mesh is that its geometry data is not available by default on the CPU, it is GPU stored. So everytime anything needs to read geometry from a mesh the RenderingServer needs to receive all those data from the GPU and that is super-slow.
No, the baking always oriented towards Vector3.UP. You would need to bake your mesh and rotate it later, e.g. with the NavigationRegion3D transform. Note that you can not rotate a navigation mesh 90° or more away from the navigation map up orientation. |
@smix8 Thank you for detailed explanation, now I have better feeling how godot baking works. For baking orientation seems like was right by rotating whole game 90 degrees and making Y axis UP. Btw: if geometry baking so slow may be better to make |
Can not change the default without breaking compatibility for existing projects. For performance it would make more sense but also new user expectation is to just hit bake and consider everything. That is why the newer 2D baking parses both visual and collision by default. |
My suggestion as to how this proposal could be implemented: PackedInt32Array Geometry2D.triangulate_polygons (PackedVector2Array[] polygons)Works in similiar manner as triangulate_polygon but instead of expecting single polygon, it takes multiple. Polygons must abide by following rules: renderable polygons must be defined in counterclockwise order. Holes are clockwise polygons. No polygons should intersect with themselves or other polygons (these are easy check/fix manually via utilities in Geometry2D class). I think this algorithm would be reasonable to implement (altough I did notice a small mistake that the author has there, but it's easy to fix). As a bonus the method would make fixing godotengine/godot#91068 relatively easy. Actually something like this is required to fix the bug anyway, and it would be beneficial to expose it for scripting also. Optionally add support for holes in Polygon2D with property |
I think holes should be in the opposite direction. |
Good catch, I'll fix it 👍 |
What is the status of this proposal? |
My issue also regards the creation of holes inside polygons and workaround saves the day. Since Geometry2D.clip_polygons() does not clip if polygon B is completely inside polygon A, I had the idea to simply move the closest point of B regarding A, outside of A (and also create 2 auxiliary points to minimize impact). After this is done, clip_polygons() worked. polygons.mp4This works for my use case (draw a line and create a collision polygon for that line) and that was the target of it. Hopefully this helps someone find their own custom solution in the mean time.
|
Thanks! |
Describe the project you are working on
Working on infinite scrolling game and it need enemies chasing main hero.
Describe the problem or limitation you are having in your project
For purpose of enemies following hero I need updating navigation mesh but baking creates a FPS drop. Another option is just generate Navigation mesh manually but 2d polygon should have a holes, I can't find any method to make a runtime holes in polygon other than manually generate squares and fill a navigation mesh with them.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
goostengine/goost#42
Is it possible to have ability define a hole in the polygon and triangulate it?
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
Just should give a triangulated polygon with holes.
If this enhancement will not be used often, can it be worked around with a few lines of script?
It can be generated manually, but it painful.
Is there a reason why this should be core and not an add-on in the asset library?
Seems like goostengine have this option but last commit there is 2 yars ago.
The text was updated successfully, but these errors were encountered: