Skip to content

Commit 06f909d

Browse files
committed
make Trigrid contain Lines instead of draw itself
1 parent 7074606 commit 06f909d

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

lib/PDL/Graphics/TriD/GL.pm

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,6 @@ sub PDL::Graphics::TriD::Trigrid::gdraw {
279279
PDL::gl_lines_col($facearrows,[0.5,0.5,0.5]);
280280
}
281281
}
282-
if ($options->{Lines}) {
283-
PDL::gl_lines_col($faces->dice_axis(1,[0,1,2,0]), [0,0,0]);
284-
}
285282
}
286283

287284
# A special construct which always faces the display and takes the entire window

lib/PDL/Graphics/TriD/Objects.pm

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,21 +124,27 @@ use base qw/PDL::Graphics::TriD::GObject/;
124124
use fields qw/Faceidx FaceNormals VertexNormals/;
125125
sub new {
126126
my $options = ref($_[-1]) eq 'HASH' ? pop : {};
127-
my($type,$points,$faceidx,$colors) = @_;
127+
my ($type,$points,$faceidx,$colors) = @_;
128128
my $this = $type->SUPER::new($points,$colors,$options);
129129
# faceidx is 2D pdl of indices into points for each face
130-
$this->{Faceidx} = $faceidx->ulong;
130+
$faceidx = $this->{Faceidx} = $faceidx->ulong;
131131
$options = $this->{Options};
132-
if ($options->{Shading} or $options->{ShowNormals}) {
132+
if ($options->{ShowNormals}) {
133133
my ($fn, $vn) = triangle_normals($this->{Points}, $faceidx);
134134
$this->{VertexNormals} = $vn if $options->{Smooth} or $options->{ShowNormals};
135135
$this->{FaceNormals} = $fn if !$options->{Smooth} or $options->{ShowNormals};
136136
}
137137
my %less = %$options; delete @less{qw(ShowNormals Lines)};
138138
$less{Shading} = 3 if $options->{Shading};
139139
$this->add_object(PDL::Graphics::TriD::Triangles->new($points, $faceidx->clump(1..$faceidx->ndims-1), $colors, \%less));
140+
if ($options->{Lines}) {
141+
$points = PDL::Graphics::TriD::realcoords($type->r_type,$points);
142+
my $faces = $points->dice_axis(1,$this->{Faceidx}->flat)->splitdim(1,3);
143+
$this->add_object(PDL::Graphics::TriD::Lines->new($faces->dice_axis(1,[0,1,2,0]), PDL::float(0,0,0)));
144+
}
140145
$this;
141146
}
147+
sub r_type { return "";}
142148
sub get_valid_options { +{
143149
UseDefcols => 0,
144150
Lines => 0,

0 commit comments

Comments
 (0)