SceneBuilderWorker.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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/Component.h>
  10. #include <AzCore/std/smart_ptr/shared_ptr.h>
  11. #include <AssetBuilderSDK/AssetBuilderBusses.h>
  12. #include <AssetBuilderSDK/AssetBuilderSDK.h>
  13. namespace AssetBuilderSDK
  14. {
  15. struct CreateJobsRequest;
  16. struct CreateJobsResponse;
  17. struct ProcessJobRequest;
  18. struct ProcessJobResponse;
  19. struct JobProduct;
  20. }
  21. namespace AZ
  22. {
  23. namespace SceneAPI
  24. {
  25. namespace Containers
  26. {
  27. class Scene;
  28. }
  29. namespace Events
  30. {
  31. struct ExportProduct;
  32. class ExportProductList;
  33. }
  34. }
  35. }
  36. namespace SceneBuilder
  37. {
  38. class SceneBuilderWorker
  39. : public AssetBuilderSDK::AssetBuilderCommandBus::Handler
  40. {
  41. public:
  42. ~SceneBuilderWorker() override = default;
  43. void CreateJobs(const AssetBuilderSDK::CreateJobsRequest& request, AssetBuilderSDK::CreateJobsResponse& response);
  44. void ProcessJob(const AssetBuilderSDK::ProcessJobRequest& request, AssetBuilderSDK::ProcessJobResponse& response);
  45. void ShutDown() override;
  46. const char* GetFingerprint() const;
  47. static void PopulateSourceDependencies(
  48. const AZStd::string& manifestJson, AZStd::vector<AssetBuilderSDK::SourceFileDependency>& sourceFileDependencies);
  49. static bool ManifestDependencyCheck(const AssetBuilderSDK::CreateJobsRequest& request, AssetBuilderSDK::CreateJobsResponse& response);
  50. static AZ::Uuid GetUUID();
  51. void PopulateProductDependencies(const AZ::SceneAPI::Events::ExportProduct& exportProduct, const char* watchFolder, AssetBuilderSDK::JobProduct& jobProduct) const;
  52. protected:
  53. bool LoadScene(AZStd::shared_ptr<AZ::SceneAPI::Containers::Scene>& result,
  54. const AssetBuilderSDK::ProcessJobRequest& request, AssetBuilderSDK::ProcessJobResponse& response);
  55. // @brief Execute runtime modifications to the Scene graph
  56. //
  57. // This step is run after the scene is loaded, but before the scene
  58. // is exported. It emits events with the GenerateEventContext.
  59. // Event handlers bound to that event can apply arbitrary
  60. // transformations to the Scene, adding new nodes, replacing nodes,
  61. // or removing nodes.
  62. bool GenerateScene(AZ::SceneAPI::Containers::Scene* result,
  63. const AssetBuilderSDK::ProcessJobRequest& request, AssetBuilderSDK::ProcessJobResponse& response);
  64. bool ExportScene(const AZStd::shared_ptr<AZ::SceneAPI::Containers::Scene>& scene,
  65. const AssetBuilderSDK::ProcessJobRequest& request, AssetBuilderSDK::ProcessJobResponse& response);
  66. AZ::u32 BuildSubId(const AZ::SceneAPI::Events::ExportProduct& product) const;
  67. bool m_isShuttingDown = false;
  68. mutable AZStd::string m_cachedFingerprint;
  69. };
  70. } // namespace SceneBuilder