Пример #1
0
        public override void OnInspectorGUI()
        {
            serializedObject.DrawScript();
            m_setter.Clear();

            m_setter.DrawProperty(Labels.Type, m_serializedProperties.Type);
            m_setter.DrawProperty(Labels.Operation, m_serializedProperties.Operation);
            m_setter.DrawProperty(Labels.Flip, m_serializedProperties.Flip);

            using (EditorGUILayout.VerticalScope box = new EditorGUILayout.VerticalScope(EditorStyles.helpBox))
            {
                switch (m_sdfPrimitive.Type)
                {
                case SDFPrimitiveType.Sphere:
                    m_setter.DrawVectorSettingX(Labels.Radius, m_serializedProperties.Data, min: 0f);
                    break;

                case SDFPrimitiveType.Torus:
                    m_setter.DrawVectorSettingX(Labels.MajorRadius, m_serializedProperties.Data, min: 0f);
                    m_setter.DrawVectorSettingY(Labels.MinorRadius, m_serializedProperties.Data, min: 0f);
                    break;

                case SDFPrimitiveType.Cuboid:
                    m_setter.DrawVector3Setting(Labels.Bounds, m_serializedProperties.Data, min: 0f);
                    m_setter.DrawVectorSettingW(Labels.Roundedness, m_serializedProperties.Data, min: 0f);
                    break;

                case SDFPrimitiveType.BoxFrame:
                    m_setter.DrawVector3Setting(Labels.Bounds, m_serializedProperties.Data, min: 0f);
                    m_setter.DrawVectorSettingW(Labels.Thickness, m_serializedProperties.Data, min: 0f);
                    break;
                }
            }

            m_setter.Update();
        }
        public override void OnInspectorGUI()
        {
            m_setter.Clear();

            serializedObject.DrawScript();

            GUI.enabled = false;
            EditorGUILayout.PropertyField(m_serializedProperties.ComputeShader, Labels.ComputeShader);
            GUI.enabled = true;

            GUI.enabled = false;
            EditorGUILayout.PropertyField(m_serializedProperties.SDFGroup, Labels.SDFGroup);
            GUI.enabled = true;

            bool isControlledExternally = m_serializedProperties.SettingsControlledByGrid.boolValue;

            if (isControlledExternally)
            {
                EditorGUILayout.HelpBox(Labels.SettingsControlledByGridWarning, MessageType.Info);
                return;
            }

            GUI.enabled = !isControlledExternally;

            m_setter.DrawProperty(Labels.AutoUpdate, m_serializedProperties.AutoUpdate);

            m_setter.DrawEnumSetting <OutputMode>(Labels.OutputMode, m_serializedProperties.OutputMode, onValueChangedCallback: m_sdfGroupMeshGen.OnOutputModeChanged);

            OutputMode outputMode = (OutputMode)m_serializedProperties.OutputMode.enumValueIndex;

            if (outputMode == OutputMode.Procedural)
            {
                m_setter.DrawProperty(Labels.ProceduralMaterial, m_serializedProperties.ProceduralMaterial);
            }
            else if (outputMode == OutputMode.MeshFilter)
            {
                m_setter.DrawProperty(Labels.IsAsynchronous, m_serializedProperties.IsAsynchronous);
            }

            if (m_isVoxelSettingsOpen = EditorGUILayout.Foldout(m_isVoxelSettingsOpen, Labels.VoxelSettings, true))
            {
                using (EditorGUILayout.VerticalScope box = new EditorGUILayout.VerticalScope(EditorStyles.helpBox))
                {
                    using (EditorGUI.IndentLevelScope indent = new EditorGUI.IndentLevelScope())
                    {
                        m_setter.DrawProperty(Labels.CellSizeMode, m_serializedProperties.CellSizeMode);

                        CellSizeMode cellSizeMode = (CellSizeMode)m_serializedProperties.CellSizeMode.enumValueIndex;

                        if (cellSizeMode == CellSizeMode.Fixed)
                        {
                            m_setter.DrawFloatSetting(Labels.CellSize, m_serializedProperties.CellSize, min: 0.005f, onValueChangedCallback: m_sdfGroupMeshGen.OnCellSizeChanged);
                            m_setter.DrawIntSetting(Labels.CellCount, m_serializedProperties.CellCount, min: 2, max: 200, onValueChangedCallback: m_sdfGroupMeshGen.OnCellCountChanged);
                        }
                        else if (cellSizeMode == CellSizeMode.Density)
                        {
                            m_setter.DrawFloatSetting(Labels.VolumeSize, m_serializedProperties.VolumeSize, min: 0.05f, onValueChangedCallback: m_sdfGroupMeshGen.OnDensitySettingChanged);
                            m_setter.DrawFloatSetting(Labels.CellDensity, m_serializedProperties.CellDensity, min: 0.05f, onValueChangedCallback: m_sdfGroupMeshGen.OnDensitySettingChanged);
                        }
                    }
                }
            }

            if (m_isAlgorithmSettingsOpen = EditorGUILayout.Foldout(m_isAlgorithmSettingsOpen, Labels.AlgorithmSettings, true))
            {
                using (EditorGUILayout.VerticalScope box = new EditorGUILayout.VerticalScope(EditorStyles.helpBox))
                {
                    using (EditorGUI.IndentLevelScope indent = new EditorGUI.IndentLevelScope())
                    {
                        m_setter.DrawEnumSetting <IsosurfaceExtractionType>(Labels.IsosurfaceExtractionType, m_serializedProperties.IsosurfaceExtractionType, onValueChangedCallback: m_sdfGroupMeshGen.OnIsosurfaceExtractionTypeChanged);

                        EditorGUILayout.Space();
                        EditorGUILayout.LabelField("Normal Settings", EditorStyles.boldLabel);

                        m_setter.DrawFloatSetting(Labels.MaxAngleTolerance, m_serializedProperties.MaxAngleTolerance, min: 0f, max: 180f, onValueChangedCallback: m_sdfGroupMeshGen.OnMaxAngleToleranceChanged);
                        m_setter.DrawFloatSetting(Labels.VisualNormalSmoothing, m_serializedProperties.VisualNormalSmoothing, min: 1e-5f, max: 10f, onValueChangedCallback: m_sdfGroupMeshGen.OnVisualNormalSmoothingChanged);

                        EditorGUILayout.Space();
                        EditorGUILayout.LabelField("Edge Intersection Settings", EditorStyles.boldLabel);

                        m_setter.DrawEnumSetting <EdgeIntersectionType>(Labels.EdgeIntersectionType, m_serializedProperties.EdgeIntersectionType, onValueChangedCallback: m_sdfGroupMeshGen.OnBinarySearchIterationsChanged);

                        if ((EdgeIntersectionType)m_serializedProperties.EdgeIntersectionType.enumValueIndex == EdgeIntersectionType.BinarySearch)
                        {
                            m_setter.DrawIntSetting(Labels.BinarySearchIterations, m_serializedProperties.BinarySearchIterations, min: 1, onValueChangedCallback: m_sdfGroupMeshGen.OnBinarySearchIterationsChanged);
                        }

                        EditorGUILayout.Space();
                        EditorGUILayout.LabelField("Gradient Descent Settings", EditorStyles.boldLabel);

                        m_setter.DrawBoolSetting(Labels.ApplyGradientDescent, m_serializedProperties.ApplyGradientDescent, onValueChangedCallback: m_sdfGroupMeshGen.OnGradientDescentIterationsChanged);

                        if (m_serializedProperties.ApplyGradientDescent.boolValue)
                        {
                            m_setter.DrawIntSetting(Labels.GradientDescentIterations, m_serializedProperties.GradientDescentIterations, min: 1, onValueChangedCallback: m_sdfGroupMeshGen.OnGradientDescentIterationsChanged);
                        }
                    }
                }
            }

            if (m_isDebugSettingsOpen = EditorGUILayout.Foldout(m_isDebugSettingsOpen, Labels.DebugSettings, true))
            {
                using (EditorGUILayout.VerticalScope box = new EditorGUILayout.VerticalScope(EditorStyles.helpBox))
                {
                    using (EditorGUI.IndentLevelScope indent = new EditorGUI.IndentLevelScope())
                    {
                        m_setter.DrawProperty(Labels.ShowGrid, m_serializedProperties.ShowGrid);
                    }
                }
            }

            m_setter.Update();

            GUI.enabled = true;
        }
        public override void OnInspectorGUI()
        {
            m_setter.Clear();

            serializedObject.DrawScript();

            if (GUILayout.Button("Update Mesh"))
            {
                m_sdfGroupMeshGen.UpdateMesh();
            }

            GUI.enabled = false;
            EditorGUILayout.PropertyField(m_serializedProperties.ComputeShader, Labels.ComputeShader);
            GUI.enabled = true;

            GUI.enabled = false;
            EditorGUILayout.PropertyField(m_serializedProperties.SDFGroup, Labels.SDFGroup);
            GUI.enabled = true;

            m_setter.DrawProperty(Labels.AutoUpdate, m_serializedProperties.AutoUpdate);

            m_setter.DrawEnumSetting <OutputMode>(Labels.OutputMode, m_serializedProperties.OutputMode, onValueChangedCallback: m_sdfGroupMeshGen.OnOutputModeChanged);

            if (m_sdfGroupMeshGen.OutputMode == OutputMode.Procedural)
            {
                m_setter.DrawProperty(Labels.ProceduralMaterial, m_serializedProperties.ProceduralMaterial);
            }
            else if (m_sdfGroupMeshGen.OutputMode == OutputMode.MeshFilter)
            {
                m_setter.DrawProperty(Labels.IsAsynchronous, m_serializedProperties.IsAsynchronous);
            }

            if (m_isVoxelSettingsOpen = EditorGUILayout.Foldout(m_isVoxelSettingsOpen, Labels.VoxelSettings, true))
            {
                using (EditorGUILayout.VerticalScope box = new EditorGUILayout.VerticalScope(EditorStyles.helpBox))
                {
                    using (EditorGUI.IndentLevelScope indent = new EditorGUI.IndentLevelScope())
                    {
                        m_setter.DrawProperty(Labels.CellSizeMode, m_serializedProperties.CellSizeMode);

                        if (m_sdfGroupMeshGen.CellSizeMode == CellSizeMode.Fixed)
                        {
                            m_setter.DrawFloatSetting(Labels.CellSize, m_serializedProperties.CellSize, min: 0.005f, onValueChangedCallback: m_sdfGroupMeshGen.OnCellSizeChanged);
                            m_setter.DrawIntSetting(Labels.CellCount, m_serializedProperties.CellCount, min: 2, max: 200, onValueChangedCallback: m_sdfGroupMeshGen.OnCellCountChanged);
                        }
                        else if (m_sdfGroupMeshGen.CellSizeMode == CellSizeMode.Density)
                        {
                            m_setter.DrawFloatSetting(Labels.VolumeSize, m_serializedProperties.VolumeSize, min: 0.05f, onValueChangedCallback: m_sdfGroupMeshGen.OnDensitySettingChanged);
                            m_setter.DrawFloatSetting(Labels.CellDensity, m_serializedProperties.CellDensity, min: 0.05f, onValueChangedCallback: m_sdfGroupMeshGen.OnDensitySettingChanged);
                        }
                    }
                }
            }

            if (m_isAlgorithmSettingsOpen = EditorGUILayout.Foldout(m_isAlgorithmSettingsOpen, Labels.AlgorithmSettings, true))
            {
                using (EditorGUILayout.VerticalScope box = new EditorGUILayout.VerticalScope(EditorStyles.helpBox))
                {
                    using (EditorGUI.IndentLevelScope indent = new EditorGUI.IndentLevelScope())
                    {
                        m_setter.DrawEnumSetting <IsosurfaceExtractionType>(Labels.IsosurfaceExtractionType, m_serializedProperties.IsosurfaceExtractionType, onValueChangedCallback: m_sdfGroupMeshGen.OnIsosurfaceExtractionTypeChanged);

                        if (m_sdfGroupMeshGen.IsosurfaceExtractionType == IsosurfaceExtractionType.DualContouring)
                        {
                            m_setter.DrawFloatSetting(Labels.ConstrainToCellUnits, m_serializedProperties.ConstrainToCellUnits, min: 0f, onValueChangedCallback: m_sdfGroupMeshGen.OnConstrainToCellUnitsChanged);
                        }

                        EditorGUILayout.Space();
                        EditorGUILayout.LabelField("Normal Settings", EditorStyles.boldLabel);

                        m_setter.DrawFloatSetting(Labels.MaxAngleTolerance, m_serializedProperties.MaxAngleTolerance, min: 0f, max: 180f, onValueChangedCallback: m_sdfGroupMeshGen.OnMaxAngleToleranceChanged);
                        m_setter.DrawFloatSetting(Labels.VisualNormalSmoothing, m_serializedProperties.VisualNormalSmoothing, min: 1e-5f, max: 10f, onValueChangedCallback: m_sdfGroupMeshGen.OnVisualNormalSmoothingChanged);

                        if (m_sdfGroupMeshGen.IsosurfaceExtractionType == IsosurfaceExtractionType.DualContouring)
                        {
                            EditorGUILayout.Space();
                            EditorGUILayout.LabelField("QEF Settings", EditorStyles.boldLabel);

                            m_setter.DrawBoolSetting(Labels.OverrideQEFSettings, m_serializedProperties.OverrideQEFSettings, onValueChangedCallback: m_sdfGroupMeshGen.OnQEFSettingsOverrideChanged);

                            if (m_sdfGroupMeshGen.OverrideQEFSettings)
                            {
                                m_setter.DrawIntSetting(Labels.QEFSweeps, m_serializedProperties.QEFSweeps, min: 1, onValueChangedCallback: m_sdfGroupMeshGen.OnQEFSettingsOverrideChanged);
                                m_setter.DrawFloatSetting(Labels.QEFPseudoInverseThreshold, m_serializedProperties.QEFPseudoInverseThreshold, min: 1e-7f, onValueChangedCallback: m_sdfGroupMeshGen.OnQEFSettingsOverrideChanged);
                            }

                            EditorGUILayout.Space();
                            EditorGUILayout.LabelField("Nudge Settings", EditorStyles.boldLabel);

                            m_setter.DrawFloatSetting(Labels.NudgeVerticesToAverageNormalScalar, m_serializedProperties.NudgeVerticesToAverageNormalScalar, min: 0f, onValueChangedCallback: m_sdfGroupMeshGen.OnNudgeSettingsChanged);
                            m_setter.DrawFloatSetting(Labels.NudgeMaxMagnitude, m_serializedProperties.NudgeMaxMagnitude, min: 0f, onValueChangedCallback: m_sdfGroupMeshGen.OnNudgeSettingsChanged);
                        }

                        EditorGUILayout.Space();
                        EditorGUILayout.LabelField("Edge Intersection Settings", EditorStyles.boldLabel);

                        m_setter.DrawEnumSetting <EdgeIntersectionType>(Labels.EdgeIntersectionType, m_serializedProperties.EdgeIntersectionType, onValueChangedCallback: m_sdfGroupMeshGen.OnEdgeIntersectionTypeChanged);

                        if (m_sdfGroupMeshGen.EdgeIntersectionType == EdgeIntersectionType.BinarySearch)
                        {
                            m_setter.DrawIntSetting(Labels.BinarySearchIterations, m_serializedProperties.BinarySearchIterations, min: 1, onValueChangedCallback: m_sdfGroupMeshGen.OnBinarySearchIterationsChanged);
                        }

                        EditorGUILayout.Space();
                        EditorGUILayout.LabelField("Gradient Descent Settings", EditorStyles.boldLabel);

                        m_setter.DrawBoolSetting(Labels.ApplyGradientDescent, m_serializedProperties.ApplyGradientDescent, onValueChangedCallback: m_sdfGroupMeshGen.OnApplyGradientDescentChanged);

                        if (m_sdfGroupMeshGen.ApplyGradientDescent)
                        {
                            m_setter.DrawIntSetting(Labels.GradientDescentIterations, m_serializedProperties.GradientDescentIterations, min: 1, onValueChangedCallback: m_sdfGroupMeshGen.OnGradientDescentIterationsChanged);
                        }
                    }
                }
            }

            if (m_isDebugSettingsOpen = EditorGUILayout.Foldout(m_isDebugSettingsOpen, Labels.DebugSettings, true))
            {
                using (EditorGUILayout.VerticalScope box = new EditorGUILayout.VerticalScope(EditorStyles.helpBox))
                {
                    using (EditorGUI.IndentLevelScope indent = new EditorGUI.IndentLevelScope())
                    {
                        m_setter.DrawProperty(Labels.ShowGrid, m_serializedProperties.ShowGrid);
                    }
                }
            }

            m_setter.Update();
        }
Пример #4
0
        public override void OnInspectorGUI()
        {
            serializedObject.DrawScript();
            m_setter.Clear();

            m_setter.DrawProperty(Labels.MeshAsset, m_serializedProperties.MeshAsset);

            bool hasMeshAsset = m_serializedProperties.MeshAsset.objectReferenceValue;

            if (!hasMeshAsset)
            {
                EditorGUILayout.HelpBox(Labels.MeshAssetRequiredMessage, MessageType.Warning);
            }

            GUI.enabled = hasMeshAsset;

            m_setter.DrawProperty(Labels.Operation, m_serializedProperties.Operation);
            m_setter.DrawProperty(Labels.Flip, m_serializedProperties.Flip);
            m_setter.DrawFloatSetting(Labels.Smoothing, m_serializedProperties.Smoothing, min: 0f);

            if (m_isMaterialOpen = EditorGUILayout.Foldout(m_isMaterialOpen, Labels.Material, true))
            {
                using (EditorGUILayout.VerticalScope box = new EditorGUILayout.VerticalScope(EditorStyles.helpBox))
                {
                    using (EditorGUI.IndentLevelScope indent = new EditorGUI.IndentLevelScope())
                    {
                        m_setter.DrawProperty(Labels.MaterialType, m_serializedProperties.MaterialType);

                        if (m_sdfMesh.Material.Type != SDFMaterial.MaterialType.None)
                        {
                            if (m_sdfMesh.Material.Type == SDFMaterial.MaterialType.Texture)
                            {
                                m_setter.DrawProperty(Labels.MaterialTexture, m_serializedProperties.MaterialTexture);
                            }

                            m_setter.DrawProperty(Labels.Colour, m_serializedProperties.Colour);
                            m_setter.DrawFloatSetting(Labels.MaterialSmoothing, m_serializedProperties.MaterialSmoothing, min: 0f);
                            m_setter.DrawProperty(Labels.Emission, m_serializedProperties.Emission);
                            m_setter.DrawProperty(Labels.Metallic, m_serializedProperties.Metallic);
                            m_setter.DrawProperty(Labels.Smoothness, m_serializedProperties.Smoothness);
                            m_setter.DrawProperty(Labels.SubsurfaceColour, m_serializedProperties.SubsurfaceColour);
                            m_setter.DrawProperty(Labels.SubsurfaceScatteringPower, m_serializedProperties.SubsurfaceScatteringPower);
                        }
                    }
                }
            }

            m_setter.Update();

            GUI.enabled = true;
        }
Пример #5
0
        public override void OnInspectorGUI()
        {
            serializedObject.DrawScript();
            m_setter.Clear();

            m_setter.DrawProperty(Labels.Type, m_serializedProperties.Type);
            m_setter.DrawProperty(Labels.Operation, m_serializedProperties.Operation);
            m_setter.DrawProperty(Labels.Flip, m_serializedProperties.Flip);
            m_setter.DrawFloatSetting(Labels.Smoothing, m_serializedProperties.Smoothing, min: 0f);

            using (EditorGUILayout.VerticalScope box = new EditorGUILayout.VerticalScope(EditorStyles.helpBox))
            {
                switch (m_sdfPrimitive.Type)
                {
                case SDFPrimitiveType.Sphere:
                    m_setter.DrawVectorSettingX(Labels.Radius, m_serializedProperties.Data, min: 0f);
                    break;

                case SDFPrimitiveType.Torus:
                    m_setter.DrawVectorSettingX(Labels.MajorRadius, m_serializedProperties.Data, min: 0f);
                    m_setter.DrawVectorSettingY(Labels.MinorRadius, m_serializedProperties.Data, min: 0f);
                    break;

                case SDFPrimitiveType.Cuboid:
                    m_setter.DrawVector3Setting(Labels.Bounds, m_serializedProperties.Data, min: 0f);
                    m_setter.DrawVectorSettingW(Labels.Roundedness, m_serializedProperties.Data, min: 0f);
                    break;

                case SDFPrimitiveType.BoxFrame:
                    m_setter.DrawVector3Setting(Labels.Bounds, m_serializedProperties.Data, min: 0f);
                    m_setter.DrawVectorSettingW(Labels.Thickness, m_serializedProperties.Data, min: 0f);
                    break;

                case SDFPrimitiveType.Cylinder:
                    m_setter.DrawVectorSettingX(Labels.CylinderRadius, m_serializedProperties.Data, min: 0f);
                    m_setter.DrawVectorSettingY(Labels.CylinderLength, m_serializedProperties.Data, min: 0f);
                    break;
                }
            }

            if (m_isMaterialOpen = EditorGUILayout.Foldout(m_isMaterialOpen, Labels.Material, true))
            {
                using (EditorGUILayout.VerticalScope box = new EditorGUILayout.VerticalScope(EditorStyles.helpBox))
                {
                    using (EditorGUI.IndentLevelScope indent = new EditorGUI.IndentLevelScope())
                    {
                        m_setter.DrawProperty(Labels.MaterialType, m_serializedProperties.MaterialType);

                        if (m_sdfPrimitive.Material.Type != SDFMaterial.MaterialType.None)
                        {
                            if (m_sdfPrimitive.Material.Type == SDFMaterial.MaterialType.Texture)
                            {
                                m_setter.DrawProperty(Labels.MaterialTexture, m_serializedProperties.MaterialTexture);
                            }

                            m_setter.DrawProperty(Labels.Colour, m_serializedProperties.Colour);
                            m_setter.DrawFloatSetting(Labels.MaterialSmoothing, m_serializedProperties.MaterialSmoothing, min: 0f);
                            m_setter.DrawProperty(Labels.Emission, m_serializedProperties.Emission);
                            m_setter.DrawProperty(Labels.Metallic, m_serializedProperties.Metallic);
                            m_setter.DrawProperty(Labels.Smoothness, m_serializedProperties.Smoothness);
                            m_setter.DrawProperty(Labels.SubsurfaceColour, m_serializedProperties.SubsurfaceColour);
                            m_setter.DrawProperty(Labels.SubsurfaceScatteringPower, m_serializedProperties.SubsurfaceScatteringPower);
                        }
                    }
                }
            }

            m_setter.Update();
        }