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.hh26
1 files changed, 19 insertions, 7 deletions
diff --git a/source/blender/blenlib/BLI_float4x4.hh b/source/blender/blenlib/BLI_float4x4.hh
index a8b939ed32e..0433197b22a 100644
--- a/source/blender/blenlib/BLI_float4x4.hh
+++ b/source/blender/blenlib/BLI_float4x4.hh
@@ -31,18 +31,18 @@ struct float4x4 {
memcpy(values, matrix, sizeof(float) * 16);
}
- float4x4(const float matrix[4][4]) : float4x4((float *)matrix)
+ float4x4(const float matrix[4][4]) : float4x4(static_cast<const float *>(matrix[0]))
{
}
operator float *()
{
- return (float *)this;
+ return &values[0][0];
}
operator const float *() const
{
- return (const float *)this;
+ return &values[0][0];
}
friend float4x4 operator*(const float4x4 &a, const float4x4 &b)
@@ -70,8 +70,8 @@ struct float4x4 {
float4x4 inverted() const
{
- float result[4][4];
- invert_m4_m4(result, values);
+ float4x4 result;
+ invert_m4_m4(result.values, values);
return result;
}
@@ -85,6 +85,18 @@ struct float4x4 {
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;
@@ -112,8 +124,8 @@ struct float4x4 {
{
uint64_t h = 435109;
for (int i = 0; i < 16; i++) {
- float value = ((const float *)this)[i];
- h = h * 33 + (*(uint32_t *)&value);
+ float value = (static_cast<const float *>(values[0]))[i];
+ h = h * 33 + *reinterpret_cast<const uint32_t *>(&value);
}
return h;
}