[Bf-blender-cvs] [2c7cd93] hair_system: Fallback for hair frame calculation from a single normal, in case the normal is in Z direction exactly.

Lukas Tönne noreply at git.blender.org
Tue Oct 14 16:28:41 CEST 2014


Commit: 2c7cd9337b5afb60c05dbf5c10d2d87dae731c4d
Author: Lukas Tönne
Date:   Tue Oct 14 16:27:25 2014 +0200
Branches: hair_system
https://developer.blender.org/rB2c7cd9337b5afb60c05dbf5c10d2d87dae731c4d

Fallback for hair frame calculation from a single normal, in case the
normal is in Z direction exactly.

This should be considered a temporary measure, the tangent should be
defined more reliably by the mesh sampling system.

===================================================================

M	source/blender/blenkernel/intern/hair.c

===================================================================

diff --git a/source/blender/blenkernel/intern/hair.c b/source/blender/blenkernel/intern/hair.c
index e7542bb..4b7aec3 100644
--- a/source/blender/blenkernel/intern/hair.c
+++ b/source/blender/blenkernel/intern/hair.c
@@ -258,7 +258,15 @@ static void get_hair_frame(float frame[3][3], const float normal[3], const float
 		const float up[3] = {0.0f, 0.0f, 1.0f};
 		
 		madd_v3_v3v3fl(frame[0], up, normal, -dot_v3v3(up, normal));
-		normalize_v3(frame[0]);
+		if (!is_zero_v3(frame[0])) {
+			normalize_v3(frame[0]);
+		}
+		else {
+			const float up[3] = {0.0f, 1.0f, 0.0f};
+			
+			madd_v3_v3v3fl(frame[0], up, normal, -dot_v3v3(up, normal));
+			normalize_v3(frame[0]);
+		}
 	}
 	
 	cross_v3_v3v3(frame[1], frame[2], frame[0]);




More information about the Bf-blender-cvs mailing list