Merge pull request #112593 from kleonc/sprite3d_no_redrawing_outside_tree

Don't redraw `Sprite3D`/`AnimatedSprite3D` outside the tree
This commit is contained in:
Rémi Verschelde
2025-11-26 23:43:51 +01:00
2 changed files with 13 additions and 6 deletions

View File

@ -68,17 +68,17 @@ void SpriteBase3D::_propagate_color_changed() {
void SpriteBase3D::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
if (!pending_update) {
_im_update();
}
_im_update();
} break;
case NOTIFICATION_PARENTED: {
parent_sprite = Object::cast_to<SpriteBase3D>(get_parent());
if (parent_sprite) {
pI = parent_sprite->children.push_back(this);
}
} break;
case NOTIFICATION_EXIT_TREE: {
case NOTIFICATION_UNPARENTED: {
if (parent_sprite) {
parent_sprite->children.erase(pI);
pI = nullptr;
@ -417,15 +417,21 @@ Vector3::Axis SpriteBase3D::get_axis() const {
}
void SpriteBase3D::_im_update() {
if (!redraw_needed) {
return;
}
_draw();
redraw_needed = false;
pending_update = false;
//texture->draw_rect_region(ci,dst_rect,src_rect,modulate);
}
void SpriteBase3D::_queue_redraw() {
// The 3D equivalent of CanvasItem.queue_redraw().
redraw_needed = true;
if (!is_inside_tree()) {
return;
}
if (pending_update) {
return;
}

View File

@ -92,6 +92,7 @@ private:
float alpha_antialiasing_edge = 0.0f;
StandardMaterial3D::BillboardMode billboard_mode = StandardMaterial3D::BILLBOARD_DISABLED;
StandardMaterial3D::TextureFilter texture_filter = StandardMaterial3D::TEXTURE_FILTER_LINEAR_WITH_MIPMAPS;
bool redraw_needed = false;
bool pending_update = false;
void _im_update();