Skip to content

Commit add6cc1

Browse files
committed
add test of some Objects, fix Lattice with Shading but no Smooth
1 parent 112a891 commit add6cc1

3 files changed

Lines changed: 32 additions & 1 deletion

File tree

MANIFEST

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,5 @@ Makefile.PL
4040
MANIFEST This list of files
4141
MANIFEST.SKIP
4242
t/arcball.t
43+
t/objects.t
4344
t/quaternion.t

lib/PDL/Graphics/TriD/Objects.pm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,8 @@ sub new {
215215
$this->{Normals} = $vn;
216216
} else {
217217
$this->{Points} = $this->{Points}->dice_axis(1,$idxflat);
218-
$this->{Colors} = $this->{Colors}->dice_axis(1,$idxflat);
218+
my ($cols) = grep defined $this->{$_}, qw(Colors TexCoord);
219+
$this->{$cols} = $this->{$cols}->dice_axis(1,$idxflat);
219220
$this->{Normals} = $fn->dummy(1,$idx0)->clump(1,2);
220221
$this->{Faceidx} = PDL->sequence(PDL::ulong,$idx0,@idxdims);
221222
}

t/objects.t

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
use strict;
2+
use warnings;
3+
use Test::More;
4+
use PDL;
5+
use PDL::Graphics::TriD;
6+
7+
my $size = 5;
8+
my $y = PDL->zeroes(3,$size,$size);
9+
axisvalues($y->slice("(0)")->inplace);
10+
axisvalues($y->slice("(1)")->transpose->inplace);
11+
srandom(5);
12+
random((my $ysl2 = $y->slice("(2)"))->inplace);
13+
$ysl2 /= 5;
14+
my $c = PDL->random(3,$size,$size);
15+
16+
for (
17+
['LineStrip'],
18+
['Lattice', {Shading=>0}],
19+
['Lattice', {Shading=>1}],
20+
['Lattice', {Shading=>2}],
21+
['Lattice', {Shading=>3, Lighting => 1, ShowNormals => 1}],
22+
['Lattice', {Shading=>3, Lighting => 1, ShowNormals => 1, Smooth=>1}],
23+
) {
24+
my ($class, $opts) = @$_;
25+
eval { "PDL::Graphics::TriD::$class"->new($y,$c,$opts) };
26+
is $@, '' or diag 'Spec was: ', explain $opts;
27+
}
28+
29+
done_testing;

0 commit comments

Comments
 (0)