# 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
@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) {
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;