@@ -23,11 +23,11 @@ only for internal use - see source
2323
2424=head1 AUTHOR
2525
26- Copyright (C) 1997,1998 Tuomas J. Lukka.
26+ Copyright (C) 1997,1998 Tuomas J. Lukka.
2727All rights reserved. There is no warranty. You are allowed
2828to redistribute this software / documentation under certain
29- conditions. For details, see the file COPYING in the PDL
30- distribution. If this file is separated from the PDL distribution,
29+ conditions. For details, see the file COPYING in the PDL
30+ distribution. If this file is separated from the PDL distribution,
3131the copyright notice should be included in the file.
3232
3333=cut
@@ -188,7 +188,7 @@ pp_def('gl_arrows',
188188 float tmp2[3] = { 0.000001, -0.0001, 1 };
189189 broadcastloop %{
190190 PDL_Indx a = $indsa(), b = $indsb();
191- float tmp1[3];
191+ float tmp1[3];
192192 float norm[3];
193193 float norm2[3];
194194 float normlen,origlen,norm2len;
@@ -276,4 +276,19 @@ pp_def('gl_arrows',
276276 @internal
277277);
278278
279+ pp_def('vertex_normals',
280+ Pars => 'vertices(tri=3,v); facenormals(tri,f); uint faceidx(trivert=3,f); [o] vertnorm(tri,v)',
281+ GenericTypes => $F,
282+ Code => <<'EOF',
283+ loop(v,tri) %{ $vertnorm() = 0.0f; %}
284+ loop(f,trivert) %{
285+ PDL_ULong vertidx = $faceidx();
286+ if (vertidx >= $SIZE(v))
287+ $CROAK("faceidx number %"IND_FLAG",%"IND_FLAG" out of range: %"IND_FLAG" > %"IND_FLAG, f, trivert, vertidx, $SIZE(v)-1);
288+ loop(tri) %{ $vertnorm(v=>vertidx) += $facenormals(); %}
289+ %}
290+ EOF
291+ @internal,
292+ );
293+
279294pp_done();
0 commit comments