We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7a16fb2 commit cdb3376Copy full SHA for cdb3376
lib/PDL/Graphics/OpenGLQ.pd
@@ -47,9 +47,11 @@ pp_addhdr('
47
to[1] = -(v1[0]*v2[2] - v2[0]*v1[2]); \
48
to[2] = v1[0]*v2[1] - v2[0]*v1[1]; \
49
}
50
+#define PDL_3D_VECLEN(v) \
51
+ sqrtf(v[0]*v[0] + v[1]*v[1] + v[2]*v[2])
52
#define PDL_3D_SETVECLEN(v, newlen) \
53
{ \
- float len = sqrtf(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]), fac = newlen/len; \
54
+ float len = PDL_3D_VECLEN(v), fac = newlen/len; \
55
int i; \
56
for (i = 0; i < 3; i++) v[i] *= fac; \
57
@@ -186,8 +188,9 @@ loop(n) %{
186
188
%}
187
189
PDL_3D_CROSS(norm, tmp1, tmp2);
190
PDL_3D_CROSS(norm2, tmp1, norm);
- PDL_3D_SETVECLEN(norm, w);
- PDL_3D_SETVECLEN(norm2, w);
191
+ float wthis = w*PDL_3D_VECLEN(tmp1);
192
+ PDL_3D_SETVECLEN(norm, wthis);
193
+ PDL_3D_SETVECLEN(norm2, wthis);
194
PDL_3D_SETVECLEN(tmp1, 1);
195
loop(tri) %{ $trivertices(nv=>nvbase+0) = $coords(v => b); %}
196
loop(tri) %{ $trivertices(nv=>nvbase+1) = partback[tri] + norm[tri]; %}
0 commit comments