mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 15:14:50 +00:00
Fix Triangle2d
/Triangle3d
interior sampling to correctly follow triangle (#12766)
# Objective When I wrote #12747 I neglected to translate random samples from triangles back to the point where they originated, so they would be sampled near the origin instead of at the actual triangle location. ## Solution Translate by the first vertex location so that the samples follow the actual triangle.
This commit is contained in:
parent
741803d8c9
commit
bcdb20d4f3
1 changed files with 2 additions and 2 deletions
|
@ -159,9 +159,9 @@ fn sample_triangle_interior<P: NormedVectorSpace, R: Rng + ?Sized>(
|
|||
if u + v > 1. {
|
||||
let u1 = 1. - v;
|
||||
let v1 = 1. - u;
|
||||
ab * u1 + ac * v1
|
||||
a + (ab * u1 + ac * v1)
|
||||
} else {
|
||||
ab * u + ac * v
|
||||
a + (ab * u + ac * v)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue