MeshLinesGenerator.GenerateLineMesh C# (CSharp) Метод

GenerateLineMesh() публичный Метод

public GenerateLineMesh ( ) : void
Результат void
    void GenerateLineMesh()
    {
        freshMeshLineIndex = GetFreeMeshLineIndex();

        if(freshMeshLineIndex == -1)
            return;
        else
        {
            tempMeshLineGO = meshLinesPoolArray[freshMeshLineIndex];
            tempMeshLineGO.SetActive(true);
            activeMeshLinesList.Add(tempMeshLineGO);

            tempMeshLineGO.transform.rotation = transform.rotation;

            float amplitudeScale;
            if(isAmplitudeScale)
            {
                amplitudeScale = Mathf.Clamp(audioDirector.averageAmplitude, minimumAmplitude, maximumAmplitude) ;

            }
            else
            {
                amplitudeScale = staticAmpltiudeScale;
            }

            tempMeshLineGO.transform.localScale = 0.03f * amplitudeScale * flatScale;

            tempMeshLineGO.transform.position = transform.position;
            //tempMeshLineGO.GetComponent<MeshLine>().UpdateCenter(verticesFrequencyDepthCount, verticesSpread);

            currentLinesForward = tempMeshLineGO.transform.forward;

        }

        tempMesh = meshLinesMeshComponentArray[freshMeshLineIndex];

        // SET HEIGHT

        for(int i = 0; i<verticesFrequencyDepthCount; i++)
        {
            tempVector = verticesArray[ verticesFrequencyDepthCount - i -1];
            tempVector.y = 16.0f * audioDirector.pseudoLogArrayBuffer[i/(dataRepCount+1)]; //* verticesAudioHeightScale * yScale; // normal version
            //tempVector.y = ( tempHeight * verticesAudioHeightScale + verticesArray[i + verticesFrequencyDepthCount].y)/2.0f ; // time axis smoothing version
            verticesArray[verticesFrequencyDepthCount - i -1] = tempVector;
        }

        // reset the audio data buffer
        for(int i = 0; i < audioDirector.pseudoLogArray.Length; i++)
            audioDirector.pseudoLogArrayBuffer[i] = 0;

        // calculate normals

        // push down normals
        for(int i = 0; i < verticesFrequencyDepthCount; i ++)
        {
            vertsArrayLast2[i + verticesFrequencyDepthCount] = vertsArrayLast2[i];
        }
        // insert new data
        for(int i = 0; i < verticesFrequencyDepthCount; i++)
        {
            vertsArrayLast2[i] = verticesArray[i];
        }

        calculationsMiniMesh.vertices = vertsArrayLast2;
        calculationsMiniMesh.RecalculateNormals();

        // apply data to mesh
        tempMesh.vertices = verticesArray;
        for(int i = 0 ; i < verticesArray.Length; i++)
        {
            meshLineDataArray[freshMeshLineIndex].meshlineVerticesArray[i] = verticesArray[i];
        }

        //meshLineDataArray[freshMeshLineIndex].meshlineVerticesArray = verticesArray;// this jsut passes a refrence to the array, we need a copy

        // looks like copying values from one array to another causes GC to go wilde spikes >_<
        // Take() is much better than manual copy though
        Profiler.BeginSample("Mesh take");
        freshLineMeshNormalsArray = calculationsMiniMesh.normals.Take(verticesFrequencyDepthCount).ToArray();
        tempMesh.normals = freshLineMeshNormalsArray; //calculationsMiniMesh.normals.Take(verticesFrequencyDepthCount).ToArray();
        Profiler.EndSample();

        // TODO  : no need for pva, will probabbly remove entierly later
        //meshLinesPVAComponentArray[freshMeshLineIndex].ResetPVA();
        //meshLinesPVAComponentArray[freshMeshLineIndex].velocity = meshSpeed * transform.forward;
    }