prismarine-world
Advanced tools
Comparing version
## History | ||
### 3.3.1 | ||
* Fix raycasting when ray is axis aligned | ||
### 3.3.0 | ||
@@ -4,0 +8,0 @@ |
{ | ||
"name": "prismarine-world", | ||
"version": "3.3.0", | ||
"version": "3.3.1", | ||
"description": "The core implementation of the world for prismarine", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -117,2 +117,6 @@ const { Vec3 } = require('vec3') | ||
this.invDirX = (dir.x === 0) ? Number.MAX_VALUE : 1 / dir.x | ||
this.invDirY = (dir.y === 0) ? Number.MAX_VALUE : 1 / dir.y | ||
this.invDirZ = (dir.z === 0) ? Number.MAX_VALUE : 1 / dir.z | ||
this.stepX = Math.sign(dir.x) | ||
@@ -141,6 +145,6 @@ this.stepY = Math.sign(dir.y) | ||
for (const shape of shapes) { | ||
let tmin = this.stepX * (shape[this.stepX > 0 ? 0 : 3] - p.x) * this.tDeltaX | ||
let tmax = this.stepX * (shape[this.stepX > 0 ? 3 : 0] - p.x) * this.tDeltaX | ||
const tymin = this.stepY * (shape[this.stepY > 0 ? 1 : 4] - p.y) * this.tDeltaY | ||
const tymax = this.stepY * (shape[this.stepY > 0 ? 4 : 1] - p.y) * this.tDeltaY | ||
let tmin = (shape[this.invDirX > 0 ? 0 : 3] - p.x) * this.invDirX | ||
let tmax = (shape[this.invDirX > 0 ? 3 : 0] - p.x) * this.invDirX | ||
const tymin = (shape[this.invDirY > 0 ? 1 : 4] - p.y) * this.invDirY | ||
const tymax = (shape[this.invDirY > 0 ? 4 : 1] - p.y) * this.invDirY | ||
@@ -156,4 +160,4 @@ let face = this.stepX > 0 ? BlockFace.WEST : BlockFace.EAST | ||
const tzmin = this.stepZ * (shape[this.stepZ > 0 ? 2 : 5] - p.z) * this.tDeltaZ | ||
const tzmax = this.stepZ * (shape[this.stepZ > 0 ? 5 : 2] - p.z) * this.tDeltaZ | ||
const tzmin = (shape[this.invDirZ > 0 ? 2 : 5] - p.z) * this.invDirZ | ||
const tzmax = (shape[this.invDirZ > 0 ? 5 : 2] - p.z) * this.invDirZ | ||
@@ -160,0 +164,0 @@ if ((tmin > tzmax) || (tzmin > tmax)) continue |
43359
4.57%21
5%883
5.37%