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.

(cherry picked from commit 791d8001db)
This commit is contained in:
Lyuma 2023-06-29 16:03:20 +02:00 committed by Yuri Sizov
parent 52c8c8c174
commit f745ef03a3
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) {
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
}

View File

@ -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
}