AtomActor.cpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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/base.h>
  9. #include <AzCore/Casting/numeric_cast.h>
  10. #include <AzCore/Component/TickBus.h>
  11. #include <AzCore/Math/Transform.h>
  12. #include <Integration/System/SystemCommon.h>
  13. #include <Integration/Assets/ActorAsset.h>
  14. #include <EMotionFX/Source/Actor.h>
  15. #include <EMotionFX/Source/Mesh.h>
  16. #include <EMotionFX/Source/SubMesh.h>
  17. #include <EMotionFX/Source/SkinningInfoVertexAttributeLayer.h>
  18. #include <AtomActor.h>
  19. #include <ActorAsset.h>
  20. #include <Atom/Feature/SkinnedMesh/SkinnedMeshInputBuffers.h>
  21. namespace AZ
  22. {
  23. namespace Render
  24. {
  25. AZ_CLASS_ALLOCATOR_IMPL(AtomActor, EMotionFX::Integration::EMotionFXAllocator);
  26. AtomActor::AtomActor(EMotionFX::Integration::ActorAsset* actorAsset)
  27. : RenderActor()
  28. , m_actorAsset(actorAsset)
  29. {
  30. AZ_Assert(m_actorAsset, "AtomActor created with a null EmotionFX ActorAsset.");
  31. const AZ::Data::AssetId& actorAssetId = m_actorAsset->GetId();
  32. if (actorAssetId.IsValid())
  33. {
  34. AZ_Assert(m_actorAsset->GetActor(), "AtomActor created with a null EMotionFX Actor.");
  35. }
  36. }
  37. AtomActor::~AtomActor()
  38. {
  39. m_skinnedMeshInputBuffers.reset();
  40. }
  41. AZStd::intrusive_ptr<AZ::Render::SkinnedMeshInputBuffers> AtomActor::FindOrCreateSkinnedMeshInputBuffers()
  42. {
  43. if (!m_skinnedMeshInputBuffers)
  44. {
  45. m_skinnedMeshInputBuffers = AZ::Render::CreateSkinnedMeshInputFromActor(m_actorAsset->GetId(), m_actorAsset->GetActor());
  46. }
  47. return m_skinnedMeshInputBuffers;
  48. }
  49. } // namespace Render
  50. } // namespace AZ