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:
authorLukas Tönne <lukas.toenne@gmail.com>2014-09-12 13:22:39 +0400
committerLukas Tönne <lukas.toenne@gmail.com>2015-01-20 11:29:59 +0300
commitb391e963a98db4dded824e29e50147d754757a75 (patch)
tree2f6a065e3ae15feb6c7ac62eb171ef578beeb819 /source/blender/blenkernel
parentc5038b12c3d06d34c121412ceac14c08dda75bb2 (diff)
Option for disabling the root frame transformation altogether, mostly
for testing.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/intern/implicit.c62
-rw-r--r--source/blender/blenkernel/intern/implicit.h2
2 files changed, 64 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c
index 78f615e9a67..e8b78bd60fd 100644
--- a/source/blender/blenkernel/intern/implicit.c
+++ b/source/blender/blenkernel/intern/implicit.c
@@ -806,43 +806,66 @@ int implicit_free(ClothModifierData *clmd)
/* x_root = R^T * x_world */
BLI_INLINE void loc_world_to_root(float r[3], const float v[3], const RootTransform *root)
{
+#ifdef CLOTH_ROOT_FRAME
sub_v3_v3v3(r, v, root->loc);
mul_transposed_m3_v3((float (*)[3])root->rot, r);
+#else
+ copy_v3_v3(r, v);
+ (void)root;
+#endif
}
/* x_world = R * x_root */
BLI_INLINE void loc_root_to_world(float r[3], const float v[3], const RootTransform *root)
{
+#ifdef CLOTH_ROOT_FRAME
copy_v3_v3(r, v);
mul_m3_v3((float (*)[3])root->rot, r);
add_v3_v3(r, root->loc);
+#else
+ copy_v3_v3(r, v);
+ (void)root;
+#endif
}
/* v_root = cross(w, x_root) + R^T*(v_world - v0) */
BLI_INLINE void vel_world_to_root(float r[3], const float x_root[3], const float v[3], const RootTransform *root)
{
+#ifdef CLOTH_ROOT_FRAME
float angvel[3];
cross_v3_v3v3(angvel, root->omega, x_root);
sub_v3_v3v3(r, v, root->vel);
mul_transposed_m3_v3((float (*)[3])root->rot, r);
add_v3_v3(r, angvel);
+#else
+ copy_v3_v3(r, v);
+ (void)x_root;
+ (void)root;
+#endif
}
/* v_world = R*(v_root - cross(w, x_root)) + v0 */
BLI_INLINE void vel_root_to_world(float r[3], const float x_root[3], const float v[3], const RootTransform *root)
{
+#ifdef CLOTH_ROOT_FRAME
float angvel[3];
cross_v3_v3v3(angvel, root->omega, x_root);
sub_v3_v3v3(r, v, angvel);
mul_m3_v3((float (*)[3])root->rot, r);
add_v3_v3(r, root->vel);
+#else
+ copy_v3_v3(r, v);
+ (void)x_root;
+ (void)root;
+#endif
}
/* a_root = -cross(dwdt, x_root) - 2*cross(w, v_root) - cross(w, cross(w, x_root)) + R^T*(a_world - a0) */
BLI_INLINE void force_world_to_root(float r[3], const float x_root[3], const float v_root[3], const float force[3], float mass, const RootTransform *root)
{
+#ifdef CLOTH_ROOT_FRAME
float euler[3], coriolis[3], centrifugal[3], rotvel[3];
cross_v3_v3v3(euler, root->domega_dt, x_root);
@@ -856,11 +879,19 @@ BLI_INLINE void force_world_to_root(float r[3], const float x_root[3], const flo
madd_v3_v3fl(r, euler, mass);
madd_v3_v3fl(r, coriolis, mass);
madd_v3_v3fl(r, centrifugal, mass);
+#else
+ copy_v3_v3(r, force);
+ (void)x_root;
+ (void)v_root;
+ (void)mass;
+ (void)root;
+#endif
}
/* a_world = R*[ a_root + cross(dwdt, x_root) + 2*cross(w, v_root) + cross(w, cross(w, x_root)) ] + a0 */
BLI_INLINE void force_root_to_world(float r[3], const float x_root[3], const float v_root[3], const float force[3], float mass, const RootTransform *root)
{
+#ifdef CLOTH_ROOT_FRAME
float euler[3], coriolis[3], centrifugal[3], rotvel[3];
cross_v3_v3v3(euler, root->domega_dt, x_root);
@@ -874,6 +905,13 @@ BLI_INLINE void force_root_to_world(float r[3], const float x_root[3], const flo
madd_v3_v3fl(r, centrifugal, mass);
mul_m3_v3((float (*)[3])root->rot, r);
madd_v3_v3fl(r, root->acc, mass);
+#else
+ copy_v3_v3(r, force);
+ (void)x_root;
+ (void)v_root;
+ (void)mass;
+ (void)root;
+#endif
}
BLI_INLINE void acc_world_to_root(float r[3], const float x_root[3], const float v_root[3], const float acc[3], const RootTransform *root)
@@ -903,6 +941,7 @@ BLI_INLINE void cross_v3_identity(float r[3][3], const float v[3])
/* dfdx_root = m*[ -cross(dwdt, I) - cross(w, cross(w, I)) ] + R^T*(dfdx_world) */
BLI_INLINE void dfdx_world_to_root(float m[3][3], float dfdx[3][3], float mass, const RootTransform *root)
{
+#ifdef CLOTH_ROOT_FRAME
float t[3][3], u[3][3];
copy_m3_m3(t, (float (*)[3])root->rot);
@@ -917,11 +956,17 @@ BLI_INLINE void dfdx_world_to_root(float m[3][3], float dfdx[3][3], float mass,
cross_m3_v3m3(t, root->omega, u);
mul_m3_fl(t, mass);
sub_m3_m3m3(m, m, t);
+#else
+ copy_m3_m3(m, dfdx);
+ (void)mass;
+ (void)root;
+#endif
}
/* dfdx_world = R*(dfdx_root + m*[ cross(dwdt, I) + cross(w, cross(w, I)) ]) */
BLI_INLINE void dfdx_root_to_world(float m[3][3], float dfdx[3][3], float mass, const RootTransform *root)
{
+#ifdef CLOTH_ROOT_FRAME
float t[3][3], u[3][3];
cross_v3_identity(t, root->domega_dt);
@@ -934,11 +979,17 @@ BLI_INLINE void dfdx_root_to_world(float m[3][3], float dfdx[3][3], float mass,
add_m3_m3m3(m, m, t);
mul_m3_m3m3(m, (float (*)[3])root->rot, m);
+#else
+ copy_m3_m3(m, dfdx);
+ (void)mass;
+ (void)root;
+#endif
}
/* dfdv_root = -2*m*cross(w, I) + R^T*(dfdv_world) */
BLI_INLINE void dfdv_world_to_root(float m[3][3], float dfdv[3][3], float mass, const RootTransform *root)
{
+#ifdef CLOTH_ROOT_FRAME
float t[3][3];
copy_m3_m3(t, (float (*)[3])root->rot);
@@ -948,11 +999,17 @@ BLI_INLINE void dfdv_world_to_root(float m[3][3], float dfdv[3][3], float mass,
cross_v3_identity(t, root->omega);
mul_m3_fl(t, 2.0f*mass);
sub_m3_m3m3(m, m, t);
+#else
+ copy_m3_m3(m, dfdv);
+ (void)mass;
+ (void)root;
+#endif
}
/* dfdv_world = R*(dfdv_root + 2*m*cross(w, I)) */
BLI_INLINE void dfdv_root_to_world(float m[3][3], float dfdv[3][3], float mass, const RootTransform *root)
{
+#ifdef CLOTH_ROOT_FRAME
float t[3][3];
cross_v3_identity(t, root->omega);
@@ -960,6 +1017,11 @@ BLI_INLINE void dfdv_root_to_world(float m[3][3], float dfdv[3][3], float mass,
add_m3_m3m3(m, dfdv, t);
mul_m3_m3m3(m, (float (*)[3])root->rot, m);
+#else
+ copy_m3_m3(m, dfdv);
+ (void)mass;
+ (void)root;
+#endif
}
/* ================================ */
diff --git a/source/blender/blenkernel/intern/implicit.h b/source/blender/blenkernel/intern/implicit.h
index 144560e8867..31b8069846e 100644
--- a/source/blender/blenkernel/intern/implicit.h
+++ b/source/blender/blenkernel/intern/implicit.h
@@ -39,6 +39,8 @@
//#define IMPLICIT_SOLVER_EIGEN
#define IMPLICIT_SOLVER_BLENDER
+#define CLOTH_ROOT_FRAME /* enable use of root frame coordinate transform */
+
#define CLOTH_FORCE_GRAVITY
#define CLOTH_FORCE_DRAG
#define CLOTH_FORCE_SPRING_STRUCTURAL