Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <campbell@blender.org>2022-08-24 09:34:04 +0300
committerCampbell Barton <campbell@blender.org>2022-08-24 09:34:04 +0300
commit4fb64068a7f02cede132b0f011caafb86b32414b (patch)
tree658f994db4ff5ddf926124e1abf50909a011c0a3 /source/blender/blenlib/BLI_math_matrix.h
parentf39c9d1596f7e2efae2cac30e09dc87989485c6f (diff)
Cleanup: use determinant_m3(m) < 0 to implement is_negative_m3/m4
Use a more direct method of checking if a matrix is negative instead of using cross & dot product. Also replace some determinant_m3() < 0 checks with is_negative_m3.
Diffstat (limited to 'source/blender/blenlib/BLI_math_matrix.h')
-rw-r--r--source/blender/blenlib/BLI_math_matrix.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h
index 15264dbe8b7..87a01e0c264 100644
--- a/source/blender/blenlib/BLI_math_matrix.h
+++ b/source/blender/blenlib/BLI_math_matrix.h
@@ -528,7 +528,18 @@ void interp_m3_m3m3(float R[3][3], const float A[3][3], const float B[3][3], flo
*/
void interp_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4], float t);
+/**
+ * Return true when the matrices determinant is less than zero.
+ *
+ * \note This is often used to check if a matrix flips content in 3D space,
+ * where transforming geometry (for example) would flip the direction of polygon normals
+ * from pointing outside a closed volume, to pointing inside (or the reverse).
+ *
+ * When the matrix is constructed from location, rotation & scale
+ * as matrix will be negative when it has an odd number of negative scales.
+ */
bool is_negative_m3(const float mat[3][3]);
+/** A version of #is_negative_m3 that takes a 4x4 matrix. */
bool is_negative_m4(const float mat[4][4]);
bool is_zero_m3(const float mat[3][3]);