mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-11-20 17:39:46 +00:00
add tests for positions far from the world origin
dev/tests/far_coords.lua: at 1M and 30M blocks a position of a player, a spawn point and an entity is read back as it was set, a ray hits the block it is cast to, a body with a velocity moves the same way as at the world origin, and a position at 30M survives saving and loading of the world. test/physics/Hitbox.cpp checks the AABB of a hitbox far from the world origin, test/window/Camera.cpp checks the view relative to the rendering origin with positions in doubles.
This commit is contained in:
parent
ebd506de09
commit
95d2121318
3 changed files with 133 additions and 9 deletions
|
|
@ -31,18 +31,18 @@ TEST(Camera, ViewRotationFarFromOrigin) {
|
|||
}
|
||||
|
||||
TEST(Camera, ViewRelativeToOrigin) {
|
||||
for (float coord : {0.0f, 500.0f, -1e5f, 1e6f, 3e7f}) {
|
||||
Camera camera(glm::vec3(coord, 64.0f, -coord), 1.0f);
|
||||
for (double coord : {0.0, 500.3, -1e5 - 0.3, 1e6 + 0.3, 3e7 + 0.3}) {
|
||||
Camera camera(worldvec3(coord, 64.0, -coord), 1.0f);
|
||||
camera.rotate(glm::radians(-20.0f), glm::radians(35.0f), 0.0f);
|
||||
|
||||
glm::dvec3 origin = camera.getOrigin();
|
||||
glm::vec3 local = camera.getLocalPosition();
|
||||
EXPECT_LE(glm::abs(local.x), 512.0f) << "at " << coord;
|
||||
EXPECT_LE(glm::abs(local.z), 512.0f) << "at " << coord;
|
||||
EXPECT_EQ(glm::dvec3(camera.position), origin + glm::dvec3(local));
|
||||
worldvec3 origin = camera.getOrigin();
|
||||
worldvec3 local = camera.getLocalPosition();
|
||||
EXPECT_LE(glm::abs(local.x), 512.0) << "at " << coord;
|
||||
EXPECT_LE(glm::abs(local.z), 512.0) << "at " << coord;
|
||||
EXPECT_NEAR(camera.position.x, origin.x + local.x, 1e-4) << coord;
|
||||
EXPECT_NEAR(camera.position.z, origin.z + local.z, 1e-4) << coord;
|
||||
|
||||
glm::dvec3 point =
|
||||
glm::dvec3(camera.position) + glm::dvec3(camera.front) * 10.0;
|
||||
worldvec3 point = camera.position + worldvec3(camera.front) * 10.0;
|
||||
glm::vec4 viewPoint =
|
||||
camera.getView() * glm::vec4(glm::vec3(point - origin), 1.0f);
|
||||
EXPECT_NEAR(viewPoint.x, 0.0f, 1e-3f) << "at " << coord;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue