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:
Diffstat (limited to 'source/blender/blenlib/BLI_float4x4.hh')
-rw-r--r--source/blender/blenlib/BLI_float4x4.hh56
1 files changed, 39 insertions, 17 deletions
diff --git a/source/blender/blenlib/BLI_float4x4.hh b/source/blender/blenlib/BLI_float4x4.hh
index 0abfb751ebf..b4f12f17cc2 100644
--- a/source/blender/blenlib/BLI_float4x4.hh
+++ b/source/blender/blenlib/BLI_float4x4.hh
@@ -46,23 +46,6 @@ struct float4x4 {
return (const float *)this;
}
- float4x4 inverted() const
- {
- float result[4][4];
- invert_m4_m4(result, values);
- return result;
- }
-
- /**
- * Matrix inversion can be implemented more efficiently for affine matrices.
- */
- float4x4 inverted_affine() const
- {
- BLI_assert(values[0][3] == 0.0f && values[1][3] == 0.0f && values[2][3] == 0.0f &&
- values[3][3] == 1.0f);
- return this->inverted();
- }
-
friend float4x4 operator*(const float4x4 &a, const float4x4 &b)
{
float4x4 result;
@@ -86,6 +69,35 @@ struct float4x4 {
return m * float3(v);
}
+ float4x4 inverted() const
+ {
+ float4x4 result;
+ invert_m4_m4(result.values, values);
+ return result;
+ }
+
+ /**
+ * Matrix inversion can be implemented more efficiently for affine matrices.
+ */
+ float4x4 inverted_affine() const
+ {
+ BLI_assert(values[0][3] == 0.0f && values[1][3] == 0.0f && values[2][3] == 0.0f &&
+ values[3][3] == 1.0f);
+ return this->inverted();
+ }
+
+ float4x4 transposed() const
+ {
+ float4x4 result;
+ transpose_m4_m4(result.values, values);
+ return result;
+ }
+
+ float4x4 inverted_transposed_affine() const
+ {
+ return this->inverted_affine().transposed();
+ }
+
struct float3x3_ref {
const float4x4 &data;
@@ -108,6 +120,16 @@ struct float4x4 {
interp_m4_m4m4(result, a.values, b.values, t);
return result;
}
+
+ uint64_t hash() const
+ {
+ uint64_t h = 435109;
+ for (int i = 0; i < 16; i++) {
+ float value = ((const float *)this)[i];
+ h = h * 33 + (*(uint32_t *)&value);
+ }
+ return h;
+ }
};
} // namespace blender