13
0
geforkt von Mirrors/Paper

SPIGOT-6017: BoundingBox#rayTrace returns incorrect null

By: blablubbabc <lukas@wirsindwir.de>
Dieser Commit ist enthalten in:
Bukkit/Spigot 2020-07-25 09:37:24 +10:00
Ursprung 0fac9ae437
Commit 1bf30431ae
2 geänderte Dateien mit 16 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -844,12 +844,14 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable {
double startZ = start.getZ();
// ray direction:
Vector dir = direction.clone().normalize();
Vector dir = direction.clone().normalizeZeros().normalize();
double dirX = dir.getX();
double dirY = dir.getY();
double dirZ = dir.getZ();
// saving a few divisions below:
// Note: If one of the direction vector components is 0.0, these
// divisions result in infinity. But this is not a problem.
double divX = 1.0D / dirX;
double divY = 1.0D / dirY;
double divZ = 1.0D / dirZ;

Datei anzeigen

@ -365,6 +365,19 @@ public class Vector implements Cloneable, ConfigurationSerializable {
return this;
}
/**
* Converts each component of value <code>-0.0</code> to <code>0.0</code>.
*
* @return This vector.
*/
@NotNull
Vector normalizeZeros() {
if (x == -0.0D) x = 0.0D;
if (y == -0.0D) y = 0.0D;
if (z == -0.0D) z = 0.0D;
return this;
}
/**
* Returns whether this vector is in an axis-aligned bounding box.
* <p>