Fix ViewportTexture::get_size

This commit is contained in:
scgm0 2025-01-18 00:04:17 +08:00
parent 791c87eb7a
commit 949f707ad9

View file

@ -126,7 +126,10 @@ int ViewportTexture::get_width() const {
_err_print_viewport_not_set();
return 0;
}
return get_size().width;
if (vp->is_sub_viewport()) {
return vp->size.width;
}
return vp->size.width * vp->get_stretch_transform().get_scale().width;
}
int ViewportTexture::get_height() const {
@ -134,7 +137,10 @@ int ViewportTexture::get_height() const {
_err_print_viewport_not_set();
return 0;
}
return get_size().height;
if (vp->is_sub_viewport()) {
return vp->size.height;
}
return vp->size.height * vp->get_stretch_transform().get_scale().height;
}
Size2 ViewportTexture::get_size() const {
@ -142,8 +148,11 @@ Size2 ViewportTexture::get_size() const {
_err_print_viewport_not_set();
return Size2();
}
float scale = MIN(vp->get_screen_transform().get_scale().width, vp->get_screen_transform().get_scale().height);
return Size2(vp->size.width * scale, vp->size.height * scale).ceil();
if (vp->is_sub_viewport()) {
return vp->size;
}
Size2 scale = vp->get_stretch_transform().get_scale();
return Size2(vp->size.width * scale.width, vp->size.height * scale.height).ceil();
}
RID ViewportTexture::get_rid() const {