Skip to content

Commit

Permalink
[gl_viewer] Fix: Use changes TRS type & assert on missing indices
Browse files Browse the repository at this point in the history
  • Loading branch information
spnda committed Jan 25, 2024
1 parent 73fa420 commit b6d282d
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions examples/gl_viewer/gl_viewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ glm::mat4 getTransformMatrix(const fastgltf::Node& node, glm::mat4x4& base) {
return base * glm::mat4x4(glm::make_mat4x4(pMatrix->data()));
}

if (const auto* pTransform = std::get_if<fastgltf::Node::TRS>(&node.transform)) {
if (const auto* pTransform = std::get_if<fastgltf::TRS>(&node.transform)) {
// Warning: The quaternion to mat4x4 conversion here is not correct with all versions of glm.
// glTF provides the quaternion as (x, y, z, w), which is the same layout glm used up to version 0.9.9.8.
// However, with commit 59ddeb7 (May 2021) the default order was changed to (w, x, y, z).
Expand Down Expand Up @@ -349,13 +349,8 @@ bool loadMesh(Viewer* viewer, fastgltf::Mesh& mesh) {

for (auto it = mesh.primitives.begin(); it != mesh.primitives.end(); ++it) {
auto* positionIt = it->findAttribute("POSITION");
// A mesh primitive is required to hold the POSITION attribute.
assert(positionIt != it->attributes.end());

// We only support indexed geometry.
if (!it->indicesAccessor.has_value()) {
return false;
}
assert(positionIt != it->attributes.end()); // A mesh primitive is required to hold the POSITION attribute.
assert(it->indicesAccessor.has_value()); // We specify GenerateMeshIndices, so we should always have indices

// Generate the VAO
GLuint vao = GL_NONE;
Expand Down

0 comments on commit b6d282d

Please sign in to comment.