Closed ottah closed 5 months ago
Maybe I misunderstand something, but it seems that triangle_index contains only the first vertex index of the triangle. How can I get the other two vertex indices?
This should give you the triange index. In indexed geometry, you would look up the triangle with this index, and get the three vertices. In a non-indexed geometry the next three vertices should give you the triangle.
Hi @aevyrie
Sorry for bothering you again with this issue, but after looking at the code again I'm pretty sure that it does not contain the triangle index but a vertex index. Looking at this line: https://github.com/aevyrie/bevy_mod_raycast/blob/dbc5ef32fe48997a1a7eeec7434d9dd8b829e52e/src/raycast.rs#L118
Current implementation
for index in indices.chunks(3) {
let triangle_index = Some(index[0].into_usize());
How it could be implemented instead:
for (i, index) in indices.chunks(3).enumerate() {
let triangle_index = Some(i);
Ah, I see the issue. Please open a PR or a new issue, or this is going to get lost.
This change exposes the intersection's barycentric coord and the triangle index so they can be used to look up vertex attributes and texcoords.