Skip to content

Commit c85c35c

Browse files
cfontasFuchsia Internal LUCI
authored andcommitted
[flatland] Fix Pixel Scale Calculation
Pixel Scale calculation in the LinkSystem was incorrectly extracting the scale value from matrices, and including translations in the calculation, causing unnecessarily large scales to be returned to clients. Fixed: 90588 Change-Id: I5322bd99437e66013a43a7ae14421f6d55737c6c Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/680137 Commit-Queue: Chris Fontas <cfontas@google.com> Reviewed-by: Emircan Uysaler <emircan@google.com>
1 parent d214d17 commit c85c35c

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/ui/scenic/lib/flatland/link_system.cc

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,20 @@ namespace flatland {
2020

2121
namespace {
2222

23+
// Scale can be extracted from a matrix by finding the length of the
24+
// column the scale is located in:
25+
//
26+
// a b c
27+
// e f g
28+
// i j k
29+
//
30+
// If |a| is the x scale and rotation, and |f| is the y scale and rotation, then
31+
// we can calculate the x scale with length(vector(a,e,i)) and y scale with
32+
// length(vector(b,f,j)).
2333
glm::vec2 ComputeScale(const glm::mat3& matrix) {
24-
const glm::vec3 x_row = glm::row(matrix, 0);
25-
const glm::vec3 y_row = glm::row(matrix, 1);
26-
return {std::fabs(glm::length(x_row)), std::fabs(glm::length(y_row))};
34+
const glm::vec3 x_column = glm::column(matrix, 0);
35+
const glm::vec3 y_column = glm::column(matrix, 1);
36+
return {glm::length(x_column), glm::length(y_column)};
2737
}
2838

2939
} // namespace

0 commit comments

Comments
 (0)