polyanya icon indicating copy to clipboard operation
polyanya copied to clipboard

Emit polygon path

Open taktoa opened this issue 2 years ago • 5 comments

For 2D pathfinding, the current Path type works fine, but if you want to do 3D pathfinding (with multiple overlapping floors etc.), the current interface is insufficient. In particular, I'm imagining that you project out the X and Y positions of each point in a mesh, which may result in duplicate points. Polyanya supports duplicate points and overlapping/zero-area triangles, at least from my experimentation, but since it only outputs a list of positions it's impossible to know which of many overlapping triangles a given element in a path is from (and therefore what its Z position is). If the indices of polygons traversed were included in the Path then this wouldn't be an issue.

taktoa avatar May 22 '23 02:05 taktoa

Hmm, looks like I was mistaken and Polyanya only supports duplicate points and zero-area triangles, but not overlapping triangles.

taktoa avatar May 22 '23 02:05 taktoa

Polyanya with overlapping meshes!

output.webm

This is on a local fork where I've converted everything to use indices to uniquely identify points instead of Vec2s. The purpose of this demo was actually just to double check that that was working as expected.

gmorenz avatar Jun 25 '24 17:06 gmorenz

I also have something working for overlapping meshes in https://github.com/vleue/polyanya/pull/62

https://github.com/user-attachments/assets/108136da-4b41-4f79-be85-877ba048ec6f

This is still working with Vec2s. @gmorenz did you continue with your demo? Did you put it somewhere on GitHub?

mockersf avatar Sep 06 '24 18:09 mockersf

I didn't continue with my demo. The math I thought would work to generalize this to non-uniform-cost movement didn't pan out as I expected (which was actually what I was more interested in at the time), and after hitting a dead end there I moved on for the time being.

I'm happy to push the non-planar demo to github tomorrow

gmorenz avatar Sep 07 '24 01:09 gmorenz

The math I thought would work to generalize this to non-uniform-cost movement didn't pan out as I expected (which was actually what I was more interested in at the time), and after hitting a dead end there I moved on for the time being.

I have something that works for that now, see this test: https://github.com/vleue/polyanya/blob/c74391be7a14c8070c188664560c4c3872a785ea/src/stitching.rs#L899

it's setting up a navmesh with 5 layers like so:

00
13
23
44

with layers 1 and 2 having a higher cost of traversal than layer 3, then for 20 points equally distributed in a line in layer 0, find the path to the corresponding points in layer 4. The path correctly goes either through slower layers or around them depending on the cost.

@taktoa to support overlapping polygons I added the notion of "layer" that can be connected at some of their vertices. The path with the layer information can be retrieved when feature detailed-layers is enabled, as it can be costly https://github.com/vleue/polyanya/blob/c74391be7a14c8070c188664560c4c3872a785ea/src/lib.rs#L64-L66 Does that work for you?

mockersf avatar Sep 07 '24 13:09 mockersf