From 791d8001db16c6b3557109f9bcec1bc884655a82 Mon Sep 17 00:00:00 2001 From: Lyuma Date: Fri, 19 May 2023 18:47:11 -0700 Subject: [PATCH] Fix AABB for unused bones Fixes bug where bounding box of 1 unit was used in some skinned models and had wrong LODs. (this could become very large if the mesh is scaled, such as FBX conversions) Also fixes a mistake in calcualting bone index. --- drivers/gles3/storage/mesh_storage.cpp | 4 ++-- servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gles3/storage/mesh_storage.cpp b/drivers/gles3/storage/mesh_storage.cpp index 44c9dc714c0..585ed5ff96c 100644 --- a/drivers/gles3/storage/mesh_storage.cpp +++ b/drivers/gles3/storage/mesh_storage.cpp @@ -534,7 +534,7 @@ AABB MeshStorage::mesh_get_aabb(RID p_mesh, RID p_skeleton) { if (skeleton->use_2d) { for (int j = 0; j < bs; j++) { - if (skbones[0].size == Vector3()) { + if (skbones[j].size == Vector3(-1, -1, -1)) { continue; //bone is unused } @@ -561,7 +561,7 @@ AABB MeshStorage::mesh_get_aabb(RID p_mesh, RID p_skeleton) { } } else { for (int j = 0; j < bs; j++) { - if (skbones[0].size == Vector3()) { + if (skbones[j].size == Vector3(-1, -1, -1)) { continue; //bone is unused } diff --git a/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp b/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp index b91e73c8858..d3c22e4826c 100644 --- a/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp +++ b/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp @@ -627,7 +627,7 @@ AABB MeshStorage::mesh_get_aabb(RID p_mesh, RID p_skeleton) { if (skeleton->use_2d) { for (int j = 0; j < bs; j++) { - if (skbones[0].size == Vector3()) { + if (skbones[j].size == Vector3(-1, -1, -1)) { continue; //bone is unused } @@ -654,7 +654,7 @@ AABB MeshStorage::mesh_get_aabb(RID p_mesh, RID p_skeleton) { } } else { for (int j = 0; j < bs; j++) { - if (skbones[0].size == Vector3()) { + if (skbones[j].size == Vector3(-1, -1, -1)) { continue; //bone is unused }