#pragma once #include #include #include namespace orange { //#define USE_32BIT_INDICES #ifdef USE_32BIT_INDICES using IndexType = uint32_t; static constexpr VkIndexType VulkanIndexType = VK_INDEX_TYPE_UINT32; static constexpr size_t MaxMeshIndex = UINT32_MAX; #else using IndexType = uint16_t; static constexpr VkIndexType VulkanIndexType = VK_INDEX_TYPE_UINT16; static constexpr size_t MaxMeshIndex = UINT16_MAX; #endif struct MeshVertexData { MeshVertexData(MeshVertexType type) : vertexType(type) { switch(vertexType) { case MeshVertexType::Static: vertices.Construct>(); break; case MeshVertexType::Skinned: vertices.Construct>(); break; } } Vector& GetStaticVertices() { Assert(vertexType == MeshVertexType::Static); return vertices.Get>(); } Vector& GetSkinnedVertices() { Assert(vertexType == MeshVertexType::Skinned); return vertices.Get>(); } BufferView View() { switch(vertexType) { case MeshVertexType::Static: return GetStaticVertices(); break; case MeshVertexType::Skinned: return GetSkinnedVertices(); break; default: return BufferView{ nullptr, 0 }; } } uint32_t VertexCount() const { // Type doesn't matter here, just want to grab m_size. return uint32_t(vertices.Get>().Size()); } MeshVertexType vertexType; Variant, Vector> vertices; }; struct MeshData { MeshData(MeshVertexType type) : vertexData{ type } {} MeshVertexData vertexData; Vector indices; AABB bounds; }; Result ParseOBJ(StringView buffer); }