MeshComponent.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // Copyright (C) 2009-present, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #pragma once
  6. #include <AnKi/Scene/Components/SceneComponent.h>
  7. #include <AnKi/Resource/Forward.h>
  8. #include <AnKi/Scene/GpuSceneArray.h>
  9. namespace anki {
  10. // Holds geometry information.
  11. class MeshComponent final : public SceneComponent
  12. {
  13. ANKI_SCENE_COMPONENT(MeshComponent)
  14. public:
  15. MeshComponent(SceneNode* node);
  16. ~MeshComponent();
  17. MeshComponent& setMeshFilename(CString fname);
  18. Bool hasMeshResource() const
  19. {
  20. return !!m_resource;
  21. }
  22. CString getMeshFilename() const;
  23. Bool isValid() const;
  24. const MeshResource& getMeshResource() const
  25. {
  26. ANKI_ASSERT(isValid());
  27. return *m_resource;
  28. }
  29. ANKI_INTERNAL U32 getGpuSceneMeshLodsIndex(U32 submeshIdx) const
  30. {
  31. ANKI_ASSERT(isValid());
  32. return m_gpuSceneMeshLods[submeshIdx].getIndex() * kMaxLodCount;
  33. }
  34. ANKI_INTERNAL Bool gpuSceneReallocationsThisFrame() const
  35. {
  36. ANKI_ASSERT(isValid());
  37. return m_gpuSceneMeshLodsReallocatedThisFrame;
  38. }
  39. private:
  40. MeshResourcePtr m_resource;
  41. SceneDynamicArray<GpuSceneArrays::MeshLod::Allocation> m_gpuSceneMeshLods;
  42. Bool m_resourceDirty = true;
  43. Bool m_gpuSceneMeshLodsReallocatedThisFrame = false;
  44. void update(SceneComponentUpdateInfo& info, Bool& updated) override;
  45. Error serialize(SceneSerializer& serializer) override;
  46. };
  47. } // end namespace anki