--- deliantra/Deliantra-Client/DC/MapWidget.pm 2009/12/17 02:49:38 1.155 +++ deliantra/Deliantra-Client/DC/MapWidget.pm 2009/12/21 23:52:34 1.158 @@ -398,16 +398,20 @@ sub scroll { my ($self, $dx, $dy) = @_; - $::MAP->scroll ($dx, $dy); - - $self->{last_fow_texture} = $self->{fow_texture}; - $self->{ldx} = $self->{sdx} + $dx * $self->{tilesize}; # smooth displacement - $self->{ldy} = $self->{sdy} + $dy * $self->{tilesize}; - $self->movement_update; $self->{sdx} += $dx * $self->{tilesize}; # smooth displacement $self->{sdy} += $dy * $self->{tilesize}; + + # save old fow texture, if applicable + $self->{last_fow_texture} = $self->{fow_texture} + if $::CFG->{smooth_transitions}; + $self->{lfdx} = $dx; + $self->{lfdy} = $dy; + $self->{lmdx} = $self->{dx}; + $self->{lmdy} = $self->{dy}; + + $::MAP->scroll ($dx, $dy); } sub set_magicmap { @@ -488,21 +492,15 @@ my $dy = $self->{dy} = DC::ceil 0.5 * ($::MAP->h - $sh) - $sy; if ($::CFG->{fow_enable}) { - my ($sdx_t, $sdy_t);#d# do not anchor at player - - my ($w, $h, $data) = $::MAP->fow_texture ( - $dx + (min 0, $sdx_t), - $dy + (min 0, $sdy_t), - $sw + abs $sdx_t, - $sh + abs $sdy_t - ); + # draw_fow_texture REQUIRES the fow texture to stay the same size. + my ($w, $h, $data) = $::MAP->fow_texture ($dx, $dy, $sw, $sh); $self->{fow_texture} = new DC::Texture w => $w, h => $h, data => $data, - internalformat => GL_INTENSITY, - format => GL_LUMINANCE; + internalformat => GL_ALPHA, + format => GL_ALPHA; } else { delete $self->{fow_texture}; } @@ -519,52 +517,32 @@ $::CONN->{player}{tag}, -$self->{sdx}, -$self->{sdy}); - #d#glTranslate -$self->{sdx}, -$self->{sdy}; # anchor fow at player glScale $self->{tilesize}, $self->{tilesize}; if (my $tex = $self->{fow_texture}) { - if (0 && $self->{last_fow_texture}) { - my $d1 = ($self->{sdx} ** 2 + $self->{sdy} ** 2) ** 0.5; - my $d2 = ($self->{ldx} ** 2 + $self->{ldy} ** 2) ** 0.5; + if ($DC::OpenGL::GL_MULTITEX && $self->{last_fow_texture}) {#d# + my $d1 = DC::distance $self->{sdx}, $self->{sdy}; + my $d2 = (DC::distance $self->{lfdx}, $self->{lfdy}) * $tilesize; if ($d1 * $d2) { - my $a2 = $d1 / $d2; - my $a1 = 1 - $a2; - - #$a1 *= 0.9; - #$a2 *= 0.9; - - printf "%8g %8g %8g %8g\n", $d1, $d2, $a1, $a2;#d# - - #$a1 = 1 - (1-$a1) * 0.707; - #$a2 = 1 - (1-$a2) * 0.707; - - glColor 1,0,0,1; - glBegin GL_QUADS; - glVertex 10 + $sdx_t, 10; - glVertex 11 + $sdx_t, 10; - glVertex 11 + $sdx_t, 11; - glVertex 10 + $sdx_t, 11; - glEnd; - - if(0){ - glBlendFunc GL_ZERO, GL_DST_COLOR; - glColor +($::CFG->{fow_intensity}) x 3, $a2; - glPushMatrix; - glTranslate $sdx_t, $sdy_t; # anchor at player - glTranslate $self->{ldx} / -$tilesize, $self->{ldy} / -$tilesize; - glScale 1/3, 1/3; - $self->{last_fow_texture}->draw_quad_alpha (0, 0); - glPopMatrix; - } + DC::Texture::draw_fow_texture + $::CFG->{fow_intensity}, + $self->{hidden_tex}{name}, + @{$self->{fow_texture}}{qw(name data s t w h)}, + (min 1, $d1 / $d2), + $self->{lmdx} - $dx - $self->{lfdx}, + $self->{lmdy} - $dy - $self->{lfdy}, + @{$self->{last_fow_texture}}{qw(name data)}; } else { delete $self->{last_fow_texture}; } - } else { + } + + unless ($self->{last_fow_texture}) { DC::Texture::draw_fow_texture $::CFG->{fow_intensity}, - @{$self->{fow_texture}}{qw(name s t w h)}; - #d#glTranslate +(min 0, $sdx_t), (min 0, $sdy_t); # anchor at player + $self->{hidden_tex}{name}, + @{$self->{fow_texture}}{qw(name data s t w h)}; } } @@ -576,13 +554,16 @@ glTranslate - $x - 1, - $y - 1; glBindTexture GL_TEXTURE_2D, $magicmap_tex->{name}; - $::MAP->draw_magicmap ($x, $y, $w, $h, $data); + $::MAP->draw_magicmap ($w, $h, $data); } glPopMatrix; glEndList; } } else { + delete $self->{last_fow_texture}; + delete $self->{fow_texture}; + glDeleteList delete $self->{list} if $self->{list}; }