PassGraphCompiler.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. #include <AzCore/RTTI/RTTI.h>
  9. #include <AzCore/Serialization/SerializeContext.h>
  10. #include <AzCore/Utils/Utils.h>
  11. #include <Document/PassGraphCompiler.h>
  12. namespace PassCanvas
  13. {
  14. void PassGraphCompiler::Reflect(AZ::ReflectContext* context)
  15. {
  16. if (auto serialize = azrtti_cast<AZ::SerializeContext*>(context))
  17. {
  18. serialize->Class<PassGraphCompiler, AtomToolsFramework::GraphCompiler>()
  19. ->Version(0)
  20. ;
  21. }
  22. }
  23. PassGraphCompiler::PassGraphCompiler(const AZ::Crc32& toolId)
  24. : AtomToolsFramework::GraphCompiler(toolId)
  25. {
  26. }
  27. PassGraphCompiler::~PassGraphCompiler()
  28. {
  29. }
  30. AZStd::string PassGraphCompiler::GetGraphPath() const
  31. {
  32. if (const auto& graphPath = AtomToolsFramework::GraphCompiler::GetGraphPath(); graphPath.ends_with(".passgraph"))
  33. {
  34. return graphPath;
  35. }
  36. return AZStd::string::format("%s/Assets/Passes/Generated/untitled.passgraph", AZ::Utils::GetProjectPath().c_str());
  37. }
  38. bool PassGraphCompiler::CompileGraph(GraphModel::GraphPtr graph, const AZStd::string& graphName, const AZStd::string& graphPath)
  39. {
  40. if (!AtomToolsFramework::GraphCompiler::CompileGraph(graph, graphName, graphPath))
  41. {
  42. return false;
  43. }
  44. SetState(State::Complete);
  45. return true;
  46. }
  47. } // namespace PassCanvas