Merge pull request #32571 from DavidSichma/rect_flip

Correctly flip texture src region
This commit is contained in:
Rémi Verschelde 2019-10-08 16:15:45 +02:00 committed by GitHub
commit 45577e4233
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View file

@ -926,7 +926,7 @@ void ItemList::_notification(int p_what) {
current_columns = max_columns; current_columns = max_columns;
while (true) { while (true) {
//repeat util all fits //repeat until all fits
bool all_fit = true; bool all_fit = true;
Vector2 ofs; Vector2 ofs;
int col = 0; int col = 0;

View file

@ -680,11 +680,22 @@ void VisualServerCanvas::canvas_item_add_texture_rect_region(RID p_item, const R
rect->flags |= RasterizerCanvas::CANVAS_RECT_FLIP_H; rect->flags |= RasterizerCanvas::CANVAS_RECT_FLIP_H;
rect->rect.size.x = -rect->rect.size.x; rect->rect.size.x = -rect->rect.size.x;
} }
if (p_src_rect.size.x < 0) {
rect->flags ^= RasterizerCanvas::CANVAS_RECT_FLIP_H;
rect->source.size.x = -rect->source.size.x;
}
if (p_rect.size.y < 0) { if (p_rect.size.y < 0) {
rect->flags |= RasterizerCanvas::CANVAS_RECT_FLIP_V; rect->flags |= RasterizerCanvas::CANVAS_RECT_FLIP_V;
rect->rect.size.y = -rect->rect.size.y; rect->rect.size.y = -rect->rect.size.y;
} }
if (p_src_rect.size.y < 0) {
rect->flags ^= RasterizerCanvas::CANVAS_RECT_FLIP_V;
rect->source.size.y = -rect->source.size.y;
}
if (p_transpose) { if (p_transpose) {
rect->flags |= RasterizerCanvas::CANVAS_RECT_TRANSPOSE; rect->flags |= RasterizerCanvas::CANVAS_RECT_TRANSPOSE;
SWAP(rect->rect.size.x, rect->rect.size.y); SWAP(rect->rect.size.x, rect->rect.size.y);