More AxisAlignedBB::one() usages

This commit is contained in:
Dylan K. Taylor 2018-11-24 19:49:15 +00:00
parent fcd81ada04
commit 7ddcd2941b

View File

@ -45,7 +45,7 @@ abstract class Thin extends Transparent{
} }
protected function recalculateBoundingBox() : ?AxisAlignedBB{ protected function recalculateBoundingBox() : ?AxisAlignedBB{
$bb = new AxisAlignedBB(0, 0, 0, 1, 1, 1); $bb = AxisAlignedBB::one();
foreach(Facing::HORIZONTAL as $facing){ foreach(Facing::HORIZONTAL as $facing){
if(!isset($this->connections[$facing])){ if(!isset($this->connections[$facing])){
$bb->trim($facing, 7 / 16); $bb->trim($facing, 7 / 16);
@ -61,8 +61,7 @@ abstract class Thin extends Transparent{
$bbs = []; $bbs = [];
if(isset($this->connections[Facing::WEST]) or isset($this->connections[Facing::EAST])){ if(isset($this->connections[Facing::WEST]) or isset($this->connections[Facing::EAST])){
$bb = new AxisAlignedBB(0, 0, 0, 1, 1, 1); $bb = AxisAlignedBB::one()->squash(Facing::AXIS_Z, $inset);
$bb->squash(Facing::AXIS_Z, $inset);
if(!isset($this->connections[Facing::WEST])){ if(!isset($this->connections[Facing::WEST])){
$bb->trim(Facing::WEST, $inset); $bb->trim(Facing::WEST, $inset);
@ -73,8 +72,7 @@ abstract class Thin extends Transparent{
} }
if(isset($this->connections[Facing::NORTH]) or isset($this->connections[Facing::SOUTH])){ if(isset($this->connections[Facing::NORTH]) or isset($this->connections[Facing::SOUTH])){
$bb = new AxisAlignedBB(0, 0, 0, 1, 1, 1); $bb = AxisAlignedBB::one()->squash(Facing::AXIS_X, $inset);
$bb->squash(Facing::AXIS_X, $inset);
if(!isset($this->connections[Facing::NORTH])){ if(!isset($this->connections[Facing::NORTH])){
$bb->trim(Facing::NORTH, $inset); $bb->trim(Facing::NORTH, $inset);
@ -86,9 +84,8 @@ abstract class Thin extends Transparent{
if(empty($bbs)){ if(empty($bbs)){
//centre post AABB (only needed if not connected on any axis - other BBs overlapping will do this if any connections are made) //centre post AABB (only needed if not connected on any axis - other BBs overlapping will do this if any connections are made)
$bb = new AxisAlignedBB(0, 0, 0, 1, 1, 1);
return [ return [
$bb->contract($inset, 0, $inset) AxisAlignedBB::one()->contract($inset, 0, $inset)
]; ];
} }