@@ -250,18 +250,14 @@ sub PDL::Graphics::TriD::Trigrid::gdraw {
250250 my $faces = $points -> dice_axis(1,$this -> {Faceidx }-> flat)-> splitdim(1,3);
251251 my $colours = $this -> {Colors }-> dice_axis(1,$this -> {Faceidx }-> flat)-> splitdim(1,3);
252252 glShadeModel(GL_SMOOTH); # By-vertex doesn't make sense otherwise.
253- my $idx = [0,1,2,0]; # for lines, below
254- if (!$this -> {Options }{Shading }) {
255- PDL::gl_triangles(map $_ -> mv(1,-1)-> dog, $faces , $colours );
256- } else {
257- my $f = ' PDL::gl_triangles' ;
258- $f .= ' _' . ($this -> {Options }{Smooth } ? ' w' : ' ' ) . ' n_mat' ;
259- { no strict ' refs' ; $f = \&$f ; }
260- my $tmpn = $this -> {Options }{Smooth }
261- ? $this -> {VertexNormals }-> dice_axis(1,$this -> {Faceidx }-> flat)
262- -> splitdim(1,$this -> {Faceidx }-> dim(0)) : undef ;
263- $f -> (map $_ -> mv(1,-1)-> dog, $faces , $this -> {Options }{Smooth } ? $tmpn : (), $colours );
264- }
253+ my $f = ' PDL::gl_triangles' ;
254+ my $send_normals = $this -> {Options }{Smooth } && $this -> {Options }{Shading };
255+ $f .= ' _' . ($send_normals ? ' w' : ' ' ) . ' n_mat' if $this -> {Options }{Shading };
256+ { no strict ' refs' ; $f = \&$f ; }
257+ my $tmpn = $send_normals
258+ ? $this -> {VertexNormals }-> dice_axis(1,$this -> {Faceidx }-> flat)
259+ -> splitdim(1,$this -> {Faceidx }-> dim(0)) : undef ;
260+ $f -> (map $_ -> mv(1,-1)-> dog, $faces , $send_normals ? $tmpn : (), $colours );
265261 if ($this -> {Options }{ShowNormals }) {
266262 die " No normals to show!" if !grep defined $this -> {$_ }, qw( FaceNormals VertexNormals) ;
267263 if (defined $this -> {VertexNormals }) {
@@ -280,7 +276,7 @@ sub PDL::Graphics::TriD::Trigrid::gdraw {
280276 }
281277 if ($this -> {Options }{Lines }) {
282278 glColor3f(0,0,0);
283- PDL::gl_lines_nc($faces -> dice_axis(1,$idx ));
279+ PDL::gl_lines_nc($faces -> dice_axis(1,[0,1,2,0] ));
284280 }
285281}
286282
0 commit comments