Merge pull request #101700 from scgm0/Fix-ViewportTexture--get_size

Fix `ViewportTexture::get_size`
This commit is contained in:
Thaddeus Crews 2025-01-21 11:55:33 -06:00
commit b5737f897e
No known key found for this signature in database
GPG key ID: 62181B86FE9E5D84

View file

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