erebus

diff liberebus/src/camera.cc @ 5:9621beb22694

huh?
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 24 May 2014 02:20:44 +0300
parents 4abdce1361b9
children e2d9bf168a41
line diff
     1.1 --- a/liberebus/src/camera.cc	Tue Apr 29 07:38:40 2014 +0300
     1.2 +++ b/liberebus/src/camera.cc	Sat May 24 02:20:44 2014 +0300
     1.3 @@ -10,6 +10,7 @@
     1.4  	cached_matrix_valid = false;
     1.5  
     1.6  	rdir_cache_width = rdir_cache_height = 0;
     1.7 +	rdir_cache_fov = 0;
     1.8  	rdir_cache = 0;
     1.9  }
    1.10  
    1.11 @@ -20,6 +21,7 @@
    1.12  	cached_matrix_valid = false;
    1.13  
    1.14  	rdir_cache_width = rdir_cache_height = 0;
    1.15 +	rdir_cache_fov = 0;
    1.16  	rdir_cache = 0;
    1.17  }
    1.18  
    1.19 @@ -31,9 +33,6 @@
    1.20  void Camera::set_fov(float vfov)
    1.21  {
    1.22  	this->vfov = vfov;
    1.23 -
    1.24 -	// invalidate the dir cache
    1.25 -	delete [] rdir_cache;
    1.26  }
    1.27  
    1.28  float Camera::get_fov() const
    1.29 @@ -80,8 +79,9 @@
    1.30  {
    1.31  #pragma omp single
    1.32  	{
    1.33 -		if(!rdir_cache || rdir_cache_width != xsz || rdir_cache_height != ysz) {
    1.34 -			printf("calculating primary ray direction cache\n");
    1.35 +		if(!rdir_cache || rdir_cache_width != xsz || rdir_cache_height != ysz ||
    1.36 +				fabs(rdir_cache_fov - vfov) > 1e-4) {
    1.37 +			printf("calculating primary ray direction cache (%dx%d)\n", xsz, ysz);
    1.38  
    1.39  			delete [] rdir_cache;
    1.40  			rdir_cache = new Vector3[xsz * ysz];
    1.41 @@ -102,6 +102,7 @@
    1.42  			}
    1.43  			rdir_cache_width = xsz;
    1.44  			rdir_cache_height = ysz;
    1.45 +			rdir_cache_fov = vfov;
    1.46  		}
    1.47  	}
    1.48