@@ -43,6 +43,8 @@ public partial class AudioCore
4343 [ Range ( 0 , 1 ) ]
4444 public float velocityMultiplier = 0.95f ;
4545 public int batchSize = 100 ;
46+ [ Tooltip ( "Randomization of triangle index, set to 0 if you don't want to randomize it." ) ]
47+ public uint seed ;
4648 [ InspectOnly ] public int totalTriangles ;
4749
4850 private Mesh modifiedSampleMesh ;
@@ -90,6 +92,25 @@ private void InitAudioVisualizer()
9092 bandVelocities . CopyFrom ( bandVelocities ) ;
9193
9294 sampleMeshData . Dispose ( ) ;
95+
96+ if ( seed != 0 )
97+ {
98+ // if randomized is turned on
99+ int [ ] seqArray = MathUtil . GenerateSeqArray ( totalTriangles ) ;
100+ MathUtil . ShuffleArray < int > ( ref seqArray , seed ) ;
101+
102+ // triangle indices
103+ NativeArray < int > trianglesCopy = new NativeArray < int > ( triangles , Allocator . Temp ) ;
104+
105+ for ( int s = 0 ; s < seqArray . Length ; s ++ )
106+ {
107+ triangles [ s * 3 ] = trianglesCopy [ seqArray [ s ] * 3 ] ;
108+ triangles [ s * 3 + 1 ] = trianglesCopy [ seqArray [ s ] * 3 + 1 ] ;
109+ triangles [ s * 3 + 2 ] = trianglesCopy [ seqArray [ s ] * 3 + 2 ] ;
110+ }
111+
112+ trianglesCopy . Dispose ( ) ;
113+ }
93114 }
94115
95116 private void UpdateAudioVisualizer ( )
@@ -151,7 +172,7 @@ public struct AudioMeshVisualizer : IJobParallelFor
151172 public int bandAverage ;
152173
153174 [ NativeDisableContainerSafetyRestriction ]
154- [ WriteOnly ] public NativeArray < float3 > vertices ;
175+ public NativeArray < float3 > vertices ;
155176
156177 public NativeArray < float > prevBands ;
157178 public NativeArray < float > bandVelocities ;
0 commit comments