Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/draco/scene/scene_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ StatusOr<std::unique_ptr<Mesh>> SceneUtils::InstantiateMesh(
const Scene &scene, const MeshInstance &instance) {
// Check if the |scene| has base mesh corresponding to mesh |instance|.
if (scene.NumMeshes() <= instance.mesh_index.value()) {
Status(Status::DRACO_ERROR, "Scene has no corresponding base mesh.");
return Status(Status::DRACO_ERROR, "Scene has no corresponding base mesh.");
}

// Check that mesh has valid positions.
Expand Down
12 changes: 12 additions & 0 deletions src/draco/scene/scene_utils_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,18 @@ TEST(SceneUtilsTest, TestInstantiateMesh) {
EXPECT_NEAR(instanced_bbox.GetMaxPoint()[2], +1.05800, tolerance);
}

TEST(SceneUtilsTest, TestInstantiateMeshWithInvalidMeshIndex) {
// Instantiating a mesh with an index that is not present in the scene must
// return an error instead of accessing the out-of-bounds mesh.
draco::Scene scene;
const draco::SceneUtils::MeshInstance invalid_instance = {
draco::MeshIndex(0), draco::SceneNodeIndex(0), 0,
Eigen::Matrix4d::Identity()};
const auto result =
draco::SceneUtils::InstantiateMesh(scene, invalid_instance);
EXPECT_FALSE(result.ok());
}

TEST(SceneUtilsTest, TestCleanupEmptyMeshGroup) {
auto scene =
draco::ReadSceneFromTestFile("CesiumMilkTruck/glTF/CesiumMilkTruck.gltf");
Expand Down