mirror of
https://github.com/Minestom/Minestom.git
synced 2024-11-15 07:05:52 +01:00
Improve physics performance
This commit is contained in:
parent
7d1dfabc51
commit
a6314abbad
@ -37,20 +37,29 @@ public class CollisionUtils {
|
||||
final BoundingBox boundingBox = entity.getBoundingBox();
|
||||
|
||||
Vector intermediaryPosition = new Vector();
|
||||
final boolean yCollision = stepAxis(instance, originChunk, currentPosition.toVector(), Y_AXIS, deltaPosition.getY(),
|
||||
intermediaryPosition,
|
||||
deltaPosition.getY() > 0 ? boundingBox.getTopFace() : boundingBox.getBottomFace()
|
||||
);
|
||||
boolean yCollision = false;
|
||||
if (deltaPosition.getY() != 0) {
|
||||
yCollision = stepAxis(instance, originChunk, currentPosition.toVector(), Y_AXIS, deltaPosition.getY(),
|
||||
intermediaryPosition,
|
||||
deltaPosition.getY() > 0 ? boundingBox.getTopFace() : boundingBox.getBottomFace()
|
||||
);
|
||||
}
|
||||
|
||||
final boolean xCollision = stepAxis(instance, originChunk, intermediaryPosition, X_AXIS, deltaPosition.getX(),
|
||||
intermediaryPosition,
|
||||
deltaPosition.getX() < 0 ? boundingBox.getLeftFace() : boundingBox.getRightFace()
|
||||
);
|
||||
boolean xCollision = false;
|
||||
if (deltaPosition.getX() != 0) {
|
||||
xCollision = stepAxis(instance, originChunk, intermediaryPosition, X_AXIS, deltaPosition.getX(),
|
||||
intermediaryPosition,
|
||||
deltaPosition.getX() < 0 ? boundingBox.getLeftFace() : boundingBox.getRightFace()
|
||||
);
|
||||
}
|
||||
|
||||
final boolean zCollision = stepAxis(instance, originChunk, intermediaryPosition, Z_AXIS, deltaPosition.getZ(),
|
||||
intermediaryPosition,
|
||||
deltaPosition.getZ() > 0 ? boundingBox.getBackFace() : boundingBox.getFrontFace()
|
||||
);
|
||||
boolean zCollision = false;
|
||||
if (deltaPosition.getZ() != 0) {
|
||||
zCollision = stepAxis(instance, originChunk, intermediaryPosition, Z_AXIS, deltaPosition.getZ(),
|
||||
intermediaryPosition,
|
||||
deltaPosition.getZ() > 0 ? boundingBox.getBackFace() : boundingBox.getFrontFace()
|
||||
);
|
||||
}
|
||||
|
||||
positionOut.setX(intermediaryPosition.getX());
|
||||
positionOut.setY(intermediaryPosition.getY());
|
||||
|
Loading…
Reference in New Issue
Block a user