Change quick-exit check for passable.

* Include the case for manhattan == 1.
* Use BlockProperties.isPassable.
This commit is contained in:
asofold 2014-08-17 22:46:55 +02:00
parent 7c1b2eaed3
commit 589dc77510
2 changed files with 14 additions and 6 deletions

View File

@ -28,13 +28,20 @@ public class Passable extends Check {
String tags = "";
// Block distances (sum, max) for from-to (not for loc!).
final int manhattan = from.manhattan(to);
// Skip moves inside of ignored blocks right away.
if (manhattan == 0 && (BlockProperties.getBlockFlags(from.getTypeId()) & BlockProperties.F_IGN_PASSABLE) != 0) {
return null;
}
// Skip moves inside of ignored blocks right away [works as long as we only check between foot-locations].
if (manhattan <= 1 && BlockProperties.isPassable(from.getTypeId())) {
// TODO: Monitor: BlockProperties.isPassable checks slightly different than before.
if (manhattan == 0){
return null;
} else {
// manhattan == 1
if (BlockProperties.isPassable(to.getTypeId())) {
return null;
}
}
}
boolean toPassable = to.isPassable();
// General condition check for using ray-tracing.
// TODO: Optimize: manhattan <= 1 and all blocks are completely passable.
if (toPassable && cc.passableRayTracingCheck && (!cc.passableRayTracingBlockChangeOnly || manhattan > 0)) {
rayTracing.set(from, to);
rayTracing.loop();

View File

@ -1379,13 +1379,14 @@ public class BlockProperties {
}
/**
* Just check if a position is not inside of a block that has a bounding box.<br>
* Just check if a block type is fully passable by default.<br>
* This is an inaccurate check, it also returns false for doors etc.
* @param id
* @return
*/
public static final boolean isPassable(final int id){
final long flags = blockFlags[id];
// TODO: What with non-solid blocks that are not passable ?
if ((flags & (F_LIQUID | F_IGN_PASSABLE)) != 0) return true;
else return (flags & F_SOLID) == 0;
}