Exemplo n.º 1
0
    private bool ComputeSourceAverage(ref Vector3 _out, bool _includeInputField = false)
    {
        NPVoxModel     voxModel   = m_context.MeshOutput.GetVoxModel();
        List <Vector3> normalsSum = new List <Vector3>();

        Vector3[] normalsMesh = m_context.PreviewMesh.normals;

        foreach (NPVoxMeshData vox in m_context.MeshOutput.GetVoxMeshData())
        {
            if (!vox.isHidden)
            {
                NPVoxCoord coord = vox.voxCoord;
                int        index = voxModel.GetIndex(coord);

                if (GetSelection(coord) == SELECTED_SOURCE)
                {
                    normalsSum.Add(normalsMesh[vox.vertexIndexOffsetBegin]);
                }
            }
        }

        if (_includeInputField)
        {
            normalsSum.Add(m_normalField);
        }

        bool bResult = MathUtilities.Statistical.ComputeAverage(normalsSum, ref _out);

        return(bResult);
    }
Exemplo n.º 2
0
    private void ApplyNormalStage()
    {
        NPVoxModel voxModel = m_context.MeshOutput.GetVoxModel();

        Vector3[] normals = m_context.PreviewMesh.normals;

        NPVoxNormalProcessor_UserOverride processor = ( NPVoxNormalProcessor_UserOverride )m_context.ViewedProcessor;

        foreach (NPVoxMeshData vox in m_context.MeshOutput.GetVoxMeshData())
        {
            if (!vox.isHidden)
            {
                NPVoxCoord coord = vox.voxCoord;
                int        index = voxModel.GetIndex(coord);

                if (GetSelection(coord) == SELECTED_TARGET)
                {
                    processor.m_overrideNormalsRT[vox.voxCoord] = m_normalStage[index];

                    for (int i = 0; i < vox.numVertices; i++)
                    {
                        normals[vox.vertexIndexOffsetBegin + i] = m_normalStage[index];
                    }
                }
            }
        }

        RemoveRedundantOverrides();

        UnityEditor.EditorUtility.SetDirty(processor);

        m_context.PreviewMesh.normals = normals;
    }