TerrainAreaMaterialRequestBus.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #include <AzCore/Component/ComponentBus.h>
  10. #include <SurfaceData/SurfaceDataTypes.h>
  11. #include <Atom/RPI.Public/Material/Material.h>
  12. namespace Terrain
  13. {
  14. //! This bus provides retrieval of information from Terrain Surfaces.
  15. class TerrainAreaMaterialRequests
  16. : public AZ::ComponentBus
  17. {
  18. public:
  19. ////////////////////////////////////////////////////////////////////////
  20. // EBusTraits
  21. using MutexType = AZStd::recursive_mutex;
  22. ////////////////////////////////////////////////////////////////////////
  23. virtual ~TerrainAreaMaterialRequests() = default;
  24. //! Get the Aabb for the region where a TerrainSurfaceMaterialMapping exists
  25. virtual const AZ::Aabb& GetTerrainSurfaceMaterialRegion() const = 0;
  26. //! Get the Materials assigned to various surface tags.
  27. virtual const AZStd::vector<struct TerrainSurfaceMaterialMapping>& GetSurfaceMaterialMappings() const = 0;
  28. //! Get the default material
  29. virtual const TerrainSurfaceMaterialMapping& GetDefaultMaterial() const = 0;
  30. };
  31. using TerrainAreaMaterialRequestBus = AZ::EBus<TerrainAreaMaterialRequests>;
  32. //! Notifications for when the surface -> material mapping changes..
  33. class TerrainAreaMaterialNotifications : public AZ::EBusTraits
  34. {
  35. public:
  36. //////////////////////////////////////////////////////////////////////////
  37. // EBusTraits overrides
  38. static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Multiple;
  39. static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
  40. //////////////////////////////////////////////////////////////////////////
  41. //! The default surface material has been assigned and loaded
  42. virtual void OnTerrainDefaultSurfaceMaterialCreated(
  43. [[maybe_unused]] AZ::EntityId entityId,
  44. [[maybe_unused]] AZ::Data::Instance<AZ::RPI::Material> material)
  45. {
  46. }
  47. //! The default surface material has been unassigned
  48. virtual void OnTerrainDefaultSurfaceMaterialDestroyed(
  49. [[maybe_unused]] AZ::EntityId entityId)
  50. {
  51. }
  52. //! The default surface material has been changed to a different material
  53. virtual void OnTerrainDefaultSurfaceMaterialChanged(
  54. [[maybe_unused]] AZ::EntityId entityId,
  55. [[maybe_unused]] AZ::Data::Instance<AZ::RPI::Material> newMaterial)
  56. {
  57. }
  58. //! A loaded material mapped to a valid surface tag has been created
  59. virtual void OnTerrainSurfaceMaterialMappingCreated(
  60. [[maybe_unused]] AZ::EntityId entityId,
  61. [[maybe_unused]] SurfaceData::SurfaceTag surface,
  62. [[maybe_unused]] AZ::Data::Instance<AZ::RPI::Material> material)
  63. {
  64. }
  65. //! Either the material or surface tag was unassigned, making this mapping invalid
  66. virtual void OnTerrainSurfaceMaterialMappingDestroyed(
  67. [[maybe_unused]] AZ::EntityId entityId,
  68. [[maybe_unused]] SurfaceData::SurfaceTag surface)
  69. {
  70. }
  71. //! The surface tag has changed to tag for an existing material
  72. virtual void OnTerrainSurfaceMaterialMappingTagChanged(
  73. [[maybe_unused]] AZ::EntityId entityId,
  74. [[maybe_unused]] SurfaceData::SurfaceTag oldSurface,
  75. [[maybe_unused]] SurfaceData::SurfaceTag newSurface)
  76. {
  77. }
  78. //! The material has changed for an existing surface tag
  79. virtual void OnTerrainSurfaceMaterialMappingMaterialChanged(
  80. [[maybe_unused]] AZ::EntityId entityId,
  81. [[maybe_unused]] SurfaceData::SurfaceTag surface,
  82. [[maybe_unused]] AZ::Data::Instance<AZ::RPI::Material> material)
  83. {
  84. }
  85. //! A set of surface material mappings has been created
  86. virtual void OnTerrainSurfaceMaterialMappingRegionCreated(
  87. [[maybe_unused]] AZ::EntityId entityId,
  88. [[maybe_unused]] const AZ::Aabb& region)
  89. {
  90. }
  91. //! A set of surface material mappings has been destroyed
  92. virtual void OnTerrainSurfaceMaterialMappingRegionDestroyed(
  93. [[maybe_unused]] AZ::EntityId entityId,
  94. [[maybe_unused]] const AZ::Aabb& oldRegion)
  95. {
  96. }
  97. //! The bounds of this set of surface material mappings has changed
  98. virtual void OnTerrainSurfaceMaterialMappingRegionChanged(
  99. [[maybe_unused]] AZ::EntityId entityId,
  100. [[maybe_unused]] const AZ::Aabb& oldRegion,
  101. [[maybe_unused]] const AZ::Aabb& newRegion)
  102. {
  103. }
  104. };
  105. using TerrainAreaMaterialNotificationBus = AZ::EBus<TerrainAreaMaterialNotifications>;
  106. } // namespace Terrain