]> git.mxchange.org Git - flightgear.git/blobdiff - utils/Modeller/ac3d-despeckle
Fix stray back-button in Qt launcher
[flightgear.git] / utils / Modeller / ac3d-despeckle
index 296326b828b9cd9168354d9a7b05a248dc0089e8..abecec42c2452894a84106b4ff3126306016e2c5 100755 (executable)
@@ -3,14 +3,13 @@
 # Melchior FRANZ  < mfranz # aon : at >  Public Domain
 #
 # Older nVidia cards like the GF4 MX440 don't like UV faces
-# where all cooridnates are equal, and thus don't have an area.
+# where all coordinates are equal, and thus don't have an area.
 # This leads to grey spots that are constantly going on and off.
 # The script fixes UV faces with 3 and 4 references by assigning
 # a one (half)pixel sized area, and moves coordinates into the
 # texture area if necessary.
 #
 use strict;
-use POSIX qw(floor);
 
 my $SELF = $0;
 $SELF =~ s,.*\/,,;
@@ -131,7 +130,7 @@ while (<>) {
                if ($n < 3 or $n > 4) {
                        report("?") if $VERBOSE;
                        unless ($NOOP) {
-                               print scalar(<>) foreach (0 .. $n);
+                               print scalar(<>) foreach (1 .. $n);
                        }
                        next;
                }
@@ -143,7 +142,7 @@ while (<>) {
                @ref3 = split /\s+/, <> if $n == 4;
 
                goto writeuv if $ref0[1] != $ref1[1] or $ref0[2] != $ref1[2] or $ref1[1] != $ref2[1] or $ref1[2] != $ref2[2];
-               goto writeuv if $1 == 4 and ($ref2[1] != $ref3[1] or $ref2[2] != $ref3[2]);
+               goto writeuv if $n == 4 and ($ref2[1] != $ref3[1] or $ref2[2] != $ref3[2]);
 
 
                if (defined $TEXTURE) {
@@ -151,13 +150,13 @@ while (<>) {
 
                        my ($x, $y) = @ref0[1, 2];
 
-                       $x = -0.5 if $x < -0.5;
-                       $x = 0.5 - $PIXW if $x > 0.5 - $PIXW;
-                       $y = -0.5 if $y < -0.5;
-                       $y = 0.5 - $PIXH if $y > 0.5 - $PIXH;
+                       $x = 0.0 if $x < 0.0;
+                       $x = 1.0 - $PIXW if $x > 1.0 - $PIXW;
+                       $y = 0.0 if $y < 0.0;
+                       $y = 1.0 - $PIXH if $y > 1.0 - $PIXH;
 
-                       $x -= $x - POSIX::floor($x / $PIXW) * $PIXW;
-                       $y -= $y - POSIX::floor($y / $PIXH) * $PIXH;
+                       $x = int($x / $PIXW) * $PIXW;
+                       $y = int($y / $PIXH) * $PIXH;
 
                        $ref0[1] = $x, $ref0[2] = $y;
                        $ref1[1] = $x + $PIXW;