From 172543fc88d83b248006f2d3dee59f2e93c42d08 Mon Sep 17 00:00:00 2001 From: johndoe6345789 Date: Wed, 7 Jan 2026 15:20:15 +0000 Subject: [PATCH] feat(cube_logic): Fix string formatting for object_type in create_spinning_cube function --- scripts/cube_logic.lua | 2 +- tests/test_cube_script.cpp | 23 ++++++++++++----------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/scripts/cube_logic.lua b/scripts/cube_logic.lua index 519bf62..3650800 100644 --- a/scripts/cube_logic.lua +++ b/scripts/cube_logic.lua @@ -875,7 +875,7 @@ local function create_spinning_cube() indices = cube_indices, compute_model_matrix = compute_model_matrix, shader_keys = {shader_key}, - object_type = \"spinning_cube\", + object_type = "spinning_cube", } end diff --git a/tests/test_cube_script.cpp b/tests/test_cube_script.cpp index 16d6d35..07ccfde 100644 --- a/tests/test_cube_script.cpp +++ b/tests/test_cube_script.cpp @@ -624,18 +624,20 @@ void RunCubeDemoSceneTests(int& failures) { if (!object.vertices.empty()) { ExpectColorNear(object.vertices.front(), white, "ceiling vertex color", failures); } - } else if (shaderKey == "solid") { + } else if (objectType == "lantern") { solidIndices.push_back(index); lanternTranslations.push_back(summary.translation); Assert(ApproximatelyEqual(summary.scale[0], lanternSize), "lantern scale mismatch", failures); if (!object.vertices.empty()) { ExpectColorNear(object.vertices.front(), lanternColor, "lantern vertex color", failures); } - } else if (shaderKey == "skybox") { + } else if (objectType == "skybox") { skyboxIndices.push_back(index); if (!object.vertices.empty()) { ExpectColorNear(object.vertices.front(), skyboxColor, "skybox vertex color", failures); } + } else if (objectType == "physics_cube" || objectType == "spinning_cube") { + // Physics cube is tracked separately below } else { otherIndices.push_back(index); } @@ -645,8 +647,8 @@ void RunCubeDemoSceneTests(int& failures) { Assert(wallIndices.size() == 4, "expected 4 wall objects", failures); Assert(solidIndices.size() == 8, "expected 8 lantern objects", failures); Assert(skyboxIndices.size() == 1, "expected 1 skybox object", failures); - Assert(floorIndices.size() == 2, "expected 2 floor-key objects (floor + cube)", failures); - Assert(otherIndices.empty(), "unexpected shader keys in cube demo scene", failures); + Assert(floorIndices.size() == 1, "expected 1 floor object", failures); + Assert(otherIndices.empty(), "unexpected object types in cube demo scene", failures); const std::vector> expectedWallTranslations = { {0.0f, wallCenterY, -wallOffset}, @@ -690,19 +692,18 @@ void RunCubeDemoSceneTests(int& failures) { Assert(found, "missing lantern at expected translation", failures); } + // Find floor and physics cube by object type size_t floorObjectIndex = std::numeric_limits::max(); size_t cubeObjectIndex = std::numeric_limits::max(); - for (size_t idx : floorIndices) { - // Floor has many vertices (441 from 20x20 tessellation) - // Cube has few vertices (~24 from cube mesh) - if (objects[idx].vertices.size() > 100) { - // This is the floor (many vertices from tessellation) + + for (size_t idx = 0; idx < objects.size(); ++idx) { + if (objects[idx].objectType == "floor") { floorObjectIndex = idx; - } else { - // This is the physics cube (using cube mesh, should be checking "floor" shader on small object) + } else if (objects[idx].objectType == "physics_cube" || objects[idx].objectType == "spinning_cube") { cubeObjectIndex = idx; } } + Assert(floorObjectIndex != std::numeric_limits::max(), "floor object not found", failures); Assert(cubeObjectIndex != std::numeric_limits::max(), "dynamic cube object not found", failures);