@@ -261,14 +261,20 @@ sub PDL::Graphics::TriD::Trigrid::gdraw {
261261 PDL::gl_triangles_n_mat(map $_ -> mv(1,-1)-> dog, $faces , $colours );
262262 }
263263 if ($this -> {Options }{ShowNormals }) {
264- my $arrows = $points -> append($points + $this -> {Normals }*0.1)-> splitdim(0,3);
265- glDisable(GL_LIGHTING);
266- glColor3d(1,1,1);
267- PDL::Graphics::OpenGLQ::gl_arrows($arrows , 0, 1, 0.5, 0.02);
268- my $facecentres = $faces -> transpose-> avgover;
269- my $facearrows = $facecentres -> append($facecentres + $this -> {FaceNormals }*0.1)-> splitdim(0,3);
270- glColor3d(0.5,0.5,0.5);
271- PDL::Graphics::OpenGLQ::gl_arrows($facearrows , 0, 1, 0.5, 0.02);
264+ die " No normals to show!" if !grep defined $this -> {$_ }, qw( FaceNormals Normals) ;
265+ if (defined $this -> {Normals }) {
266+ my $arrows = $points -> append($points + $this -> {Normals }*0.1)-> splitdim(0,3);
267+ glDisable(GL_LIGHTING);
268+ glColor3d(1,1,1);
269+ PDL::Graphics::OpenGLQ::gl_arrows($arrows , 0, 1, 0.5, 0.02);
270+ }
271+ if (defined $this -> {FaceNormals }) {
272+ my $facecentres = $faces -> transpose-> avgover;
273+ my $facearrows = $facecentres -> append($facecentres + $this -> {FaceNormals }*0.1)-> splitdim(0,3);
274+ glDisable(GL_LIGHTING);
275+ glColor3d(0.5,0.5,0.5);
276+ PDL::Graphics::OpenGLQ::gl_arrows($facearrows , 0, 1, 0.5, 0.02);
277+ }
272278 }
273279 if ($this -> {Options }{Lines }) {
274280 glColor3f(0,0,0);
0 commit comments