Skip to content

Commit

Permalink
Fix AABB for unused bones
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lyuma committed May 20, 2023
1 parent 809a982 commit 791d800
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions drivers/gles3/storage/mesh_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

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

Expand Down
4 changes: 2 additions & 2 deletions servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

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

Expand Down

0 comments on commit 791d800

Please sign in to comment.