@@ -37,13 +37,25 @@ public struct ParticleVector2Parameter : IEquatable<ParticleVector2Parameter>
3737 /// </summary>
3838 public Vector2 RandomMax ;
3939
40+ /// <summary>
41+ /// When <see langword="true"/> and <see cref="Kind"/> is <see cref="ParticleValueKind.Random"/>, a single random
42+ /// value is sampled and applied to both X and Y, preserving the aspect ratio of each particle.
43+ /// </summary>
44+ /// <remarks>
45+ /// The X components of <see cref="RandomMin"/> and <see cref="RandomMax"/> define the uniform range.
46+ /// When <see langword="false"/>, X and Y are sampled independently.
47+ /// </remarks>
48+ public bool Uniform ;
49+
4050 /// <summary>
4151 /// Gets the current value of this parameter based on its <see cref="Kind"/>
4252 /// </summary>
4353 /// <remarks>
4454 /// If <see cref="Kind"/> is <see cref="ParticleValueKind.Constant"/>, returns <see cref="Constant"/>.
45- /// If <see cref="Kind"/> is <see cref="ParticleValueKind.Random"/>, returns a random value between
46- /// <see cref="RandomMin"/> and <see cref="RandomMax"/>.
55+ /// If <see cref="Kind"/> is <see cref="ParticleValueKind.Random"/> and <see cref="Uniform"/> is
56+ /// <see langword="false"/>, returns a random value with X and Y sampled independently from their respective ranges.
57+ /// If <see cref="Kind"/> is <see cref="ParticleValueKind.Random"/> and <see cref="Uniform"/> is
58+ /// <see langword="true"/>, returns a random value with a single sample applied to both X and Y using the X range.
4759 /// </remarks>
4860 public Vector2 Value
4961 {
@@ -55,6 +67,12 @@ public Vector2 Value
5567 return Constant ;
5668 }
5769
70+ if ( Uniform )
71+ {
72+ float s = FastRandom . Shared . NextSingle ( RandomMin . X , RandomMax . X ) ;
73+ return new Vector2 ( s , s ) ;
74+ }
75+
5876 Vector2 v ;
5977 v . X = FastRandom . Shared . NextSingle ( RandomMin . X , RandomMax . X ) ;
6078 v . Y = FastRandom . Shared . NextSingle ( RandomMin . Y , RandomMax . Y ) ;
0 commit comments