X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fvoxscape.c;fp=src%2Fvoxscape.c;h=2ccb5f9507e8e4bbeb9e04a4a39a432b2e171368;hb=5e9496165d81a0f9923d67969dcb64a2f81ffdab;hp=df34f20ea535cfeb36a303b2de389f71ea05e20f;hpb=7efa828ba87fe6c90b8c55019f4789066d2e4af3;p=voxscape diff --git a/src/voxscape.c b/src/voxscape.c index df34f20..2ccb5f9 100644 --- a/src/voxscape.c +++ b/src/voxscape.c @@ -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; inslices; 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;