Exemplo n.º 1
0
    private void OnValueChanged(float value)
    {
        polycountLabel.text = $"{Math.Round(100 * value)}% ({Math.Round(value * _polycount)}/{_polycount} triangles)";

        Profiling.Start("Convert");

        var connectedMeshes = _originalMeshes.Select(x => UnityConverter.ToSharedMesh(x).ToConnectedMesh()).ToArray();

        Debug.Log(Profiling.End("Convert"));
        Profiling.Start("Clean");

        foreach (var connectedMesh in connectedMeshes)
        {
            // Important step :
            // We merge positions to increase chances of having correct topology information
            // We merge attributes in order to make interpolation properly operate on every face
            connectedMesh.MergePositions(0.0001f);
            connectedMesh.MergeAttributes();
            connectedMesh.Compact();
        }

        Debug.Log(Profiling.End("Clean"));
        Profiling.Start("Decimate");

        SceneDecimator sceneDecimator = new SceneDecimator();

        sceneDecimator.Initialize(connectedMeshes);

        sceneDecimator.DecimateToRatio(value);

        Debug.Log(Profiling.End("Decimate"));
        Profiling.Start("Convert back");

        for (int i = 0; i < connectedMeshes.Length; i++)
        {
            _meshes[i].Clear();
            connectedMeshes[i].ToSharedMesh().ToUnityMesh(_meshes[i]);
            _meshes[i].bindposes = _originalMeshes[i].bindposes;
        }

        Debug.Log(Profiling.End("Convert back"));
    }
Exemplo n.º 2
0
        private int ExecuteTask(Task task)
        {
            string name = "Task";

            if (task.ProducedFiles != null && task.ProducedFiles.Count != 0)
            {
                name = Path.GetFileName(task.ProducedFiles[0]);
            }
            var profilerEvent = Profiling.Begin(name);

            var startInfo = new ProcessStartInfo
            {
                WorkingDirectory       = task.WorkingDirectory,
                FileName               = task.CommandPath,
                Arguments              = task.CommandArguments,
                UseShellExecute        = false,
                RedirectStandardInput  = false,
                RedirectStandardOutput = true,
                RedirectStandardError  = true,
                CreateNoWindow         = true,
            };

            if (Configuration.Verbose)
            {
                lock (_locker)
                {
                    Log.Verbose("");
                    Log.Verbose(task.CommandPath);
                    Log.Verbose(task.CommandArguments);
                    Log.Verbose("");
                }
            }

            if (task.InfoMessage != null)
            {
                Log.Info(task.InfoMessage);
            }

            Process process = null;

            try
            {
                try
                {
                    process                     = new Process();
                    process.StartInfo           = startInfo;
                    process.OutputDataReceived += ProcessDebugOutput;
                    process.ErrorDataReceived  += ProcessDebugOutput;
                    process.Start();

                    process.BeginOutputReadLine();
                    process.BeginErrorReadLine();
                }
                catch (Exception ex)
                {
                    Log.Error("Failed to start local process for task");
                    Log.Exception(ex);
                    return(-1);
                }

                // Hang until process end
                process.WaitForExit();

                Profiling.End(profilerEvent);
                return(process.ExitCode);
            }
            finally
            {
                Profiling.End(profilerEvent);

                // Ensure to cleanup data
                process?.Close();
            }
        }