From 23cf27b1208a2300026726de260d258111d18ace Mon Sep 17 00:00:00 2001 From: antopilo Date: Mon, 21 Apr 2025 11:36:42 -0400 Subject: [PATCH] Re-enabled mesh colliders --- .../Nuake/Scene/Systems/PhysicsSystem.cpp | 56 +++++++++---------- 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/Nuake/Source/Nuake/Scene/Systems/PhysicsSystem.cpp b/Nuake/Source/Nuake/Scene/Systems/PhysicsSystem.cpp index 221d5d57..245efa6a 100644 --- a/Nuake/Source/Nuake/Scene/Systems/PhysicsSystem.cpp +++ b/Nuake/Source/Nuake/Scene/Systems/PhysicsSystem.cpp @@ -203,20 +203,19 @@ namespace Nuake auto& meshColliderComponent = meshColliderView.get(e); if (!meshColliderComponent.Shape) { - const auto& modelComponent = entity.GetComponent(); - - //if (modelComponent.ModelResource.Get()) - //{ - // uint32_t subMeshId = meshColliderComponent.SubMesh; - // const std::vector>& submeshes = modelComponent.ModelResource.Get()->GetMeshes(); - // if (subMeshId >= submeshes.size()) - // { - // Logger::Log("Cannot create mesh collider, invalid submesh ID", "physics", WARNING); - // } - // - // Ref mesh = submeshes[subMeshId]; - // meshColliderComponent.Shape = CreateRef(mesh); - //} + auto& modelComponent = entity.GetComponent(); + if (modelComponent.ModelResource.Get()) + { + uint32_t subMeshId = meshColliderComponent.SubMesh; + const std::vector>& submeshes = modelComponent.ModelResource.Get()->GetMeshes(); + if (subMeshId >= submeshes.size()) + { + Logger::Log("Cannot create mesh collider, invalid submesh ID", "physics", WARNING); + } + + Ref mesh = submeshes[subMeshId]; + meshColliderComponent.Shape = CreateRef(mesh); + } } } } @@ -276,24 +275,23 @@ namespace Nuake Logger::Log("Cannot use mesh collider without model component", "physics", WARNING); } - const auto& modelComponent = ent.GetComponent(); - const auto& component = ent.GetComponent(); + auto& modelComponent = ent.GetComponent(); + auto& component = ent.GetComponent(); isTrigger = component.IsTrigger; - //modelComponent.ModelResource.Data() - //if (modelComponent.ModelResource.Get()) - //{ - // uint32_t subMeshId = component.SubMesh; - // const std::vector>& submeshes = modelComponent.ModelResource.Get()->GetMeshes(); - // if (subMeshId >= submeshes.size()) - // { - // Logger::Log("Cannot create mesh collider, invalid submesh ID", "physics", WARNING); - // } - // - // Ref mesh = submeshes[subMeshId]; - // shape = CreateRef(mesh); - //} + if (modelComponent.ModelResource.Get()) + { + uint32_t subMeshId = component.SubMesh; + const std::vector>& submeshes = modelComponent.ModelResource.Get()->GetMeshes(); + if (subMeshId >= submeshes.size()) + { + Logger::Log("Cannot create mesh collider, invalid submesh ID", "physics", WARNING); + } + + Ref mesh = submeshes[subMeshId]; + shape = CreateRef(mesh); + } } if (!shape)