Skip to content

Commit

Permalink
Fixed incorrect handling of models with no materials
Browse files Browse the repository at this point in the history
  • Loading branch information
JuanDiegoMontoya committed Aug 2, 2024
1 parent 61ee2c8 commit 430b799
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 7 deletions.
3 changes: 0 additions & 3 deletions src/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,6 @@ Application::Application(const CreateInfo& createInfo)
glfwSetWindowPos(window, videoMode->width / 2 - windowFramebufferWidth / 2 + monitorLeft, videoMode->height / 2 - windowFramebufferHeight / 2 + monitorTop);

glfwSetWindowUserPointer(window, this);
//glfwMakeContextCurrent(window);
//glfwSwapInterval(vsyncEnabled ? 1 : 0);
// TODO: configure vsync

glfwSetCursorPosCallback(window, ApplicationAccess::CursorPosCallback);
glfwSetCursorEnterCallback(window, ApplicationAccess::CursorEnterCallback);
Expand Down
2 changes: 1 addition & 1 deletion src/Scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ namespace Scene
{
auto& meshInstanceId = meshInstanceIds.emplace_back(renderer.RegisterMeshInstance({
.meshGeometry = meshGeometryIds[baseMeshGeometryIndex + meshIndex],
.material = materialIds[baseMaterialIndex + materialIndex],
.material = materialIds[materialIndex.has_value() ? baseMaterialIndex + *materialIndex : 0],
}));

auto meshId = meshIds.emplace_back(renderer.SpawnMesh(meshInstanceId));
Expand Down
4 changes: 2 additions & 2 deletions src/SceneLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1026,11 +1026,11 @@ namespace Utility
rawMeshIndex = it->second;
}

auto materialId = primitive.materialIndex.has_value() ? uint32_t(primitive.materialIndex.value()) : 0;
auto materialId = primitive.materialIndex;

if (skipMaterials)
{
materialId = 0;
materialId = std::nullopt;
}

node->meshes.emplace_back(rawMeshIndex, materialId);
Expand Down
2 changes: 1 addition & 1 deletion src/SceneLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace Utility
struct MeshIndices
{
size_t meshIndex;
size_t materialIndex;
std::optional<size_t> materialIndex;
};
std::vector<MeshIndices> meshes;
std::optional<Render::GpuLight> light; // TODO: hold a light without position/direction type safety
Expand Down

0 comments on commit 430b799

Please sign in to comment.