Blender V5.3
gpu_shader_math_matrix_conversion.bsl.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
11
12/* -------------------------------------------------------------------- */
15
20{
21 return float3(length(mat[0]), length(mat[1]), length(mat[2]));
22}
23
27{
28 return to_scale(to_float3x3(mat));
29}
30
33template<typename MatT, bool allow_negative_scale> float3 to_scale(MatT mat)
34{
35 float3 result = to_scale(mat);
36 if (allow_negative_scale) {
37 if (is_negative(mat)) {
38 result = -result;
39 }
40 }
41 return result;
42}
47
float length(VecOp< float, D >) RET
bool is_negative(float3x3 mat)
float3 to_scale(float3x3 mat)
MatBase< float, 4, 4 > float4x4