CpuMeshResource.cpp 905 B

123456789101112131415161718192021222324252627
  1. // Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #include <AnKi/Resource/CpuMeshResource.h>
  6. #include <AnKi/Resource/MeshBinaryLoader.h>
  7. #include <AnKi/Resource/ResourceManager.h>
  8. #include <AnKi/Physics/PhysicsWorld.h>
  9. namespace anki {
  10. Error CpuMeshResource::load(const ResourceFilename& filename, [[maybe_unused]] Bool async)
  11. {
  12. MeshBinaryLoader loader(&ResourceMemoryPool::getSingleton());
  13. ANKI_CHECK(loader.load(filename));
  14. ANKI_CHECK(loader.storeIndicesAndPosition(0, m_indices, m_positions));
  15. // Create the collision shape
  16. const Bool convex = !!(loader.getHeader().m_flags & MeshBinaryFlag::kConvex);
  17. m_physicsShape = PhysicsWorld::getSingleton().newInstance<PhysicsTriangleSoup>(m_positions, m_indices, convex);
  18. return Error::kNone;
  19. }
  20. } // end namespace anki