[Bf-blender-cvs] [c556ce9] hair_system: Transform3 type for pure rotational matrices.
Lukas Tönne
noreply at git.blender.org
Tue Jul 29 15:47:41 CEST 2014
Commit: c556ce9a5d7590fdd469d84d69d8bfaeb18bfcca
Author: Lukas Tönne
Date: Tue Jul 29 13:45:32 2014 +0200
Branches: hair_system
https://developer.blender.org/rBc556ce9a5d7590fdd469d84d69d8bfaeb18bfcca
Transform3 type for pure rotational matrices.
===================================================================
M source/blender/hair/intern/HAIR_types.cpp
M source/blender/hair/intern/HAIR_types.h
===================================================================
diff --git a/source/blender/hair/intern/HAIR_types.cpp b/source/blender/hair/intern/HAIR_types.cpp
index 4ade06c..4066dc4 100644
--- a/source/blender/hair/intern/HAIR_types.cpp
+++ b/source/blender/hair/intern/HAIR_types.cpp
@@ -33,4 +33,8 @@ const Transform Transform::Identity = Transform(float4(1.0f, 0.0f, 0.0f, 0.0f),
float4(0.0f, 0.0f, 1.0f, 0.0f),
float4(0.0f, 0.0f, 0.0f, 1.0f));
+const Transform3 Transform3::Identity = Transform3(float3(1.0f, 0.0f, 0.0f),
+ float3(0.0f, 1.0f, 0.0f),
+ float3(0.0f, 0.0f, 1.0f));
+
HAIR_NAMESPACE_END
diff --git a/source/blender/hair/intern/HAIR_types.h b/source/blender/hair/intern/HAIR_types.h
index ad24476..7699cce 100644
--- a/source/blender/hair/intern/HAIR_types.h
+++ b/source/blender/hair/intern/HAIR_types.h
@@ -102,7 +102,7 @@ struct float4 {
};
-typedef struct Transform {
+struct Transform {
float4 x, y, z, w; /* rows */
static const Transform Identity;
@@ -149,7 +149,27 @@ typedef struct Transform {
float4_col col(int i) { return float4_col(*this, i); }
float4_col_const col(int i) const { return float4_col_const(*this, i); }
-} Transform;
+};
+
+struct Transform3 {
+ float3 x, y, z; /* rows */
+
+ static const Transform3 Identity;
+
+ __forceinline Transform3() {}
+ __forceinline Transform3(const float3 &x, const float3 &y, const float3 &z) : x(x), y(y), z(z) {}
+ __forceinline Transform3(float data[3][3]) :
+ x(data[0][0], data[1][0], data[2][0]),
+ y(data[0][1], data[1][1], data[2][1]),
+ z(data[0][2], data[1][2], data[2][2])
+ {}
+
+ __forceinline float3 operator[](int i) const { return *(&x + i); }
+ __forceinline float3& operator[](int i) { return *(&x + i); }
+
+ float3 row(int i) const { return *(&x + i); }
+ float3 &row(int i) { return *(&x + i); }
+};
/* -------------------------------------------------- */
More information about the Bf-blender-cvs
mailing list