Skip to content

Commit 7074606

Browse files
committed
make Trigrid contain Triangles instead of draw itself
1 parent 1189d90 commit 7074606

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

lib/PDL/Graphics/TriD/GL.pm

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ sub PDL::Graphics::TriD::Triangles::gdraw {
217217
my $tmpn = $shading <= 2 ? undef : $options->{Smooth}
218218
? $this->{VertexNormals}->dice_axis(1,$this->{Faceidx}->flat)
219219
->splitdim(1,$this->{Faceidx}->dim(0)) : $this->{FaceNormals}->dummy(1,3);
220-
$f->($points->dice_axis(1,$this->{Faceidx})->splitdim(1,3), $shading > 2 ? $tmpn : (), $colours);
220+
$f->($points->dice_axis(1,$this->{Faceidx}->flat)->splitdim(1,3), $shading > 2 ? $tmpn : (), $colours);
221221
if ($shading > 2) { glDisable(GL_COLOR_MATERIAL); }
222222
}
223223

@@ -259,16 +259,6 @@ sub PDL::Graphics::TriD::Trigrid::gdraw {
259259
my $faces = $points->dice_axis(1,$this->{Faceidx}->flat)->splitdim(1,3);
260260
my $colours = $this->{Colors}->dice_axis(1,$this->{Faceidx}->flat)->splitdim(1,3);
261261
my $options = $this->{Options};
262-
glShadeModel(GL_SMOOTH); # By-vertex doesn't make sense otherwise.
263-
my $f = 'PDL::gl_triangles';
264-
$f .= '_wn' if $options->{Shading};
265-
{ no strict 'refs'; $f = \&$f; }
266-
my $tmpn = !$options->{Shading} ? undef : $options->{Smooth}
267-
? $this->{VertexNormals}->dice_axis(1,$this->{Faceidx}->flat)
268-
->splitdim(1,$this->{Faceidx}->dim(0)) : $this->{FaceNormals}->dummy(1,3);
269-
if ($options->{Shading}) { glColorMaterial(GL_FRONT_AND_BACK,GL_DIFFUSE); glEnable(GL_COLOR_MATERIAL); }
270-
$f->($faces, $options->{Shading} ? $tmpn : (), $colours);
271-
if ($options->{Shading}) { glDisable(GL_COLOR_MATERIAL); }
272262
if ($options->{ShowNormals}) {
273263
die "No normals to show!" if !grep defined $this->{$_}, qw(FaceNormals VertexNormals);
274264
if (defined $this->{VertexNormals}) {

lib/PDL/Graphics/TriD/Objects.pm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ sub new {
134134
$this->{VertexNormals} = $vn if $options->{Smooth} or $options->{ShowNormals};
135135
$this->{FaceNormals} = $fn if !$options->{Smooth} or $options->{ShowNormals};
136136
}
137+
my %less = %$options; delete @less{qw(ShowNormals Lines)};
138+
$less{Shading} = 3 if $options->{Shading};
139+
$this->add_object(PDL::Graphics::TriD::Triangles->new($points, $faceidx->clump(1..$faceidx->ndims-1), $colors, \%less));
137140
$this;
138141
}
139142
sub get_valid_options { +{

0 commit comments

Comments
 (0)