CpuMeshResource.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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/Resource/ResourceObject.h>
  7. #include <AnKi/Math.h>
  8. #include <AnKi/Util/WeakArray.h>
  9. #include <AnKi/Physics2/PhysicsCollisionShape.h>
  10. namespace anki {
  11. /// @addtogroup resource
  12. /// @{
  13. /// CPU Mesh Resource. It contains the geometry packed in CPU buffers.
  14. class CpuMeshResource : public ResourceObject
  15. {
  16. public:
  17. /// Default constructor
  18. CpuMeshResource() = default;
  19. ~CpuMeshResource() = default;
  20. /// Load from a mesh file
  21. Error load(const ResourceFilename& filename, Bool async);
  22. const v2::PhysicsCollisionShapePtr& getOrCreateCollisionShape(Bool isStatic, U32 lod = kMaxLodCount - 1) const;
  23. private:
  24. ResourceDynamicArray<Vec3> m_positionsMaxLod;
  25. ResourceDynamicArray<U32> m_indicesMaxLod;
  26. mutable v2::PhysicsCollisionShapePtr m_collisionShape;
  27. mutable SpinLock m_shapeMtx;
  28. Bool m_isConvex = false;
  29. U8 m_maxLod = 0;
  30. };
  31. /// @}
  32. } // namespace anki