mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-11-21 18:09:46 +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
|
|
@ -180,10 +180,10 @@ void Shadows::generateShadowsMap(
|
|||
float shadowMapScale = 0.32f / (1 << glm::max(0, quality)) * scale;
|
||||
float shadowMapSize = resolution * shadowMapScale;
|
||||
|
||||
glm::vec3 basePos = glm::floor(camera.position / 4.0f) * 4.0f;
|
||||
glm::vec3 prevPos = shadowCamera.position;
|
||||
worldvec3 basePos = glm::floor(camera.position / 4.0) * 4.0;
|
||||
worldvec3 prevPos = shadowCamera.position;
|
||||
shadowCamera = Camera(
|
||||
glm::distance2(prevPos, basePos) > 25.0f ? basePos : prevPos,
|
||||
glm::distance2(prevPos, basePos) > 25.0 ? basePos : prevPos,
|
||||
shadowMapSize
|
||||
);
|
||||
shadowCamera.near = 0.1f;
|
||||
|
|
@ -206,9 +206,9 @@ void Shadows::generateShadowsMap(
|
|||
glm::radians(0.0f)
|
||||
);
|
||||
|
||||
shadowCamera.position -= shadowCamera.front * 500.0f;
|
||||
shadowCamera.position += shadowCamera.up * 0.0f;
|
||||
shadowCamera.position += camera.front * 0.0f;
|
||||
shadowCamera.position -= worldvec3(shadowCamera.front * 500.0f);
|
||||
shadowCamera.position += worldvec3(shadowCamera.up * 0.0f);
|
||||
shadowCamera.position += worldvec3(camera.front * 0.0f);
|
||||
|
||||
auto view = shadowCamera.getView();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue