From 475a879b515200e7ccbc15481a48f9892756f3d9 Mon Sep 17 00:00:00 2001 From: MitchellHansen Date: Sun, 1 Jan 2017 17:42:25 -0800 Subject: [PATCH] =?UTF-8?q?=C2=96Why=20the=20off=20by=20one=20on=20voxel.y?= =?UTF-8?q?=3F=20lolololol?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernels/ray_caster_kernel.cl | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/kernels/ray_caster_kernel.cl b/kernels/ray_caster_kernel.cl index 93c90e6..bfb7286 100644 --- a/kernels/ray_caster_kernel.cl +++ b/kernels/ray_caster_kernel.cl @@ -133,9 +133,7 @@ __kernel void raycaster( voxel_step *= (ray_dir > 0) - (ray_dir < 0); // Setup the voxel coords from the camera origin - // Off by one error here in regards to the camera position. - // Will need to hunt this down later - int3 voxel = convert_int3(*cam_pos + 1); + int3 voxel = convert_int3(*cam_pos); // Delta T is the units a ray must travel along an axis in order to // traverse an integer split @@ -197,8 +195,7 @@ __kernel void raycaster( // If we hit a voxel //int index = voxel.x * (*map_dim).y * (*map_dim).z + voxel.z * (*map_dim).z + voxel.y; - // Why the off by one on voxel.y? - int index = voxel.x + (*map_dim).x * (voxel.y + (*map_dim).z * (voxel.z-1)); + int index = voxel.x + (*map_dim).x * (voxel.y + (*map_dim).z * (voxel.z)); int voxel_data = map[index]; if (voxel_data != 0) {