Skip to content

Commit

Permalink
PropTool: Fix sel outling when scale is negative
Browse files Browse the repository at this point in the history
  • Loading branch information
cmann1 committed Feb 3, 2023
1 parent 79931ee commit 35ebc4b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 10 deletions.
30 changes: 22 additions & 8 deletions ed/adv_tools/tools/prop_tool/PropData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,18 +424,32 @@ class PropData : SelectableData

void store_selection_bounds()
{
selection_local_x1 = local_x1 / abs(prop_scale_x);
selection_local_y1 = local_y1 / abs(prop_scale_y);
selection_local_x2 = local_x2 / abs(prop_scale_x);
selection_local_y2 = local_y2 / abs(prop_scale_y);
selection_local_x1 = local_x1 / prop_scale_x;
selection_local_y1 = local_y1 / prop_scale_y;
selection_local_x2 = local_x2 / prop_scale_x;
selection_local_y2 = local_y2 / prop_scale_y;
}

void get_selection_bounds(float &out x1, float &out y1, float &out x2, float &out y2)
{
x1 = selection_local_x1 * abs(prop_scale_x);
y1 = selection_local_y1 * abs(prop_scale_y);
x2 = selection_local_x2 * abs(prop_scale_x);
y2 = selection_local_y2 * abs(prop_scale_y);
x1 = selection_local_x1 * prop_scale_x;
y1 = selection_local_y1 * prop_scale_y;
x2 = selection_local_x2 * prop_scale_x;
y2 = selection_local_y2 * prop_scale_y;

if(x2 < x1)
{
const float t = x1;
x1 = x2;
x2 = t;
}

if(y2 < y1)
{
const float t = y1;
y1 = y2;
y2 = t;
}
}

//
Expand Down
14 changes: 12 additions & 2 deletions ed/adv_tools/tools/prop_tool/PropTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ class PropTool : Tool

if(script.alt.down)
{
update_selection_bounds();
update_selection_bounds(scale < 0);
}
else
{
Expand Down Expand Up @@ -1360,7 +1360,7 @@ class PropTool : Tool
selection_y2 -= selection_y;
}

private void update_selection_bounds()
private void update_selection_bounds(const bool flipped=false)
{
selection_x1 = MAX_FLOAT;
selection_y1 = MAX_FLOAT;
Expand All @@ -1383,6 +1383,16 @@ class PropTool : Tool
selection_y1 -= selection_y;
selection_x2 -= selection_x;
selection_y2 -= selection_y;

if(flipped)
{
const float tx = selection_x1;
const float ty = selection_y1;
selection_x1 = selection_x2;
selection_y1 = selection_y2;
selection_x2 = tx;
selection_y2 = ty;
}
}

private void update_selection_layer()
Expand Down

0 comments on commit 35ebc4b

Please sign in to comment.