More robust saturation mechanism

This commit is contained in:
Clement Roblot 2024-11-27 00:29:08 +07:00
parent 907e146385
commit 52e92a99be
2 changed files with 5 additions and 4 deletions

View File

@ -78,10 +78,10 @@ class HBox : public Node {
selection.y_max > box_.y_max || selection.x_max > box_.x_max; selection.y_max > box_.y_max || selection.x_max > box_.x_max;
if (xmin_saturated) { if (xmin_saturated) {
selection.x_min = box_.x_min; selection.x_min = std::min(box_.x_min, selection.x_min);
} }
if (xmax_saturated) { if (xmax_saturated) {
selection.x_max = box_.x_max; selection.x_max = std::max(box_.x_max, selection.x_max);
} }
for (auto& child : children_) { for (auto& child : children_) {

View File

@ -76,11 +76,12 @@ class VBox : public Node {
selection.x_min < box_.x_min || selection.y_min < box_.y_min; selection.x_min < box_.x_min || selection.y_min < box_.y_min;
const bool ymax_saturated = const bool ymax_saturated =
selection.x_max > box_.x_max || selection.y_max > box_.y_max; selection.x_max > box_.x_max || selection.y_max > box_.y_max;
if (ymin_saturated) { if (ymin_saturated) {
selection.y_min = box_.y_min; selection.y_min = std::min(box_.y_min, selection.y_min);
} }
if (ymax_saturated) { if (ymax_saturated) {
selection.y_max = box_.y_max; selection.y_max = std::max(box_.y_max, selection.y_max);
} }
for (auto& child : children_) { for (auto& child : children_) {