diff --git a/scene/3d/mesh_instance.cpp b/scene/3d/mesh_instance.cpp index 56fa6de72fb6..4b727b398475 100644 --- a/scene/3d/mesh_instance.cpp +++ b/scene/3d/mesh_instance.cpp @@ -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; }