Merge pull request #53144 from nekomatata/software-skinning-aabb
Update mesh AABB when software skinning is used
This commit is contained in:
commit
d4d4603827
1 changed files with 12 additions and 0 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue