mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-11-21 09:59:44 +00:00
use double precision for camera position and ray casts
A float position has a step of 6 cm at 1M blocks and of 2 m at 30M: the camera moved by jumps and rays started not where the camera is. worldvec3 (glm::dvec3) is the type of a position in the world. Camera::position, the start and the end of block and entity ray casts and the hit position of the player selection use it. Lua numbers are doubles already, so cameras.set_pos/get_pos, block.raycast, entities.raycast and world.raycast only stop rounding to float. Entities::rayCast intersects a hitbox in the coordinates relative to its position instead of a float AABB in the world space.
This commit is contained in:
parent
89bdadd6aa
commit
ad69663b2e
18 changed files with 86 additions and 71 deletions
|
|
@ -118,7 +118,7 @@ void DebugLinesRenderer::render(
|
|||
|
||||
if (showChunkBorders) {
|
||||
linesShader.uniformMatrix("u_projview", camera.getProjView());
|
||||
glm::vec3 coord = camera.position;
|
||||
worldvec3 coord = camera.position;
|
||||
if (coord.x < 0) coord.x--;
|
||||
if (coord.z < 0) coord.z--;
|
||||
int cx = floordiv(static_cast<int>(coord.x), CHUNK_W);
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ void Decorator::updateAcoustics(const Camera& camera) {
|
|||
glm::vec3 dir = { r * std::cos(phi), r * std::sin(phi), z };
|
||||
|
||||
dir = glm::normalize(dir);
|
||||
glm::vec3 end;
|
||||
worldvec3 end;
|
||||
glm::ivec3 norm;
|
||||
glm::ivec3 iend;
|
||||
blocks_agent::RaycastSettings raycast {};
|
||||
|
|
@ -128,7 +128,7 @@ void Decorator::updateAcoustics(const Camera& camera) {
|
|||
if (vox == nullptr) {
|
||||
continue;
|
||||
}
|
||||
auto distance = glm::distance(start, end);
|
||||
float distance = glm::distance(start, end);
|
||||
if (distance >= length * 0.98f) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue