mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 16:51:42 +00:00
Reduced duplicated code in AxisAlignedBB->calculateIntercept()
This commit is contained in:
parent
41f292d995
commit
b524b841c5
@ -397,30 +397,13 @@ class AxisAlignedBB{
|
||||
}
|
||||
|
||||
$vector = null;
|
||||
$distance = PHP_INT_MAX;
|
||||
|
||||
|
||||
if($v1 !== null and ($vector === null or $pos1->distanceSquared($v1) < $pos1->distanceSquared($vector))){
|
||||
$vector = $v1;
|
||||
}
|
||||
|
||||
if($v2 !== null and ($vector === null or $pos1->distanceSquared($v2) < $pos1->distanceSquared($vector))){
|
||||
$vector = $v2;
|
||||
}
|
||||
|
||||
if($v3 !== null and ($vector === null or $pos1->distanceSquared($v3) < $pos1->distanceSquared($vector))){
|
||||
$vector = $v3;
|
||||
}
|
||||
|
||||
if($v4 !== null and ($vector === null or $pos1->distanceSquared($v4) < $pos1->distanceSquared($vector))){
|
||||
$vector = $v4;
|
||||
}
|
||||
|
||||
if($v5 !== null and ($vector === null or $pos1->distanceSquared($v5) < $pos1->distanceSquared($vector))){
|
||||
$vector = $v5;
|
||||
}
|
||||
|
||||
if($v6 !== null and ($vector === null or $pos1->distanceSquared($v6) < $pos1->distanceSquared($vector))){
|
||||
$vector = $v6;
|
||||
foreach([$v1, $v2, $v3, $v4, $v5, $v6] as $v){
|
||||
if($v !== null and ($d = $pos1->distanceSquared($v)) < $distance){
|
||||
$vector = $v;
|
||||
$distance = $d;
|
||||
}
|
||||
}
|
||||
|
||||
if($vector === null){
|
||||
|
Loading…
x
Reference in New Issue
Block a user