Update mesh AABB when software skinning is used

Not updating the mesh properly can cause rendering issues in some cases,
like shadows not updating properly.
This commit is contained in:
PouleyKetchoupp 2021-09-27 11:56:58 -07:00
parent dd0ee48728
commit 941cff4157

View file

@ -390,6 +390,9 @@ void MeshInstance::_update_skinning() {
RID skeleton = skin_ref->get_skeleton();
ERR_FAIL_COND(!skeleton.is_valid());
AABB aabb;
bool first_vertex = true;
VisualServer *visual_server = VisualServer::get_singleton();
// Prepare bone transforms.
@ -499,11 +502,20 @@ void MeshInstance::_update_skinning() {
tangent = transform.basis.xform(tangent_read);
}
}
if (first_vertex) {
aabb.position = vertex;
first_vertex = false;
} else {
aabb.expand_to(vertex);
}
}
visual_server->mesh_surface_update_region(mesh_rid, surface_index, 0, buffer);
}
visual_server->mesh_set_custom_aabb(mesh_rid, aabb);
software_skinning_flags |= SoftwareSkinning::FLAG_BONES_READY;
}