mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-09-27 14:13:11 +02:00
Meanwhile ... passable and ray-racing... and fixes.
* Increase precision of debug logging. * Fix iteration conditions for the axes. * Fix margins for collidesFence (method + THICK_FENCE workaround parameter).
This commit is contained in:
parent
181502cdd4
commit
5d0d5d411d
@ -36,7 +36,14 @@ import fr.neatmonster.nocheatplus.utilities.collision.PassableRayTracing;
|
||||
public class Passable extends Check {
|
||||
|
||||
/** TESTING RATHER. */
|
||||
private static boolean preferAxisWise = false;
|
||||
|
||||
// TODO: Make this configurable once a working set of settings has been found.
|
||||
// TODO: Once made configurable... intense testing... and test cases.
|
||||
private static boolean rt_legacy = true;
|
||||
// TODO: rt_xzFactor = 1.0; // Problems: Doors, fences.
|
||||
private static double rt_xzFactor = 0.98;
|
||||
// TODO: Test bumping head into things.
|
||||
private static double rt_heightFactor = 1.0;
|
||||
|
||||
/**
|
||||
* Convenience for player moving, to keep a better overview.
|
||||
@ -46,10 +53,11 @@ public class Passable extends Check {
|
||||
* @return
|
||||
*/
|
||||
public static boolean isPassable(Location from, Location to) {
|
||||
return preferAxisWise ? BlockProperties.isPassableAxisWise(from, to) : BlockProperties.isPassable(from, to);
|
||||
return rt_legacy ? BlockProperties.isPassable(from, to) : BlockProperties.isPassableAxisWise(from, to);
|
||||
}
|
||||
|
||||
private final ICollidePassable rayTracing = preferAxisWise ? new PassableAxisTracing() : new PassableRayTracing();
|
||||
// TODO: Store both and select on check (with config then).
|
||||
private final ICollidePassable rayTracing = rt_legacy ? new PassableRayTracing() : new PassableAxisTracing();
|
||||
|
||||
public Passable() {
|
||||
super(CheckType.MOVING_PASSABLE);
|
||||
@ -78,7 +86,7 @@ public class Passable extends Check {
|
||||
boolean toPassable = to.isPassable();
|
||||
// General condition check for using ray-tracing.
|
||||
if (toPassable && cc.passableRayTracingCheck && (!cc.passableRayTracingBlockChangeOnly || manhattan > 0)) {
|
||||
rayTracing.setMargins(from.getEyeHeight(), from.getWidth() / 2.0); // max from/to + resolution ?
|
||||
rayTracing.setMargins(from.getEyeHeight() * rt_heightFactor, from.getWidth() / 2.0 * rt_xzFactor); // max from/to + resolution ?
|
||||
rayTracing.set(from, to);
|
||||
rayTracing.loop();
|
||||
if (rayTracing.collides() || rayTracing.getStepsDone() >= rayTracing.getMaxSteps()) {
|
||||
@ -271,7 +279,7 @@ public class Passable extends Check {
|
||||
debug(player, "Raytracing collision (" + tag + "): " + rayTracing.getCollidingAxis());
|
||||
}
|
||||
else if (rayTracing.getStepsDone() >= rayTracing.getMaxSteps()) {
|
||||
debug(player, "Raytracing collision (" + tag + "): max steps exceeded.");
|
||||
debug(player, "Raytracing max steps exceeded (" + tag + "): "+ rayTracing.getCollidingAxis());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1886,7 +1886,7 @@ public class BlockProperties {
|
||||
return true;
|
||||
}
|
||||
else if ((flags & F_THICK_FENCE) != 0) {
|
||||
if (!collidesFence(fx, fz, dX, dZ, dT, 0.425)) {
|
||||
if (!collidesFence(fx, fz, dX, dZ, dT, 0.125)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -1939,11 +1939,11 @@ public class BlockProperties {
|
||||
public static boolean collidesFence(final double fx, final double fz, final double dX, final double dZ, final double dT, final double d) {
|
||||
final double dFx = 0.5 - fx;
|
||||
final double dFz = 0.5 - fz;
|
||||
if (Math.abs(dFx) > 0.05 && Math.abs(dFz) > d) {
|
||||
if (Math.abs(dFx) > d && Math.abs(dFz) > d) {
|
||||
// Check moving between quadrants.
|
||||
final double dFx2 = 0.5 - (fx + dX * dT);
|
||||
final double dFz2 = 0.5 - (fz + dZ * dT);
|
||||
if (Math.abs(dFx2) > 0.05 && Math.abs(dFz2) > d) {
|
||||
if (Math.abs(dFx2) > d && Math.abs(dFz2) > d) {
|
||||
if (dFx * dFx2 > 0.0 && dFz * dFz2 > 0.0) {
|
||||
return false;
|
||||
}
|
||||
|
@ -123,6 +123,7 @@ public abstract class AxisTracing implements ICollide, ISetMargins {
|
||||
double z = this.z0;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
final Axis axis = axisOrder[i];
|
||||
collidesAxis = axis; // Ensure here, to get it on max steps.
|
||||
if (axis == Axis.Y_AXIS) {
|
||||
runAxisY(x, y, z);
|
||||
y = this.y1;
|
||||
@ -142,7 +143,6 @@ public abstract class AxisTracing implements ICollide, ISetMargins {
|
||||
}
|
||||
// NONE = skip
|
||||
if (collides) {
|
||||
collidesAxis = axis;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -161,24 +161,26 @@ public abstract class AxisTracing implements ICollide, ISetMargins {
|
||||
final double zMin = zIn - marginZneg;
|
||||
final double zMax = zIn + marginZpos;
|
||||
final double yStart, yEnd;
|
||||
final int iEndY;
|
||||
if (yIn < this.y1) {
|
||||
increment = 1;
|
||||
yStart = yIn - marginYneg;
|
||||
yEnd = this.y1 + marginYpos;
|
||||
iEndY = Location.locToBlock(yEnd) + 1;
|
||||
}
|
||||
else {
|
||||
increment = -1;
|
||||
yStart = yIn + marginYpos;
|
||||
yEnd = this.y1 - marginYneg;
|
||||
iEndY = Location.locToBlock(yEnd) - 1;
|
||||
}
|
||||
final int iMinX = Location.locToBlock(xMin);
|
||||
final int iMaxX = Location.locToBlock(xMax);
|
||||
final int iMinZ = Location.locToBlock(zMin);
|
||||
final int iMaxZ = Location.locToBlock(zMax);
|
||||
final int iStartY = Location.locToBlock(yStart);
|
||||
final int iEndY = Location.locToBlock(yEnd);
|
||||
axisStep = 0;
|
||||
for (int y = iStartY; y <= iEndY; y += increment) {
|
||||
for (int y = iStartY; y != iEndY; y += increment) {
|
||||
++step;
|
||||
++axisStep;
|
||||
if (step > maxSteps) {
|
||||
@ -210,24 +212,26 @@ public abstract class AxisTracing implements ICollide, ISetMargins {
|
||||
final double zMin = zIn - marginZneg;
|
||||
final double zMax = zIn + marginZpos;
|
||||
final double xStart, xEnd;
|
||||
final int iEndX;
|
||||
if (xIn < this.x1) {
|
||||
increment = 1;
|
||||
xStart = xIn - marginXneg;
|
||||
xEnd = this.x1 + marginXpos;
|
||||
iEndX = Location.locToBlock(xEnd) + 1;
|
||||
}
|
||||
else {
|
||||
increment = -1;
|
||||
xStart = xIn + marginXpos;
|
||||
xEnd = this.x1 - marginXneg;
|
||||
iEndX = Location.locToBlock(xEnd) - 1;
|
||||
}
|
||||
final int iMinY = Location.locToBlock(yMin);
|
||||
final int iMaxY = Location.locToBlock(yMax);
|
||||
final int iMinZ = Location.locToBlock(zMin);
|
||||
final int iMaxZ = Location.locToBlock(zMax);
|
||||
final int iStartX = Location.locToBlock(xStart);
|
||||
final int iEndX = Location.locToBlock(xEnd);
|
||||
axisStep = 0;
|
||||
for (int x = iStartX; x <= iEndX; x += increment) {
|
||||
for (int x = iStartX; x != iEndX; x += increment) {
|
||||
++step;
|
||||
++axisStep;
|
||||
if (step > maxSteps) {
|
||||
@ -259,24 +263,26 @@ public abstract class AxisTracing implements ICollide, ISetMargins {
|
||||
final double xMin = xIn - marginXneg;
|
||||
final double xMax = xIn + marginXpos;
|
||||
final double zStart, zEnd;
|
||||
final int iEndZ;
|
||||
if (zIn < this.z1) {
|
||||
increment = 1;
|
||||
zStart = zIn - marginZneg;
|
||||
zEnd = this.z1 + marginZpos;
|
||||
iEndZ = Location.locToBlock(zEnd + 1);
|
||||
}
|
||||
else {
|
||||
increment = -1;
|
||||
zStart = zIn + marginZpos;
|
||||
zEnd = this.z1 - marginZneg;
|
||||
iEndZ = Location.locToBlock(zEnd - 1);
|
||||
}
|
||||
final int iMinY = Location.locToBlock(yMin);
|
||||
final int iMaxY = Location.locToBlock(yMax);
|
||||
final int iMinX = Location.locToBlock(xMin);
|
||||
final int iMaxX = Location.locToBlock(xMax);
|
||||
final int iStartZ = Location.locToBlock(zStart);
|
||||
final int iEndZ = Location.locToBlock(zEnd);
|
||||
axisStep = 0;
|
||||
for (int z = iStartZ; z <= iEndZ; z += increment) {
|
||||
for (int z = iStartZ; z != iEndZ; z += increment) {
|
||||
++step;
|
||||
++axisStep;
|
||||
if (step > maxSteps) {
|
||||
|
@ -10,6 +10,7 @@ public class PassableAxisTracing extends AxisTracing implements ICollidePassable
|
||||
|
||||
private boolean ignoreFirst = false;
|
||||
|
||||
// TODO: Might need another option for margins (option to skip margin for the axis-start point, or alter ignoreFirst behavior).
|
||||
// TODO: Consider an iteration margin as well (0.5 below for fences).
|
||||
|
||||
public BlockCache getBlockCache() {
|
||||
|
Loading…
Reference in New Issue
Block a user