Subversion Repositories gelsvn

Rev

Rev 419 | Rev 595 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 419 Rev 541
Line 38... Line 38...
38
		// For each face
38
		// For each face
39
		int NF = geometry.no_faces();
39
		int NF = geometry.no_faces();
40
		for(i=0;i<NF; ++i)
40
		for(i=0;i<NF; ++i)
41
      {
41
      {
42
				// Compute the normal
42
				// Compute the normal
43
				const Vec3i f  = geometry.face(i);
43
				const Vec3i& f  = geometry.face(i);
44
				const Vec3f p0 = geometry.vertex(f[0]);
44
				const Vec3f& p0 = geometry.vertex(f[0]);
45
				const Vec3f a  = geometry.vertex(f[1]) - p0;
45
				const Vec3f& a  = geometry.vertex(f[1]) - p0;
46
				const Vec3f b  = geometry.vertex(f[2]) - p0;
46
				const Vec3f& b  = geometry.vertex(f[2]) - p0;
47
				Vec3f face_normal = cross(a,b);
47
				Vec3f face_normal = cross(a,b);
48
				float l = sqr_length(face_normal);
48
				float l = sqr_length(face_normal);
49
				if(l > 0.0f)
49
				if(l > 0.0f)
50
					face_normal /= sqrt(l);
50
					face_normal /= sqrt(l);
51
				
51
				
52
				// Add the angle weighted normal to each vertex
52
				// Add the angle weighted normal to each vertex
53
				for(int j=0;j<3; ++j)
53
				for(int j=0;j<3; ++j)
54
					{
54
					{
55
						const Vec3f p0 = geometry.vertex(f[j]);
55
						const Vec3f& p0 = geometry.vertex(f[j]);
56
						Vec3f a = geometry.vertex(f[(j+1)%3]) - p0;
56
						Vec3f a = geometry.vertex(f[(j+1)%3]) - p0;
57
						float l_a = sqr_length(a);
57
						float l_a = sqr_length(a);
58
						if(l_a > 0.0f)
58
						if(l_a > 0.0f)
59
							a /= sqrt(l_a);
59
							a /= sqrt(l_a);
60
						Vec3f b = geometry.vertex(f[(j+2)%3]) - p0;
60
						Vec3f b = geometry.vertex(f[(j+2)%3]) - p0;