From c52c6b14b973758a5a4876e2b12d995bafc9c5d7 Mon Sep 17 00:00:00 2001 From: Yggdrasil75 Date: Tue, 20 Jan 2026 15:01:35 -0500 Subject: [PATCH] correct something in my uv map --- util/grid/g3_serialization.hpp | 1 + util/grid/grid3.hpp | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/util/grid/g3_serialization.hpp b/util/grid/g3_serialization.hpp index f5981fd..7d1063b 100644 --- a/util/grid/g3_serialization.hpp +++ b/util/grid/g3_serialization.hpp @@ -18,6 +18,7 @@ inline bool VoxelGrid::serializeToFile(const std::string& filename) { int dims[3] = {gridSize.x, gridSize.y, gridSize.z}; file.write(reinterpret_cast(dims), sizeof(dims)); size_t voxelCount = voxels.size(); + file.write(reinterpret_cast(&voxelCount), sizeof(voxelCount)); for (const Voxel& voxel : voxels) { auto write_member = [&file](const auto& member) { file.write(reinterpret_cast(&member), sizeof(member)); diff --git a/util/grid/grid3.hpp b/util/grid/grid3.hpp index fd81d1f..3eefa8b 100644 --- a/util/grid/grid3.hpp +++ b/util/grid/grid3.hpp @@ -333,12 +333,12 @@ public: frame outFrame(resolution.x, resolution.y, frame::colormap::RGB); std::vector colorBuffer(resolution.x * resolution.y * 3); #pragma omp parallel for - for (int y = 0; y < resolution.x; y++) { - float v = (static_cast(y) / static_cast(resolution.x - 1)) - 0.5f; - for (int x = 0; x < resolution.y; x++) { + for (int x = 0; x < resolution.x; x++) { + float v = (2.0 * (x + 0.5f) / resolution.y - 1.f) * viewH; + for (int y = 0; y < resolution.y; y++) { Voxel outVoxel(0,false,0.f,Vec3ui8(10, 10, 255)); - float u = (static_cast(x) / static_cast(resolution.y - 1)) - 0.5f; - Vec3f rayDirWorld = (forward + right * (u * viewW) + upCor * (v * viewH)).normalized(); + float u = (1.f - 2.f * (y + 0.5f) / resolution.x) * viewW; + Vec3f rayDirWorld = (forward + right * v + upCor * u).normalized(); Vec3f rayEnd = cam.posfor.origin + rayDirWorld * maxDist; Vec3d rayStartGrid = cam.posfor.origin.toDouble() / binSize; Vec3d rayEndGrid = rayEnd.toDouble() / binSize;