Skip to content
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

Terrain painting tool can generate bad geometry with explosive number of points #29

Open
1j01 opened this issue Sep 1, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@1j01
Copy link
Owner

1j01 commented Sep 1, 2024

When editing a polygonal entity, there are a number of tools to edit the polygon, one being the "paint" tool, for which I implemented a bespoke boolean add/subtract algorithm tailored to brush strokes.
The algorithm breaks down in cases where it would need to generate multiple polygons, i.e. deleting a middle part of a polygon, leaving two ends. When this happens it creates many points around the circle of the brush, and if you don't release the mouse button it can quickly escalate, slowing down the page until it totally freezes up.

The obvious thing to do is to create two (or more) entities as a copy of the original with different polygons, when it needs to be split.
However, the current model only allows editing one entity at a time, so it would have to pick one, unless this is to be changed.

Alternatively, the entity model could be changed to have terrain entities own a list of polygons instead of just one.
And perhaps a separate list of holes? What about holes?

Alternatively, multi-polygons and polygons with holes could be represented as a still a single list of points, with zero-width isthmuses and canals. This might be simpler in some ways, but it would certainly put some edge cases front and center, which would need to be handled correctly. It's also a bit unintuitive and would be weird if it showed these zero-width isthmuses and canals when editing, and e.g. allowed you to select a terrain entity via an invisible bridge between two terrain regions.

Regardless, the algorithm should be patched to avoid creating exponentially many points.

@1j01 1j01 added the bug Something isn't working label Sep 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant