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.
This commit is contained in:
Lyuma 2023-05-19 18:47:11 -07:00
parent 809a982162
commit 791d8001db
2 changed files with 4 additions and 4 deletions

View File

@ -534,7 +534,7 @@ AABB MeshStorage::mesh_get_aabb(RID p_mesh, RID p_skeleton) {
if (skeleton->use_2d) { if (skeleton->use_2d) {
for (int j = 0; j < bs; j++) { for (int j = 0; j < bs; j++) {
if (skbones[0].size == Vector3()) { if (skbones[j].size == Vector3(-1, -1, -1)) {
continue; //bone is unused continue; //bone is unused
} }
@ -561,7 +561,7 @@ AABB MeshStorage::mesh_get_aabb(RID p_mesh, RID p_skeleton) {
} }
} else { } else {
for (int j = 0; j < bs; j++) { for (int j = 0; j < bs; j++) {
if (skbones[0].size == Vector3()) { if (skbones[j].size == Vector3(-1, -1, -1)) {
continue; //bone is unused continue; //bone is unused
} }

View File

@ -627,7 +627,7 @@ AABB MeshStorage::mesh_get_aabb(RID p_mesh, RID p_skeleton) {
if (skeleton->use_2d) { if (skeleton->use_2d) {
for (int j = 0; j < bs; j++) { for (int j = 0; j < bs; j++) {
if (skbones[0].size == Vector3()) { if (skbones[j].size == Vector3(-1, -1, -1)) {
continue; //bone is unused continue; //bone is unused
} }
@ -654,7 +654,7 @@ AABB MeshStorage::mesh_get_aabb(RID p_mesh, RID p_skeleton) {
} }
} else { } else {
for (int j = 0; j < bs; j++) { for (int j = 0; j < bs; j++) {
if (skbones[0].size == Vector3()) { if (skbones[j].size == Vector3(-1, -1, -1)) {
continue; //bone is unused continue; //bone is unused
} }