@@ -251,18 +251,18 @@ sub PDL::Graphics::TriD::Trigrid::gdraw {
251251 my ($this ,$points ) = @_ ;
252252 my $faces = $points -> dice_axis(1,$this -> {Faceidx }-> flat)-> splitdim(1,3);
253253 my $colours = $this -> {Colors }-> dice_axis(1,$this -> {Faceidx }-> flat)-> splitdim(1,3);
254+ my $options = $this -> {Options };
254255 glShadeModel(GL_SMOOTH); # By-vertex doesn't make sense otherwise.
255256 my $f = ' PDL::gl_triangles' ;
256- my $send_normals = $this -> {Options }{Smooth } && $this -> {Options }{Shading };
257- $f .= ' _' . ($send_normals ? ' w' : ' ' ) . ' n' if $this -> {Options }{Shading };
257+ $f .= ' _wn' if $options -> {Shading };
258258 { no strict ' refs' ; $f = \&$f ; }
259- my $tmpn = $send_normals
259+ my $tmpn = ! $options -> { Shading } ? undef : $options -> { Smooth }
260260 ? $this -> {VertexNormals }-> dice_axis(1,$this -> {Faceidx }-> flat)
261- -> splitdim(1,$this -> {Faceidx }-> dim(0)) : undef ;
262- if ($this -> { Options } {Shading }) { glColorMaterial(GL_FRONT_AND_BACK,GL_DIFFUSE); glEnable(GL_COLOR_MATERIAL); }
263- $f -> (map $_ -> mv(1,-1)-> dog, $faces , $send_normals ? $tmpn : (), $colours );
264- if ($this -> { Options } {Shading }) { glDisable(GL_COLOR_MATERIAL); }
265- if ($this -> { Options } {ShowNormals }) {
261+ -> splitdim(1,$this -> {Faceidx }-> dim(0)) : $this -> { FaceNormals } -> dummy(1,3) ;
262+ if ($options -> {Shading }) { glColorMaterial(GL_FRONT_AND_BACK,GL_DIFFUSE); glEnable(GL_COLOR_MATERIAL); }
263+ $f -> (map $_ -> mv(1,-1)-> dog, $faces , $options -> { Shading } ? $tmpn : (), $colours );
264+ if ($options -> {Shading }) { glDisable(GL_COLOR_MATERIAL); }
265+ if ($options -> {ShowNormals }) {
266266 die " No normals to show!" if !grep defined $this -> {$_ }, qw( FaceNormals VertexNormals) ;
267267 if (defined $this -> {VertexNormals }) {
268268 my $arrows = $points -> append($points + $this -> {VertexNormals }*0.1)-> splitdim(0,3);
@@ -278,7 +278,7 @@ sub PDL::Graphics::TriD::Trigrid::gdraw {
278278 PDL::Graphics::OpenGLQ::gl_arrows($facearrows , 0, 1, 0.5, 0.02);
279279 }
280280 }
281- if ($this -> { Options } {Lines }) {
281+ if ($options -> {Lines }) {
282282 glColor3f(0,0,0);
283283 PDL::gl_lines_nc($faces -> dice_axis(1,[0,1,2,0]));
284284 }
0 commit comments