A ray meets a surface's triangles without gaps, across a shared edge or corner as inside a face #15
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "task/3889-a-ray-exactly-along-an-edge-shared-by-tw"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Tracker: #3889
A ray that crossed a surface exactly on an edge or a corner two or more triangles share could pass between them.
rayTrianglecomputed the hit point in each triangle's own plane and tested it against that triangle's edges. Each neighbour rounded the point its own way, so both could reject it. On the baked first map a vertical ray at Blender (180, 0), a vertex of the terrain's 2 m grid, missed the world. So did 32,946 of the 346,921 vertical rays on the map's integer lattice, the points on its grid lines and on its cells' diagonals.What changes
rayTriangle(src/physics/collision.sx) now runs the watertight ray/triangle test (Woop, Benthin and Wald, 2013).raybuilds aRay: the axis the ray's direction leans along most, and a shear that makes the ray run straight down that axis.seenplaces each corner in that frame, so a corner lands at one point whichever triangle it belongs to.acrossthe edge opposite it, is computed in f64. Products of f32s are exact there, so the sign is exact, and swapping the ends negates the value exactly. A ray that crosses a closed surface therefore meets at least one of its triangles. A ray across a shared edge or corner meets every triangle that shares it.edgeDistancetakes the distance from the edge's ends alone, by a formula symmetric in them, and every triangle sharing the edge answers the same bits. At a corner, the weights already give exactly the corner's distance. The existing tie rule, least distance and then lowest index, therefore names the lowest-indexed triangle sharing the edge or corner.Rays are queried only by tests: nothing in src/ or tools/ calls
ray, and the bake is unchanged.Tests
tests/physics_queries.sx:
nearandnearVecfail on NaN, which>let through.At master (
71450a5) the grid-line, vertex, halfway and hair-off rays fail.tests/first_map_world.sx: the ray at Blender (180, 0) over the baked map meets the ground that a ray 1 cm off meets.
groundAtno longer says its points must avoid the grid lines, and assets/scenes/first_map_prefabs.py no longer says WRECK lies off them so that a ray down meets the floor there. tests/physics_seeded.sx calls the newrayTriangleandrayHitsignatures.Evidence
edgeDistancepicking its axis by a signed difference.sak-gate fullpassed at999c9d5(gate run 818), 24 of 24.