Fixed entity physics

This commit is contained in:
Shoghi Cervantes
2014-08-28 18:26:37 +02:00
parent eab86f5f90
commit 9fb46d8fe8
3 changed files with 202 additions and 137 deletions

View File

@ -75,7 +75,7 @@ class AxisAlignedBB{
return $this;
}
public function expand($x, $y, $z){
public function grow($x, $y, $z){
$vec = clone $this;
$vec->minX -= $x;
$vec->minY -= $y;
@ -87,19 +87,29 @@ class AxisAlignedBB{
return $vec;
}
public function offset($x, $y, $z){
$vec = clone $this;
$vec->minX += $x;
$vec->minY += $y;
$vec->minZ += $z;
$vec->maxX += $x;
$vec->maxY += $y;
$vec->maxZ += $z;
public function expand($x, $y, $z){
$this->minX -= $x;
$this->minY -= $y;
$this->minZ -= $z;
$this->maxX += $x;
$this->maxY += $y;
$this->maxZ += $z;
return $vec;
return $this;
}
public function contract($x, $y, $z){
public function offset($x, $y, $z){
$this->minX += $x;
$this->minY += $y;
$this->minZ += $z;
$this->maxX += $x;
$this->maxY += $y;
$this->maxZ += $z;
return $this;
}
public function shrink($x, $y, $z){
$vec = clone $this;
$vec->minX += $x;
$vec->minY += $y;
@ -111,6 +121,17 @@ class AxisAlignedBB{
return $vec;
}
public function contract($x, $y, $z){
$this->minX += $x;
$this->minY += $y;
$this->minZ += $z;
$this->maxX -= $x;
$this->maxY -= $y;
$this->maxZ -= $z;
return $this;
}
public function setBB(AxisAlignedBB $bb){
return new AxisAlignedBB(
min($this->minX, $bb->minX),
@ -123,7 +144,15 @@ class AxisAlignedBB{
}
public function getOffsetBoundingBox($x, $y, $z){
return new AxisAlignedBB($this->minX + $x, $this->minY + $y, $this->minZ + $z, $this->maxX + $x, $this->maxY + $y, $this->maxZ + $z);
$vec = clone $this;
$vec->minX += $x;
$vec->minY += $y;
$vec->minZ += $z;
$vec->maxX += $x;
$vec->maxY += $y;
$vec->maxZ += $z;
return $vec;
}
public function calculateXOffset(AxisAlignedBB $bb, $x){