You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I'm trying to make a 3d TTRPG and would like to be able to place tiles based on the nav-mesh. Would it be possible to add a function to test if a particular point lies on or near a walkable point? I've been trying to use find_closest_polygon_in_box but it seems to return very inconsistent results.
Here's sample of what I have.
And the code for check_point and point_in_triangle:
fncheck_point(point:Vec3,tile_coord:UVec2,poly_index:u16,tiles:&NavMeshTiles) -> bool{let tile = tiles.get_tiles().get(&tile_coord).unwrap();let poly = &tile.polygons[poly_index asusize];let indices = &poly.indices;for i in(0..indices.len()).step_by(3){let a = tile.vertices[indices[i]asusize];let b = tile.vertices[indices[(i + 1) % indices.len()]asusize];let c = tile.vertices[indices[(i + 2) % indices.len()]asusize];ifpoint_in_triangle(point,[a, b, c]){returntrue}}returnfalse}pubfnpoint_in_triangle(point:Vec3,triangle:[Vec3;3]) -> bool{letmut a = triangle[0];letmut b = triangle[1];letmut c = triangle[2];let p = point;
a -= p;
b -= p;
c -= p;let u = b.cross(c);let v = c.cross(a);let w = a.cross(b);if u.dot(v) < 0f32{returnfalse}if u.dot(w) < 0f32{returnfalse;}true}
The text was updated successfully, but these errors were encountered:
Hi, I'm trying to make a 3d TTRPG and would like to be able to place tiles based on the nav-mesh. Would it be possible to add a function to test if a particular point lies on or near a walkable point? I've been trying to use find_closest_polygon_in_box but it seems to return very inconsistent results.
Here's sample of what I have.
And the code for check_point and point_in_triangle:
The text was updated successfully, but these errors were encountered: