@ -40,15 +40,17 @@ namespace Terrain
- > DataElement ( AZ : : Edit : : UIHandlers : : Default , & TerrainWorldConfig : : m_worldMin , " World Bounds (Min) " , " " )
// Temporary constraint until the rest of the Terrain system is updated to support larger worlds.
- > Attribute ( AZ : : Edit : : Attributes : : ChangeValidate , & TerrainWorldConfig : : ValidateWorldMin )
- > Attribute ( AZ : : Edit : : Attributes : : Min , - 2048.0f )
- > Attribute ( AZ : : Edit : : Attributes : : Max , 2048.0f )
- > DataElement ( AZ : : Edit : : UIHandlers : : Default , & TerrainWorldConfig : : m_worldMax , " World Bounds (Max) " , " " )
// Temporary constraint until the rest of the Terrain system is updated to support larger worlds.
- > Attribute ( AZ : : Edit : : Attributes : : ChangeValidate , & TerrainWorldConfig : : ValidateWorldMax )
- > Attribute ( AZ : : Edit : : Attributes : : Min , - 2048.0f )
- > Attribute ( AZ : : Edit : : Attributes : : Max , 2048.0f )
- > DataElement (
AZ : : Edit : : UIHandlers : : Default , & TerrainWorldConfig : : m_heightQueryResolution , " Height Query Resolution (m) " , " " )
;
- > Attribute ( AZ : : Edit : : Attributes : : ChangeValidate , & TerrainWorldConfig : : ValidateWorldHeight ) ;
}
}
}
@ -128,4 +130,42 @@ namespace Terrain
}
return false ;
}
}
float TerrainWorldConfig : : NumberOfSamples ( AZ : : Vector3 * min , AZ : : Vector3 * max , AZ : : Vector2 * heightQuery )
{
float numberOfSamples = ( ( max - > GetX ( ) - min - > GetX ( ) ) / heightQuery - > GetX ( ) ) * ( ( max - > GetY ( ) - min - > GetY ( ) ) / heightQuery - > GetY ( ) ) ;
return numberOfSamples ;
}
AZ : : Outcome < void , AZStd : : string > TerrainWorldConfig : : DetermineMessage ( float numSamples )
{
const float maximumSamplesAllowed = 8.0f * 1024.0f * 1024.0f ;
if ( numSamples < maximumSamplesAllowed )
{
return AZ : : Success ( ) ;
}
return AZ : : Failure ( AZStd : : string ( " The number of samples exceeds the maximum allowed. " ) ) ;
}
AZ : : Outcome < void , AZStd : : string > TerrainWorldConfig : : ValidateWorldMin ( void * newValue , [[maybe_unused]] const AZ : : Uuid & valueType )
{
AZ : : Vector3 minValue = * static_cast < AZ : : Vector3 * > ( newValue ) ;
return DetermineMessage ( NumberOfSamples ( & minValue , & m_worldMax , & m_heightQueryResolution ) ) ;
}
AZ : : Outcome < void , AZStd : : string > TerrainWorldConfig : : ValidateWorldMax ( void * newValue , [[maybe_unused]] const AZ : : Uuid & valueType )
{
AZ : : Vector3 maxValue = * static_cast < AZ : : Vector3 * > ( newValue ) ;
return DetermineMessage ( NumberOfSamples ( & m_worldMin , & maxValue , & m_heightQueryResolution ) ) ;
}
AZ : : Outcome < void , AZStd : : string > TerrainWorldConfig : : ValidateWorldHeight ( void * newValue , [[maybe_unused]] const AZ : : Uuid & valueType )
{
AZ : : Vector2 heightValue = * static_cast < AZ : : Vector2 * > ( newValue ) ;
return DetermineMessage ( NumberOfSamples ( & m_worldMin , & m_worldMax , & heightValue ) ) ;
}
} // namespace Terrain