diff --git a/src/Apps/Tools/CubeTest.cpp b/src/Apps/Tools/CubeTest.cpp index 75fb535..6ce3d90 100644 --- a/src/Apps/Tools/CubeTest.cpp +++ b/src/Apps/Tools/CubeTest.cpp @@ -28,21 +28,54 @@ struct AABB } }; +enum class MeshVertexType +{ + Static, + Skinned, +}; + struct Vertex { vec3 pos; vec2 uv; vec3 normal; + vec3 tangent; bool operator == (const Vertex& other) const { - return pos == other.pos && uv == other.uv && normal == other.normal; + return pos == other.pos && + uv == other.uv && + normal == other.normal && + tangent == other.tangent; } }; +struct SkinnedVertex : public Vertex +{ + static constexpr uint32_t MaxVertexWeights = 4; + + bool operator == (const SkinnedVertex& other) const + { + return pos == other.pos && + uv == other.uv && + normal == other.normal && + tangent == other.tangent && + boneIndices == other.boneIndices && + boneWeights == other.boneWeights; + } + + Array boneIndices; + Array boneWeights; +} + struct MeshData { - Vector vertices; + MeshVertexType vertexType; + union + { + Vector staticVertices; + Vector skinnedVertices; + }; Vector indices; AABB bounds; }; @@ -50,6 +83,7 @@ struct MeshData Result ParseOBJ(StringView buffer) { MeshData data; + data.vertexType = MeshVertexType::Static; Vector positions; Vector uvs; @@ -121,11 +155,11 @@ Result ParseOBJ(StringView buffer) .normal = indices[i][2] != -1 ? normals [indices[i][2]] : vec3{}, }; - size_t vertexIdx = data.vertices.FindIdx(vertex); + size_t vertexIdx = data.staticVertices.FindIdx(vertex); if (vertexIdx == Vector::InvalidIdx) { data.bounds.Extend(vertex.pos); - vertexIdx = data.vertices.PushBack(vertex); + vertexIdx = data.staticVertices.PushBack(vertex); } Assert(vertexIdx < UINT16_MAX);