Ensure bone AABBs are properly transformed to affect mesh AABB, fixes #19281
This commit is contained in:
parent
5d152cc42d
commit
634aa4fc24
|
@ -3787,12 +3787,14 @@ AABB RasterizerStorageGLES3::mesh_get_aabb(RID p_mesh, RID p_skeleton) const {
|
|||
Mesh *mesh = mesh_owner.get(p_mesh);
|
||||
ERR_FAIL_COND_V(!mesh, AABB());
|
||||
|
||||
if (mesh->custom_aabb != AABB())
|
||||
if (mesh->custom_aabb != AABB()) {
|
||||
return mesh->custom_aabb;
|
||||
}
|
||||
|
||||
Skeleton *sk = NULL;
|
||||
if (p_skeleton.is_valid())
|
||||
if (p_skeleton.is_valid()) {
|
||||
sk = skeleton_owner.get(p_skeleton);
|
||||
}
|
||||
|
||||
AABB aabb;
|
||||
|
||||
|
@ -3831,6 +3833,7 @@ AABB RasterizerStorageGLES3::mesh_get_aabb(RID p_mesh, RID p_skeleton) const {
|
|||
mtx.origin.y = texture[base_ofs + 3];
|
||||
|
||||
AABB baabb = mtx.xform(skbones[j]);
|
||||
|
||||
if (first) {
|
||||
laabb = baabb;
|
||||
first = false;
|
||||
|
@ -3863,6 +3866,8 @@ AABB RasterizerStorageGLES3::mesh_get_aabb(RID p_mesh, RID p_skeleton) const {
|
|||
mtx.basis[2].z = texture[base_ofs + 2];
|
||||
mtx.origin.z = texture[base_ofs + 3];
|
||||
|
||||
print_line("surface " + itos(i) + " bone " + itos(j) + " aabb: " + skbones[j]);
|
||||
|
||||
AABB baabb = mtx.xform(skbones[j]);
|
||||
if (first) {
|
||||
laabb = baabb;
|
||||
|
|
|
@ -706,6 +706,7 @@ bool ArrayMesh::_get(const StringName &p_name, Variant &r_ret) const {
|
|||
|
||||
Vector<AABB> skel_aabb = VS::get_singleton()->mesh_surface_get_skeleton_aabb(mesh, idx);
|
||||
Array arr;
|
||||
arr.resize(skel_aabb.size());
|
||||
for (int i = 0; i < skel_aabb.size(); i++) {
|
||||
arr[i] = skel_aabb[i];
|
||||
}
|
||||
|
|
|
@ -343,7 +343,7 @@ RID VisualServer::get_white_texture() {
|
|||
#define SMALL_VEC2 Vector2(0.00001, 0.00001)
|
||||
#define SMALL_VEC3 Vector3(0.00001, 0.00001, 0.00001)
|
||||
|
||||
Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_t *p_offsets, uint32_t p_stride, PoolVector<uint8_t> &r_vertex_array, int p_vertex_array_len, PoolVector<uint8_t> &r_index_array, int p_index_array_len, AABB &r_aabb, Vector<AABB> r_bone_aabb) {
|
||||
Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_t *p_offsets, uint32_t p_stride, PoolVector<uint8_t> &r_vertex_array, int p_vertex_array_len, PoolVector<uint8_t> &r_index_array, int p_index_array_len, AABB &r_aabb, Vector<AABB> &r_bone_aabb) {
|
||||
|
||||
PoolVector<uint8_t>::Write vw = r_vertex_array.write();
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ protected:
|
|||
RID white_texture;
|
||||
RID test_material;
|
||||
|
||||
Error _surface_set_data(Array p_arrays, uint32_t p_format, uint32_t *p_offsets, uint32_t p_stride, PoolVector<uint8_t> &r_vertex_array, int p_vertex_array_len, PoolVector<uint8_t> &r_index_array, int p_index_array_len, AABB &r_aabb, Vector<AABB> r_bone_aabb);
|
||||
Error _surface_set_data(Array p_arrays, uint32_t p_format, uint32_t *p_offsets, uint32_t p_stride, PoolVector<uint8_t> &r_vertex_array, int p_vertex_array_len, PoolVector<uint8_t> &r_index_array, int p_index_array_len, AABB &r_aabb, Vector<AABB> &r_bone_aabb);
|
||||
|
||||
static VisualServer *(*create_func)();
|
||||
static void _bind_methods();
|
||||
|
|
Loading…
Reference in New Issue