diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Grid/EditorGridComponent.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Grid/EditorGridComponent.cpp index f500bdd6e2..81fc3aa170 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Grid/EditorGridComponent.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Grid/EditorGridComponent.cpp @@ -54,13 +54,14 @@ namespace AZ ->ClassElement(AZ::Edit::ClassElements::EditorData, "") ->Attribute(AZ::Edit::Attributes::AutoExpand, true) ->DataElement(AZ::Edit::UIHandlers::Default, &GridComponentConfig::m_gridSize, "Grid Size", "Grid width and depth") - ->Attribute(AZ::Edit::Attributes::Min, 0.0f) + ->Attribute(AZ::Edit::Attributes::Min, GridComponentController::MinGridSize) + ->Attribute(AZ::Edit::Attributes::Max, GridComponentController::MaxGridSize) ->Attribute(AZ::Edit::Attributes::Suffix, " m") ->DataElement(AZ::Edit::UIHandlers::Default, &GridComponentConfig::m_primarySpacing, "Primary Grid Spacing", "Amount of space between grid lines") - ->Attribute(AZ::Edit::Attributes::Min, 0.01f) + ->Attribute(AZ::Edit::Attributes::Min, GridComponentController::MinSpacing) ->Attribute(AZ::Edit::Attributes::Suffix, " m") ->DataElement(AZ::Edit::UIHandlers::Default, &GridComponentConfig::m_secondarySpacing, "Secondary Grid Spacing", "Amount of space between sub-grid lines") - ->Attribute(AZ::Edit::Attributes::Min, 0.01f) + ->Attribute(AZ::Edit::Attributes::Min, GridComponentController::MinSpacing) ->Attribute(AZ::Edit::Attributes::Suffix, " m") ->DataElement(AZ::Edit::UIHandlers::Color, &GridComponentConfig::m_axisColor, "Axis Color", "Color of the grid axis") ->DataElement(AZ::Edit::UIHandlers::Color, &GridComponentConfig::m_primaryColor, "Primary Color", "Color of the primary grid lines") diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Grid/GridComponentController.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Grid/GridComponentController.cpp index c2f9c896af..279c8d9035 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Grid/GridComponentController.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Grid/GridComponentController.cpp @@ -115,7 +115,7 @@ namespace AZ void GridComponentController::SetSize(float gridSize) { - m_configuration.m_gridSize = gridSize; + m_configuration.m_gridSize = AZStd::clamp(gridSize, MinGridSize, MaxGridSize); m_dirty = true; } @@ -126,7 +126,7 @@ namespace AZ void GridComponentController::SetPrimarySpacing(float gridPrimarySpacing) { - m_configuration.m_primarySpacing = gridPrimarySpacing; + m_configuration.m_primarySpacing = AZStd::max(gridPrimarySpacing, MinSpacing); m_dirty = true; } @@ -137,7 +137,7 @@ namespace AZ void GridComponentController::SetSecondarySpacing(float gridSecondarySpacing) { - m_configuration.m_secondarySpacing = gridSecondarySpacing; + m_configuration.m_secondarySpacing = AZStd::max(gridSecondarySpacing, MinSpacing); m_dirty = true; } diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Grid/GridComponentController.h b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Grid/GridComponentController.h index afba6d8327..ad603f11e1 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Grid/GridComponentController.h +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Grid/GridComponentController.h @@ -46,6 +46,10 @@ namespace AZ void SetConfiguration(const GridComponentConfig& config); const GridComponentConfig& GetConfiguration() const; + static constexpr float MinGridSize = 0.0f; + static constexpr float MaxGridSize = 1000000.0f; + static constexpr float MinSpacing = 0.01f; + private: AZ_DISABLE_COPY(GridComponentController);