geforkt von Mirrors/Paper
SPIGOT-6017: BoundingBox#rayTrace returns incorrect null
By: blablubbabc <lukas@wirsindwir.de>
Dieser Commit ist enthalten in:
Ursprung
0fac9ae437
Commit
1bf30431ae
@ -844,12 +844,14 @@ public class BoundingBox implements Cloneable, ConfigurationSerializable {
|
|||||||
double startZ = start.getZ();
|
double startZ = start.getZ();
|
||||||
|
|
||||||
// ray direction:
|
// ray direction:
|
||||||
Vector dir = direction.clone().normalize();
|
Vector dir = direction.clone().normalizeZeros().normalize();
|
||||||
double dirX = dir.getX();
|
double dirX = dir.getX();
|
||||||
double dirY = dir.getY();
|
double dirY = dir.getY();
|
||||||
double dirZ = dir.getZ();
|
double dirZ = dir.getZ();
|
||||||
|
|
||||||
// saving a few divisions below:
|
// 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 divX = 1.0D / dirX;
|
||||||
double divY = 1.0D / dirY;
|
double divY = 1.0D / dirY;
|
||||||
double divZ = 1.0D / dirZ;
|
double divZ = 1.0D / dirZ;
|
||||||
|
@ -365,6 +365,19 @@ public class Vector implements Cloneable, ConfigurationSerializable {
|
|||||||
return this;
|
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.
|
* Returns whether this vector is in an axis-aligned bounding box.
|
||||||
* <p>
|
* <p>
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren