Skip to content

Commit 9fdbb0a

Browse files
committed
pass gen_arrowheads more idiomatic flattened data
1 parent 7f36540 commit 9fdbb0a

File tree

1 file changed

+12
-12
lines changed
  • lib/PDL/Graphics/TriD

1 file changed

+12
-12
lines changed

lib/PDL/Graphics/TriD/GL.pm

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -181,20 +181,20 @@ sub PDL::Graphics::TriD::Lattice::gdraw {
181181
die "No normals to show!" if !grep defined $this->{$_}, qw(FaceNormals VertexNormals);
182182
if (defined $this->{VertexNormals}) {
183183
my $points_clumped = $points->clump(1..$points->ndims-1);
184-
my $arrows = $points_clumped->append($points_clumped + $this->{VertexNormals}*0.1)->splitdim(0,3);
184+
my $arrows = $points_clumped->append($points_clumped + $this->{VertexNormals}*0.1)->splitdim(0,3)->clump(1,2);
185185
glDisable(GL_LIGHTING);
186-
my ($tv, $ti) = PDL::Graphics::OpenGLQ::gen_arrowheads($arrows,0,1,
186+
my ($tv, $ti) = PDL::Graphics::OpenGLQ::gen_arrowheads($arrows,sequence(ulong,2,$points_clumped->dim(1))->t->dog,
187187
0.5, 0.02);
188-
PDL::gl_triangles($tv->clump(1,2)->dice_axis(1,($ti+$ti->yvals*$tv->dim(1))->flat)->splitdim(1,3), [1,1,1]);
188+
PDL::gl_triangles($tv->dice_axis(1,$ti)->splitdim(1,3), [1,1,1]);
189189
PDL::gl_lines_col($arrows,[1,1,1]);
190190
}
191191
if (defined $this->{FaceNormals}) {
192192
my $facecentres = $faces->transpose->avgover;
193-
my $facearrows = $facecentres->append($facecentres + $this->{FaceNormals}*0.1)->splitdim(0,3);
193+
my $facearrows = $facecentres->append($facecentres + $this->{FaceNormals}*0.1)->splitdim(0,3)->clump(1,2);
194194
glDisable(GL_LIGHTING);
195-
my ($tv, $ti) = PDL::Graphics::OpenGLQ::gen_arrowheads($facearrows,0,1,
195+
my ($tv, $ti) = PDL::Graphics::OpenGLQ::gen_arrowheads($facearrows,sequence(ulong,2,$facecentres->dim(1))->t->dog,
196196
0.5, 0.02);
197-
PDL::gl_triangles($tv->clump(1,2)->dice_axis(1,($ti+$ti->yvals*$tv->dim(1))->flat)->splitdim(1,3), [0.5,0.5,0.5]);
197+
PDL::gl_triangles($tv->dice_axis(1,$ti)->splitdim(1,3), [0.5,0.5,0.5]);
198198
PDL::gl_lines_col($facearrows,[0.5,0.5,0.5]);
199199
}
200200
}
@@ -263,20 +263,20 @@ sub PDL::Graphics::TriD::Trigrid::gdraw {
263263
if ($options->{ShowNormals}) {
264264
die "No normals to show!" if !grep defined $this->{$_}, qw(FaceNormals VertexNormals);
265265
if (defined $this->{VertexNormals}) {
266-
my $arrows = $points->append($points + $this->{VertexNormals}*0.1)->splitdim(0,3);
266+
my $arrows = $points->append($points + $this->{VertexNormals}*0.1)->splitdim(0,3)->clump(1,2);
267267
glDisable(GL_LIGHTING);
268-
my ($tv, $ti) = PDL::Graphics::OpenGLQ::gen_arrowheads($arrows,0,1,
268+
my ($tv, $ti) = PDL::Graphics::OpenGLQ::gen_arrowheads($arrows,sequence(ulong,2,$points->dim(1))->t->dog,
269269
0.5, 0.02);
270-
PDL::gl_triangles($tv->clump(1,2)->dice_axis(1,($ti+$ti->yvals*$tv->dim(1))->flat)->splitdim(1,3), [1,1,1]);
270+
PDL::gl_triangles($tv->dice_axis(1,$ti)->splitdim(1,3), [1,1,1]);
271271
PDL::gl_lines_col($arrows,[1,1,1]);
272272
}
273273
if (defined $this->{FaceNormals}) {
274274
my $facecentres = $faces->transpose->avgover;
275-
my $facearrows = $facecentres->append($facecentres + $this->{FaceNormals}*0.1)->splitdim(0,3);
275+
my $facearrows = $facecentres->append($facecentres + $this->{FaceNormals}*0.1)->splitdim(0,3)->clump(1,2);
276276
glDisable(GL_LIGHTING);
277-
my ($tv, $ti) = PDL::Graphics::OpenGLQ::gen_arrowheads($facearrows,0,1,
277+
my ($tv, $ti) = PDL::Graphics::OpenGLQ::gen_arrowheads($facearrows,sequence(ulong,2,$facecentres->dim(1))->t->dog,
278278
0.5, 0.02);
279-
PDL::gl_triangles($tv->clump(1,2)->dice_axis(1,($ti+$ti->yvals*$tv->dim(1))->flat)->splitdim(1,3), [0.5,0.5,0.5]);
279+
PDL::gl_triangles($tv->dice_axis(1,$ti)->splitdim(1,3), [0.5,0.5,0.5]);
280280
PDL::gl_lines_col($facearrows,[0.5,0.5,0.5]);
281281
}
282282
}

0 commit comments

Comments
 (0)