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 <ideasman42@gmail.com>2014-02-28 14:23:06 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-02-28 14:26:19 +0400
commitf4bf97729a4e83e462f63574a32f5209be8812f6 (patch)
tree86275532a98a1c84a4361a92d348b578cb9a03fe
parent771b0e354c3ce3fbce5f73c3ca42e8ce0465659a (diff)
Crazyspace: calculate normal around a (0,0,0)
instead of creating a new triangle in the models space and using that.
-rw-r--r--source/blender/editors/util/crazyspace.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/source/blender/editors/util/crazyspace.c b/source/blender/editors/util/crazyspace.c
index 86d2017e997..b90cfad28a5 100644
--- a/source/blender/editors/util/crazyspace.c
+++ b/source/blender/editors/util/crazyspace.c
@@ -55,21 +55,23 @@ typedef struct {
BLI_bitmap *vertex_visit;
} MappedUserData;
-BLI_INLINE void tan_calc_v3(float a[3], const float b[3], const float c[3])
-{
- a[0] = b[0] + 0.2f * (b[0] - c[0]);
- a[1] = b[1] + 0.2f * (b[1] - c[1]);
- a[2] = b[2] + 0.2f * (b[2] - c[2]);
-}
-
BLI_INLINE void tan_calc_quat_v3(
float r_quat[4],
const float co_1[3], const float co_2[3], const float co_3[3])
{
float vec_u[3], vec_v[3];
- tan_calc_v3(vec_u, co_1, co_2);
- tan_calc_v3(vec_v, co_1, co_3);
- if (tri_to_quat(r_quat, co_1, vec_u, vec_v) < FLT_EPSILON) {
+ float nor[3];
+
+ sub_v3_v3v3(vec_u, co_1, co_2);
+ sub_v3_v3v3(vec_v, co_1, co_3);
+
+ cross_v3_v3v3(nor, vec_u, vec_v);
+
+ if (normalize_v3(nor) > FLT_EPSILON) {
+ const float zero_vec[3] = {0.0f};
+ tri_to_quat_ex(r_quat, zero_vec, vec_u, vec_v, nor);
+ }
+ else {
unit_qt(r_quat);
}
}