libobs: Fix flip calculations in bounding box

This fixes flipping behaviour when positional alignement inside the
bounding box is other than centered, bringing it in line with the
behaviour when centered, i.e. flip the item in-place in the bounding
box.
This commit is contained in:
Penwywern 2023-07-06 22:46:43 +02:00 committed by Lain
parent cb5f65b529
commit 23ca4cf704

View file

@ -401,13 +401,19 @@ static void calculate_bounds_data(struct obs_scene_item *item,
width = (float)(*cx) * scale->x;
height = (float)(*cy) * scale->y;
width_diff = item->bounds.x - width;
height_diff = item->bounds.y - height;
/* Disregards flip when calculating size diff */
width_diff = item->bounds.x - fabsf(width);
height_diff = item->bounds.y - fabsf(height);
*cx = (uint32_t)item->bounds.x;
*cy = (uint32_t)item->bounds.y;
add_alignment(origin, item->bounds_align, (int)-width_diff,
(int)-height_diff);
/* Makes the item stay in-place in the box if flipped */
origin->x += (width < 0.0f) ? width : 0.0f;
origin->y += (height < 0.0f) ? height : 0.0f;
}
static inline uint32_t calc_cx(const struct obs_scene_item *item,