commit
5ed58995d5
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue