ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/gentregvec.pl
(Generate patch)

Comparing ray/src/util/gentregvec.pl (file contents):
Revision 2.1 by greg, Tue Jun 16 04:54:08 2009 UTC vs.
Revision 2.4 by greg, Wed Jun 24 19:19:38 2009 UTC

# Line 21 | Line 21 | my @skydesc;
21   my $lightline;
22   my @sunval;
23   my $sunline;
24 + my $skyOK = 0;
25 + my $srcmod;     # putting this inside loop breaks code(?!)
26   while (<>) {
25        my $srcmatch = '^WONTMATCHANYTHING$';
26        my $srcmod;
27          push @skydesc, $_;
28          if (/^\w+\s+light\s+/) {
29 <                s/\s+$//; s/^.*\s//;
29 >                s/\s*$//; s/^.*\s//;
30                  $srcmod = $_;
31                  $lightline = $#skydesc;
32 <                $srcmatch = "^$srcmod\\s+source\\s";
33 <        } elsif (/^solar\s+source\s/) {
32 >        } elsif (defined($srcmod) && /^($srcmod)\s+source\s/) {
33                  @sunval = split(/\s+/, $skydesc[$lightline + 3]);
34                  shift @sunval;
35                  $sunline = $#skydesc;
36 +        } elsif (/\sskyfunc\s*$/) {
37 +                $skyOK = 1;
38          }
39   }
40 < die "Empty input!\n" if (! @skydesc);
40 > die "Bad sky description!\n" if (! $skyOK);
41   # Strip out the solar source if present
42   my @sundir;
43   if (defined $sunline) {
44          @sundir = split(/\s+/, $skydesc[$sunline + 3]);
45          shift @sundir;
46          undef @sundir if ($sundir[2] <= 0);
47 <        @skydesc[$sunline .. $sunline + 4] = ('', '', '', '', '');
47 >        splice(@skydesc, $sunline, 5);
48   }
49   # Get Tregenza sample file
50   my $found;
# Line 73 | Line 74 | if ($#tregval != 145) {
74          exit 1;
75   }
76   unlink $octree;
77 < # Find closest patches to sun and divvy up direct solar contribution
77 > # Find closest 3 patches to sun and divvy up direct solar contribution
78   my @bestdir;
79   if (@sundir) {
80 <        my $somega = ($sundir[3]/360)^2 * 3.141592654^3;
80 >        my $somega = ($sundir[3]/360)**2 * 3.141592654**3;
81          my @tindex = (30, 60, 84, 108, 126, 138, 144, 145);
82          my @tomega = (0.0435449227, 0.0416418006, 0.0473984151,
83                          0.0406730411, 0.0428934136, 0.0445221864,
# Line 95 | Line 96 | if (@sundir) {
96          for my $i (0..2) {
97                  my $ti = 0;
98                  while ($ndx[$i] > $tindex[$ti]) { $ti++ }
99 <                my $wt = $wtot/($ang[$i]+.02) * $somega / $tomega[$ti];
99 >                my $wt = 1/($ang[$i]+.02)/$wtot * $somega / $tomega[$ti];
100                  my @scolor = split(/\s+/, $tregval[$ndx[$i]]);
101                  for my $j (0..2) { $scolor[$j] += $wt * $sunval[$j]; }
102                  $tregval[$ndx[$i]] = "@scolor\n";
103          }
104   }
105 + # Output our final vector
106   print @tregval;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines