Fix underflow panic in InitTriInfo
(#14893)
# Objective
- Fix #14874
## Solution
- Change the place where a panic occurs from `t < iNrTrianglesIn - 1` to
`t + 1 < iNrTrianglesIn`.
## Testing
- After the fix, the following code runs successfully without any panic.
```rust
use bevy::prelude::Mesh;
use bevy_render::{
mesh::{Indices, PrimitiveTopology},
render_asset::RenderAssetUsages,
};
const POSITIONS: &[[f32; 3]] = &[[0.0, 1.0, 0.0], [0.0, 0.0, 0.0], [0.0, 1.0, 0.0]];
const NORMALS: &[[f32; 3]] = &[[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]];
const INDICES: &[u32] = &[0, 1, 2];
const UVS: &[[f32; 2]] = &[[0.0, 1.0], [0.0, 0.0], [0.0, 1.0]];
fn main() {
let mut mesh = Mesh::new(
PrimitiveTopology::TriangleList,
RenderAssetUsages::default(),
);
mesh.insert_attribute(Mesh::ATTRIBUTE_POSITION, POSITIONS.to_vec());
mesh.insert_attribute(Mesh::ATTRIBUTE_UV_0, UVS.to_vec());
mesh.insert_attribute(Mesh::ATTRIBUTE_NORMAL, NORMALS.to_vec());
mesh.insert_indices(Indices::U32(INDICES.to_vec()));
mesh.generate_tangents().ok();
}
```
## Migration Guide
- No breaking changes introduced.