diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2022-05-18 22:27:43 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2022-05-19 00:01:07 +0300 |
commit | c4c6ea7ea9f151ef79a13ae933029b1c6060eb69 (patch) | |
tree | 82cf2c25ccd6c2b06a177b7f706641824f564b3a /source/blender/blenlib | |
parent | c34e3f0f1925aa3a90f5d2a157ae42310d1f7e84 (diff) |
BLI: float4x4: Add << operator
Use nice formating to have lining up rows.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_float4x4.hh | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_float4x4.hh b/source/blender/blenlib/BLI_float4x4.hh index 9f7fbffc692..1ed4d2f1ae1 100644 --- a/source/blender/blenlib/BLI_float4x4.hh +++ b/source/blender/blenlib/BLI_float4x4.hh @@ -246,6 +246,25 @@ struct float4x4 { } return h; } + + friend std::ostream &operator<<(std::ostream &stream, const float4x4 &mat) + { + char fchar[16]; + stream << "(\n"; + for (int i = 0; i < 4; i++) { + stream << "("; + for (int j = 0; j < 4; j++) { + snprintf(fchar, sizeof(fchar), "%11.6f", mat[j][i]); + stream << fchar; + if (i != 3) { + stream << ", "; + } + } + stream << ")\n"; + } + stream << ")\n"; + return stream; + } }; } // namespace blender |