ImporterUtilities.inl 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 <SceneAPI/SceneBuilder/Importers/ImporterUtilities.h>
  9. #include <SceneAPI/SceneCore/Containers/Scene.h>
  10. #include <SceneAPI/SceneCore/DataTypes/IGraphObject.h>
  11. namespace AZ
  12. {
  13. namespace SceneAPI
  14. {
  15. namespace SceneBuilder
  16. {
  17. bool NodeIsOfType(const CoreSceneGraph& sceneGraph, CoreGraphNodeIndex nodeIndex, const AZ::Uuid& uuid)
  18. {
  19. if (nodeIndex.IsValid() && sceneGraph.HasNodeContent(nodeIndex) &&
  20. sceneGraph.GetNodeContent(nodeIndex)->RTTI_IsTypeOf(uuid))
  21. {
  22. return true;
  23. }
  24. else
  25. {
  26. return false;
  27. }
  28. }
  29. bool NodeParentIsOfType(const CoreSceneGraph& sceneGraph, CoreGraphNodeIndex nodeIndex, const AZ::Uuid& uuid)
  30. {
  31. CoreGraphNodeIndex parentIndex = sceneGraph.GetNodeParent(nodeIndex);
  32. return NodeIsOfType(sceneGraph, parentIndex, uuid);
  33. }
  34. bool NodeHasAncestorOfType(const CoreSceneGraph& sceneGraph, CoreGraphNodeIndex nodeIndex, const AZ::Uuid& uuid)
  35. {
  36. CoreGraphNodeIndex parentIndex = sceneGraph.GetNodeParent(nodeIndex);
  37. while (parentIndex.IsValid())
  38. {
  39. if (NodeIsOfType(sceneGraph, parentIndex, uuid))
  40. {
  41. return true;
  42. }
  43. parentIndex = sceneGraph.GetNodeParent(parentIndex);
  44. }
  45. return false;
  46. }
  47. bool AreScenesEqual(const CoreScene& lhs, const CoreScene& rhs)
  48. {
  49. if (lhs.GetGraph().GetNodeCount() != rhs.GetGraph().GetNodeCount())
  50. {
  51. return false;
  52. }
  53. if (!AreSceneGraphsEqual(lhs.GetGraph(), rhs.GetGraph()))
  54. {
  55. return false;
  56. }
  57. return true;
  58. }
  59. } // namespace SceneBuilder
  60. } // namespace SceneAPI
  61. } // namespace AZ