Merge pull request #140 from thorlucas/master

Added raycast case for integer positions
master
Marc 2020-05-06 22:55:20 +01:00 committed by GitHub
commit 5ed58995d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 0 deletions

View File

@ -75,6 +75,28 @@ bool voxel_raycast(
} else
tcross_z = g_infinite; // Will never cross on X
// Workaround for integer positions
// Adapted from https://github.com/bulletphysics/bullet3/blob/3dbe5426bf7387e532c17df9a1c5e5a4972c298a/src/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp#L418
if (tcross_x == 0.0) {
tcross_x += tdelta_x;
// If going backwards, we should ignore the position we would get by the above flooring,
// because the ray is not heading in that direction
if (xi_step == -1)
hit_pos.x -= 1;
}
if (tcross_y == 0.0) {
tcross_y += tdelta_y;
if (yi_step == -1)
hit_pos.y -= 1;
}
if (tcross_z == 0.0) {
tcross_z += tdelta_z;
if (zi_step == -1)
hit_pos.z -= 1;
}
/* Iteration */
do {