From fb4e55bb7a89583e7e34ab099e11bddfa236e7ea Mon Sep 17 00:00:00 2001 From: clayjohn Date: Mon, 20 Jul 2020 20:22:12 -0700 Subject: [PATCH] Pass Sprite3D AABBs to VisualServer --- scene/3d/sprite_3d.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp index d1edcd2496d..2af30c4e592 100644 --- a/scene/3d/sprite_3d.cpp +++ b/scene/3d/sprite_3d.cpp @@ -592,13 +592,15 @@ void Sprite3D::_draw() { copymem(&write_buffer[i * mesh_stride + mesh_surface_offsets[VS::ARRAY_COLOR]], v_color, 4); copymem(&write_buffer[i * mesh_stride + mesh_surface_offsets[VS::ARRAY_TEX_UV]], v_uv, 2 * 2); } - set_aabb(aabb); write_buffer.release(); RID mesh = get_mesh(); VS::get_singleton()->mesh_surface_update_region(mesh, 0, 0, mesh_buffer); + VS::get_singleton()->mesh_set_custom_aabb(mesh, aabb); + set_aabb(aabb); + set_base(mesh); RID mat = SpatialMaterial::get_material_rid_for_2d(get_draw_flag(FLAG_SHADED), get_draw_flag(FLAG_TRANSPARENT), get_draw_flag(FLAG_DOUBLE_SIDED), get_alpha_cut_mode() == ALPHA_CUT_DISCARD, get_alpha_cut_mode() == ALPHA_CUT_OPAQUE_PREPASS, get_billboard_mode() == SpatialMaterial::BILLBOARD_ENABLED, get_billboard_mode() == SpatialMaterial::BILLBOARD_FIXED_Y); @@ -950,13 +952,15 @@ void AnimatedSprite3D::_draw() { copymem(&write_buffer[i * mesh_stride + mesh_surface_offsets[VS::ARRAY_COLOR]], v_color, 4); copymem(&write_buffer[i * mesh_stride + mesh_surface_offsets[VS::ARRAY_TEX_UV]], v_uv, 2 * 2); } - set_aabb(aabb); write_buffer.release(); RID mesh = get_mesh(); VS::get_singleton()->mesh_surface_update_region(mesh, 0, 0, mesh_buffer); + VS::get_singleton()->mesh_set_custom_aabb(mesh, aabb); + set_aabb(aabb); + set_base(mesh); RID mat = SpatialMaterial::get_material_rid_for_2d(get_draw_flag(FLAG_SHADED), get_draw_flag(FLAG_TRANSPARENT), get_draw_flag(FLAG_DOUBLE_SIDED), get_alpha_cut_mode() == ALPHA_CUT_DISCARD, get_alpha_cut_mode() == ALPHA_CUT_OPAQUE_PREPASS, get_billboard_mode() == SpatialMaterial::BILLBOARD_ENABLED, get_billboard_mode() == SpatialMaterial::BILLBOARD_FIXED_Y);