foo
[voxscape] / src / voxscape.c
index df34f20..2ccb5f9 100644 (file)
@@ -185,7 +185,7 @@ void vox_begin(struct voxscape *vox)
        memset(vox->coltop, 0, vox->fbwidth * sizeof *vox->coltop);
 
        if(!(vox->valid & SLICELEN)) {
-               float theta = (float)vox->angle * M_PI / 360.0f;        /* half angle */
+               float theta = (float)vox->fov * M_PI / 360.0f;  /* half angle */
                for(i=0; i<vox->nslices; i++) {
                        vox->slicelen[i] = (int32_t)((vox->znear + i) * tan(theta) * 2.0f * 65536.0f);
                }
@@ -209,7 +209,8 @@ void vox_render_slice(struct voxscape *vox, int n)
                tx = (x >> 16) & vox->xmask;
                ty = (y >> 16) & vox->ymask;
 
-               hval = (vox->height[(ty << vox->xshift) + tx] - vox->vheight) * vox->proj_dist / y;
+               hval = vox->height[(ty << vox->xshift) + tx];
+               hval = (hval - vox->vheight) * vox->proj_dist / (vox->znear + i);
                if(hval > vox->coltop[i]) {
                        color = vox->color[(ty << vox->xshift) + tx];
                        colstart = vox->fbheight - 1 - hval;