Allow "on edge" interior sampling
This commit is contained in:
parent
d044295b75
commit
879c6af856
@ -228,8 +228,8 @@ impl ShapeSample for Rhombus {
|
|||||||
type Output = Vec2;
|
type Output = Vec2;
|
||||||
|
|
||||||
fn sample_interior<R: Rng + ?Sized>(&self, rng: &mut R) -> Vec2 {
|
fn sample_interior<R: Rng + ?Sized>(&self, rng: &mut R) -> Vec2 {
|
||||||
let x: f32 = rng.gen_range(0.0..1.0);
|
let x: f32 = rng.gen_range(0.0..=1.0);
|
||||||
let y: f32 = rng.gen_range(0.0..1.0);
|
let y: f32 = rng.gen_range(0.0..=1.0);
|
||||||
|
|
||||||
let unit_p = Vec2::NEG_X + x * Vec2::ONE + Vec2::new(y, -y);
|
let unit_p = Vec2::NEG_X + x * Vec2::ONE + Vec2::new(y, -y);
|
||||||
unit_p * self.half_diagonals
|
unit_p * self.half_diagonals
|
||||||
|
Loading…
Reference in New Issue
Block a user