#description: Regular roof

=comment

If brush is a wedge, creates a half roof, otherwise makes both sides of roof

=cut

my $br;

$shingle=$tl->texture('city/blushngl');
$basetex=defined($textures[0])?sub{$tl->texture($textures[0])}:sub{$tl->texture('core_1/blustn')};

#$overhang=$extra1[0]==undef()?1:$extra1[0];
$overhang=.5;

if ($brush->{kind}==wedge()) {

print "wedge roof\n";

$edgeh=$overhang;
$edgew=($w/$h)*$edgeh;

$toph=$h+$overhang;
$topw=($w/$h)*$toph;

$br = $bunch->addBrush(solid(), wedge(), 0,0+(($w+$edgew)/2),0-(($h+$edgeh)/2), $edgew,$l+$overhang,$edgeh, $shingle, 180,0,0);
$bunch->setTexture($br, side2(), &$basetex);
$br = $bunch->addBrush(solid(), wedge(), 0,0+($edgew/2),0+($edgeh/2), $topw,$l+$overhang,$toph, $shingle);
$bunch->setTexture($br, side2(), &$basetex);

$br = $bunch->addBrush(air(), wedge(), 0+($l/2)+($overhang/4),0,0, $w,$overhang/2,$h, $shingle);
$bunch->setTexture($br, top(), &$basetex);
$bunch->setTexture($br, bottom(), &$basetex);
$bunch->setTexture($br, side2(), &$basetex);

$br = $bunch->addBrush(air(), wedge(), 0-($l/2)-($overhang/4),0,0, $w,$overhang/2,$h, $shingle);
$bunch->setTexture($br, top(), &$basetex);
$bunch->setTexture($br, bottom(), &$basetex);
$bunch->setTexture($br, side2(), &$basetex);

} else {

print "other roof\n";

$hw=$w/2;

$edgeh=$overhang;
$edgew=($hw/$h)*$edgeh;

$toph=$h+$overhang;
$topw=($hw/$h)*$toph;


$tmpy=$hw/2;
$br = $bunch->addBrush(solid(), wedge(), 0,$tmpy+(($hw+$edgew)/2),0-(($h+$edgeh)/2), $edgew,$l+$overhang,$edgeh, $shingle, 180,0,0);
$bunch->setTexture($br, side2(), &$basetex);
$br = $bunch->addBrush(solid(), wedge(), 0,$tmpy+($edgew/2),0+($edgeh/2), $topw,$l+$overhang,$toph, $shingle);
$bunch->setTexture($br, side2(), &$basetex);
$br = $bunch->addBrush(air(), wedge(), 0+($l/2)+($overhang/4),$tmpy,0, $hw,$overhang/2,$h, $shingle);
$bunch->setTexture($br, top(), &$basetex);
$bunch->setTexture($br, bottom(), &$basetex);
$bunch->setTexture($br, side2(), &$basetex);
$br = $bunch->addBrush(air(), wedge(), 0-($l/2)-($overhang/4),$tmpy,0, $hw,$overhang/2,$h, $shingle);
$bunch->setTexture($br, top(), &$basetex);
$bunch->setTexture($br, bottom(), &$basetex);
$bunch->setTexture($br, side2(), &$basetex);

$tmpy=0-($hw/2);
$br = $bunch->addBrush(solid(), wedge(), 0,$tmpy-(($hw+$edgew)/2),0-(($h+$edgeh)/2), $edgew,$l+$overhang,$edgeh, $shingle, 180,0,180);
$bunch->setTexture($br, side2(), &$basetex);
$br = $bunch->addBrush(solid(), wedge(), 0,$tmpy-($edgew/2),0+($edgeh/2), $topw,$l+$overhang,$toph, $shingle, 0,0,180);
$bunch->setTexture($br, side2(), &$basetex);
$br = $bunch->addBrush(air(), wedge(), 0+($l/2)+($overhang/4),$tmpy,0, $hw,$overhang/2,$h, $shingle, 0,0,180);
$bunch->setTexture($br, top(), &$basetex);
$bunch->setTexture($br, bottom(), &$basetex);
$bunch->setTexture($br, side2(), &$basetex);
$br = $bunch->addBrush(air(), wedge(), 0-($l/2)-($overhang/4),$tmpy,0, $hw,$overhang/2,$h, $shingle, 0,0,180);
$bunch->setTexture($br, top(), &$basetex);
$bunch->setTexture($br, bottom(), &$basetex);
$bunch->setTexture($br, side2(), &$basetex);


}
