@@ -47,11 +47,11 @@ pp_addhdr('
4747 to[1] = -(v1[0]*v2[2] - v2[0]*v1[2]); \
4848 to[2] = v1[0]*v2[1] - v2[0]*v1[1]; \
4949 }
50- #define PDL_3D_UNITISE (v, factor ) \
50+ #define PDL_3D_SETVECLEN (v, newlen ) \
5151 { \
52- float len = sqrtf(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]); \
52+ float len = sqrtf(v[0]* v[0] + v[1]* v[1] + v[2]* v[2]), fac = newlen/len ; \
5353 int i; \
54- for (i = 0; i < 3; i++) v[i] *= factor/len ; \
54+ for (i = 0; i < 3; i++) v[i] *= fac ; \
5555 }
5656');
5757
@@ -181,9 +181,9 @@ broadcastloop %{
181181 %}
182182 PDL_3D_CROSS(norm, tmp1, tmp2);
183183 PDL_3D_CROSS(norm2, tmp1, norm);
184- PDL_3D_UNITISE (norm, w);
185- PDL_3D_UNITISE (norm2, w);
186- PDL_3D_UNITISE (tmp1, 1);
184+ PDL_3D_SETVECLEN (norm, w);
185+ PDL_3D_SETVECLEN (norm2, w);
186+ PDL_3D_SETVECLEN (tmp1, 1);
187187 glBegin(GL_LINES);
188188 glVertex3d( $coords(tri => 0, n => a) ,
189189 $coords(tri => 1, n => a) ,
@@ -254,7 +254,7 @@ loop(f) %{
254254 tmp0_2[tri] = $vertices(v => vertidx[2]) - $vertices(v => vertidx[0]);
255255 %}
256256 PDL_3D_CROSS(tmpcross, tmp0_1, tmp0_2);
257- PDL_3D_UNITISE (tmpcross, 1);
257+ PDL_3D_SETVECLEN (tmpcross, 1);
258258 loop(tri) %{ $facenorm() = tmpcross[tri]; %}
259259 loop(trivert,tri) %{ $vertnorm(v=>vertidx[trivert]) += $facenorm(); %}
260260%}
0 commit comments